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 Export NAdd. Module NOrderProp (Import N : NAxiomsMiniSig'). Include NAddProp N. (* Theorems that are true for natural numbers but not for integers *)well_founded ltwell_founded ltwell_founded (fun n m : t => 0 <= n < m)relation_equivalence lt (fun n m : t => 0 <= n < m)relation_equivalence lt (fun n m : t => 0 <= n < m)x, y:tx < y -> 0 <= x < yx, y:t0 <= x < y -> x < ynow intros [_ H]. Defined. (* "le_0_l : forall n : N, 0 <= n" was proved in NBase.v *)x, y:t0 <= x < y -> x < yforall n : t, ~ n < 0forall n : t, ~ n < 0apply le_0_l. Qed.n:t0 <= nforall n : t, ~ S n <= 0intros n H; apply le_succ_l in H; false_hyp H nlt_0_r. Qed.forall n : t, ~ S n <= 0forall n : t, n <= 0 <-> n == 0forall n : t, n <= 0 <-> n == 0n:tH:n <= 0n == 0n:tH:n == 0n <= 0now apply eq_le_incl. Qed.n:tH:n == 0n <= 0forall n : t, 0 < S ninduct n; [apply lt_succ_diag_r | intros n H; now apply lt_lt_succ_r]. Qed.forall n : t, 0 < S nforall n : t, n ~= 0 <-> 0 < nforall n : t, n ~= 0 <-> 0 < n0 ~= 0 <-> 0 < 0forall n : t, S n ~= 0 <-> 0 < S nintro n; split; intro H; [apply lt_0_succ | apply neq_succ_0]. Qed.forall n : t, S n ~= 0 <-> 0 < S nforall n : t, n == 0 \/ 0 < nforall n : t, n == 0 \/ 0 < n0 == 0 \/ 0 < 0forall n : t, S n == 0 \/ 0 < S nintro; right; apply lt_0_succ. Qed.forall n : t, S n == 0 \/ 0 < S nforall n : t, n == 0 \/ n == 1 \/ 1 < nforall n : t, n == 0 \/ n == 1 \/ 1 < nforall n : t, n == 0 \/ n == S 0 \/ S 0 < n0 == 0 \/ 0 == S 0 \/ S 0 < 0forall n : t, n == 0 \/ n == S 0 \/ S 0 < n -> S n == 0 \/ S n == S 0 \/ S 0 < S nforall n : t, n == 0 \/ n == S 0 \/ S 0 < n -> S n == 0 \/ S n == S 0 \/ S 0 < S n0 == 0 \/ 0 == S 0 \/ S 0 < 0 -> S 0 == 0 \/ S 0 == S 0 \/ S 0 < S 0forall n : t, S n == 0 \/ S n == S 0 \/ S 0 < S n -> S (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)forall n : t, S n == 0 \/ S n == S 0 \/ S 0 < S n -> S (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tIH:S n == 0 \/ S n == S 0 \/ S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S n == 0S (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S n == S 0S (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S n == S 0S (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S n == S 0S 0 < S (S n)n:tH:S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S n == S 0S 0 < S (S 0)n:tH:S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)n:tH:S 0 < S nS (S n) == 0 \/ S (S n) == S 0 \/ S 0 < S (S n)now apply lt_lt_succ_r. Qed.n:tH:S 0 < S nS 0 < S (S n)forall n : t, n < 1 <-> n == 0forall n : t, n < 1 <-> n == 0forall n : t, n < S 0 <-> n == 00 < S 0 <-> 0 == 0forall n : t, S n < S 0 <-> S n == 0forall n : t, S n < S 0 <-> S n == 0n:tS n < S 0 <-> S n == 0split; intro H; [false_hyp H nlt_0_r | false_hyp H neq_succ_0]. Qed.n:tn < 0 <-> S n == 0forall n : t, n <= 1 <-> n == 0 \/ n == 1forall n : t, n <= 1 <-> n == 0 \/ n == 1forall n : t, n <= S 0 <-> n == 0 \/ n == S 00 <= S 0 <-> 0 == 0 \/ 0 == S 0forall n : t, S n <= S 0 <-> S n == 0 \/ S n == S 0forall n : t, S n <= S 0 <-> S n == 0 \/ S n == S 0n:tS n <= S 0 <-> S n == 0 \/ S n == S 0split; [intro; now right | intros [H | H]; [false_hyp H neq_succ_0 | assumption]]. Qed.n:tn == 0 <-> S n == 0 \/ n == 0forall n m : t, n < m -> 0 < mforall n m : t, n < m -> 0 < mm:t0 < m -> 0 < mm:tforall n : t, (n < m -> 0 < m) -> S n < m -> 0 < mm:tforall n : t, (n < m -> 0 < m) -> S n < m -> 0 < mapply IH; now apply lt_succ_l. Qed.m, n:tIH:n < m -> 0 < mH:S n < m0 < mforall n m p : t, n < m -> m < p -> 1 < pforall n m p : t, n < m -> m < p -> 1 < pn, m, p:tH:n < mH0:m < p1 < pn, m, p:tH:n < mH0:m < p0 < mnow apply le_0_l. Qed.n, m, p:tH:n < mH0:m < p0 <= n
Elimination principlies for < and <= for relations
Section RelElim. Variable R : relation N.t. Hypothesis R_wd : Proper (N.eq==>N.eq==>iff) R.R:relation tR_wd:Proper (eq ==> eq ==> iff) R(forall m : t, R 0 m) -> (forall n m : t, n <= m -> R n m -> R (S n) (S m)) -> forall n m : t, n <= m -> R n mR:relation tR_wd:Proper (eq ==> eq ==> iff) R(forall m : t, R 0 m) -> (forall n m : t, n <= m -> R n m -> R (S n) (S m)) -> forall n m : t, n <= m -> R n mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 mStep:forall n m : t, n <= m -> R n m -> R (S n) (S m)forall m : t, 0 <= m -> R 0 mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 mStep:forall n m : t, n <= m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n <= m -> R n m) -> forall m : t, S n <= m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 mStep:forall n m : t, n <= m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n <= m -> R n m) -> forall m : t, S n <= m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mR (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mProper (eq ==> iff) (fun m0 : t => R (S n) m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mR (S n) (S n)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mforall m0 : t, S n <= m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mR (S n) (S n)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mforall m0 : t, S n <= m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mforall m0 : t, S n <= m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mk:tH1:S n <= kH2:R (S n) kR (S n) (S k)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mk:tH1:n < kH2:R (S n) kR (S n) (S k)auto. Qed.R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 m0Step:forall n0 m0 : t, n0 <= m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n <= m0 -> R n m0m:tH:S n <= mk:tH1:n <= kH2:R (S n) kR (S n) (S k)R:relation tR_wd:Proper (eq ==> eq ==> iff) R(forall m : t, R 0 (S m)) -> (forall n m : t, n < m -> R n m -> R (S n) (S m)) -> forall n m : t, n < m -> R n mR:relation tR_wd:Proper (eq ==> eq ==> iff) R(forall m : t, R 0 (S m)) -> (forall n m : t, n < m -> R n m -> R (S n) (S m)) -> forall n m : t, n < m -> R n mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 (S m)Step:forall n m : t, n < m -> R n m -> R (S n) (S m)forall m : t, 0 < m -> R 0 mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 (S m)Step:forall n m : t, n < m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n < m -> R n m) -> forall m : t, S n < m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n m0 : t, n < m0 -> R n m0 -> R (S n) (S m0)m:tH:0 < mR 0 mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 (S m)Step:forall n m : t, n < m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n < m -> R n m) -> forall m : t, S n < m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n m0 : t, n < m0 -> R n m0 -> R (S n) (S m0)m, m':tH:m == S m'R 0 mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 (S m)Step:forall n m : t, n < m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n < m -> R n m) -> forall m : t, S n < m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m : t, R 0 (S m)Step:forall n m : t, n < m -> R n m -> R (S n) (S m)forall n : t, (forall m : t, n < m -> R n m) -> forall m : t, S n < m -> R (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mR (S n) mR:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mProper (eq ==> iff) (fun m0 : t => R (S n) m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mR (S n) (S (S n))R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mforall m0 : t, S n < m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mR (S n) (S (S n))R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mforall m0 : t, S n < m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mforall m0 : t, S n < m0 -> R (S n) m0 -> R (S n) (S m0)R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mk:tH1:S n < kH2:R (S n) kR (S n) (S k)auto. Qed. End RelElim.R:relation tR_wd:Proper (eq ==> eq ==> iff) RBase:forall m0 : t, R 0 (S m0)Step:forall n0 m0 : t, n0 < m0 -> R n0 m0 -> R (S n0) (S m0)n:tIH:forall m0 : t, n < m0 -> R n m0m:tH:S n < mk:tH1:n < kH2:R (S n) kR (S n) (S k)
Predecessor and order
forall n : t, 0 < n -> S (P n) == nforall n : t, 0 < n -> S (P n) == nfalse_hyp H lt_irrefl. Qed.n:tH:0 < 0H1:n == 0Falseforall n : t, P n <= nforall n : t, P n <= nP 0 <= 0forall n : t, P (S n) <= S nintros; rewrite pred_succ; apply le_succ_diag_r. Qed.forall n : t, P (S n) <= S nforall n : t, n ~= 0 -> P n < nforall n : t, n ~= 0 -> P n < n0 ~= 0 -> P 0 < 0forall n : t, S n ~= 0 -> P (S n) < S nintros; rewrite pred_succ; apply lt_succ_diag_r. Qed.forall n : t, S n ~= 0 -> P (S n) < S nforall n m : t, n <= m -> P n <= mforall n m : t, n <= m -> P n <= mn, m:tH:n <= mP n <= nn, m:tH:n <= mn <= massumption. Qed.n, m:tH:n <= mn <= mforall n m : t, n < m -> P n < mforall n m : t, n < m -> P n < mn, m:tH:n < mP n <= nn, m:tH:n < mn < massumption. Qed.n, m:tH:n < mn < m(* Converse is false for n == m == 0 *)forall n m : t, n < m -> n <= P mforall n m : t, n < m -> n <= P mn:tn < 0 -> n <= P 0n:tforall n0 : t, n < S n0 -> n <= P (S n0)n:tforall n0 : t, n < S n0 -> n <= P (S n0)rewrite pred_succ; now apply lt_succ_r. Qed.n, m:tIH:n < S mn <= P (S m)(* Converse is false for n == m == 0 *)forall n m : t, P n < m -> n <= mforall n m : t, P n < m -> n <= mm:tP 0 < m -> 0 <= mm:tforall n : t, P (S n) < m -> S n <= mm:tforall n : t, P (S n) < m -> S n <= mm, n:tIH:P (S n) < mS n <= mnow apply le_succ_l. Qed.m, n:tIH:n < mS n <= mforall n m : t, n < P m -> n < mintros n m H; apply lt_le_trans with (P m); [assumption | apply le_pred_l]. Qed.forall n m : t, n < P m -> n < mforall n m : t, n <= P m -> n <= mintros n m H; apply le_trans with (P m); [assumption | apply le_pred_l]. Qed.forall n m : t, n <= P m -> n <= m(* Converse is false for n == 1, m == 0 *)forall n m : t, n <= m -> P n <= P mforall n m : t, n <= m -> P n <= P mn, m:tH:n <= mProper (eq ==> eq ==> iff) (fun n0 m0 : t => P n0 <= P m0)n, m:tH:n <= mforall m0 : t, P 0 <= P m0n, m:tH:n <= mforall n0 m0 : t, n0 <= m0 -> P n0 <= P m0 -> P (S n0) <= P (S m0)n, m:tH:n <= mforall m0 : t, P 0 <= P m0n, m:tH:n <= mforall n0 m0 : t, n0 <= m0 -> P n0 <= P m0 -> P (S n0) <= P (S m0)intros p q H1 _; now do 2 rewrite pred_succ. Qed.n, m:tH:n <= mforall n0 m0 : t, n0 <= m0 -> P n0 <= P m0 -> P (S n0) <= P (S m0)forall n m : t, n ~= 0 -> n < m <-> P n < P mforall n m : t, n ~= 0 -> n < m <-> P n < P mn, m:tH1:n ~= 0H2:n < mP n < P mn, m:tH1:n ~= 0H2:P n < P mn < mn, m:tH1:n ~= 0H2:n < mm ~= 0n, m:tH1:n ~= 0H2:n < mH:m ~= 0P n < P mn, m:tH1:n ~= 0H2:P n < P mn < mn, m:tH1:n ~= 0H2:n < m0 < mn, m:tH1:n ~= 0H2:n < mH:m ~= 0P n < P mn, m:tH1:n ~= 0H2:P n < P mn < mn, m:tH1:n ~= 0H2:n < mH:m ~= 0P n < P mn, m:tH1:n ~= 0H2:P n < P mn < mn, m:tH1:n ~= 0H2:P n < P mn < mn, m:tH1:n ~= 0H2:P n < P mm ~= 0n, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mn, m:tH1:n ~= 0H2:P n < P m0 < mn, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mn, m:tH1:n ~= 0H2:P n < P mP n < mn, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mn, m:tH1:n ~= 0H2:P n < P mP n < P mn, m:tH1:n ~= 0H2:P n < P mP m <= mn, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mn, m:tH1:n ~= 0H2:P n < P mP m <= mn, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mn, m:tH1:n ~= 0H2:P n < P mH:m ~= 0n < mnow do 2 rewrite succ_pred in H2. Qed.n, m:tH1:n ~= 0H2:S (P n) < S (P m)H:m ~= 0n < mforall n m : t, S n < m <-> n < P mforall n m : t, S n < m <-> n < P mn, m:tS n < m <-> n < P mnow rewrite pred_succ. Qed.n, m:tP (S n) < P m <-> n < P m(* Converse is false for n == m == 0 *)forall n m : t, S n <= m -> n <= P mforall n m : t, S n <= m -> n <= P mn, m:tH:S n <= mn <= P mnow apply le_succ_l. Qed.n, m:tH:S n <= mn < m(* Converse is false for n == m == 0 *)forall n m : t, P n < m -> n < S mforall n m : t, P n < m -> n < S mn, m:tH:P n < mn < S mnow apply lt_pred_le. Qed.n, m:tH:P n < mn <= mforall n m : t, P n <= m <-> n <= S mforall n m : t, P n <= m <-> n <= S mm:tP 0 <= m <-> 0 <= S mm:tforall n : t, P (S n) <= m <-> S n <= S mm:t0 <= m <-> 0 <= S mm:tforall n : t, P (S n) <= m <-> S n <= S mm:tforall n : t, P (S n) <= m <-> S n <= S mm, n:tP (S n) <= m <-> S n <= S mapply succ_le_mono. Qed. End NOrderProp.m, n:tn <= m <-> S n <= S m