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 ZBase. Module ZAddProp (Import Z : ZAxiomsMiniSig'). Include ZBaseProp Z.
Theorems that are either not valid on N or have different proofs
on N and Z
Hint Rewrite opp_0 : nz.forall n m : t, P n + m == P (n + m)forall n m : t, P n + m == P (n + m)n, m:tP n + m == P (n + m)now rewrite add_succ_l, pred_succ. Qed.n, m:tP n + m == P (S (P n) + m)forall n m : t, n + P m == P (n + m)intros n m; rewrite 2 (add_comm n); apply add_pred_l. Qed.forall n m : t, n + P m == P (n + m)forall n m : t, n + - m == n - mforall n m : t, n + - m == n - mn:tn + - 0 == n - 0n:tforall n0 : t, n + - n0 == n - n0 <-> n + - S n0 == n - S n0n:tforall n0 : t, n + - n0 == n - n0 <-> n + - S n0 == n - S n0n, m:tn + - m == n - m <-> n + - S m == n - S mnow rewrite pred_inj_wd. Qed.n, m:tn + - m == n - m <-> P (n + - m) == P (n - m)forall n : t, 0 - n == - nintro n; rewrite <- add_opp_r; now rewrite add_0_l. Qed.forall n : t, 0 - n == - nforall n m : t, S n - m == S (n - m)intros n m; rewrite <- 2 add_opp_r; now rewrite add_succ_l. Qed.forall n m : t, S n - m == S (n - m)forall n m : t, P n - m == P (n - m)forall n m : t, P n - m == P (n - m)n, m:tP n - m == P (n - m)rewrite sub_succ_l; now rewrite pred_succ. Qed.n, m:tP n - m == P (S (P n) - m)forall n m : t, n - P m == S (n - m)forall n m : t, n - P m == S (n - m)n, m:tn - P m == S (n - m)rewrite sub_succ_r; now rewrite succ_pred. Qed.n, m:tn - P m == S (n - S (P m))forall n : t, - P n == S (- n)forall n : t, - P n == S (- n)n:t- P n == S (- n)n:t- P n == S (- S (P n))now rewrite succ_pred. Qed.n:t- P n == S (P (- P n))forall n : t, n - n == 0forall n : t, n - n == 00 - 0 == 0forall n : t, n - n == 0 <-> S n - S n == 0forall n : t, n - n == 0 <-> S n - S n == 0rewrite sub_succ_r, sub_succ_l; now rewrite pred_succ. Qed.n:tn - n == 0 <-> S n - S n == 0forall n : t, - n + n == 0intro n; now rewrite add_comm, add_opp_r, sub_diag. Qed.forall n : t, - n + n == 0forall n : t, n + - n == 0intro n; rewrite add_comm; apply add_opp_diag_l. Qed.forall n : t, n + - n == 0forall n m : t, - m + n == n - mintros n m; rewrite <- add_opp_r; now rewrite add_comm. Qed.forall n m : t, - m + n == n - mforall n m p : t, n + (m - p) == n + m - pintros n m p; rewrite <- 2 add_opp_r; now rewrite add_assoc. Qed.forall n m p : t, n + (m - p) == n + m - pforall n : t, - - n == nforall n : t, - - n == n- - 0 == 0forall n : t, - - n == n <-> - - S n == S nforall n : t, - - n == n <-> - - S n == S nn:t- - n == n <-> - - S n == S nnow rewrite succ_inj_wd. Qed.n:t- - n == n <-> S (- - n) == S nforall n m : t, - (n + m) == - n + - mforall n m : t, - (n + m) == - n + - mm:t- (0 + m) == - 0 + - mm:tforall n : t, - (n + m) == - n + - m <-> - (S n + m) == - S n + - mm:tforall n : t, - (n + m) == - n + - m <-> - (S n + m) == - S n + - mm, n:t- (n + m) == - n + - m <-> - (S n + m) == - S n + - mnow rewrite pred_inj_wd. Qed.m, n:t- (n + m) == - n + - m <-> P (- (n + m)) == P (- n + - m)forall n m : t, - (n - m) == - n + mforall n m : t, - (n - m) == - n + mnow rewrite opp_involutive. Qed.n, m:t- n + - - m == - n + mforall n m : t, - n == - m -> n == mforall n m : t, - n == - m -> n == mn, m:tH:- n == - mn == mnow rewrite 2 opp_involutive in H. Qed.n, m:tH:- - n == - - mn == mforall n m : t, - n == - m <-> n == mintros n m; split; [apply opp_inj | intros; now f_equiv]. Qed.forall n m : t, - n == - m <-> n == mforall n m : t, - n == m <-> n == - mforall n m : t, - n == m <-> n == - mnow rewrite <- (opp_inj_wd (- n) m), opp_involutive. Qed.n, m:t- n == m <-> n == - mforall n m : t, n == - m <-> - n == msymmetry; apply eq_opp_l. Qed.forall n m : t, n == - m <-> - n == mforall n m p : t, n - (m + p) == n - m - pforall n m p : t, n - (m + p) == n - m - pnow rewrite 2 add_opp_r. Qed.n, m, p:tn + - m + - p == n - m - pforall n m p : t, n - (m - p) == n - m + pforall n m p : t, n - (m - p) == n - m + pnow rewrite add_opp_r. Qed.n, m, p:tn + - m + p == n - m + pforall n m : t, - n - m == - m - nforall n m : t, - n - m == - m - nn, m:t- n - m == - m - nnow rewrite add_comm. Qed.n, m:t- n + - m == - m + - nforall n m : t, n - - m == n + mintros n m; rewrite <- add_opp_r; now rewrite opp_involutive. Qed.forall n m : t, n - - m == n + mforall n m p : t, n + m - p == n - p + mforall n m p : t, n + m - p == n - p + mn, m, p:tn + m - p == n - p + mnow rewrite add_opp_l. Qed.n, m, p:tn + (m - p) == n + (- p + m)forall n m p : t, n - m == n - p <-> m == pforall n m p : t, n - m == n - p <-> m == pn, m, p:tn - m == n - p <-> m == pn, m, p:t- n + (n - m) == - n + (n - p) <-> m == pn, m, p:t- n + n - m == - n + n - p <-> m == papply opp_inj_wd. Qed.n, m, p:t- m == - p <-> m == pforall n m p : t, n - p == m - p <-> n == mforall n m p : t, n - p == m - p <-> n == mn, m, p:tn - p == m - p <-> n == mnow do 2 rewrite <- sub_sub_distr, sub_diag, sub_0_r. Qed.n, m, p:tn - p + p == m - p + p <-> n == m
The next several theorems are devoted to moving terms from one
side of an equation to the other. The name contains the operation
in the original equation (add or sub) and the indication
whether the left or right term is moved.
forall n m p : t, n + m == p <-> m == p - nforall n m p : t, n + m == p <-> m == p - nn, m, p:tn + m == p <-> m == p - nnow rewrite add_comm, <- add_sub_assoc, sub_diag, add_0_r. Qed.n, m, p:tn + m - n == p - n <-> m == p - nforall n m p : t, n + m == p <-> n == p - mintros n m p; rewrite add_comm; now apply add_move_l. Qed.forall n m p : t, n + m == p <-> n == p - m
The two theorems above do not allow rewriting subformulas of the
form n - m == p to n == p + m since subtraction is in the
right-hand side of the equation. Hence the following two
theorems.
forall n m p : t, n - m == p <-> - m == p - nintros n m p; rewrite <- (add_opp_r n m); apply add_move_l. Qed.forall n m p : t, n - m == p <-> - m == p - nforall n m p : t, n - m == p <-> n == p + mforall n m p : t, n - m == p <-> n == p + mnow rewrite add_move_r, sub_opp_r. Qed.n, m, p:tn + - m == p <-> n == p + mforall n m : t, n + m == 0 <-> m == - nintros n m; now rewrite add_move_l, sub_0_l. Qed.forall n m : t, n + m == 0 <-> m == - nforall n m : t, n + m == 0 <-> n == - mintros n m; now rewrite add_move_r, sub_0_l. Qed.forall n m : t, n + m == 0 <-> n == - mforall n m : t, n - m == 0 <-> - m == - nforall n m : t, n - m == 0 <-> - m == - nnow rewrite sub_move_l, sub_0_l. Qed.n, m:tn - m == 0 <-> - m == - nforall n m : t, n - m == 0 <-> n == mforall n m : t, n - m == 0 <-> n == mnow rewrite sub_move_r, add_0_l. Qed.n, m:tn - m == 0 <-> n == m
The following section is devoted to cancellation of like
terms. The name includes the first operator and the position of
the term being canceled.
forall n m : t, n + m - n == mintros; now rewrite add_sub_swap, sub_diag, add_0_l. Qed.forall n m : t, n + m - n == mforall n m : t, n + m - m == nintros; now rewrite <- add_sub_assoc, sub_diag, add_0_r. Qed.forall n m : t, n + m - m == nforall n m : t, - n - m + n == - mintros; now rewrite <- add_sub_swap, add_opp_diag_l, sub_0_l. Qed.forall n m : t, - n - m + n == - mforall n m : t, n - m + m == nintros; now rewrite <- sub_sub_distr, sub_diag, sub_0_r. Qed.forall n m : t, n - m + m == nforall n m : t, m - n + n == mforall n m : t, m - n + n == mnow rewrite <- add_sub_swap, add_simpl_r. Qed.n, m:tm - n + n == m
Now we have two sums or differences; the name includes the two
operators and the position of the terms being canceled
forall n m p : t, n + m - (n + p) == m - pforall n m p : t, n + m - (n + p) == m - pnow rewrite (add_comm n m), <- add_sub_assoc, sub_add_distr, sub_diag, sub_0_l, add_opp_r. Qed.n, m, p:tn + m - (n + p) == m - pforall n m p : t, n + m - (p + n) == m - pforall n m p : t, n + m - (p + n) == m - prewrite (add_comm p n); apply add_add_simpl_l_l. Qed.n, m, p:tn + m - (p + n) == m - pforall n m p : t, n + m - (m + p) == n - pforall n m p : t, n + m - (m + p) == n - prewrite (add_comm n m); apply add_add_simpl_l_l. Qed.n, m, p:tn + m - (m + p) == n - pforall n m p : t, n + m - (p + m) == n - pforall n m p : t, n + m - (p + m) == n - prewrite (add_comm p m); apply add_add_simpl_r_l. Qed.n, m, p:tn + m - (p + m) == n - pforall n m p : t, n - m + (m + p) == n + pforall n m p : t, n - m + (m + p) == n + pnow rewrite <- sub_sub_distr, sub_add_distr, sub_diag, sub_0_l, sub_opp_r. Qed.n, m, p:tn - m + (m + p) == n + pforall n m p : t, n - m + (p + m) == n + pforall n m p : t, n - m + (p + m) == n + prewrite (add_comm p m); apply sub_add_simpl_r_l. Qed.n, m, p:tn - m + (p + m) == n + p
Of course, there are many other variants
End ZAddProp.