17870
|
1 |
(* $Id$ *)
|
|
2 |
|
|
3 |
(* METHOD FOR ANALYSING EQUATION INVOLVING PERMUTATION *)
|
|
4 |
|
|
5 |
local
|
|
6 |
|
|
7 |
(* applies the expand_fun_eq rule to the first goal and strips off all universal quantifiers *)
|
|
8 |
val Expand_Fun_Eq_tac =
|
|
9 |
("extensionality on functions",
|
|
10 |
EVERY [simp_tac (HOL_basic_ss addsimps [expand_fun_eq]) 1, REPEAT_DETERM (rtac allI 1)]);
|
|
11 |
|
|
12 |
(* applies the perm_compose rule - this rule would loop in the simplifier *)
|
|
13 |
fun Apply_Perm_Compose_tac ctxt =
|
|
14 |
let
|
|
15 |
val perm_compose = PureThy.get_thm (ProofContext.theory_of ctxt) (Name ("perm_compose"));
|
|
16 |
in ("analysing permutation compositions",rtac (perm_compose RS trans) 1)
|
|
17 |
end;
|
|
18 |
|
|
19 |
(* unfolds the definition of permutations applied to functions *)
|
|
20 |
fun Unfold_Perm_Fun_Def_tac ctxt =
|
|
21 |
let
|
|
22 |
val perm_fun_def = PureThy.get_thm (ProofContext.theory_of ctxt) (Name ("nominal.perm_fun_def"))
|
|
23 |
in ("unfolding of perms on functions", simp_tac (HOL_basic_ss addsimps [perm_fun_def]) 1)
|
|
24 |
end
|
|
25 |
|
|
26 |
(* applies the perm_eq_lam and perm_eq_app simplifications *)
|
|
27 |
fun Apply_SimProc_tac ctxt =
|
|
28 |
let
|
|
29 |
val thy = ProofContext.theory_of ctxt;
|
|
30 |
val perm_app_eq = PureThy.get_thm thy (Name ("perm_app_eq"));
|
|
31 |
val perm_lam_eq = PureThy.get_thm thy (Name ("perm_eq_lam"));
|
|
32 |
in
|
|
33 |
("simplification of permutation on applications and lambdas",
|
|
34 |
asm_full_simp_tac (HOL_basic_ss addsimps [perm_app_eq,perm_lam_eq]) 1)
|
|
35 |
end;
|
|
36 |
|
|
37 |
(* applying Stefan's smart congruence tac *)
|
|
38 |
val Apply_Cong_tac = ("application of congruence",
|
|
39 |
(fn st => DatatypeAux.cong_tac 1 st handle Subscript => no_tac st));
|
|
40 |
|
|
41 |
(* initial simplification step in the tactic *)
|
|
42 |
fun Initial_Simp_tac thms ctxt =
|
|
43 |
let
|
|
44 |
val thy = ProofContext.theory_of ctxt;
|
|
45 |
val perm_swap = PureThy.get_thm thy (Name ("perm_swap"));
|
|
46 |
val perm_fresh = PureThy.get_thm thy (Name ("perm_fresh_fresh"));
|
|
47 |
val perm_bij = PureThy.get_thm thy (Name ("perm_bij"));
|
|
48 |
val simps = (local_simpset_of ctxt) addsimps (thms @ [perm_swap,perm_fresh,perm_bij])
|
|
49 |
in
|
|
50 |
("general simplification step", FIRST [rtac conjI 1, asm_full_simp_tac simps 1])
|
|
51 |
end;
|
|
52 |
|
|
53 |
|
|
54 |
(* debugging *)
|
|
55 |
fun DEBUG_tac (msg,tac) =
|
|
56 |
EVERY [print_tac ("before application of "^msg), CHANGED tac, print_tac ("after "^msg)];
|
|
57 |
fun NO_DEBUG_tac (_,tac) = CHANGED tac;
|
|
58 |
|
|
59 |
(* Main Tactic *)
|
|
60 |
(* "repeating"-depth is set to 40 - this seems sufficient *)
|
|
61 |
fun perm_simp_tac tactical thms ctxt =
|
|
62 |
REPEAT_DETERM_N 40
|
|
63 |
(FIRST[tactical (Initial_Simp_tac thms ctxt),
|
|
64 |
tactical (Apply_Perm_Compose_tac ctxt),
|
|
65 |
tactical (Apply_SimProc_tac ctxt),
|
|
66 |
tactical Apply_Cong_tac,
|
|
67 |
tactical (Unfold_Perm_Fun_Def_tac ctxt),
|
|
68 |
tactical Expand_Fun_Eq_tac]);
|
|
69 |
|
|
70 |
(* tactic that unfolds first the support definition *)
|
|
71 |
(* and then applies perm_simp *)
|
|
72 |
fun supports_tac tactical thms ctxt =
|
|
73 |
let
|
|
74 |
val thy = ProofContext.theory_of ctxt;
|
|
75 |
val supports_def = PureThy.get_thm thy (Name ("nominal.op supports_def"));
|
|
76 |
val fresh_def = PureThy.get_thm thy (Name ("nominal.fresh_def"));
|
|
77 |
val fresh_prod = PureThy.get_thm thy (Name ("nominal.fresh_prod"));
|
|
78 |
val simps = [supports_def,symmetric fresh_def,fresh_prod];
|
|
79 |
|
|
80 |
in
|
|
81 |
EVERY [tactical ("unfolding of supports",simp_tac (HOL_basic_ss addsimps simps) 1),
|
|
82 |
tactical ("stripping of foralls " ,REPEAT_DETERM (rtac allI 1)),
|
|
83 |
tactical ("geting rid of the imp",rtac impI 1),
|
|
84 |
tactical ("eliminating conjuncts",REPEAT_DETERM (etac conjE 1)),
|
|
85 |
tactical ("applying perm_simp ",perm_simp_tac tactical thms ctxt)]
|
|
86 |
end;
|
|
87 |
|
|
88 |
in
|
|
89 |
|
|
90 |
val perm_eq_meth =
|
|
91 |
Method.thms_ctxt_args
|
|
92 |
(fn thms => fn ctxt => Method.SIMPLE_METHOD (DETERM (perm_simp_tac NO_DEBUG_tac thms ctxt)));
|
|
93 |
|
|
94 |
val perm_eq_meth_debug =
|
|
95 |
Method.thms_ctxt_args
|
|
96 |
(fn thms => fn ctxt => Method.SIMPLE_METHOD (DETERM (perm_simp_tac DEBUG_tac thms ctxt)));
|
|
97 |
|
|
98 |
val supports_meth =
|
|
99 |
Method.thms_ctxt_args
|
|
100 |
(fn thms => fn ctxt => Method.SIMPLE_METHOD (DETERM (supports_tac NO_DEBUG_tac thms ctxt)));
|
|
101 |
|
|
102 |
val supports_meth_debug =
|
|
103 |
Method.thms_ctxt_args
|
|
104 |
(fn thms => fn ctxt => Method.SIMPLE_METHOD (DETERM (supports_tac DEBUG_tac thms ctxt)));
|
|
105 |
|
|
106 |
end
|
|
107 |
|
|
108 |
|
|
109 |
|