~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to theories/Numbers/Natural/Peano/NPeano.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(************************************************************************)
 
2
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
 
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
 
4
(*   \VV/  **************************************************************)
 
5
(*    //   *      This file is distributed under the terms of the       *)
 
6
(*         *       GNU Lesser General Public License Version 2.1        *)
 
7
(************************************************************************)
 
8
(*                      Evgeny Makarov, INRIA, 2007                     *)
 
9
(************************************************************************)
 
10
 
 
11
(*i $Id: NPeano.v 11040 2008-06-03 00:04:16Z letouzey $ i*)
 
12
 
 
13
Require Import Arith.
 
14
Require Import Min.
 
15
Require Import Max.
 
16
Require Import NSub.
 
17
 
 
18
Module NPeanoAxiomsMod <: NAxiomsSig.
 
19
Module Export NZOrdAxiomsMod <: NZOrdAxiomsSig.
 
20
Module Export NZAxiomsMod <: NZAxiomsSig.
 
21
 
 
22
Definition NZ := nat.
 
23
Definition NZeq := (@eq nat).
 
24
Definition NZ0 := 0.
 
25
Definition NZsucc := S.
 
26
Definition NZpred := pred.
 
27
Definition NZadd := plus.
 
28
Definition NZsub := minus.
 
29
Definition NZmul := mult.
 
30
 
 
31
Theorem NZeq_equiv : equiv nat NZeq.
 
32
Proof (eq_equiv nat).
 
33
 
 
34
Add Relation nat NZeq
 
35
 reflexivity proved by (proj1 NZeq_equiv)
 
36
 symmetry proved by (proj2 (proj2 NZeq_equiv))
 
37
 transitivity proved by (proj1 (proj2 NZeq_equiv))
 
38
as NZeq_rel.
 
39
 
 
40
(* If we say "Add Relation nat (@eq nat)" instead of "Add Relation nat NZeq"
 
41
then the theorem generated for succ_wd below is forall x, succ x = succ x,
 
42
which does not match the axioms in NAxiomsSig *)
 
43
 
 
44
Add Morphism NZsucc with signature NZeq ==> NZeq as NZsucc_wd.
 
45
Proof.
 
46
congruence.
 
47
Qed.
 
48
 
 
49
Add Morphism NZpred with signature NZeq ==> NZeq as NZpred_wd.
 
50
Proof.
 
51
congruence.
 
52
Qed.
 
53
 
 
54
Add Morphism NZadd with signature NZeq ==> NZeq ==> NZeq as NZadd_wd.
 
55
Proof.
 
56
congruence.
 
57
Qed.
 
58
 
 
59
Add Morphism NZsub with signature NZeq ==> NZeq ==> NZeq as NZsub_wd.
 
60
Proof.
 
61
congruence.
 
62
Qed.
 
63
 
 
64
Add Morphism NZmul with signature NZeq ==> NZeq ==> NZeq as NZmul_wd.
 
65
Proof.
 
66
congruence.
 
67
Qed.
 
68
 
 
69
Theorem NZinduction :
 
70
  forall A : nat -> Prop, predicate_wd (@eq nat) A ->
 
71
    A 0 -> (forall n : nat, A n <-> A (S n)) -> forall n : nat, A n.
 
72
Proof.
 
73
intros A A_wd A0 AS. apply nat_ind. assumption. intros; now apply -> AS.
 
74
Qed.
 
75
 
 
76
Theorem NZpred_succ : forall n : nat, pred (S n) = n.
 
77
Proof.
 
78
reflexivity.
 
79
Qed.
 
80
 
 
81
Theorem NZadd_0_l : forall n : nat, 0 + n = n.
 
82
Proof.
 
83
reflexivity.
 
84
Qed.
 
85
 
 
86
Theorem NZadd_succ_l : forall n m : nat, (S n) + m = S (n + m).
 
87
Proof.
 
88
reflexivity.
 
89
Qed.
 
90
 
 
91
Theorem NZsub_0_r : forall n : nat, n - 0 = n.
 
92
Proof.
 
93
intro n; now destruct n.
 
94
Qed.
 
95
 
 
96
Theorem NZsub_succ_r : forall n m : nat, n - (S m) = pred (n - m).
 
97
Proof.
 
98
intros n m; induction n m using nat_double_ind; simpl; auto. apply NZsub_0_r.
 
99
Qed.
 
100
 
 
101
Theorem NZmul_0_l : forall n : nat, 0 * n = 0.
 
102
Proof.
 
103
reflexivity.
 
104
Qed.
 
105
 
 
106
Theorem NZmul_succ_l : forall n m : nat, S n * m = n * m + m.
 
107
Proof.
 
108
intros n m; now rewrite plus_comm.
 
109
Qed.
 
110
 
 
111
End NZAxiomsMod.
 
112
 
 
113
Definition NZlt := lt.
 
114
Definition NZle := le.
 
115
Definition NZmin := min.
 
116
Definition NZmax := max.
 
117
 
 
118
Add Morphism NZlt with signature NZeq ==> NZeq ==> iff as NZlt_wd.
 
119
Proof.
 
120
unfold NZeq; intros x1 x2 H1 y1 y2 H2; rewrite H1; now rewrite H2.
 
121
Qed.
 
122
 
 
123
Add Morphism NZle with signature NZeq ==> NZeq ==> iff as NZle_wd.
 
124
Proof.
 
125
unfold NZeq; intros x1 x2 H1 y1 y2 H2; rewrite H1; now rewrite H2.
 
126
Qed.
 
127
 
 
128
Add Morphism NZmin with signature NZeq ==> NZeq ==> NZeq as NZmin_wd.
 
129
Proof.
 
130
congruence.
 
131
Qed.
 
132
 
 
133
Add Morphism NZmax with signature NZeq ==> NZeq ==> NZeq as NZmax_wd.
 
134
Proof.
 
135
congruence.
 
136
Qed.
 
137
 
 
138
Theorem NZlt_eq_cases : forall n m : nat, n <= m <-> n < m \/ n = m.
 
139
Proof.
 
140
intros n m; split.
 
141
apply le_lt_or_eq.
 
142
intro H; destruct H as [H | H].
 
143
now apply lt_le_weak. rewrite H; apply le_refl.
 
144
Qed.
 
145
 
 
146
Theorem NZlt_irrefl : forall n : nat, ~ (n < n).
 
147
Proof.
 
148
exact lt_irrefl.
 
149
Qed.
 
150
 
 
151
Theorem NZlt_succ_r : forall n m : nat, n < S m <-> n <= m.
 
152
Proof.
 
153
intros n m; split; [apply lt_n_Sm_le | apply le_lt_n_Sm].
 
154
Qed.
 
155
 
 
156
Theorem NZmin_l : forall n m : nat, n <= m -> NZmin n m = n.
 
157
Proof.
 
158
exact min_l.
 
159
Qed.
 
160
 
 
161
Theorem NZmin_r : forall n m : nat, m <= n -> NZmin n m = m.
 
162
Proof.
 
163
exact min_r.
 
164
Qed.
 
165
 
 
166
Theorem NZmax_l : forall n m : nat, m <= n -> NZmax n m = n.
 
167
Proof.
 
168
exact max_l.
 
169
Qed.
 
170
 
 
171
Theorem NZmax_r : forall n m : nat, n <= m -> NZmax n m = m.
 
172
Proof.
 
173
exact max_r.
 
174
Qed.
 
175
 
 
176
End NZOrdAxiomsMod.
 
177
 
 
178
Definition recursion : forall A : Type, A -> (nat -> A -> A) -> nat -> A :=
 
179
  fun A : Type => nat_rect (fun _ => A).
 
180
Implicit Arguments recursion [A].
 
181
 
 
182
Theorem succ_neq_0 : forall n : nat, S n <> 0.
 
183
Proof.
 
184
intros; discriminate.
 
185
Qed.
 
186
 
 
187
Theorem pred_0 : pred 0 = 0.
 
188
Proof.
 
189
reflexivity.
 
190
Qed.
 
191
 
 
192
Theorem recursion_wd : forall (A : Type) (Aeq : relation A),
 
193
  forall a a' : A, Aeq a a' ->
 
194
    forall f f' : nat -> A -> A, fun2_eq (@eq nat) Aeq Aeq f f' ->
 
195
      forall n n' : nat, n = n' ->
 
196
        Aeq (recursion a f n) (recursion a' f' n').
 
197
Proof.
 
198
unfold fun2_eq; induction n; intros n' Enn'; rewrite <- Enn' in *; simpl; auto.
 
199
Qed.
 
200
 
 
201
Theorem recursion_0 :
 
202
  forall (A : Type) (a : A) (f : nat -> A -> A), recursion a f 0 = a.
 
203
Proof.
 
204
reflexivity.
 
205
Qed.
 
206
 
 
207
Theorem recursion_succ :
 
208
  forall (A : Type) (Aeq : relation A) (a : A) (f : nat -> A -> A),
 
209
    Aeq a a -> fun2_wd (@eq nat) Aeq Aeq f ->
 
210
      forall n : nat, Aeq (recursion a f (S n)) (f n (recursion a f n)).
 
211
Proof.
 
212
induction n; simpl; auto.
 
213
Qed.
 
214
 
 
215
End NPeanoAxiomsMod.
 
216
 
 
217
(* Now we apply the largest property functor *)
 
218
 
 
219
Module Export NPeanoSubPropMod := NSubPropFunct NPeanoAxiomsMod.
 
220