(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(*                      Evgeny Makarov, INRIA, 2007                     *)
(************************************************************************)
Require Export NMulOrder.
Module Type NSubProp (Import N : NAxiomsMiniSig').
Include NMulOrderProp N.

(* Specifications: *)
Theorem sub_0_l : forall n, 0 - n == 0.
Theorem sub_succ : forall n m, S n - S m == n - m.
Theorem sub_diag : forall n, n - n == 0.
Theorem sub_gt : forall n m, n > m -> n - m ~= 0.
Theorem add_sub_assoc : forall n m p, p <= m -> n + (m - p) == (n + m) - p.
Theorem sub_succ_l : forall n m, n <= m -> S m - n == S (m - n).
Theorem add_sub : forall n m, (n + m) - m == n.
Theorem sub_add : forall n m, n <= m -> (m - n) + n == m.
Theorem add_sub_eq_l : forall n m p, m + p == n -> n - m == p.
Theorem add_sub_eq_r : forall n m p, m + p == n -> n - p == m.
(* This could be proved by adding m to both sides. Then the proof would use add_sub_assoc and sub_0_le, which is proven below. *)
Theorem add_sub_eq_nz : forall n m p, p ~= 0 -> n - m == p -> m + p == n.
Theorem sub_add_distr : forall n m p, n - (m + p) == (n - m) - p.
Theorem add_sub_swap : forall n m p, p <= n -> n + m - p == n - p + m.
(** Sub and order *)
Theorem le_sub_l : forall n m, n - m <= n.
Theorem sub_0_le : forall n m, n - m == 0 <-> n <= m.
Theorem sub_pred_l : forall n m, P n - m == P (n - m).
Theorem sub_pred_r : forall n m, m ~= 0 -> m <= n -> n - P m == S (n - m).
Theorem sub_add_le : forall n m, n <= n - m + m.
Theorem le_sub_le_add_r : forall n m p,
n - p <= m <-> n <= m + p.
Theorem le_sub_le_add_l : forall n m p, n - m <= p <-> n <= m + p.
Theorem lt_sub_lt_add_r : forall n m p,
n - p < m -> n < m + p.