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. Module Type NZBaseProp (Import NZ : NZDomainSig'). Include BackportEq NZ NZ.
eq_refl, eq_sym, eq_trans
forall x y : t, x == y <-> y == xintros; split; symmetry; auto. Qed. (* TODO: how register ~= (which is just a notation) as a Symmetric relation, hence allowing "symmetry" tac ? *)forall x y : t, x == y <-> y == xforall n m : t, n ~= m -> m ~= nintros n m H1 H2; symmetry in H2; false_hyp H2 H1. Qed.forall n m : t, n ~= m -> m ~= nforall x y z : t, x == y -> x == z -> z == yintros x y z H1 H2; now rewrite <- H1. Qed. Declare Left Step eq_stepl. (* The right step lemma is just the transitivity of eq *) Declare Right Step (@Equivalence_Transitive _ _ eq_equiv).forall x y z : t, x == y -> x == z -> z == yforall n1 n2 : t, S n1 == S n2 -> n1 == n2forall n1 n2 : t, S n1 == S n2 -> n1 == n2n1, n2:tH:S n1 == S n2n1 == n2now do 2 rewrite pred_succ in H. Qed. (* The following theorem is useful as an equivalence for proving bidirectional induction steps *)n1, n2:tH:P (S n1) == P (S n2)n1 == n2forall n1 n2 : t, S n1 == S n2 <-> n1 == n2forall n1 n2 : t, S n1 == S n2 <-> n1 == n2n1, n2:tS n1 == S n2 -> n1 == n2n1, n2:tn1 == n2 -> S n1 == S n2apply succ_inj.n1, n2:tS n1 == S n2 -> n1 == n2n1, n2:tn1 == n2 -> S n1 == S n2now f_equiv. Qed.n1, n2:tH:n1 == n2S n1 == S n2forall n m : t, S n ~= S m <-> n ~= mintros; now rewrite succ_inj_wd. Qed. (* We cannot prove that the predecessor is injective, nor that it is left-inverse to the successor at this point *) Section CentralInduction. Variable A : t -> Prop. Hypothesis A_wd : Proper (eq==>iff) A.forall n m : t, S n ~= S m <-> n ~= mA:t -> PropA_wd:Proper (eq ==> iff) Aforall z : t, A z -> (forall n : t, A n <-> A (S n)) -> forall n : t, A nA:t -> PropA_wd:Proper (eq ==> iff) Aforall z : t, A z -> (forall n : t, A n <-> A (S n)) -> forall n : t, A nA:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)Proper (eq ==> iff) (fun t0 : t => A t0 -> forall n : t, A n)A:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)A 0 -> forall n : t, A nA:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)forall n : t, (A n -> forall n0 : t, A n0) <-> (A (S n) -> forall n0 : t, A n0)solve_proper.A:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)Proper (eq ==> iff) (fun t0 : t => A t0 -> forall n : t, A n)intro; now apply bi_induction.A:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)A 0 -> forall n : t, A nintro; pose proof (Step n); tauto. Qed. End CentralInduction. Tactic Notation "nzinduct" ident(n) := induction_maker n ltac:(apply bi_induction). Tactic Notation "nzinduct" ident(n) constr(u) := induction_maker n ltac:(apply central_induction with (z := u)). End NZBaseProp.A:t -> PropA_wd:Proper (eq ==> iff) Az:tStep:forall n : t, A n <-> A (S n)forall n : t, (A n -> forall n0 : t, A n0) <-> (A (S n) -> forall n0 : t, A n0)