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 |
|
|
127 |
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
|
|
128 |
apply intro
|
10957
|
129 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
10295
|
130 |
|
|
131 |
apply (elim conjE disjE)
|
|
132 |
apply assumption
|
10957
|
133 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
10295
|
134 |
|
10843
|
135 |
by (erule contrapos_np, rule conjI)
|
10957
|
136 |
text{*
|
10295
|
137 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
|
|
138 |
\isanewline
|
|
139 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
140 |
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
|
|
141 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
|
|
142 |
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
|
|
143 |
*}
|
|
144 |
|
|
145 |
|
|
146 |
text{*Quantifiers*}
|
|
147 |
|
|
148 |
lemma "\<forall>x. P x \<longrightarrow> P x"
|
|
149 |
apply (rule allI)
|
10843
|
150 |
by (rule impI)
|
10295
|
151 |
|
|
152 |
lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)"
|
10843
|
153 |
apply (rule impI, rule allI)
|
10295
|
154 |
apply (drule spec)
|
10843
|
155 |
by (drule mp)
|
10957
|
156 |
|
|
157 |
text{*NEW: rename_tac*}
|
|
158 |
lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
|
|
159 |
apply intro
|
|
160 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
|
161 |
apply (rename_tac v w)
|
|
162 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
|
163 |
oops
|
|
164 |
|
10295
|
165 |
|
10843
|
166 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
|
10295
|
167 |
apply (frule spec)
|
10957
|
168 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
10295
|
169 |
apply (drule mp, assumption)
|
|
170 |
apply (drule spec)
|
10957
|
171 |
--{* @{subgoals[display,indent=0,margin=65]} *}
|
10843
|
172 |
by (drule mp)
|
10295
|
173 |
|
|
174 |
|
|
175 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
|
|
176 |
by blast
|
|
177 |
|
10957
|
178 |
text{*
|
10843
|
179 |
Hilbert-epsilon theorems*}
|
|
180 |
|
|
181 |
text{*
|
|
182 |
@{thm[display] some_equality[no_vars]}
|
|
183 |
\rulename{some_equality}
|
|
184 |
|
|
185 |
@{thm[display] someI[no_vars]}
|
|
186 |
\rulename{someI}
|
|
187 |
|
|
188 |
@{thm[display] someI2[no_vars]}
|
|
189 |
\rulename{someI2}
|
|
190 |
|
|
191 |
needed for examples
|
|
192 |
|
|
193 |
@{thm[display] inv_def[no_vars]}
|
|
194 |
\rulename{inv_def}
|
|
195 |
|
|
196 |
@{thm[display] Least_def[no_vars]}
|
|
197 |
\rulename{Least_def}
|
|
198 |
|
|
199 |
@{thm[display] order_antisym[no_vars]}
|
|
200 |
\rulename{order_antisym}
|
|
201 |
*}
|
|
202 |
|
|
203 |
|
|
204 |
lemma "inv Suc (Suc x) = x"
|
|
205 |
by (simp add: inv_def)
|
|
206 |
|
|
207 |
text{*but we know nothing about inv Suc 0*}
|
|
208 |
|
|
209 |
theorem Least_equality:
|
|
210 |
"\<lbrakk> P (k::nat); \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k"
|
|
211 |
apply (simp add: Least_def)
|
|
212 |
|
|
213 |
txt{*omit maybe?
|
|
214 |
@{subgoals[display,indent=0,margin=65]}
|
|
215 |
*};
|
|
216 |
|
|
217 |
apply (rule some_equality)
|
|
218 |
|
|
219 |
txt{*
|
|
220 |
@{subgoals[display,indent=0,margin=65]}
|
|
221 |
|
|
222 |
first subgoal is existence; second is uniqueness
|
|
223 |
*};
|
|
224 |
by (auto intro: order_antisym)
|
|
225 |
|
|
226 |
|
|
227 |
theorem axiom_of_choice:
|
|
228 |
"(\<forall>x. \<exists> y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
|
|
229 |
apply (rule exI, rule allI)
|
|
230 |
|
|
231 |
txt{*
|
|
232 |
@{subgoals[display,indent=0,margin=65]}
|
|
233 |
|
|
234 |
state after intro rules
|
|
235 |
*};
|
|
236 |
apply (drule spec, erule exE)
|
|
237 |
|
|
238 |
txt{*
|
|
239 |
@{subgoals[display,indent=0,margin=65]}
|
|
240 |
|
|
241 |
applying @text{someI} automatically instantiates
|
|
242 |
@{term f} to @{term "\<lambda>x. SOME y. P x y"}
|
|
243 |
*};
|
|
244 |
|
|
245 |
by (rule someI)
|
|
246 |
|
|
247 |
(*both can be done by blast, which however hasn't been introduced yet*)
|
|
248 |
lemma "[| P (k::nat); \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k";
|
|
249 |
apply (simp add: Least_def)
|
|
250 |
by (blast intro: some_equality order_antisym);
|
|
251 |
|
|
252 |
theorem axiom_of_choice: "(\<forall>x. \<exists> y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
|
|
253 |
apply (rule exI [of _ "\<lambda>x. SOME y. P x y"])
|
|
254 |
by (blast intro: someI);
|
|
255 |
|
10957
|
256 |
text{*end of Epsilon section*}
|
|
257 |
|
10843
|
258 |
|
10295
|
259 |
lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
|
|
260 |
apply elim
|
|
261 |
apply intro
|
|
262 |
apply assumption
|
|
263 |
apply (intro exI disjI2) (*or else we get disjCI*)
|
|
264 |
apply assumption
|
|
265 |
done
|
|
266 |
|
|
267 |
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)"
|
|
268 |
apply intro
|
|
269 |
apply elim
|
|
270 |
apply assumption
|
|
271 |
done
|
|
272 |
|
|
273 |
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)"
|
|
274 |
apply intro
|
|
275 |
apply (elim conjE disjE)
|
|
276 |
apply blast
|
|
277 |
apply blast
|
|
278 |
apply blast
|
|
279 |
apply blast
|
|
280 |
(*apply elim*)
|
|
281 |
done
|
|
282 |
|
|
283 |
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)"
|
|
284 |
apply (erule exE)
|
|
285 |
apply (erule conjE)
|
|
286 |
apply (rule conjI)
|
|
287 |
apply assumption
|
|
288 |
apply (rule exI)
|
|
289 |
apply assumption
|
|
290 |
done
|
|
291 |
|
|
292 |
lemma "(\<exists>x. P x) \<and> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<and> Q x"
|
|
293 |
apply (erule conjE)
|
|
294 |
apply (erule exE)
|
|
295 |
apply (erule exE)
|
|
296 |
apply (rule exI)
|
|
297 |
apply (rule conjI)
|
|
298 |
apply assumption
|
|
299 |
oops
|
|
300 |
|
|
301 |
lemma "\<forall> z. R z z \<Longrightarrow> \<exists>x. \<forall> y. R x y"
|
|
302 |
apply (rule exI)
|
|
303 |
apply (rule allI)
|
|
304 |
apply (drule spec)
|
|
305 |
oops
|
|
306 |
|
|
307 |
lemma "\<forall>x. \<exists> y. x=y"
|
|
308 |
apply (rule allI)
|
|
309 |
apply (rule exI)
|
|
310 |
apply (rule refl)
|
|
311 |
done
|
|
312 |
|
|
313 |
lemma "\<exists>x. \<forall> y. x=y"
|
|
314 |
apply (rule exI)
|
|
315 |
apply (rule allI)
|
|
316 |
oops
|
|
317 |
|
|
318 |
end
|