83 |
83 |
84 |
84 |
85 (*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *) |
85 (*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *) |
86 qed_goalw "iffE" IFOL.thy [iff_def] |
86 qed_goalw "iffE" IFOL.thy [iff_def] |
87 "[| P <-> Q; [| P-->Q; Q-->P |] ==> R |] ==> R" |
87 "[| P <-> Q; [| P-->Q; Q-->P |] ==> R |] ==> R" |
88 (fn prems => [ (resolve_tac [conjE] 1), (REPEAT (ares_tac prems 1)) ]); |
88 (fn prems => [ (rtac conjE 1), (REPEAT (ares_tac prems 1)) ]); |
89 |
89 |
90 (* Destruct rules for <-> similar to Modus Ponens *) |
90 (* Destruct rules for <-> similar to Modus Ponens *) |
91 |
91 |
92 qed_goalw "iffD1" IFOL.thy [iff_def] "[| P <-> Q; P |] ==> Q" |
92 qed_goalw "iffD1" IFOL.thy [iff_def] "[| P <-> Q; P |] ==> Q" |
93 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]); |
93 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]); |
123 |
123 |
124 (*Sometimes easier to use: the premises have no shared variables*) |
124 (*Sometimes easier to use: the premises have no shared variables*) |
125 qed_goal "ex_ex1I" IFOL.thy |
125 qed_goal "ex_ex1I" IFOL.thy |
126 "[| EX x.P(x); !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)" |
126 "[| EX x.P(x); !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)" |
127 (fn [ex,eq] => [ (rtac (ex RS exE) 1), |
127 (fn [ex,eq] => [ (rtac (ex RS exE) 1), |
128 (REPEAT (ares_tac [ex1I,eq] 1)) ]); |
128 (REPEAT (ares_tac [ex1I,eq] 1)) ]); |
129 |
129 |
130 qed_goalw "ex1E" IFOL.thy [ex1_def] |
130 qed_goalw "ex1E" IFOL.thy [ex1_def] |
131 "[| EX! x.P(x); !!x. [| P(x); ALL y. P(y) --> y=x |] ==> R |] ==> R" |
131 "[| EX! x.P(x); !!x. [| P(x); ALL y. P(y) --> y=x |] ==> R |] ==> R" |
132 (fn prems => |
132 (fn prems => |
133 [ (cut_facts_tac prems 1), |
133 [ (cut_facts_tac prems 1), |
169 qed_goal "imp_cong" IFOL.thy |
169 qed_goal "imp_cong" IFOL.thy |
170 "[| P <-> P'; P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')" |
170 "[| P <-> P'; P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')" |
171 (fn prems => |
171 (fn prems => |
172 [ (cut_facts_tac prems 1), |
172 [ (cut_facts_tac prems 1), |
173 (REPEAT (ares_tac [iffI,impI] 1 |
173 (REPEAT (ares_tac [iffI,impI] 1 |
174 ORELSE eresolve_tac [iffE] 1 |
174 ORELSE etac iffE 1 |
175 ORELSE mp_tac 1 ORELSE iff_tac prems 1)) ]); |
175 ORELSE mp_tac 1 ORELSE iff_tac prems 1)) ]); |
176 |
176 |
177 qed_goal "iff_cong" IFOL.thy |
177 qed_goal "iff_cong" IFOL.thy |
178 "[| P <-> P'; Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')" |
178 "[| P <-> P'; Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')" |
179 (fn prems => |
179 (fn prems => |
180 [ (cut_facts_tac prems 1), |
180 [ (cut_facts_tac prems 1), |
181 (REPEAT (eresolve_tac [iffE] 1 |
181 (REPEAT (etac iffE 1 |
182 ORELSE ares_tac [iffI] 1 |
182 ORELSE ares_tac [iffI] 1 |
183 ORELSE mp_tac 1)) ]); |
183 ORELSE mp_tac 1)) ]); |
184 |
184 |
185 qed_goal "not_cong" IFOL.thy |
185 qed_goal "not_cong" IFOL.thy |
186 "P <-> P' ==> ~P <-> ~P'" |
186 "P <-> P' ==> ~P <-> ~P'" |
193 qed_goal "all_cong" IFOL.thy |
193 qed_goal "all_cong" IFOL.thy |
194 "(!!x.P(x) <-> Q(x)) ==> (ALL x.P(x)) <-> (ALL x.Q(x))" |
194 "(!!x.P(x) <-> Q(x)) ==> (ALL x.P(x)) <-> (ALL x.Q(x))" |
195 (fn prems => |
195 (fn prems => |
196 [ (REPEAT (ares_tac [iffI,allI] 1 |
196 [ (REPEAT (ares_tac [iffI,allI] 1 |
197 ORELSE mp_tac 1 |
197 ORELSE mp_tac 1 |
198 ORELSE eresolve_tac [allE] 1 ORELSE iff_tac prems 1)) ]); |
198 ORELSE etac allE 1 ORELSE iff_tac prems 1)) ]); |
199 |
199 |
200 qed_goal "ex_cong" IFOL.thy |
200 qed_goal "ex_cong" IFOL.thy |
201 "(!!x.P(x) <-> Q(x)) ==> (EX x.P(x)) <-> (EX x.Q(x))" |
201 "(!!x.P(x) <-> Q(x)) ==> (EX x.P(x)) <-> (EX x.Q(x))" |
202 (fn prems => |
202 (fn prems => |
203 [ (REPEAT (eresolve_tac [exE] 1 ORELSE ares_tac [iffI,exI] 1 |
203 [ (REPEAT (etac exE 1 ORELSE ares_tac [iffI,exI] 1 |
204 ORELSE mp_tac 1 |
204 ORELSE mp_tac 1 |
205 ORELSE iff_tac prems 1)) ]); |
205 ORELSE iff_tac prems 1)) ]); |
206 |
206 |
207 qed_goal "ex1_cong" IFOL.thy |
207 qed_goal "ex1_cong" IFOL.thy |
208 "(!!x.P(x) <-> Q(x)) ==> (EX! x.P(x)) <-> (EX! x.Q(x))" |
208 "(!!x.P(x) <-> Q(x)) ==> (EX! x.P(x)) <-> (EX! x.Q(x))" |
239 |
239 |
240 qed_goal "subst_context" IFOL.thy |
240 qed_goal "subst_context" IFOL.thy |
241 "[| a=b |] ==> t(a)=t(b)" |
241 "[| a=b |] ==> t(a)=t(b)" |
242 (fn prems=> |
242 (fn prems=> |
243 [ (resolve_tac (prems RL [ssubst]) 1), |
243 [ (resolve_tac (prems RL [ssubst]) 1), |
244 (resolve_tac [refl] 1) ]); |
244 (rtac refl 1) ]); |
245 |
245 |
246 qed_goal "subst_context2" IFOL.thy |
246 qed_goal "subst_context2" IFOL.thy |
247 "[| a=b; c=d |] ==> t(a,c)=t(b,d)" |
247 "[| a=b; c=d |] ==> t(a,c)=t(b,d)" |
248 (fn prems=> |
248 (fn prems=> |
249 [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]); |
249 [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]); |
252 "[| a=b; c=d; e=f |] ==> t(a,c,e)=t(b,d,f)" |
252 "[| a=b; c=d; e=f |] ==> t(a,c,e)=t(b,d,f)" |
253 (fn prems=> |
253 (fn prems=> |
254 [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]); |
254 [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]); |
255 |
255 |
256 (*Useful with eresolve_tac for proving equalties from known equalities. |
256 (*Useful with eresolve_tac for proving equalties from known equalities. |
257 a = b |
257 a = b |
258 | | |
258 | | |
259 c = d *) |
259 c = d *) |
260 qed_goal "box_equals" IFOL.thy |
260 qed_goal "box_equals" IFOL.thy |
261 "[| a=b; a=c; b=d |] ==> c=d" |
261 "[| a=b; a=c; b=d |] ==> c=d" |
262 (fn prems=> |
262 (fn prems=> |
263 [ (resolve_tac [trans] 1), |
263 [ (rtac trans 1), |
264 (resolve_tac [trans] 1), |
264 (rtac trans 1), |
265 (resolve_tac [sym] 1), |
265 (rtac sym 1), |
266 (REPEAT (resolve_tac prems 1)) ]); |
266 (REPEAT (resolve_tac prems 1)) ]); |
267 |
267 |
268 (*Dual of box_equals: for proving equalities backwards*) |
268 (*Dual of box_equals: for proving equalities backwards*) |
269 qed_goal "simp_equals" IFOL.thy |
269 qed_goal "simp_equals" IFOL.thy |
270 "[| a=c; b=d; c=d |] ==> a=b" |
270 "[| a=c; b=d; c=d |] ==> a=b" |
271 (fn prems=> |
271 (fn prems=> |
272 [ (resolve_tac [trans] 1), |
272 [ (rtac trans 1), |
273 (resolve_tac [trans] 1), |
273 (rtac trans 1), |
274 (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]); |
274 (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]); |
275 |
275 |
276 (** Congruence rules for predicate letters **) |
276 (** Congruence rules for predicate letters **) |
277 |
277 |
278 qed_goal "pred1_cong" IFOL.thy |
278 qed_goal "pred1_cong" IFOL.thy |
298 |
298 |
299 (*special cases for free variables P, Q, R, S -- up to 3 arguments*) |
299 (*special cases for free variables P, Q, R, S -- up to 3 arguments*) |
300 |
300 |
301 val pred_congs = |
301 val pred_congs = |
302 flat (map (fn c => |
302 flat (map (fn c => |
303 map (fn th => read_instantiate [("P",c)] th) |
303 map (fn th => read_instantiate [("P",c)] th) |
304 [pred1_cong,pred2_cong,pred3_cong]) |
304 [pred1_cong,pred2_cong,pred3_cong]) |
305 (explode"PQRS")); |
305 (explode"PQRS")); |
306 |
306 |
307 (*special case for the equality predicate!*) |
307 (*special case for the equality predicate!*) |
308 val eq_cong = read_instantiate [("P","op =")] pred2_cong; |
308 val eq_cong = read_instantiate [("P","op =")] pred2_cong; |
309 |
309 |
310 |
310 |
358 (fn major::prems=> |
358 (fn major::prems=> |
359 [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]); |
359 [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]); |
360 |
360 |
361 (*Courtesy Krzysztof Grabczewski*) |
361 (*Courtesy Krzysztof Grabczewski*) |
362 val major::prems = goal IFOL.thy "[| P|Q; P==>R; Q==>S |] ==> R|S"; |
362 val major::prems = goal IFOL.thy "[| P|Q; P==>R; Q==>S |] ==> R|S"; |
363 br (major RS disjE) 1; |
363 by (rtac (major RS disjE) 1); |
364 by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1)); |
364 by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1)); |
365 qed "disj_imp_disj"; |
365 qed "disj_imp_disj"; |