aboutsummaryrefslogtreecommitdiffhomepage
path: root/test-suite/success/decl_mode2.v
blob: 46174e48104b5a386f862b29dfe0e4fe10abfe4f (plain)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
Theorem this_is_trivial: True.
proof.
  thus thesis.
end proof.
Qed.

Theorem T: (True /\ True) /\ True.
  split. split.
proof. (* first subgoal *)
  thus thesis.
end proof.
trivial. (* second subgoal *)
proof. (* third subgoal *)
  thus thesis.
end proof.
Abort.

Theorem this_is_not_so_trivial: False.
proof.
end proof. (* here a warning is issued *)
Fail Qed. (* fails: the proof in incomplete *)
Admitted. (* Oops! *)

Theorem T: True.
proof.
escape.
auto.
return.
Abort.

Theorem T: let a:=false in let b:= true in ( if a then True else False -> if b then True else False).
intros a b.
proof.
assume H:(if a then True else False).
reconsider H as False.
reconsider thesis as True.
Abort.

Theorem T: forall x, x=2 -> 2+x=4.
proof.
let x be such that H:(x=2).
have H':(2+x=2+2) by H.
Abort.

Theorem T: forall x, x=2 -> 2+x=4.
proof.
let x be such that H:(x=2).
then (2+x=2+2).
Abort.

Theorem T: forall x, x=2 -> x + x = x * x.
proof.
let x be such that H:(x=2).
have (4 = 4).
        ~= (2 * 2).
        ~= (x * x) by H.
        =~ (2 + 2).
        =~ H':(x + x) by H.
Abort.

Theorem T: forall x, x + x = x * x -> x = 0 \/ x = 2.
proof.
let x be such that H:(x + x = x * x).
claim H':((x - 2) * x = 0).
thus thesis. 
end claim.
Abort.

Theorem T: forall (A B:Prop), A -> B -> A /\ B.
intros A B HA HB.
proof.
hence B.
Abort.

Theorem T: forall (A B C:Prop), A -> B -> C -> A /\ B /\ C.
intros A B C HA HB HC.
proof.
thus B by HB.
Abort.

Theorem T: forall (A B C:Prop), A -> B -> C -> A /\ B.
intros A B C HA HB HC.
proof.
Fail hence C. (* fails *)
Abort.

Theorem T: forall (A B:Prop), B -> A \/ B.
intros A B HB.
proof.
hence B.
Abort.

Theorem T: forall (A B C D:Prop), C -> D -> (A /\ B) \/ (C /\ D).
intros A B C D HC HD.
proof.
thus C by HC.
Abort.

Theorem T: forall (P:nat -> Prop), P 2 -> exists x,P x.
intros P HP.
proof.
take 2.
Abort.

Theorem T: forall (P:nat -> Prop), P 2 -> exists x,P x.
intros P HP.
proof.
hence (P 2).
Abort.

Theorem T: forall (P:nat -> Prop) (R:nat -> nat -> Prop), P 2 -> R 0 2 -> exists x, exists y, P y /\ R x y.
intros P R HP HR.
proof.
thus (P 2) by HP.
Abort.

Theorem T: forall (A B:Prop) (P:nat -> Prop), (forall x, P x -> B) -> A -> A /\ B.
intros A B P HP HA.
proof.
suffices to have x such that HP':(P x) to show B by HP,HP'.
Abort.

Theorem T: forall (A:Prop) (P:nat -> Prop), P 2 -> A -> A /\ (forall x, x = 2 -> P x).
intros A P HP HA.
proof.
(* BUG: the next line fails when it should succeed.
Waiting for someone to investigate the bug.
focus on (forall x, x = 2 -> P x).
let x be such that (x = 2).
hence thesis by HP.
end focus.
*)
Abort.

Theorem T: forall x, x = 0 -> x + x = x * x.
proof.
let x be such that H:(x = 0).
define sqr x as (x * x).
reconsider thesis as (x + x = sqr x).
Abort.

Theorem T: forall (P:nat -> Prop), forall x, P x -> P x.
proof.
let P:(nat -> Prop).
let x:nat.
assume HP:(P x).
Abort.

Theorem T: forall (P:nat -> Prop), forall x, P x -> P x.
proof.
let P:(nat -> Prop).
Fail let x. (* fails because x's type is not clear *) 
let x be such that HP:(P x). (* here x's type is inferred from (P x) *)
Abort.

Theorem T: forall (P:nat -> Prop), forall x, P x -> P x -> P x.
proof.
let P:(nat -> Prop).
let x:nat.
assume (P x). (* temporary name created *)
Abort.

Theorem T: forall (P:nat -> Prop), forall x, P x -> P x.
proof.
let P:(nat -> Prop).
let x be such that (P x). (* temporary name created *)
Abort.

Theorem T: forall (P:nat -> Prop) (A:Prop), (exists x, (P x /\ A)) -> A.
proof.
let P:(nat -> Prop),A:Prop be such that H:(exists x, P x /\ A).
consider x such that HP:(P x) and HA:A from H.
Abort.

(* Here is an example with pairs: *)

Theorem T: forall p:(nat * nat)%type, (fst p >= snd p) \/ (fst p < snd p).
proof.
let p:(nat * nat)%type.
consider x:nat,y:nat from p.
reconsider thesis as (x >= y \/ x < y). 
Abort.

Theorem T: forall P:(nat -> Prop), (forall n, P n -> P (n - 1)) -> 
(exists m, P m) -> P 0.
proof.
let P:(nat -> Prop) be such that HP:(forall n, P n -> P (n - 1)).
given m such that Hm:(P m).  
Abort.

Theorem T: forall (A B C:Prop), (A -> C) -> (B -> C) -> (A \/ B) -> C.
proof.
let A:Prop,B:Prop,C:Prop be such that HAC:(A -> C) and HBC:(B -> C).
assume HAB:(A \/ B).
per cases on HAB.
suppose A.
  hence thesis by HAC.
suppose HB:B.
  thus thesis by HB,HBC.
end cases.
Abort.

Section Coq.

Hypothesis EM : forall P:Prop, P \/ ~ P.

Theorem T: forall (A C:Prop), (A -> C) -> (~A -> C) -> C.
proof.
let A:Prop,C:Prop be such that HAC:(A -> C) and HNAC:(~A -> C).
per cases of (A \/ ~A) by EM.
suppose (~A).
  hence thesis by HNAC.
suppose A.
  hence thesis by HAC.
end cases.
Abort.

Theorem T: forall (A C:Prop), (A -> C) -> (~A -> C) -> C.
proof.
let A:Prop,C:Prop be such that HAC:(A -> C) and HNAC:(~A -> C).
per cases on (EM A).
suppose (~A).
Abort.
End Coq.

Theorem T: forall (A B:Prop) (x:bool), (if x then A else B) -> A \/ B.
proof.
let A:Prop,B:Prop,x:bool.
per cases on x.
suppose it is true.
  assume A.
  hence A.
suppose it is false.
  assume B.
  hence B.
end cases.
Abort.

Theorem T: forall (n:nat), n + 0 = n.
proof.
let n:nat.
per induction on n.
suppose it is 0.
  thus (0 + 0 = 0).
suppose it is (S m) and H:thesis for m.
  then (S (m + 0) = S m).
  thus =~ (S m + 0).
end induction.
Abort.