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 NBase. Module NAddProp (Import N : NAxiomsMiniSig'). Include NBaseProp N.
For theorems about add that are both valid for N and Z, see NZAdd
Now comes theorems valid for natural numbers but not for Z
forall n m : t, n + m == 0 <-> n == 0 /\ m == 0forall n m : t, n + m == 0 <-> n == 0 /\ m == 0m:t0 + m == 0 <-> 0 == 0 /\ m == 0m:tforall n : t, n + m == 0 <-> n == 0 /\ m == 0 -> S n + m == 0 <-> S n == 0 /\ m == 0m:tforall n : t, n + m == 0 <-> n == 0 /\ m == 0 -> S n + m == 0 <-> S n == 0 /\ m == 0m, n:tIH:n + m == 0 <-> n == 0 /\ m == 0S n + m == 0 <-> S n == 0 /\ m == 0m, n:tIH:n + m == 0 <-> n == 0 /\ m == 0S (n + m) == 0 <-> S n == 0 /\ m == 0m, n:tIH:n + m == 0 <-> n == 0 /\ m == 0False <-> S n == 0 /\ m == 0tauto. Qed.m, n:tIH:n + m == 0 <-> n == 0 /\ m == 0False <-> False /\ m == 0forall n m : t, (exists p : t, n + m == S p) <-> (exists n' : t, n == S n') \/ (exists m' : t, m == S m')forall n m : t, (exists p : t, n + m == S p) <-> (exists n' : t, n == S n') \/ (exists m' : t, m == S m')m:t(exists p : t, 0 + m == S p) <-> (exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')m:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m:tH:exists p : t, 0 + m == S p(exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')m:tH:(exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')exists p : t, 0 + m == S pm:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m, p:tH:0 + m == S p(exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')m:tH:(exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')exists p : t, 0 + m == S pm:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m:tH:(exists n' : t, 0 == S n') \/ (exists m' : t, m == S m')exists p : t, 0 + m == S pm:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m, n':tH:0 == S n'exists p : t, 0 + m == S pm, m':tH:m == S m'exists p : t, 0 + m == S pm:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m, m':tH:m == S m'exists p : t, 0 + m == S pm:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m:tforall n : t, (exists p : t, S n + m == S p) <-> (exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m, n:tH:exists p : t, S n + m == S p(exists n' : t, S n == S n') \/ (exists m' : t, m == S m')m, n:tH:(exists n' : t, S n == S n') \/ (exists m' : t, m == S m')exists p : t, S n + m == S pexists (n + m); now rewrite add_succ_l. Qed.m, n:tH:(exists n' : t, S n == S n') \/ (exists m' : t, m == S m')exists p : t, S n + m == S pforall n m : t, n + m == 1 -> n == 1 /\ m == 0 \/ n == 0 /\ m == 1forall n m : t, n + m == 1 -> n == 1 /\ m == 0 \/ n == 0 /\ m == 1n, m:tn + m == 1 -> n == 1 /\ m == 0 \/ n == 0 /\ m == 1n, m:tn + m == S 0 -> n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0H1:exists p : t, n + m == S pn == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0H1:(exists n' : t, n == S n') \/ (exists m' : t, m == S m')n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0n':tH1:n == S n'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0m':tH1:m == S m'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0n':tH1:n == S n'n == S 0 /\ m == 0n, m:tH:n + m == S 0m':tH1:m == S m'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m, n':tH:n' + m == 0H1:n == S n'n == S 0 /\ m == 0n, m:tH:n + m == S 0m':tH1:m == S m'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m, n':tH:n' == 0 /\ m == 0H1:n == S n'n == S 0 /\ m == 0n, m:tH:n + m == S 0m':tH1:m == S m'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0m':tH1:m == S m'n == S 0 /\ m == 0 \/ n == 0 /\ m == S 0n, m:tH:n + m == S 0m':tH1:m == S m'n == 0 /\ m == S 0n, m, m':tH:n + m' == 0H1:m == S m'n == 0 /\ m == S 0destruct H as [H2 H3]; rewrite H3 in H1; now split. Qed.n, m, m':tH:n == 0 /\ m' == 0H1:m == S m'n == 0 /\ m == S 0forall n m : t, m ~= S (n + m)forall n m : t, m ~= S (n + m)n:t0 ~= S (n + 0)n:tforall n0 : t, n0 ~= S (n + n0) -> S n0 ~= S (n + S n0)n:tS (n + 0) ~= 0n:tforall n0 : t, n0 ~= S (n + n0) -> S n0 ~= S (n + S n0)n:tforall n0 : t, n0 ~= S (n + n0) -> S n0 ~= S (n + S n0)n, m:tIH:m ~= S (n + m)H:S m == S (n + S m)Falsen, m:tIH:m ~= S (n + m)H:m == n + S mFalseunfold not in IH; now apply IH. Qed.n, m:tIH:m ~= S (n + m)H:m == S (n + m)Falseforall n m : t, n ~= 0 -> P n + m == P (n + m)forall n m : t, n ~= 0 -> P n + m == P (n + m)m:t0 ~= 0 -> P 0 + m == P (0 + m)m:tforall n : t, S n ~= 0 -> P (S n) + m == P (S n + m)intros n IH; rewrite add_succ_l; now do 2 rewrite pred_succ. Qed.m:tforall n : t, S n ~= 0 -> P (S n) + m == P (S n + m)forall n m : t, m ~= 0 -> n + P m == P (n + m)intros n m H; rewrite (add_comm n (P m)); rewrite (add_comm n m); now apply add_pred_l. Qed. End NAddProp.forall n m : t, m ~= 0 -> n + P m == P (n + m)