~ubuntu-branches/ubuntu/hardy/coq-doc/hardy

« back to all changes in this revision

Viewing changes to library/Coq.Arith.Wf_nat.html

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-09-18 13:28:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040918132822-ees5mb8qmzd6a0fw
Tags: 8.0pl1.0-1
* Added the Coq faq, moved the tutorial to the root directory and added
  doc-base files for both, closes: #272204.
* Set dh_compat to level 4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html xmlns="http://www.w3.org/1999/xhtml">
 
2
<head>
 
3
<meta http-equiv="Content-Type" content="text/html; charset="><link rel="stylesheet" href="style.css" type="text/css"><title>Coq.Arith.Wf_nat</title>
 
4
</head>
 
5
 
 
6
<body>
 
7
 
 
8
<h1>Library Coq.Arith.Wf_nat</h1>
 
9
 
 
10
<code>
 
11
</code>
 
12
 
 
13
<table width="100%"><tr class="doc"><td>
 
14
Well-founded relations and natural numbers 
 
15
</td></tr></table>
 
16
<code>
 
17
 
 
18
<br/>
 
19
<code class="keyword">Require</code> <code class="keyword">Import</code> Lt.<br/>
 
20
 
 
21
<br/>
 
22
Open <code class="keyword">Local</code> Scope nat_scope.<br/>
 
23
 
 
24
<br/>
 
25
<code class="keyword">Implicit</code> Types m n p : <a href="Coq.Init.Datatypes.html#nat">nat</a>.<br/>
 
26
 
 
27
<br/>
 
28
<code class="keyword">Section</code> Well_founded_Nat.<br/>
 
29
 
 
30
<br/>
 
31
<code class="keyword">Variable</code> A : Set.<br/>
 
32
 
 
33
<br/>
 
34
<code class="keyword">Variable</code> f : A -&gt; <a href="Coq.Init.Datatypes.html#nat">nat</a>.<br/>
 
35
<code class="keyword">Definition</code> <a name="ltof"></a>ltof (a b:A) := f a &lt; f b.<br/>
 
36
<code class="keyword">Definition</code> <a name="gtof"></a>gtof (a b:A) := f b &gt; f a.<br/>
 
37
 
 
38
<br/>
 
39
<code class="keyword">Theorem</code> <a name="well_founded_ltof"></a>well_founded_ltof : <a href="Coq.Init.Wf.html#well_founded">well_founded</a> <a href="Coq.Arith.Wf_nat.html#ltof">ltof</a>.<br/>
 
40
<code class="keyword">Proof</code>.<br/>
 
41
red in |- *.<br/>
 
42
cut (forall n (a:A), f a &lt; n -&gt; <a href="Coq.Init.Wf.html#Acc">Acc</a> <a href="Coq.Arith.Wf_nat.html#ltof">ltof</a> a).<br/>
 
43
intros H a; apply (H (<a href="Coq.Init.Datatypes.html#S">S</a> (f a))); auto with arith.<br/>
 
44
induction n.<br/>
 
45
intros; absurd (f a &lt; 0); auto with arith.<br/>
 
46
intros a ltSma.<br/>
 
47
apply <a href="Coq.Init.Wf.html#Acc_intro">Acc_intro</a>.<br/>
 
48
unfold ltof in |- *; intros b ltfafb.<br/>
 
49
apply IHn.<br/>
 
50
apply <a href="Coq.Arith.Lt.html#lt_le_trans">lt_le_trans</a> with (f a); auto with arith.<br/>
 
51
<code class="keyword">Qed</code>.<br/>
 
52
 
 
53
<br/>
 
54
<code class="keyword">Theorem</code> <a name="well_founded_gtof"></a>well_founded_gtof : <a href="Coq.Init.Wf.html#well_founded">well_founded</a> <a href="Coq.Arith.Wf_nat.html#gtof">gtof</a>.<br/>
 
55
<code class="keyword">Proof</code> <a href="Coq.Arith.Wf_nat.html#well_founded_ltof">well_founded_ltof</a>.<br/>
 
56
 
 
57
<br/>
 
58
</code>
 
59
 
 
60
<table width="100%"><tr class="doc"><td>
 
61
It is possible to directly prove the induction principle going
 
