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

« back to all changes in this revision

Viewing changes to library/Coq.ZArith.Zmisc.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.ZArith.Zmisc</title>
 
4
</head>
 
5
 
 
6
<body>
 
7
 
 
8
<h1>Library Coq.ZArith.Zmisc</h1>
 
9
 
 
10
<code>
 
11
<code class="keyword">Require</code> <code class="keyword">Import</code> BinInt.<br/>
 
12
<code class="keyword">Require</code> <code class="keyword">Import</code> Zcompare.<br/>
 
13
<code class="keyword">Require</code> <code class="keyword">Import</code> Zorder.<br/>
 
14
<code class="keyword">Require</code> <code class="keyword">Import</code> Bool.<br/>
 
15
Open <code class="keyword">Local</code> Scope Z_scope.<br/>
 
16
 
 
17
<br/>
 
18
</code>
 
19
 
 
20
<table width="100%"><tr class="doc"><td>
 
21
Iterators 
 
22
</td></tr></table>
 
23
<code>
 
24
 
 
25
<br/>
 
26
</code>
 
27
 
 
28
<table width="100%"><tr class="doc"><td>
 
29
<code>n</code>th iteration of the function <code>f</code> 
 
30
</td></tr></table>
 
31
<code>
 
32
<code class="keyword">Fixpoint</code> <a name="iter_nat"></a>iter_nat (n:<a href="Coq.Init.Datatypes.html#nat">nat</a>) (A:Set) (f:A -&gt; A) (x:A) {struct n} : A :=<br/>
 
33
&nbsp;&nbsp;match n with<br/>
 
34
&nbsp;&nbsp;| <a href="Coq.Init.Datatypes.html#O">O</a> =&gt; x<br/>
 
35
&nbsp;&nbsp;| <a href="Coq.Init.Datatypes.html#S">S</a> n' =&gt; f (iter_nat n' A f x)<br/>
 
36
&nbsp;&nbsp;end.<br/>
 
37
 
 
38
<br/>
 
39
<code class="keyword">Fixpoint</code> <a name="iter_pos"></a>iter_pos (n:<a href="Coq.NArith.BinPos.html#positive">positive</a>) (A:Set) (f:A -&gt; A) (x:A) {struct n} : A :=<br/>
 
40
&nbsp;&nbsp;match n with<br/>
 
41
&nbsp;&nbsp;| <a href="Coq.NArith.BinPos.html#xH">xH</a> =&gt; f x<br/>
 
