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 |
|
|
39 |
text {*
|
|
40 |
substitution
|
|
41 |
|
|
42 |
@{thm[display] ssubst}
|
|
43 |
\rulename{ssubst}
|
|
44 |
*};
|
|
45 |
|
|
46 |
lemma "\<lbrakk> x = f x; P(f x) \<rbrakk> \<Longrightarrow> P x"
|
|
47 |
apply (erule ssubst)
|
|
48 |
apply assumption
|
|
49 |
done
|
|
50 |
|
|
51 |
text {*
|
|
52 |
also provable by simp (re-orients)
|
|
53 |
*};
|
|
54 |
|
|
55 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
|
|
56 |
apply (erule ssubst)
|
|
57 |
back
|
|
58 |
back
|
|
59 |
back
|
|
60 |
back
|
|
61 |
apply assumption
|
|
62 |
done
|
|
63 |
|
|
64 |
text {*
|
|
65 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ \isadigit{1}\isanewline
|
|
66 |
\isanewline
|
|
67 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
68 |
{\isasymlbrakk}x\ {\isacharequal}\ f\ x{\isacharsemicolon}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x\ x\ x\isanewline
|
|
69 |
\ \isadigit{1}{\isachardot}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}
|
|
70 |
|
|
71 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ \isadigit{1}\isanewline
|
|
72 |
\isanewline
|
|
73 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
74 |
{\isasymlbrakk}x\ {\isacharequal}\ f\ x{\isacharsemicolon}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x\ x\ x\isanewline
|
|
75 |
\ \isadigit{1}{\isachardot}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isasymLongrightarrow}\ P\ x\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}
|
|
76 |
|
|
77 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ \isadigit{1}\isanewline
|
|
78 |
\isanewline
|
|
79 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
80 |
{\isasymlbrakk}x\ {\isacharequal}\ f\ x{\isacharsemicolon}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x\ x\ x\isanewline
|
|
81 |
\ \isadigit{1}{\isachardot}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isacharparenleft}f\ x{\isacharparenright}
|
|
82 |
|
|
83 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ \isadigit{1}\isanewline
|
|
84 |
\isanewline
|
|
85 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
86 |
{\isasymlbrakk}x\ {\isacharequal}\ f\ x{\isacharsemicolon}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x\ x\ x\isanewline
|
|
87 |
\ \isadigit{1}{\isachardot}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isasymLongrightarrow}\ P\ x\ x\ {\isacharparenleft}f\ x{\isacharparenright}
|
|
88 |
|
|
89 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ \isadigit{1}\isanewline
|
|
90 |
\isanewline
|
|
91 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
92 |
{\isasymlbrakk}x\ {\isacharequal}\ f\ x{\isacharsemicolon}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x\ x\ x\isanewline
|
|
93 |
\ \isadigit{1}{\isachardot}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}\ {\isacharparenleft}f\ x{\isacharparenright}\ x
|
|
94 |
*};
|
|
95 |
|
|
96 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
|
|
97 |
apply (erule ssubst, assumption)
|
|
98 |
done
|
|
99 |
|
|
100 |
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
|
|
101 |
apply (erule_tac P="\<lambda>u. P u u x" in ssubst);
|
|
102 |
apply assumption
|
|
103 |
done
|
|
104 |
|
|
105 |
|
|
106 |
text {*
|
|
107 |
negation
|
|
108 |
|
|
109 |
@{thm[display] notI}
|
|
110 |
\rulename{notI}
|
|
111 |
|
|
112 |
@{thm[display] notE}
|
|
113 |
\rulename{notE}
|
|
114 |
|
|
115 |
@{thm[display] classical}
|
|
116 |
\rulename{classical}
|
|
117 |
|
|
118 |
@{thm[display] contrapos_pp}
|
|
119 |
\rulename{contrapos_pp}
|
|
120 |
|
|
121 |
@{thm[display] contrapos_np}
|
|
122 |
\rulename{contrapos_np}
|
|
123 |
|
|
124 |
@{thm[display] contrapos_nn}
|
|
125 |
\rulename{contrapos_nn}
|
|
126 |
*};
|
|
127 |
|
|
128 |
|
|
129 |
lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R"
|
|
130 |
apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
|
|
131 |
txt{*
|
|
132 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{1}}\isanewline
|
|
133 |
\isanewline
|
|
134 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
135 |
{\isasymlbrakk}{\isasymnot}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isacharsemicolon}\ {\isasymnot}\ {\isacharparenleft}R\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ R\isanewline
|
|
136 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isasymnot}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isacharsemicolon}\ {\isasymnot}\ R{\isasymrbrakk}\ {\isasymLongrightarrow}\ R\ {\isasymlongrightarrow}\ Q
|
|
137 |
*}
|
|
138 |
|
|
139 |
apply intro
|
|
140 |
txt{*
|
|
141 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{3}}\isanewline
|
|
142 |
\isanewline
|
|
143 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
144 |
{\isasymlbrakk}{\isasymnot}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isacharsemicolon}\ {\isasymnot}\ {\isacharparenleft}R\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ R\isanewline
|
|
145 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isasymnot}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}{\isacharsemicolon}\ {\isasymnot}\ R{\isacharsemicolon}\ R{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q
|
|
146 |
*}
|
|
147 |
apply (erule notE, assumption)
|
|
148 |
done
|
|
149 |
|
|
150 |
|
|
151 |
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
|
|
152 |
apply intro
|
|
153 |
txt{*
|
|
154 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{1}}\isanewline
|
|
155 |
\isanewline
|
|
156 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
157 |
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
|
|
158 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R{\isacharsemicolon}\ {\isasymnot}\ {\isacharparenleft}Q\ {\isasymand}\ R{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ P
|
|
159 |
*}
|
|
160 |
|
|
161 |
apply (elim conjE disjE)
|
|
162 |
apply assumption
|
|
163 |
|
|
164 |
txt{*
|
|
165 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{4}}\isanewline
|
|
166 |
\isanewline
|
|
167 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
168 |
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
|
|
169 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isasymnot}\ {\isacharparenleft}Q\ {\isasymand}\ R{\isacharparenright}{\isacharsemicolon}\ R{\isacharsemicolon}\ Q{\isasymrbrakk}\ {\isasymLongrightarrow}\ P
|
|
170 |
*}
|
|
171 |
|
|
172 |
apply (erule contrapos_np, rule conjI)
|
|
173 |
txt{*
|
|
174 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
|
|
175 |
\isanewline
|
|
176 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
177 |
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
|
|
178 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
|
|
179 |
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
|
|
180 |
*}
|
|
181 |
|
|
182 |
apply assumption
|
|
183 |
apply assumption
|
|
184 |
done
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
text{*Quantifiers*}
|
|
189 |
|
|
190 |
lemma "\<forall>x. P x \<longrightarrow> P x"
|
|
191 |
apply (rule allI)
|
|
192 |
apply (rule impI)
|
|
193 |
apply assumption
|
|
194 |
done
|
|
195 |
|
|
196 |
lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)"
|
|
197 |
apply (rule impI)
|
|
198 |
apply (rule allI)
|
|
199 |
apply (drule spec)
|
|
200 |
apply (drule mp)
|
|
201 |
apply assumption
|
|
202 |
apply assumption
|
|
203 |
done
|
|
204 |
|
|
205 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
|
|
206 |
apply (frule spec)
|
|
207 |
apply (drule mp, assumption)
|
|
208 |
apply (drule spec)
|
|
209 |
apply (drule mp, assumption, assumption)
|
|
210 |
done
|
|
211 |
|
|
212 |
text
|
|
213 |
{*
|
|
214 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{1}}\isanewline
|
|
215 |
\isanewline
|
|
216 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
217 |
{\isasymlbrakk}{\isasymforall}x{\isachardot}\ P\ x\ {\isasymlongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}{\isacharsemicolon}\ P\ a{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ {\isacharparenleft}f\ a{\isacharparenright}{\isacharparenright}\isanewline
|
|
218 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isasymforall}x{\isachardot}\ P\ x\ {\isasymlongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}{\isacharsemicolon}\ P\ a{\isacharsemicolon}\ P\ {\isacharquery}x\ {\isasymlongrightarrow}\ P\ {\isacharparenleft}f\ {\isacharquery}x{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ {\isacharparenleft}f\ a{\isacharparenright}{\isacharparenright}
|
|
219 |
*}
|
|
220 |
|
|
221 |
text{*
|
|
222 |
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{3}}\isanewline
|
|
223 |
\isanewline
|
|
224 |
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
|
|
225 |
{\isasymlbrakk}{\isasymforall}x{\isachardot}\ P\ x\ {\isasymlongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}{\isacharsemicolon}\ P\ a{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ {\isacharparenleft}f\ a{\isacharparenright}{\isacharparenright}\isanewline
|
|
226 |
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}{\isasymforall}x{\isachardot}\ P\ x\ {\isasymlongrightarrow}\ P\ {\isacharparenleft}f\ x{\isacharparenright}{\isacharsemicolon}\ P\ a{\isacharsemicolon}\ P\ {\isacharparenleft}f\ a{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}f\ {\isacharparenleft}f\ a{\isacharparenright}{\isacharparenright}
|
|
227 |
*}
|
|
228 |
|
|
229 |
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
|
|
230 |
by blast
|
|
231 |
|
|
232 |
lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
|
|
233 |
apply elim
|
|
234 |
apply intro
|
|
235 |
apply assumption
|
|
236 |
apply (intro exI disjI2) (*or else we get disjCI*)
|
|
237 |
apply assumption
|
|
238 |
done
|
|
239 |
|
|
240 |
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)"
|
|
241 |
apply intro
|
|
242 |
apply elim
|
|
243 |
apply assumption
|
|
244 |
done
|
|
245 |
|
|
246 |
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)"
|
|
247 |
apply intro
|
|
248 |
apply (elim conjE disjE)
|
|
249 |
apply blast
|
|
250 |
apply blast
|
|
251 |
apply blast
|
|
252 |
apply blast
|
|
253 |
(*apply elim*)
|
|
254 |
done
|
|
255 |
|
|
256 |
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)"
|
|
257 |
apply (erule exE)
|
|
258 |
apply (erule conjE)
|
|
259 |
apply (rule conjI)
|
|
260 |
apply assumption
|
|
261 |
apply (rule exI)
|
|
262 |
apply assumption
|
|
263 |
done
|
|
264 |
|
|
265 |
lemma "(\<exists>x. P x) \<and> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<and> Q x"
|
|
266 |
apply (erule conjE)
|
|
267 |
apply (erule exE)
|
|
268 |
apply (erule exE)
|
|
269 |
apply (rule exI)
|
|
270 |
apply (rule conjI)
|
|
271 |
apply assumption
|
|
272 |
oops
|
|
273 |
|
|
274 |
lemma "\<forall> z. R z z \<Longrightarrow> \<exists>x. \<forall> y. R x y"
|
|
275 |
apply (rule exI)
|
|
276 |
apply (rule allI)
|
|
277 |
apply (drule spec)
|
|
278 |
oops
|
|
279 |
|
|
280 |
lemma "\<forall>x. \<exists> y. x=y"
|
|
281 |
apply (rule allI)
|
|
282 |
apply (rule exI)
|
|
283 |
apply (rule refl)
|
|
284 |
done
|
|
285 |
|
|
286 |
lemma "\<exists>x. \<forall> y. x=y"
|
|
287 |
apply (rule exI)
|
|
288 |
apply (rule allI)
|
|
289 |
oops
|
|
290 |
|
|
291 |
end
|