author | paulson |
Wed, 07 Feb 2001 16:37:24 +0100 | |
changeset 11080 | 22855d091249 |
parent 10957 | 2a4a50e7ddf2 |
child 11154 | 042015819774 |
permissions | -rw-r--r-- |
10341 | 1 |
(* ID: $Id$ *) |
10295 | 2 |
theory Basic = Main: |
3 |
||
4 |
lemma conj_rule: "\<lbrakk> P; Q \<rbrakk> \<Longrightarrow> P \<and> (Q \<and> P)" |
|
5 |
apply (rule conjI) |
|
6 |
apply assumption |
|
7 |
apply (rule conjI) |
|
8 |
apply assumption |
|
9 |
apply assumption |
|
10 |
done |
|
11 |
||
12 |
||
13 |
lemma disj_swap: "P | Q \<Longrightarrow> Q | P" |
|
14 |
apply (erule disjE) |
|
15 |
apply (rule disjI2) |
|
16 |
apply assumption |
|
17 |
apply (rule disjI1) |
|
18 |
apply assumption |
|
19 |
done |
|
20 |
||
21 |
lemma conj_swap: "P \<and> Q \<Longrightarrow> Q \<and> P" |
|
22 |
apply (rule conjI) |
|
23 |
apply (drule conjunct2) |
|
24 |
apply assumption |
|
25 |
apply (drule conjunct1) |
|
26 |
apply assumption |
|
27 |
done |
|
28 |
||
29 |
lemma imp_uncurry: "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R" |
|
30 |
apply (rule impI) |
|
31 |
apply (erule conjE) |
|
32 |
apply (drule mp) |
|
33 |
apply assumption |
|
34 |
apply (drule mp) |
|
35 |
apply assumption |
|
36 |
apply assumption |
|
37 |
done |
|
38 |
||
10957 | 39 |
text {* |
10843 | 40 |
by eliminates uses of assumption and done |
41 |
*} |
|
42 |
||
43 |
lemma imp_uncurry: "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R" |
|
44 |
apply (rule impI) |
|
45 |
apply (erule conjE) |
|
46 |
apply (drule mp) |
|
47 |
apply assumption |
|
48 |
by (drule mp) |
|
49 |
||
50 |
||
10295 | 51 |
text {* |
52 |
substitution |
|
53 |
||
54 |
@{thm[display] ssubst} |
|
55 |
\rulename{ssubst} |
|
56 |
*}; |
|
57 |
||
58 |
lemma "\<lbrakk> x = f x; P(f x) \<rbrakk> \<Longrightarrow> P x" |
|
10843 | 59 |
by (erule ssubst) |
10295 | 60 |
|
61 |
text {* |
|
62 |
also provable by simp (re-orients) |
|
63 |
*}; |
|
64 |
||
65 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x" |
|
10957 | 66 |
apply (erule ssubst) |
67 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
|
68 |
back --{* @{subgoals[display,indent=0,margin=65]} *} |
|
69 |
back --{* @{subgoals[display,indent=0,margin=65]} *} |
|
70 |
back --{* @{subgoals[display,indent=0,margin=65]} *} |
|
71 |
back --{* @{subgoals[display,indent=0,margin=65]} *} |
|
10295 | 72 |
apply assumption |
73 |
done |
|
74 |
||
75 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x" |
|
76 |
apply (erule ssubst, assumption) |
|
77 |
done |
|
78 |
||
10843 | 79 |
text{* |
10957 | 80 |
or better still |
10843 | 81 |
*} |
82 |
||
10295 | 83 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x" |
10843 | 84 |
by (erule ssubst) |
85 |
||
86 |
||
87 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x" |
|
88 |
apply (erule_tac P="\<lambda>u. P u u x" in ssubst) |
|
89 |
apply (assumption) |
|
10295 | 90 |
done |
91 |
||
92 |
||
10843 | 93 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x" |
94 |
by (erule_tac P="\<lambda>u. P u u x" in ssubst) |
|
95 |
||
96 |
||
10295 | 97 |
text {* |
98 |
negation |
|
99 |
||
100 |
@{thm[display] notI} |
|
101 |
\rulename{notI} |
|
102 |
||
103 |
@{thm[display] notE} |
|
104 |
\rulename{notE} |
|
105 |
||
106 |
@{thm[display] classical} |
|
107 |
\rulename{classical} |
|
108 |
||
109 |
@{thm[display] contrapos_pp} |
|
110 |
\rulename{contrapos_pp} |
|
111 |
||
112 |
@{thm[display] contrapos_np} |
|
113 |
\rulename{contrapos_np} |
|
114 |
||
115 |
@{thm[display] contrapos_nn} |
|
116 |
\rulename{contrapos_nn} |
|
117 |
*}; |
|
118 |
||
119 |
||
120 |
lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R" |
|
121 |
apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np) |
|
10957 | 122 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10295 | 123 |
apply intro |
10957 | 124 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10843 | 125 |
by (erule notE) |
10295 | 126 |
|
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
127 |
text {* |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
128 |
@{thm[display] disjCI} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
129 |
\rulename{disjCI} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
130 |
*}; |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
131 |
|
10295 | 132 |
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R" |
133 |
apply intro |
|
10957 | 134 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10295 | 135 |
|
136 |
apply (elim conjE disjE) |
|
137 |
apply assumption |
|
10957 | 138 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10295 | 139 |
|
10843 | 140 |
by (erule contrapos_np, rule conjI) |
10957 | 141 |
text{* |
10295 | 142 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline |
143 |
\isanewline |
|
144 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline |
|
145 |
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline |
|
146 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline |
|
147 |
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R |
|
148 |
*} |
|
149 |
||
150 |
||
151 |
text{*Quantifiers*} |
|
152 |
||
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
153 |
|
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
154 |
text {* |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
155 |
@{thm[display] allI} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
156 |
\rulename{allI} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
157 |
|
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
158 |
@{thm[display] allE} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
159 |
\rulename{allE} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
160 |
|
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
161 |
@{thm[display] spec} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
162 |
\rulename{spec} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
163 |
*}; |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
164 |
|
10295 | 165 |
lemma "\<forall>x. P x \<longrightarrow> P x" |
166 |
apply (rule allI) |
|
10843 | 167 |
by (rule impI) |
10295 | 168 |
|
169 |
lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)" |
|
10843 | 170 |
apply (rule impI, rule allI) |
10295 | 171 |
apply (drule spec) |
10843 | 172 |
by (drule mp) |
10957 | 173 |
|
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
174 |
text{*rename_tac*} |
10957 | 175 |
lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)" |
176 |
apply intro |
|
177 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
|
178 |
apply (rename_tac v w) |
|
179 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
|
180 |
oops |
|
181 |
||
10295 | 182 |
|
10843 | 183 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))" |
10295 | 184 |
apply (frule spec) |
10957 | 185 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10295 | 186 |
apply (drule mp, assumption) |
187 |
apply (drule spec) |
|
10957 | 188 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10843 | 189 |
by (drule mp) |
10295 | 190 |
|
191 |
||
192 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))" |
|
193 |
by blast |
|
194 |
||
10957 | 195 |
text{* |
10843 | 196 |
Hilbert-epsilon theorems*} |
197 |
||
198 |
text{* |
|
199 |
@{thm[display] some_equality[no_vars]} |
|
200 |
\rulename{some_equality} |
|
201 |
||
202 |
@{thm[display] someI[no_vars]} |
|
203 |
\rulename{someI} |
|
204 |
||
205 |
@{thm[display] someI2[no_vars]} |
|
206 |
\rulename{someI2} |
|
207 |
||
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
208 |
@{thm[display] someI_ex[no_vars]} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
209 |
\rulename{someI_ex} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
210 |
|
10843 | 211 |
needed for examples |
212 |
||
213 |
@{thm[display] inv_def[no_vars]} |
|
214 |
\rulename{inv_def} |
|
215 |
||
216 |
@{thm[display] Least_def[no_vars]} |
|
217 |
\rulename{Least_def} |
|
218 |
||
219 |
@{thm[display] order_antisym[no_vars]} |
|
220 |
\rulename{order_antisym} |
|
221 |
*} |
|
222 |
||
223 |
||
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
224 |
lemma "inv Suc (Suc n) = n" |
10843 | 225 |
by (simp add: inv_def) |
226 |
||
227 |
text{*but we know nothing about inv Suc 0*} |
|
228 |
||
229 |
theorem Least_equality: |
|
230 |
"\<lbrakk> P (k::nat); \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k" |
|
231 |
apply (simp add: Least_def) |
|
232 |
||
233 |
txt{*omit maybe? |
|
234 |
@{subgoals[display,indent=0,margin=65]} |
|
235 |
*}; |
|
236 |
||
237 |
apply (rule some_equality) |
|
238 |
||
239 |
txt{* |
|
240 |
@{subgoals[display,indent=0,margin=65]} |
|
241 |
||
242 |
first subgoal is existence; second is uniqueness |
|
243 |
*}; |
|
244 |
by (auto intro: order_antisym) |
|
245 |
||
246 |
||
247 |
theorem axiom_of_choice: |
|
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
248 |
"(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)" |
10843 | 249 |
apply (rule exI, rule allI) |
250 |
||
251 |
txt{* |
|
252 |
@{subgoals[display,indent=0,margin=65]} |
|
253 |
||
254 |
state after intro rules |
|
255 |
*}; |
|
256 |
apply (drule spec, erule exE) |
|
257 |
||
258 |
txt{* |
|
259 |
@{subgoals[display,indent=0,margin=65]} |
|
260 |
||
261 |
applying @text{someI} automatically instantiates |
|
262 |
@{term f} to @{term "\<lambda>x. SOME y. P x y"} |
|
263 |
*}; |
|
264 |
||
265 |
by (rule someI) |
|
266 |
||
267 |
(*both can be done by blast, which however hasn't been introduced yet*) |
|
268 |
lemma "[| P (k::nat); \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k"; |
|
269 |
apply (simp add: Least_def) |
|
270 |
by (blast intro: some_equality order_antisym); |
|
271 |
||
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
272 |
theorem axiom_of_choice: "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)" |
10843 | 273 |
apply (rule exI [of _ "\<lambda>x. SOME y. P x y"]) |
274 |
by (blast intro: someI); |
|
275 |
||
10957 | 276 |
text{*end of Epsilon section*} |
277 |
||
10843 | 278 |
|
10295 | 279 |
lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x" |
280 |
apply elim |
|
281 |
apply intro |
|
282 |
apply assumption |
|
283 |
apply (intro exI disjI2) (*or else we get disjCI*) |
|
284 |
apply assumption |
|
285 |
done |
|
286 |
||
287 |
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)" |
|
288 |
apply intro |
|
289 |
apply elim |
|
290 |
apply assumption |
|
291 |
done |
|
292 |
||
293 |
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)" |
|
294 |
apply intro |
|
295 |
apply (elim conjE disjE) |
|
296 |
apply blast |
|
297 |
apply blast |
|
298 |
apply blast |
|
299 |
apply blast |
|
300 |
(*apply elim*) |
|
301 |
done |
|
302 |
||
303 |
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)" |
|
304 |
apply (erule exE) |
|
305 |
apply (erule conjE) |
|
306 |
apply (rule conjI) |
|
307 |
apply assumption |
|
308 |
apply (rule exI) |
|
309 |
apply assumption |
|
310 |
done |
|
311 |
||
312 |
lemma "(\<exists>x. P x) \<and> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<and> Q x" |
|
313 |
apply (erule conjE) |
|
314 |
apply (erule exE) |
|
315 |
apply (erule exE) |
|
316 |
apply (rule exI) |
|
317 |
apply (rule conjI) |
|
318 |
apply assumption |
|
319 |
oops |
|
320 |
||
11080
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
321 |
lemma "\<forall> y. R y y \<Longrightarrow> \<exists>x. \<forall> y. R x y" |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
322 |
apply (rule exI) |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
323 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
324 |
apply (rule allI) |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
325 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
326 |
apply (drule spec) |
22855d091249
various revisions in response to comments from Tobias
paulson
parents:
10957
diff
changeset
|
327 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
10295 | 328 |
oops |
329 |
||
330 |
lemma "\<forall>x. \<exists> y. x=y" |
|
331 |
apply (rule allI) |
|
332 |
apply (rule exI) |
|
333 |
apply (rule refl) |
|
334 |
done |
|
335 |
||
336 |
lemma "\<exists>x. \<forall> y. x=y" |
|
337 |
apply (rule exI) |
|
338 |
apply (rule allI) |
|
339 |
oops |
|
340 |
||
341 |
end |