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 NZAxioms. Require Import ZArith. Require Import Zpow_facts. Require Import DoubleType. Require Import CyclicAxioms.
A Z/nZ representation given by a module type CyclicType
implements NZAxiomsSig, e.g. the common properties between
N and Z with no ordering. Notice that the n in Z/nZ is
a power of 2.
Module NZCyclicAxiomsMod (Import Cyclic : CyclicType) <: NZAxiomsSig. Local Open Scope Z_scope. Notation wB := (base ZnZ.digits). Local Notation "[| x |]" := (ZnZ.to_Z x) (at level 0, x at level 99). Definition eq (n m : t) := [| n |] = [| m |]. Definition zero := ZnZ.zero. Definition one := ZnZ.one. Definition two := ZnZ.succ ZnZ.one. Definition succ := ZnZ.succ. Definition pred := ZnZ.pred. Definition add := ZnZ.add. Definition sub := ZnZ.sub. Definition mul := ZnZ.mul. Local Infix "==" := eq (at level 70). Local Notation "0" := zero. Notation S := succ. Notation P := pred. Local Infix "+" := add. Local Infix "-" := sub. Local Infix "*" := mul. Hint Rewrite ZnZ.spec_0 ZnZ.spec_1 ZnZ.spec_succ ZnZ.spec_pred ZnZ.spec_add ZnZ.spec_mul ZnZ.spec_sub : cyclic. Ltac zify := unfold eq, zero, one, two, succ, pred, add, sub, mul in *; autorewrite with cyclic. Ltac zcongruence := repeat red; intros; zify; congruence.Equivalence eqEquivalence eqfirstorder. Qed. Local Obligation Tactic := zcongruence. Instance succ_wd : Proper (eq ==> eq) succ. Instance pred_wd : Proper (eq ==> eq) pred. Instance add_wd : Proper (eq ==> eq ==> eq) add. Instance sub_wd : Proper (eq ==> eq ==> eq) sub. Instance mul_wd : Proper (eq ==> eq ==> eq) mul.Equivalence (fun n m : t => [|n|] = [|m|])1 < wB1 < wBapply Zpower_gt_1; unfold Z.lt; auto with zarith. Qed.1 < 2 ^ Z.pos ZnZ.digits0 < wBpose proof gt_wB_1; auto with zarith. Qed.0 < wB1 mod wB = 11 mod wB = 11 = 10 <= 1 < wB0 <= 1 < wB0 <= 11 < wBapply gt_wB_1. Qed.1 < wBforall n : Z, (n + 1) mod wB = (n mod wB + 1) mod wBforall n : Z, (n + 1) mod wB = (n mod wB + 1) mod wBn:Z(n + 1) mod wB = (n mod wB + 1) mod wBnow rewrite <- Zplus_mod. Qed.n:Z(n + 1) mod wB = (n mod wB + 1 mod wB) mod wBforall n : Z, (n - 1) mod wB = (n mod wB - 1) mod wBforall n : Z, (n - 1) mod wB = (n mod wB - 1) mod wBn:Z(n - 1) mod wB = (n mod wB - 1) mod wBnow rewrite Zminus_mod. Qed.n:Z(n - 1) mod wB = (n mod wB - 1 mod wB) mod wBforall n : t, [|n|] mod wB = [|n|]forall n : t, [|n|] mod wB = [|n|]n:t[|n|] = [|n|]n:t0 <= [|n|] < wBapply ZnZ.spec_to_Z. Qed.n:t0 <= [|n|] < wBforall n : t, P (S n) == nforall n : t, P (S n) == nn:tP (S n) == nn:t(([|n|] + 1) mod wB - 1) mod wB = [|n|]n:t([|n|] + 1 - 1) mod wB = [|n|]apply NZ_to_Z_mod. Qed.n:t[|n|] mod wB = [|n|]one == S 0one == S 0now rewrite one_mod_wB. Qed.1 = 1 mod wBtwo == S onereflexivity. Qed. Section Induction. Variable A : t -> Prop. Hypothesis A_wd : Proper (eq ==> iff) A. Hypothesis A0 : A 0. Hypothesis AS : forall n, A n <-> A (S n). (* Below, we use only -> direction *) Let B (n : Z) := A (ZnZ.of_Z n).two == S oneA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropB 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropB 0apply A0. Qed.A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropA (ZnZ.of_Z 0)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : Z, 0 <= n -> n < wB - 1 -> B n -> B (n + 1)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : Z, 0 <= n -> n < wB - 1 -> B n -> B (n + 1)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:B nB (n + 1)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (ZnZ.of_Z n)A (ZnZ.of_Z (n + 1))A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (S (ZnZ.of_Z n))A (ZnZ.of_Z (n + 1))A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (S (ZnZ.of_Z n))A (S (ZnZ.of_Z n))A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (S (ZnZ.of_Z n))ZnZ.of_Z (n + 1) == S (ZnZ.of_Z n)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (S (ZnZ.of_Z n))ZnZ.of_Z (n + 1) == S (ZnZ.of_Z n)A:t -> PropA_wd:Proper ((fun n0 m : t => [|n0|] = [|m|]) ==> iff) AA0:A ZnZ.zeroAS:forall n0 : t, A n0 <-> A (ZnZ.succ n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (ZnZ.succ (ZnZ.of_Z n))[|ZnZ.of_Z (n + 1)|] = ([|ZnZ.of_Z n|] + 1) mod wBsymmetry; apply Zmod_small; auto with zarith. Qed.A:t -> PropA_wd:Proper ((fun n0 m : t => [|n0|] = [|m|]) ==> iff) AA0:A ZnZ.zeroAS:forall n0 : t, A n0 <-> A (ZnZ.succ n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB - 1H3:A (ZnZ.succ (ZnZ.of_Z n))n + 1 = (n + 1) mod wBA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall (Q : Z -> Prop) (b : Z), Q 0 -> (forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)) -> forall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall (Q : Z -> Prop) (b : Z), Q 0 -> (forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)) -> forall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)forall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall n : Z, 0 <= n -> Q' nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Prop0 < b /\ Q 0 \/ b <= 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall z : Z, 0 <= z -> z < b /\ Q z \/ b <= z -> Z.succ z < b /\ Q (Z.succ z) \/ b <= Z.succ zA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:b <= 00 < b /\ Q 0 \/ b <= 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:0 < b0 < b /\ Q 0 \/ b <= 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall z : Z, 0 <= z -> z < b /\ Q z \/ b <= z -> Z.succ z < b /\ Q (Z.succ z) \/ b <= Z.succ zA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:0 < b0 < b /\ Q 0 \/ b <= 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall z : Z, 0 <= z -> z < b /\ Q z \/ b <= z -> Z.succ z < b /\ Q (Z.succ z) \/ b <= Z.succ zA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> Propforall z : Z, 0 <= z -> z < b /\ Q z \/ b <= z -> Z.succ z < b /\ Q (Z.succ z) \/ b <= Z.succ zA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:n < b /\ Q n \/ b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH1:n < bIH2:Q nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH1:n < bIH2:Q nH1:b - 1 <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH1:n < bIH2:Q nH1:n < b - 1Z.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH1:n < bIH2:Q nH1:n < b - 1Z.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH1:n < bIH2:Q nH1:n < b - 1Z.succ n < b /\ Q (Z.succ n)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> Propn:ZH:0 <= nIH:b <= nZ.succ n < b /\ Q (Z.succ n) \/ b <= Z.succ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n : Z, 0 <= n -> n < b - 1 -> Q n -> Q (n + 1)Q':=fun n : Z => n < b /\ Q n \/ b <= n:Z -> PropH:forall n : Z, 0 <= n -> Q' nforall n : Z, 0 <= n -> n < b -> Q nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> PropH:forall n0 : Z, 0 <= n0 -> n0 < b /\ Q n0 \/ b <= n0n:ZH1:0 <= nH2:n < bQ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> PropH:forall n0 : Z, 0 <= n0 -> n0 < b /\ Q n0 \/ b <= n0n:ZH1:0 <= nH2, H3:n < bH4:Q nQ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> PropH:forall n0 : Z, 0 <= n0 -> n0 < b /\ Q n0 \/ b <= n0n:ZH1:0 <= nH2:n < bH3:b <= nQ nnow apply Z.le_ngt in H3. Qed.A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> PropQ:Z -> Propb:ZQ0:Q 0QS:forall n0 : Z, 0 <= n0 -> n0 < b - 1 -> Q n0 -> Q (n0 + 1)Q':=fun n0 : Z => n0 < b /\ Q n0 \/ b <= n0:Z -> PropH:forall n0 : Z, 0 <= n0 -> n0 < b /\ Q n0 \/ b <= n0n:ZH1:0 <= nH2:n < bH3:b <= nQ nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : Z, 0 <= n < wB -> B nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : Z, 0 <= n < wB -> B nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBB nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBB 0A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBforall n0 : Z, 0 <= n0 -> n0 < wB - 1 -> B n0 -> B (n0 + 1)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB0 <= nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBn < wBA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBforall n0 : Z, 0 <= n0 -> n0 < wB - 1 -> B n0 -> B (n0 + 1)A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB0 <= nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBn < wBA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wB0 <= nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBn < wBassumption. Qed.A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:ZH1:0 <= nH2:n < wBn < wBA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : t, A nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n : t, A n <-> A (S n)B:=fun n : Z => A (ZnZ.of_Z n):Z -> Propforall n : t, A nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:tA nA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:tA (ZnZ.of_Z [|n|])A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:tn == ZnZ.of_Z [|n|]A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:t0 <= [|n|] < wBA:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:tn == ZnZ.of_Z [|n|]A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:tn == ZnZ.of_Z [|n|]A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:t[|n|] = [|ZnZ.of_Z [|n|]|]A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:t[|ZnZ.of_Z [|n|]|] = [|n|]apply ZnZ.spec_to_Z. Qed. End Induction.A:t -> PropA_wd:Proper (eq ==> iff) AA0:A 0AS:forall n0 : t, A n0 <-> A (S n0)B:=fun n0 : Z => A (ZnZ.of_Z n0):Z -> Propn:t0 <= [|n|] < wBforall n : t, 0 + n == nforall n : t, 0 + n == nn:t0 + n == nn:t(0 + [|n|]) mod wB = [|n|]n:t[|n|] mod wB = [|n|]apply ZnZ.spec_to_Z. Qed.n:t0 <= [|n|] < wBforall n m : t, S n + m == S (n + m)forall n m : t, S n + m == S (n + m)n, m:tS n + m == S (n + m)n, m:t(([|n|] + 1) mod wB + [|m|]) mod wB = (([|n|] + [|m|]) mod wB + 1) mod wBn, m:t(([|n|] mod wB + 1) mod wB + [|m|]) mod wB = (([|n|] + [|m|]) mod wB + 1) mod wBn, m:t([|n|] mod wB + 1 + [|m|]) mod wB = ([|n|] + [|m|] + 1) mod wBn, m:t([|n|] mod wB + (1 + [|m|])) mod wB = ([|n|] + [|m|] + 1) mod wBrewrite (Z.add_comm 1 [| m |]); now rewrite Z.add_assoc. Qed.n, m:t([|n|] + (1 + [|m|])) mod wB = ([|n|] + [|m|] + 1) mod wBforall n : t, n - 0 == nforall n : t, n - 0 == nn:tn - 0 == nn:t([|n|] - 0) mod wB = [|n|]apply NZ_to_Z_mod. Qed.n:t[|n|] mod wB = [|n|]forall n m : t, n - S m == P (n - m)forall n m : t, n - S m == P (n - m)n, m:tn - S m == P (n - m)n, m:t([|n|] - ([|m|] + 1) mod wB) mod wB = (([|n|] - [|m|]) mod wB - 1) mod wBnow replace ([|n|] - ([|m|] + 1))%Z with ([|n|] - [|m|] - 1)%Z by ring. Qed.n, m:t([|n|] - ([|m|] + 1)) mod wB = ([|n|] - [|m|] - 1) mod wBforall n : t, 0 * n == 0forall n : t, 0 * n == 0now zify. Qed.n:t0 * n == 0forall n m : t, S n * m == n * m + mforall n m : t, S n * m == n * m + mn, m:tS n * m == n * m + mn, m:t(([|n|] + 1) mod wB * [|m|]) mod wB = (([|n|] * [|m|]) mod wB + [|m|]) mod wBnow rewrite Z.mul_add_distr_r, Z.mul_1_l. Qed. Definition t := t. End NZCyclicAxiomsMod.n, m:t(([|n|] + 1) * [|m|]) mod wB = ([|n|] * [|m|] + [|m|]) mod wB