62
   back to primitive recursion on natural numbers (<code>induction_ltof1</code>)
 
63
   or to use the previous lemmas to extract a program with a fixpoint
 
64
   (<code>induction_ltof2</code>) 
 
65
 
 
66
<br/><br/>
 
67
the ML-like program for <code>induction_ltof1</code> is : 
 
68
</td></tr></table>
 
69
<code>
 
70
let induction_ltof1 F a = indrec ((f a)+1) a <br/>
 
71
&nbsp;&nbsp;&nbsp;where rec indrec = <br/>
 
72
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function 0    -&gt; (function a -&gt; error)<br/>
 
73
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|(S m) -&gt; (function a -&gt; (F a (function y -&gt; indrec y m)));;</code>
 
74
 
 
75
<table width="100%"><tr class="doc"><td>
 
76
 
 
77
 
 
78
<br/><br/>
 
79
the ML-like program for <code>induction_ltof2</code> is : 
 
80
</td></tr></table>
 
81
<code>
 
82
let induction_ltof2 F a = indrec a<br/>
 
83
&nbsp;&nbsp;&nbsp;where rec indrec a = F a indrec;;</code>
 
84
 
 
85
<table width="100%"><tr class="doc"><td>
 
86
 
 
87
</td></tr></table>
 
88
<code>
 
89
 
 
90
<br/>
 
91
<code class="keyword">Theorem</code> <a name="induction_ltof1"></a>induction_ltof1 :<br/>
 
92
&nbsp;forall P:A -&gt; Set,<br/>
 
93
&nbsp;&nbsp;&nbsp;(forall x:A, (forall y:A, <a href="Coq.Arith.Wf_nat.html#ltof">ltof</a> y x -&gt; P y) -&gt; P x) -&gt; forall a:A, P a.<br/>
 
94
<code class="keyword">Proof</code>.<br/>
 
95
intros P F; cut (forall n (a:A), f a &lt; n -&gt; P a).<br/>
 
96
intros H a; apply (H (<a href="Coq.Init.Datatypes.html#S">S</a> (f a))); auto with arith.<br/>
 
97
induction n.<br/>
 
98
intros; absurd (f a &lt; 0); auto with arith.<br/>
 
99
intros a ltSma.<br/>
 
100
apply F.<br/>
 
101
unfold ltof in |- *; intros b ltfafb.<br/>
 
102
apply IHn.<br/>
 
103
apply <a href="Coq.Arith.Lt.html#lt_le_trans">lt_le_trans</a> with (f a); auto with arith.<br/>
 
104
<code class="keyword">Defined</code>. <br/>
 
105
 
 
106
<br/>
 
107
<code class="keyword">Theorem</code> <a name="induction_gtof1"></a>induction_gtof1 :<br/>
 
108
&nbsp;forall P:A -&gt; Set,<br/>
 
109
&nbsp;&nbsp;&nbsp;(forall x:A, (forall y:A, <a href="Coq.Arith.Wf_nat.html#gtof">gtof</a> y x -&gt; P y) -&gt; P x) -&gt; forall a:A, P a.<br/>
 
110
<code class="keyword">Proof</code>.<br/>
 
111
exact <a href="Coq.Arith.Wf_nat.html#induction_ltof1">induction_ltof1</a>.<br/>
 
112
<code class="keyword">Defined</code>.<br/>
 
113
 
 
114
<br/>
 
115
<code class="keyword">Theorem</code> <a name="induction_ltof2"></a>induction_ltof2 :<br/>
 
116
&nbsp;forall P:A -&gt; Set,<br/>
 
117
&nbsp;&nbsp;&nbsp;(forall x:A, (forall y:A, <a href="Coq.Arith.Wf_nat.html#ltof">ltof</a> y x -&gt; P y) -&gt; P x) -&gt; forall a:A, P a.<br/>
 
118
<code class="keyword">Proof</code>.<br/>
 
119
exact (<a href="Coq.Init.Wf.html#well_founded_induction">well_founded_induction</a> <a href="Coq.Arith.Wf_nat.html#well_founded_ltof">well_founded_ltof</a>).<br/>
 
120
<code class="keyword">Defined</code>.<br/>
 
121
 
 
122
<br/>
 
