3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
4 Copyright 1992 University of Cambridge |
4 Copyright 1992 University of Cambridge |
5 |
5 |
6 Tactics and lemmas for IFOL.thy (intuitionistic first-order logic) |
6 Tactics and lemmas for IFOL.thy (intuitionistic first-order logic) |
7 *) |
7 *) |
8 |
|
9 open IFOL; |
|
10 |
|
11 |
8 |
12 qed_goalw "TrueI" IFOL.thy [True_def] "True" |
9 qed_goalw "TrueI" IFOL.thy [True_def] "True" |
13 (fn _ => [ (REPEAT (ares_tac [impI] 1)) ]); |
10 (fn _ => [ (REPEAT (ares_tac [impI] 1)) ]); |
14 |
11 |
15 (*** Sequent-style elimination rules for & --> and ALL ***) |
12 (*** Sequent-style elimination rules for & --> and ALL ***) |
240 qed "def_imp_iff"; |
237 qed "def_imp_iff"; |
241 |
238 |
242 val prems = goal IFOL.thy "(A == B) ==> A = B"; |
239 val prems = goal IFOL.thy "(A == B) ==> A = B"; |
243 by (rewrite_goals_tac prems); |
240 by (rewrite_goals_tac prems); |
244 by (rtac refl 1); |
241 by (rtac refl 1); |
245 qed "def_imp_eq"; |
242 qed "meta_eq_to_obj_eq"; |
|
243 |
246 |
244 |
247 (*Substitution: rule and tactic*) |
245 (*Substitution: rule and tactic*) |
248 bind_thm ("ssubst", sym RS subst); |
246 bind_thm ("ssubst", sym RS subst); |
249 |
247 |
250 (*Apply an equality or definition ONCE. |
248 (*Apply an equality or definition ONCE. |
251 Fails unless the substitution has an effect*) |
249 Fails unless the substitution has an effect*) |
252 fun stac th = |
250 fun stac th = |
253 let val th' = th RS def_imp_eq handle _ => th |
251 let val th' = th RS meta_eq_to_obj_eq handle _ => th |
254 in CHANGED_GOAL (rtac (th' RS ssubst)) |
252 in CHANGED_GOAL (rtac (th' RS ssubst)) |
255 end; |
253 end; |
256 |
254 |
257 (*A special case of ex1E that would otherwise need quantifier expansion*) |
255 (*A special case of ex1E that would otherwise need quantifier expansion*) |
258 qed_goal "ex1_equalsE" IFOL.thy |
256 qed_goal "ex1_equalsE" IFOL.thy |
395 qed "disj_imp_disj"; |
393 qed "disj_imp_disj"; |
396 |
394 |
397 |
395 |
398 (** strip ALL and --> from proved goal while preserving ALL-bound var names **) |
396 (** strip ALL and --> from proved goal while preserving ALL-bound var names **) |
399 |
397 |
|
398 fun make_new_spec rl = |
|
399 (* Use a crazy name to avoid forall_intr failing because of |
|
400 duplicate variable name *) |
|
401 let val myspec = read_instantiate [("P","?wlzickd")] rl |
|
402 val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec; |
|
403 val cvx = cterm_of (#sign(rep_thm myspec)) vx |
|
404 in (vxT, forall_intr cvx myspec) end; |
|
405 |
400 local |
406 local |
401 |
407 |
402 (* Use XXX to avoid forall_intr failing because of duplicate variable name *) |
408 val (specT, spec') = make_new_spec spec |
403 val myspec = read_instantiate [("P","?XXX")] spec; |
|
404 val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec; |
|
405 val cvx = cterm_of (#sign(rep_thm myspec)) vx; |
|
406 val aspec = forall_intr cvx myspec; |
|
407 |
409 |
408 in |
410 in |
409 |
411 |
410 fun RSspec th = |
412 fun RSspec th = |
411 (case concl_of th of |
413 (case concl_of th of |
412 _ $ (Const("All",_) $ Abs(a,_,_)) => |
414 _ $ (Const("All",_) $ Abs(a,_,_)) => |
413 let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),vxT)) |
415 let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),specT)) |
414 in th RS forall_elim ca aspec end |
416 in th RS forall_elim ca spec' end |
415 | _ => raise THM("RSspec",0,[th])); |
417 | _ => raise THM("RSspec",0,[th])); |
416 |
418 |
417 fun RSmp th = |
419 fun RSmp th = |
418 (case concl_of th of |
420 (case concl_of th of |
419 _ $ (Const("op -->",_)$_$_) => th RS mp |
421 _ $ (Const("op -->",_)$_$_) => th RS mp |
420 | _ => raise THM("RSmp",0,[th])); |
422 | _ => raise THM("RSmp",0,[th])); |
421 |
423 |
422 fun normalize_thm funs = |
424 fun normalize_thm funs = |
423 let fun trans [] th = th |
425 let fun trans [] th = th |
424 | trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th |
426 | trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th |
425 in trans funs end; |
427 in trans funs end; |
426 |
428 |
427 fun qed_spec_mp name = |
429 fun qed_spec_mp name = |
428 let val thm = normalize_thm [RSspec,RSmp] (result()) |
430 let val thm = normalize_thm [RSspec,RSmp] (result()) |
429 in bind_thm(name, thm) end; |
431 in bind_thm(name, thm) end; |
430 |
432 |