42
&nbsp;&nbsp;| <a href="Coq.NArith.BinPos.html#xO">xO</a> n' =&gt; iter_pos n' A f (iter_pos n' A f x)<br/>
 
43
&nbsp;&nbsp;| <a href="Coq.NArith.BinPos.html#xI">xI</a> n' =&gt; f (iter_pos n' A f (iter_pos n' A f x))<br/>
 
44
&nbsp;&nbsp;end.<br/>
 
45
 
 
46
<br/>
 
47
<code class="keyword">Definition</code> <a name="iter"></a>iter (n:<a href="Coq.ZArith.BinInt.html#Z">Z</a>) (A:Set) (f:A -&gt; A) (x:A) :=<br/>
 
48
&nbsp;&nbsp;match n with<br/>
 
49
&nbsp;&nbsp;| <a href="Coq.ZArith.BinInt.html#Z0">Z0</a> =&gt; x<br/>
 
50
&nbsp;&nbsp;| <a href="Coq.ZArith.BinInt.html#Zpos">Zpos</a> p =&gt; <a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> p A f x<br/>
 
51
&nbsp;&nbsp;| <a href="Coq.ZArith.BinInt.html#Zneg">Zneg</a> p =&gt; x<br/>
 
52
&nbsp;&nbsp;end.<br/>
 
53
 
 
54
<br/>
 
55
<code class="keyword">Theorem</code> <a name="iter_nat_plus"></a>iter_nat_plus :<br/>
 
56
&nbsp;forall (n m:<a href="Coq.Init.Datatypes.html#nat">nat</a>) (A:Set) (f:A -&gt; A) (x:A),<br/>
 
57
&nbsp;&nbsp;&nbsp;<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> (n + m) A f x = <a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> n A f (<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> m A f x).<br/>
 
58
<code class="keyword">Proof</code>.    <br/>
 
59
simple induction n;<br/>
 
60
&nbsp;[ simpl in |- *; auto with arith<br/>
 
61
&nbsp;| intros; simpl in |- *; apply <a href="Coq.Init.Logic.html#f_equal">f_equal</a> with (f:= f); apply H ].  <br/>
 
62
<code class="keyword">Qed</code>.<br/>
 
63
 
 
64
<br/>
 
65
<code class="keyword">Theorem</code> <a name="iter_nat_of_P"></a>iter_nat_of_P :<br/>
 
66
&nbsp;forall (p:<a href="Coq.NArith.BinPos.html#positive">positive</a>) (A:Set) (f:A -&gt; A) (x:A),<br/>
 
67
&nbsp;&nbsp;&nbsp;<a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> p A f x = <a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> (<a href="Coq.NArith.BinPos.html#nat_of_P">nat_of_P</a> p) A f x.<br/>
 
68
<code class="keyword">Proof</code>.    <br/>
 
69
intro n; induction n as [p H| p H| ];<br/>
 
70
&nbsp;[ intros; simpl in |- *; rewrite (H A f x);<br/>
 
71
&nbsp;&nbsp;&nbsp;&nbsp;rewrite (H A f (<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> (<a href="Coq.NArith.BinPos.html#nat_of_P">nat_of_P</a> p) A f x)); <br/>
 
72
&nbsp;&nbsp;&nbsp;&nbsp;rewrite (<a href="Coq.NArith.Pnat.html#ZL6">ZL6</a> p); symmetry  in |- *; apply <a href="Coq.Init.Logic.html#f_equal">f_equal</a> with (f:= f);<br/>
 
73
&nbsp;&nbsp;&nbsp;&nbsp;apply <a href="Coq.ZArith.Zmisc.html#iter_nat_plus">iter_nat_plus</a><br/>
 
74
&nbsp;| intros; unfold nat_of_P in |- *; simpl in |- *; rewrite (H A f x);<br/>
 
75
&nbsp;&nbsp;&nbsp;&nbsp;rewrite (H A f (<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> (<a href="Coq.NArith.BinPos.html#nat_of_P">nat_of_P</a> p) A f x)); <br/>
 
76
&nbsp;&nbsp;&nbsp;&nbsp;rewrite (<a href="Coq.NArith.Pnat.html#ZL6">ZL6</a> p); symmetry  in |- *; apply <a href="Coq.ZArith.Zmisc.html#iter_nat_plus">iter_nat_plus</a><br/>
 
77
&nbsp;| simpl in |- *; auto with arith ].<br/>
 
78
<code class="keyword">Qed</code>.<br/>
 
79
 
 
80
<br/>
 
81
<code class="keyword">Theorem</code> <a name="iter_pos_plus"></a>iter_pos_plus :<br/>
 
82
&nbsp;forall (p q:<a href="Coq.NArith.BinPos.html#positive">positive</a>) (A:Set) (f:A -&gt; A) (x:A),<br/>
 
83
&nbsp;&nbsp;&nbsp;<a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> (p + q) A f x = <a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> p A f (<a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> q A f x).<br/>
 
84
<code class="keyword">Proof</code>.    <br/>
 
85
intros n m; intros.<br/>
 
86
rewrite (<a href="Coq.ZArith.Zmisc.html#iter_nat_of_P">iter_nat_of_P</a> m A f x).<br/>
 
87
rewrite (<a href="Coq.ZArith.Zmisc.html#iter_nat_of_P">iter_nat_of_P</a> n A f (<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> (<a href="Coq.NArith.BinPos.html#nat_of_P">nat_of_P</a> m) A f x)).<br/>
 
88
rewrite (<a href="Coq.ZArith.Zmisc.html#iter_nat_of_P">iter_nat_of_P</a> (n + m) A f x).<br/>
 
89
rewrite (<a href="Coq.NArith.Pnat.html#nat_of_P_plus_morphism">nat_of_P_plus_morphism</a> n m).<br/>
 
90
apply <a href="Coq.ZArith.Zmisc.html#iter_nat_plus">iter_nat_plus</a>.<br/>
 
91
<code class="keyword">Qed</code>.<br/>
 
92
 
 
93
<br/>
 
94
</code>
 
95
 
 
96
<table width="100%"><tr class="doc"><td>
 
97
Preservation of invariants : if <code>f : A-&gt;A</code> preserves the invariant <code>Inv</code>, 
 
98
    then the iterates of <code>f</code> also preserve it. 
 
99
</td></tr></table>
 
100
<code>
 
101
 
 
102
<br/>
 
103
<code class="keyword">Theorem</code> <a name="iter_nat_invariant"></a>iter_nat_invariant :<br/>
 
104
&nbsp;forall (n:<a href="Coq.Init.Datatypes.html#nat">nat</a>) (A:Set) (f:A -&gt; A) (Inv:A -&gt; Prop),<br/>
 
105
&nbsp;&nbsp;&nbsp;(forall x:A, Inv x -&gt; Inv (f x)) -&gt;<br/>
 
106
&nbsp;&nbsp;&nbsp;forall x:A, Inv x -&gt; Inv (<a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> n A f x).<br/>
 
107
<code class="keyword">Proof</code>.    <br/>
 
108
simple induction n; intros;<br/>
 
109
&nbsp;[ trivial with arith<br/>
 
110
&nbsp;| simpl in |- *; apply H0 with (x:= <a href="Coq.ZArith.Zmisc.html#iter_nat">iter_nat</a> n0 A f x); apply H;<br/>
 
111
&nbsp;&nbsp;&nbsp;&nbsp;trivial with arith ].<br/>
 
112
<code class="keyword">Qed</code>.<br/>
 
113
 
 
114
<br/>
 
115
<code class="keyword">Theorem</code> <a name="iter_pos_invariant"></a>iter_pos_invariant :<br/>
 
116
&nbsp;forall (p:<a href="Coq.NArith.BinPos.html#positive">positive</a>) (A:Set) (f:A -&gt; A) (Inv:A -&gt; Prop),<br/>
 
117
&nbsp;&nbsp;&nbsp;(forall x:A, Inv x -&gt; Inv (f x)) -&gt;<br/>
 
118
&nbsp;&nbsp;&nbsp;forall x:A, Inv x -&gt; Inv (<a href="Coq.ZArith.Zmisc.html#iter_pos">iter_pos</a> p A f x).<br/>
 
119
<code class="keyword">Proof</code>.    <br/>
 
120
intros; rewrite <a href="Coq.ZArith.Zmisc.html#iter_nat_of_P">iter_nat_of_P</a>; apply <a href="Coq.ZArith.Zmisc.html#iter_nat_invariant">iter_nat_invariant</a>; trivial with arith.<br/>
 
121
<code class="keyword">Qed</code>.<br/>
 
122
</code>
 
123
<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>
 
124
</body>
 
125
</html>
 
 
b'\\ No newline at end of file'