Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \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 Import NZAxioms NZBase NZMul NZOrder. Module Type NZAddOrderProp (Import NZ : NZOrdAxiomsSig'). Include NZBaseProp NZ <+ NZMulProp NZ <+ NZOrderProp NZ.forall n m p : t, n < m <-> p + n < p + mforall n m p : t, n < m <-> p + n < p + mn, m:tn < m <-> 0 + n < 0 + mn, m:tforall n0 : t, (n < m <-> n0 + n < n0 + m) <-> (n < m <-> S n0 + n < S n0 + m)now nzsimpl.n, m:tn < m <-> 0 + n < 0 + mn, m:tforall n0 : t, (n < m <-> n0 + n < n0 + m) <-> (n < m <-> S n0 + n < S n0 + m)n, m, p:t(n < m <-> p + n < p + m) <-> (n < m <-> S p + n < S p + m)now rewrite <- succ_lt_mono. Qed.n, m, p:t(n < m <-> p + n < p + m) <-> (n < m <-> S (p + n) < S (p + m))forall n m p : t, n < m <-> n + p < m + pforall n m p : t, n < m <-> n + p < m + prewrite (add_comm n p), (add_comm m p); apply add_lt_mono_l. Qed.n, m, p:tn < m <-> n + p < m + pforall n m p q : t, n < m -> p < q -> n + p < m + qforall n m p q : t, n < m -> p < q -> n + p < m + qapply lt_trans with (m + p); [now apply add_lt_mono_r | now apply add_lt_mono_l]. Qed.n, m, p, q:tH1:n < mH2:p < qn + p < m + qforall n m p : t, n <= m <-> p + n <= p + mforall n m p : t, n <= m <-> p + n <= p + mn, m:tn <= m <-> 0 + n <= 0 + mn, m:tforall n0 : t, (n <= m <-> n0 + n <= n0 + m) <-> (n <= m <-> S n0 + n <= S n0 + m)now nzsimpl.n, m:tn <= m <-> 0 + n <= 0 + mn, m:tforall n0 : t, (n <= m <-> n0 + n <= n0 + m) <-> (n <= m <-> S n0 + n <= S n0 + m)n, m, p:t(n <= m <-> p + n <= p + m) <-> (n <= m <-> S p + n <= S p + m)now rewrite <- succ_le_mono. Qed.n, m, p:t(n <= m <-> p + n <= p + m) <-> (n <= m <-> S (p + n) <= S (p + m))forall n m p : t, n <= m <-> n + p <= m + pforall n m p : t, n <= m <-> n + p <= m + prewrite (add_comm n p), (add_comm m p); apply add_le_mono_l. Qed.n, m, p:tn <= m <-> n + p <= m + pforall n m p q : t, n <= m -> p <= q -> n + p <= m + qforall n m p q : t, n <= m -> p <= q -> n + p <= m + qapply le_trans with (m + p); [now apply add_le_mono_r | now apply add_le_mono_l]. Qed.n, m, p, q:tH1:n <= mH2:p <= qn + p <= m + qforall n m p q : t, n < m -> p <= q -> n + p < m + qforall n m p q : t, n < m -> p <= q -> n + p < m + qapply lt_le_trans with (m + p); [now apply add_lt_mono_r | now apply add_le_mono_l]. Qed.n, m, p, q:tH1:n < mH2:p <= qn + p < m + qforall n m p q : t, n <= m -> p < q -> n + p < m + qforall n m p q : t, n <= m -> p < q -> n + p < m + qapply le_lt_trans with (m + p); [now apply add_le_mono_r | now apply add_lt_mono_l]. Qed.n, m, p, q:tH1:n <= mH2:p < qn + p < m + qforall n m : t, 0 < n -> 0 < m -> 0 < n + mforall n m : t, 0 < n -> 0 < m -> 0 < n + mn, m:tH1:0 < nH2:0 < m0 < n + mnow apply add_lt_mono. Qed.n, m:tH1:0 < nH2:0 < m0 + 0 < n + mforall n m : t, 0 < n -> 0 <= m -> 0 < n + mforall n m : t, 0 < n -> 0 <= m -> 0 < n + mn, m:tH1:0 < nH2:0 <= m0 < n + mnow apply add_lt_le_mono. Qed.n, m:tH1:0 < nH2:0 <= m0 + 0 < n + mforall n m : t, 0 <= n -> 0 < m -> 0 < n + mforall n m : t, 0 <= n -> 0 < m -> 0 < n + mn, m:tH1:0 <= nH2:0 < m0 < n + mnow apply add_le_lt_mono. Qed.n, m:tH1:0 <= nH2:0 < m0 + 0 < n + mforall n m : t, 0 <= n -> 0 <= m -> 0 <= n + mforall n m : t, 0 <= n -> 0 <= m -> 0 <= n + mn, m:tH1:0 <= nH2:0 <= m0 <= n + mnow apply add_le_mono. Qed.n, m:tH1:0 <= nH2:0 <= m0 + 0 <= n + mforall n m : t, 0 < n -> m < n + mforall n m : t, 0 < n -> m < n + mn, m:t0 < n -> m < n + mnow nzsimpl. Qed.n, m:t0 + m < n + m -> m < n + mforall n m : t, 0 < n -> m < m + nintros; rewrite add_comm; now apply lt_add_pos_l. Qed.forall n m : t, 0 < n -> m < m + nforall n m p q : t, n <= m -> p + m < q + n -> p < qforall n m p q : t, n <= m -> p + m < q + n -> p < qn, m, p, q:tH1:n <= mH2:p + m < q + np < qn, m, p, q:tH1:n <= mH2:p + m < q + nH:q <= pp < qn, m, p, q:tH1:n <= mH:q <= p~ p + m < q + nnow apply add_le_mono. Qed.n, m, p, q:tH1:n <= mH:q <= pq + n <= p + mforall n m p q : t, n < m -> p + m <= q + n -> p < qforall n m p q : t, n < m -> p + m <= q + n -> p < qn, m, p, q:tH1:n < mH2:p + m <= q + np < qn, m, p, q:tH1:n < mH2:p + m <= q + nH:q <= pp < qn, m, p, q:tH1:n < mH:q <= p~ p + m <= q + nnow apply add_le_lt_mono. Qed.n, m, p, q:tH1:n < mH:q <= pq + n < p + mforall n m p q : t, n <= m -> p + m <= q + n -> p <= qforall n m p q : t, n <= m -> p + m <= q + n -> p <= qn, m, p, q:tH1:n <= mH2:p + m <= q + np <= qn, m, p, q:tH1:n <= mH2:p + m <= q + nH:q < pp <= qn, m, p, q:tH1:n <= mH:q < p~ p + m <= q + nnow apply add_lt_le_mono. Qed.n, m, p, q:tH1:n <= mH:q < pq + n < p + mforall n m p q : t, n + m < p + q -> n < p \/ m < qforall n m p q : t, n + m < p + q -> n < p \/ m < qn, m, p, q:tH:n + m < p + qH1:p <= nn < p \/ m < qn, m, p, q:tH:n + m < p + qH1:p <= nH2:q <= mn < p \/ m < qnow apply add_le_mono. Qed.n, m, p, q:tH1:p <= nH2:q <= mp + q <= n + mforall n m p q : t, n + m <= p + q -> n <= p \/ m <= qforall n m p q : t, n + m <= p + q -> n <= p \/ m <= qn, m, p, q:tH:n + m <= p + qn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:n <= pn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:p < nn <= p \/ m <= qnow left.n, m, p, q:tH:n + m <= p + qH1:n <= pn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:p < nn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:p < nH2:m <= qn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:p < nH2:q < mn <= p \/ m <= qnow right.n, m, p, q:tH:n + m <= p + qH1:p < nH2:m <= qn <= p \/ m <= qn, m, p, q:tH:n + m <= p + qH1:p < nH2:q < mn <= p \/ m <= qnow apply add_lt_mono. Qed.n, m, p, q:tH1:p < nH2:q < mp + q < n + mforall n m : t, n + m < 0 -> n < 0 \/ m < 0intros n m H; apply add_lt_cases; now nzsimpl. Qed.forall n m : t, n + m < 0 -> n < 0 \/ m < 0forall n m : t, 0 < n + m -> 0 < n \/ 0 < mintros n m H; apply add_lt_cases; now nzsimpl. Qed.forall n m : t, 0 < n + m -> 0 < n \/ 0 < mforall n m : t, n + m <= 0 -> n <= 0 \/ m <= 0intros n m H; apply add_le_cases; now nzsimpl. Qed.forall n m : t, n + m <= 0 -> n <= 0 \/ m <= 0forall n m : t, 0 <= n + m -> 0 <= n \/ 0 <= mintros n m H; apply add_le_cases; now nzsimpl. Qed.forall n m : t, 0 <= n + m -> 0 <= n \/ 0 <= m
Subtraction
We can prove the existence of a subtraction of any number by
a smaller one
forall n m : t, n <= m -> exists p : t, m == p + n /\ 0 <= pforall n m : t, n <= m -> exists p : t, m == p + n /\ 0 <= pn, m:tH:n <= mexists p : t, m == p + n /\ 0 <= pn, m:tH:n <= mProper (eq ==> iff) (fun m0 : t => exists p : t, m0 == p + n /\ 0 <= p)n, m:tH:n <= mexists p : t, n == p + n /\ 0 <= pn, m:tH:n <= mforall m0 : t, n <= m0 -> (exists p : t, m0 == p + n /\ 0 <= p) -> exists p : t, S m0 == p + n /\ 0 <= psolve_proper.n, m:tH:n <= mProper (eq ==> iff) (fun m0 : t => exists p : t, m0 == p + n /\ 0 <= p)exists 0; nzsimpl; split; order.n, m:tH:n <= mexists p : t, n == p + n /\ 0 <= pn, m:tH:n <= mforall m0 : t, n <= m0 -> (exists p : t, m0 == p + n /\ 0 <= p) -> exists p : t, S m0 == p + n /\ 0 <= pn:tforall m : t, n <= m -> (exists p : t, m == p + n /\ 0 <= p) -> exists p : t, S m == p + n /\ 0 <= pn, m:tH:n <= mp:tEQ:m == p + nLE:0 <= pexists p0 : t, S m == p0 + n /\ 0 <= p0n, m:tH:n <= mp:tEQ:m == p + nLE:0 <= pS m == S p + n /\ 0 <= S pn, m:tH:n <= mp:tEQ:m == p + nLE:0 <= pS m == S p + nn, m:tH:n <= mp:tEQ:m == p + nLE:0 <= p0 <= S pn, m:tH:n <= mp:tEQ:m == p + nLE:0 <= pS m == S p + nnow f_equiv.n, m:tH:n <= mp:tEQ:m == p + nLE:0 <= pS m == S (p + n)now apply le_le_succ_r. Qed.n, m:tH:n <= mp:tEQ:m == p + nLE:0 <= p0 <= S p
For the moment, it doesn't seem possible to relate
this existing subtraction with sub.
End NZAddOrderProp.