123
<code class="keyword">Theorem</code> <a name="induction_gtof2"></a>induction_gtof2 :<br/>
 
124
&nbsp;forall P:A -&gt; Set,<br/>
 
125
&nbsp;&nbsp;&nbsp;(forall x:A, (forall y:A, <a href="Coq.Arith.Wf_nat.html#gtof">gtof</a> y x -&gt; P y) -&gt; P x) -&gt; forall a:A, P a.<br/>
 
126
<code class="keyword">Proof</code>.<br/>
 
127
exact <a href="Coq.Arith.Wf_nat.html#induction_ltof2">induction_ltof2</a>.<br/>
 
128
<code class="keyword">Defined</code>.<br/>
 
129
 
 
130
<br/>
 
131
</code>
 
132
 
 
133
<table width="100%"><tr class="doc"><td>
 
134
If a relation <code>R</code> is compatible with <code>lt</code> i.e. if <code>x R y =&gt; f(x) &lt; f(y)</code>
 
135
    then <code>R</code> is well-founded. 
 
136
</td></tr></table>
 
137
<code>
 
138
 
 
139
<br/>
 
140
<code class="keyword">Variable</code> R : A -&gt; A -&gt; Prop.<br/>
 
141
 
 
142
<br/>
 
143
<code class="keyword">Hypothesis</code> H_compat : forall x y:A, R x y -&gt; f x &lt; f y.<br/>
 
144
 
 
145
<br/>
 
146
<code class="keyword">Theorem</code> <a name="well_founded_lt_compat"></a>well_founded_lt_compat : <a href="Coq.Init.Wf.html#well_founded">well_founded</a> R.<br/>
 
147
<code class="keyword">Proof</code>.<br/>
 
148
red in |- *.<br/>
 
149
cut (forall n (a:A), f a &lt; n -&gt; <a href="Coq.Init.Wf.html#Acc">Acc</a> R a).<br/>
 
150
intros H a; apply (H (<a href="Coq.Init.Datatypes.html#S">S</a> (f a))); auto with arith.<br/>
 
151
induction n.<br/>
 
152
intros; absurd (f a &lt; 0); auto with arith.<br/>
 
153
intros a ltSma.<br/>
 
154
apply <a href="Coq.Init.Wf.html#Acc_intro">Acc_intro</a>.<br/>
 
155
intros b ltfafb.<br/>
 
156
apply IHn.<br/>
 
157
apply <a href="Coq.Arith.Lt.html#lt_le_trans">lt_le_trans</a> with (f a); auto with arith.<br/>
 
158
<code class="keyword">Qed</code>.<br/>
 
159
 
 
160
<br/>
 
161
<code class="keyword">End</code> Well_founded_Nat.<br/>
 
162
 
 
163
<br/>
 
164
<code class="keyword">Lemma</code> <a name="lt_wf"></a>lt_wf : <a href="Coq.Init.Wf.html#well_founded">well_founded</a> <a href="Coq.Init.Peano.html#lt">lt</a>.<br/>
 
165
<code class="keyword">Proof</code> <a href="Coq.Arith.Wf_nat.html#well_founded_ltof">well_founded_ltof</a> <a href="Coq.Init.Datatypes.html#nat">nat</a> (fun m =&gt; m).<br/>
 
166
 
 
167
<br/>
 
168
<code class="keyword">Lemma</code> <a name="lt_wf_rec1"></a>lt_wf_rec1 :<br/>
 
169
&nbsp;forall n (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set), (forall n, (forall m, m &lt; n -&gt; P m) -&gt; P n) -&gt; P n.<br/>
 
170
<code class="keyword">Proof</code>.<br/>
 
171
exact<br/>
 
172
&nbsp;(fun p (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set) (F:forall n, (forall m, m &lt; n -&gt; P m) -&gt; P n) =&gt;<br/>
 
173
&nbsp;&nbsp;&nbsp;&nbsp;<a href="Coq.Arith.Wf_nat.html#induction_ltof1">induction_ltof1</a> <a href="Coq.Init.Datatypes.html#nat">nat</a> (fun m =&gt; m) P F p).<br/>
 
174
<code class="keyword">Defined</code>.<br/>
 
175
 
 
176
<br/>
 
177
<code class="keyword">Lemma</code> <a name="lt_wf_rec"></a>lt_wf_rec :<br/>
 
