1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
(* Petit bench vite fait, mal fait *)
Require Refine.
(************************************************************************)
Lemma essai : (x:nat)x=x.
Refine (([x0:nat]Cases x0 of
O => ?
| (S p) => ?
end) :: (x:nat)x=x). (* x0=x0 et x0=x0 *)
Restart.
Refine [x0:nat]<[n:nat]n=n>Case x0 of ? [p:nat]? end. (* OK *)
Restart.
Refine [x0:nat]<[n:nat]n=n>Cases x0 of O => ? | (S p) => ? end. (* OK *)
Restart.
(**
Refine [x0:nat]Cases x0 of O => ? | (S p) => ? end. (* cannot be executed *)
**)
Abort.
(************************************************************************)
Lemma T : nat.
Refine (S ?).
Abort.
(************************************************************************)
Lemma essai2 : (x:nat)x=x.
Refine Fix f{f/1 : (x:nat)x=x := [x:nat]? }.
Restart.
Refine Fix f{f/1 : (x:nat)x=x :=
[x:nat]<[n:nat](eq nat n n)>Case x of ? [p:nat]? end}.
Restart.
Refine Fix f{f/1 : (x:nat)x=x :=
[x:nat]<[n:nat]n=n>Cases x of O => ? | (S p) => ? end}.
Restart.
Refine Fix f{f/1 : (x:nat)x=x :=
[x:nat]<[n:nat](eq nat n n)>Case x of
?
[p:nat](f_equal nat nat S p p ?) end}.
Restart.
Refine Fix f{f/1 : (x:nat)x=x :=
[x:nat]<[n:nat](eq nat n n)>Cases x of
O => ?
| (S p) =>(f_equal nat nat S p p ?) end}.
Abort.
(************************************************************************)
Lemma essai : nat.
Parameter f : nat*nat -> nat -> nat.
Refine (f ? ([x:nat](? :: nat) O)).
Restart.
Refine (f ? O).
Abort.
(************************************************************************)
Parameter P : nat -> Prop.
Lemma essai : { x:nat | x=(S O) }.
Refine (exist nat ? (S O) ?). (* ECHEC *)
Restart.
(* mais si on contraint par le but alors ca marche : *)
(* Remarque : on peut toujours faire a *)
Refine ((exist nat ? (S O) ?) :: { x:nat | x=(S O) }).
Restart.
Refine (exist nat [x:nat](x=(S O)) (S O) ?).
Abort.
(************************************************************************)
Lemma essai : (n:nat){ x:nat | x=(S n) }.
Refine [n:nat]<[n:nat]{x:nat|x=(S n)}>Case n of ? [p:nat]? end.
Restart.
Refine (([n:nat]Case n of ? [p:nat]? end) :: (n:nat){ x:nat | x=(S n) }).
Restart.
Refine [n:nat]<[n:nat]{x:nat|x=(S n)}>Cases n of O => ? | (S p) => ? end.
Restart.
Refine Fix f{f/1 :(n:nat){x:nat|x=(S n)} :=
[n:nat]<[n:nat]{x:nat|x=(S n)}>Case n of ? [p:nat]? end}.
Restart.
Refine Fix f{f/1 :(n:nat){x:nat|x=(S n)} :=
[n:nat]<[n:nat]{x:nat|x=(S n)}>Cases n of O => ? | (S p) => ? end}.
Exists (S O). Trivial.
Elim (f0 p).
Refine [x:nat][h:x=(S p)](exist nat [x:nat]x=(S (S p)) (S x) ?).
Rewrite h. Auto.
Save.
(* Quelques essais de recurrence bien fonde *)
Require Wf.
Require Wf_nat.
Lemma essai_wf : nat->nat.
Refine [x:nat](well_founded_induction
nat
lt ?
[_:nat]nat->nat
[phi0:nat][w:(phi:nat)(lt phi phi0)->nat->nat](w x ?)
x x).
Exact lt_wf.
Abort.
Require Compare_dec.
Require Lt.
Lemma fibo : nat -> nat.
Refine (well_founded_induction
nat
lt ?
[_:nat]nat
[x0:nat][fib:(x:nat)(lt x x0)->nat]
Cases (zerop x0) of
(left _) => (S O)
| (right h1) => Cases (zerop (pred x0)) of
(left _) => (S O)
| (right h2) => (plus (fib (pred x0) ?)
(fib (pred (pred x0)) ?))
end
end).
(*********
Refine (well_founded_induction
nat
lt ?
[_:nat]nat
[x0:nat][fib:(x:nat)(lt x x0)->nat]
Cases x0 of
O => (S O)
| (S O) => (S O)
| (S (S p)) => (plus (fib (pred x0) ?)
(fib (pred (pred x0)) ?))
end).
***********)
Exact lt_wf.
Auto.
Apply lt_trans with m:=(pred x0); Auto.
Save.
|