178
&nbsp;forall n (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set), (forall n, (forall m, m &lt; n -&gt; P m) -&gt; P n) -&gt; P n.<br/>
 
179
<code class="keyword">Proof</code>.<br/>
 
180
exact<br/>
 
181
&nbsp;(fun p (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set) (F:forall n, (forall m, m &lt; n -&gt; P m) -&gt; P n) =&gt;<br/>
 
182
&nbsp;&nbsp;&nbsp;&nbsp;<a href="Coq.Arith.Wf_nat.html#induction_ltof2">induction_ltof2</a> <a href="Coq.Init.Datatypes.html#nat">nat</a> (fun m =&gt; m) P F p).<br/>
 
183
<code class="keyword">Defined</code>.<br/>
 
184
 
 
185
<br/>
 
186
<code class="keyword">Lemma</code> <a name="lt_wf_ind"></a>lt_wf_ind :<br/>
 
187
&nbsp;forall n (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Prop), (forall n, (forall m, m &lt; n -&gt; P m) -&gt; P n) -&gt; P n.<br/>
 
188
intro p; intros; elim (<a href="Coq.Arith.Wf_nat.html#lt_wf">lt_wf</a> p); auto with arith.<br/>
 
189
<code class="keyword">Qed</code>.<br/>
 
190
 
 
191
<br/>
 
192
<code class="keyword">Lemma</code> <a name="gt_wf_rec"></a>gt_wf_rec :<br/>
 
193
&nbsp;forall n (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set), (forall n, (forall m, n &gt; m -&gt; P m) -&gt; P n) -&gt; P n.<br/>
 
194
<code class="keyword">Proof</code>.<br/>
 
195
exact <a href="Coq.Arith.Wf_nat.html#lt_wf_rec">lt_wf_rec</a>.<br/>
 
196
<code class="keyword">Defined</code>.<br/>
 
197
 
 
198
<br/>
 
199
<code class="keyword">Lemma</code> <a name="gt_wf_ind"></a>gt_wf_ind :<br/>
 
200
&nbsp;forall n (P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Prop), (forall n, (forall m, n &gt; m -&gt; P m) -&gt; P n) -&gt; P n.<br/>
 
201
<code class="keyword">Proof</code> <a href="Coq.Arith.Wf_nat.html#lt_wf_ind">lt_wf_ind</a>.<br/>
 
202
 
 
203
<br/>
 
204
<code class="keyword">Lemma</code> <a name="lt_wf_double_rec"></a>lt_wf_double_rec :<br/>
 
205
&nbsp;forall P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; <a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Set,<br/>
 
206
&nbsp;&nbsp;&nbsp;(forall n m,<br/>
 
207
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(forall p (q:<a href="Coq.Init.Datatypes.html#nat">nat</a>), p &lt; n -&gt; P p q) -&gt;<br/>
 
208
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(forall p, p &lt; m -&gt; P n p) -&gt; P n m) -&gt; forall n m, P n m.<br/>
 
209
intros P Hrec p; pattern p in |- *; apply <a href="Coq.Arith.Wf_nat.html#lt_wf_rec">lt_wf_rec</a>.<br/>
 
210
intros n H q; pattern q in |- *; apply <a href="Coq.Arith.Wf_nat.html#lt_wf_rec">lt_wf_rec</a>; auto with arith.<br/>
 
211
<code class="keyword">Defined</code>.<br/>
 
212
 
 
213
<br/>
 
214
<code class="keyword">Lemma</code> <a name="lt_wf_double_ind"></a>lt_wf_double_ind :<br/>
 
215
&nbsp;forall P:<a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; <a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Prop,<br/>
 
216
&nbsp;&nbsp;&nbsp;(forall n m,<br/>
 
217
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(forall p (q:<a href="Coq.Init.Datatypes.html#nat">nat</a>), p &lt; n -&gt; P p q) -&gt;<br/>
 
218
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(forall p, p &lt; m -&gt; P n p) -&gt; P n m) -&gt; forall n m, P n m.<br/>
 
219
intros P Hrec p; pattern p in |- *; apply <a href="Coq.Arith.Wf_nat.html#lt_wf_ind">lt_wf_ind</a>.<br/>
 
220
intros n H q; pattern q in |- *; apply <a href="Coq.Arith.Wf_nat.html#lt_wf_ind">lt_wf_ind</a>; auto with arith.<br/>
 
221
<code class="keyword">Qed</code>.<br/>
 
222
 
 
223
<br/>
 
224
<code class="keyword">Hint</code> Resolve <a href="Coq.Arith.Wf_nat.html#lt_wf">lt_wf</a>: arith.<br/>
 
225
<code class="keyword">Hint</code> Resolve <a href="Coq.Arith.Wf_nat.html#well_founded_lt_compat">well_founded_lt_compat</a>: arith.<br/>
 
226
 
 
227
<br/>
 
228
<code class="keyword">Section</code> LT_WF_REL.<br/>
 
229
<code class="keyword">Variable</code> A : Set.<br/>
 
230
<code class="keyword">Variable</code> R : A -&gt; A -&gt; Prop.<br/>
 
231
 
 
232
<br/>
 
233
<code class="keyword">Variable</code> F : A -&gt; <a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Prop.<br/>
 
234
<code class="keyword">Definition</code> <a name="inv_lt_rel"></a>inv_lt_rel x y :=<br/>
 
235
&nbsp;&nbsp;&nbsp;exists2 n : _, F x n &amp; (forall m, F y m -&gt; n &lt; m).<br/>
 
236
 
 
237
<br/>
 
238
<code class="keyword">Hypothesis</code> F_compat : forall x y:A, R x y -&gt; <a href="Coq.Arith.Wf_nat.html#inv_lt_rel">inv_lt_rel</a> x y.<br/>
 
239
<code class="keyword">Remark</code> acc_lt_rel : forall x:A, (exists n : _, F x n) -&gt; <a href="Coq.Init.Wf.html#Acc">Acc</a> R x.<br/>
 
240
intros x [n fxn]; generalize x fxn; clear x fxn.<br/>
 
241
pattern n in |- *; apply <a href="Coq.Arith.Wf_nat.html#lt_wf_ind">lt_wf_ind</a>; intros.<br/>
 
242
constructor; intros.<br/>
 
243
case (F_compat y x); trivial; intros.<br/>
 
244
apply (H x0); auto.<br/>
 
245
<code class="keyword">Qed</code>.<br/>
 
246
 
 
247
<br/>
 
248
<code class="keyword">Theorem</code> <a name="well_founded_inv_lt_rel_compat"></a>well_founded_inv_lt_rel_compat : <a href="Coq.Init.Wf.html#well_founded">well_founded</a> R.<br/>
 
249
constructor; intros.<br/>
 
250
case (F_compat y a); trivial; intros.<br/>
 
251
apply <a href="Coq.Arith.Wf_nat.html#acc_lt_rel">acc_lt_rel</a>; trivial.<br/>
 
252
exists x; trivial.<br/>
 
253
<code class="keyword">Qed</code>.<br/>
 
254
 
 
255
<br/>
 
256
<code class="keyword">End</code> LT_WF_REL.<br/>
 
257
 
 
258
<br/>
 
259
<code class="keyword">Lemma</code> <a name="well_founded_inv_rel_inv_lt_rel"></a>well_founded_inv_rel_inv_lt_rel :<br/>
 
260
&nbsp;forall (A:Set) (F:A -&gt; <a href="Coq.Init.Datatypes.html#nat">nat</a> -&gt; Prop), <a href="Coq.Init.Wf.html#well_founded">well_founded</a> (<a href="Coq.Arith.Wf_nat.html#inv_lt_rel">inv_lt_rel</a> A F).<br/>
 
261
intros; apply (<a href="Coq.Arith.Wf_nat.html#well_founded_inv_lt_rel_compat">well_founded_inv_lt_rel_compat</a> A (<a href="Coq.Arith.Wf_nat.html#inv_lt_rel">inv_lt_rel</a> A F) F); trivial.<br/>
 
262
<code class="keyword">Qed</code>.</code>
 
263
<hr/><a href="index.html">Index</a><hr/><font size="-1">This page has been generated by <a href="http://www.lri.fr/~filliatr/coqdoc/">coqdoc</a></font>
 
264
</body>
 
265
</html>
 
 
b'\\ No newline at end of file'