author | Christian Urban <urbanc@in.tum.de> |
Sat, 31 Jul 2010 02:10:42 +0100 | |
changeset 2391 | ea143c806db6 |
parent 2390 | 920366e646b0 |
child 2392 | 9294d7cec5e2 |
permissions | -rw-r--r-- |
2297 | 1 |
(* Title: nominal_dt_alpha.ML |
2 |
Author: Cezary Kaliszyk |
|
3 |
Author: Christian Urban |
|
4 |
||
2313
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
5 |
Definitions and proofs for the alpha-relations. |
2297 | 6 |
*) |
7 |
||
8 |
signature NOMINAL_DT_ALPHA = |
|
9 |
sig |
|
10 |
val define_raw_alpha: Datatype_Aux.descr -> (string * sort) list -> bn_info -> |
|
11 |
bclause list list list -> term list -> Proof.context -> |
|
2298 | 12 |
term list * term list * thm list * thm list * thm * local_theory |
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
13 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
14 |
val mk_alpha_distincts: Proof.context -> thm list -> thm list list -> |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
15 |
term list -> term list -> bn_info -> thm list * thm list |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
16 |
|
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
17 |
val mk_alpha_eq_iff: Proof.context -> thm list -> thm list -> thm list -> |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
18 |
thm list -> (thm list * thm list) |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
19 |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
20 |
val alpha_prove: term list -> (term * ((term * term) -> term)) list -> thm -> |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
21 |
(Proof.context -> int -> tactic) -> Proof.context -> thm list |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
22 |
|
2316 | 23 |
val raw_prove_refl: term list -> term list -> thm list -> thm -> Proof.context -> thm list |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
24 |
val raw_prove_sym: term list -> thm list -> thm -> Proof.context -> thm list |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
25 |
val raw_prove_trans: term list -> thm list -> thm list -> thm -> thm list -> Proof.context -> thm list |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
26 |
val raw_prove_equivp: term list -> thm list -> thm list -> thm list -> Proof.context -> thm list |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
27 |
val raw_prove_bn_imp: term list -> term list -> thm list -> thm -> Proof.context -> thm list |
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
28 |
val raw_fv_bn_rsp_aux: term list -> term list -> term list -> term list -> |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
29 |
term list -> thm -> thm list -> Proof.context -> thm list |
2297 | 30 |
end |
31 |
||
32 |
structure Nominal_Dt_Alpha: NOMINAL_DT_ALPHA = |
|
33 |
struct |
|
34 |
||
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
35 |
fun lookup xs x = the (AList.lookup (op=) xs x) |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
36 |
fun group xs = AList.group (op=) xs |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
37 |
|
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
38 |
(** definition of the inductive rules for alpha and alpha_bn **) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
39 |
|
2297 | 40 |
(* construct the compound terms for prod_fv and prod_alpha *) |
41 |
fun mk_prod_fv (t1, t2) = |
|
42 |
let |
|
43 |
val ty1 = fastype_of t1 |
|
44 |
val ty2 = fastype_of t2 |
|
45 |
val resT = HOLogic.mk_prodT (domain_type ty1, domain_type ty2) --> @{typ "atom set"} |
|
46 |
in |
|
47 |
Const (@{const_name "prod_fv"}, [ty1, ty2] ---> resT) $ t1 $ t2 |
|
48 |
end |
|
49 |
||
50 |
fun mk_prod_alpha (t1, t2) = |
|
51 |
let |
|
52 |
val ty1 = fastype_of t1 |
|
53 |
val ty2 = fastype_of t2 |
|
54 |
val prodT = HOLogic.mk_prodT (domain_type ty1, domain_type ty2) |
|
55 |
val resT = [prodT, prodT] ---> @{typ "bool"} |
|
56 |
in |
|
57 |
Const (@{const_name "prod_alpha"}, [ty1, ty2] ---> resT) $ t1 $ t2 |
|
58 |
end |
|
59 |
||
60 |
(* generates the compound binder terms *) |
|
61 |
fun mk_binders lthy bmode args bodies = |
|
62 |
let |
|
63 |
fun bind_set lthy args (NONE, i) = setify lthy (nth args i) |
|
64 |
| bind_set _ args (SOME bn, i) = bn $ (nth args i) |
|
65 |
fun bind_lst lthy args (NONE, i) = listify lthy (nth args i) |
|
66 |
| bind_lst _ args (SOME bn, i) = bn $ (nth args i) |
|
67 |
||
68 |
val (combine_fn, bind_fn) = |
|
69 |
case bmode of |
|
70 |
Lst => (mk_append, bind_lst) |
|
71 |
| Set => (mk_union, bind_set) |
|
72 |
| Res => (mk_union, bind_set) |
|
73 |
in |
|
2375 | 74 |
bodies |
75 |
|> map (bind_fn lthy args) |
|
76 |
|> foldl1 combine_fn |
|
2297 | 77 |
end |
78 |
||
79 |
(* produces the term for an alpha with abstraction *) |
|
80 |
fun mk_alpha_term bmode fv alpha args args' binders binders' = |
|
81 |
let |
|
82 |
val (alpha_name, binder_ty) = |
|
83 |
case bmode of |
|
84 |
Lst => (@{const_name "alpha_lst"}, @{typ "atom list"}) |
|
85 |
| Set => (@{const_name "alpha_gen"}, @{typ "atom set"}) |
|
86 |
| Res => (@{const_name "alpha_res"}, @{typ "atom set"}) |
|
87 |
val ty = fastype_of args |
|
88 |
val pair_ty = HOLogic.mk_prodT (binder_ty, ty) |
|
89 |
val alpha_ty = [ty, ty] ---> @{typ "bool"} |
|
90 |
val fv_ty = ty --> @{typ "atom set"} |
|
91 |
val pair_lhs = HOLogic.mk_prod (binders, args) |
|
92 |
val pair_rhs = HOLogic.mk_prod (binders', args') |
|
93 |
in |
|
94 |
HOLogic.exists_const @{typ perm} $ Abs ("p", @{typ perm}, |
|
95 |
Const (alpha_name, [pair_ty, alpha_ty, fv_ty, @{typ "perm"}, pair_ty] ---> @{typ bool}) |
|
96 |
$ pair_lhs $ alpha $ fv $ (Bound 0) $ pair_rhs) |
|
97 |
end |
|
98 |
||
99 |
(* for non-recursive binders we have to produce alpha_bn premises *) |
|
100 |
fun mk_alpha_bn_prem alpha_bn_map args args' bodies binder = |
|
101 |
case binder of |
|
102 |
(NONE, _) => [] |
|
103 |
| (SOME bn, i) => |
|
104 |
if member (op=) bodies i then [] |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
105 |
else [lookup alpha_bn_map bn $ nth args i $ nth args' i] |
2297 | 106 |
|
107 |
(* generat the premises for an alpha rule; mk_frees is used |
|
108 |
if no binders are present *) |
|
109 |
fun mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args') bclause = |
|
110 |
let |
|
111 |
fun mk_frees i = |
|
112 |
let |
|
113 |
val arg = nth args i |
|
114 |
val arg' = nth args' i |
|
115 |
val ty = fastype_of arg |
|
116 |
in |
|
117 |
if nth is_rec i |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
118 |
then fst (lookup alpha_map ty) $ arg $ arg' |
2297 | 119 |
else HOLogic.mk_eq (arg, arg') |
120 |
end |
|
121 |
||
122 |
fun mk_alpha_fv i = |
|
123 |
let |
|
124 |
val ty = fastype_of (nth args i) |
|
125 |
in |
|
126 |
case AList.lookup (op=) alpha_map ty of |
|
127 |
NONE => (HOLogic.eq_const ty, supp_const ty) |
|
128 |
| SOME (alpha, fv) => (alpha, fv) |
|
129 |
end |
|
130 |
in |
|
131 |
case bclause of |
|
132 |
BC (_, [], bodies) => map (HOLogic.mk_Trueprop o mk_frees) bodies |
|
133 |
| BC (bmode, binders, bodies) => |
|
134 |
let |
|
135 |
val (alphas, fvs) = split_list (map mk_alpha_fv bodies) |
|
136 |
val comp_fv = foldl1 mk_prod_fv fvs |
|
137 |
val comp_alpha = foldl1 mk_prod_alpha alphas |
|
138 |
val comp_args = foldl1 HOLogic.mk_prod (map (nth args) bodies) |
|
139 |
val comp_args' = foldl1 HOLogic.mk_prod (map (nth args') bodies) |
|
140 |
val comp_binders = mk_binders lthy bmode args binders |
|
141 |
val comp_binders' = mk_binders lthy bmode args' binders |
|
142 |
val alpha_prem = |
|
143 |
mk_alpha_term bmode comp_fv comp_alpha comp_args comp_args' comp_binders comp_binders' |
|
144 |
val alpha_bn_prems = flat (map (mk_alpha_bn_prem alpha_bn_map args args' bodies) binders) |
|
145 |
in |
|
146 |
map HOLogic.mk_Trueprop (alpha_prem::alpha_bn_prems) |
|
147 |
end |
|
148 |
end |
|
149 |
||
150 |
(* produces the introduction rule for an alpha rule *) |
|
151 |
fun mk_alpha_intros lthy alpha_map alpha_bn_map (constr, ty, arg_tys, is_rec) bclauses = |
|
152 |
let |
|
153 |
val arg_names = Datatype_Prop.make_tnames arg_tys |
|
154 |
val arg_names' = Name.variant_list arg_names arg_names |
|
155 |
val args = map Free (arg_names ~~ arg_tys) |
|
156 |
val args' = map Free (arg_names' ~~ arg_tys) |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
157 |
val alpha = fst (lookup alpha_map ty) |
2297 | 158 |
val concl = HOLogic.mk_Trueprop (alpha $ list_comb (constr, args) $ list_comb (constr, args')) |
159 |
val prems = map (mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args')) bclauses |
|
160 |
in |
|
161 |
Library.foldr Logic.mk_implies (flat prems, concl) |
|
162 |
end |
|
163 |
||
164 |
(* produces the premise of an alpha-bn rule; we only need to |
|
165 |
treat the case special where the binding clause is empty; |
|
166 |
||
167 |
- if the body is not included in the bn_info, then we either |
|
168 |
produce an equation or an alpha-premise |
|
169 |
||
170 |
- if the body is included in the bn_info, then we create |
|
171 |
either a recursive call to alpha-bn, or no premise *) |
|
172 |
fun mk_alpha_bn lthy alpha_map alpha_bn_map bn_args is_rec (args, args') bclause = |
|
173 |
let |
|
174 |
fun mk_alpha_bn_prem alpha_map alpha_bn_map bn_args (args, args') i = |
|
175 |
let |
|
176 |
val arg = nth args i |
|
177 |
val arg' = nth args' i |
|
178 |
val ty = fastype_of arg |
|
179 |
in |
|
180 |
case AList.lookup (op=) bn_args i of |
|
181 |
NONE => (case (AList.lookup (op=) alpha_map ty) of |
|
182 |
NONE => [HOLogic.mk_eq (arg, arg')] |
|
183 |
| SOME (alpha, _) => [alpha $ arg $ arg']) |
|
184 |
| SOME (NONE) => [] |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
185 |
| SOME (SOME bn) => [lookup alpha_bn_map bn $ arg $ arg'] |
2297 | 186 |
end |
187 |
in |
|
188 |
case bclause of |
|
189 |
BC (_, [], bodies) => |
|
190 |
map HOLogic.mk_Trueprop |
|
191 |
(flat (map (mk_alpha_bn_prem alpha_map alpha_bn_map bn_args (args, args')) bodies)) |
|
192 |
| _ => mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args') bclause |
|
193 |
end |
|
194 |
||
195 |
fun mk_alpha_bn_intro lthy bn_trm alpha_map alpha_bn_map (bn_args, (constr, _, arg_tys, is_rec)) bclauses = |
|
196 |
let |
|
197 |
val arg_names = Datatype_Prop.make_tnames arg_tys |
|
198 |
val arg_names' = Name.variant_list arg_names arg_names |
|
199 |
val args = map Free (arg_names ~~ arg_tys) |
|
200 |
val args' = map Free (arg_names' ~~ arg_tys) |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
201 |
val alpha_bn = lookup alpha_bn_map bn_trm |
2297 | 202 |
val concl = HOLogic.mk_Trueprop (alpha_bn $ list_comb (constr, args) $ list_comb (constr, args')) |
203 |
val prems = map (mk_alpha_bn lthy alpha_map alpha_bn_map bn_args is_rec (args, args')) bclauses |
|
204 |
in |
|
205 |
Library.foldr Logic.mk_implies (flat prems, concl) |
|
206 |
end |
|
207 |
||
208 |
fun mk_alpha_bn_intros lthy alpha_map alpha_bn_map constrs_info bclausesss (bn_trm, bn_n, bn_argss) = |
|
209 |
let |
|
210 |
val nth_constrs_info = nth constrs_info bn_n |
|
211 |
val nth_bclausess = nth bclausesss bn_n |
|
212 |
in |
|
213 |
map2 (mk_alpha_bn_intro lthy bn_trm alpha_map alpha_bn_map) (bn_argss ~~ nth_constrs_info) nth_bclausess |
|
214 |
end |
|
215 |
||
216 |
fun define_raw_alpha descr sorts bn_info bclausesss fvs lthy = |
|
217 |
let |
|
218 |
val alpha_names = prefix_dt_names descr sorts "alpha_" |
|
219 |
val alpha_arg_tys = all_dtyps descr sorts |
|
220 |
val alpha_tys = map (fn ty => [ty, ty] ---> @{typ bool}) alpha_arg_tys |
|
221 |
val alpha_frees = map Free (alpha_names ~~ alpha_tys) |
|
222 |
val alpha_map = alpha_arg_tys ~~ (alpha_frees ~~ fvs) |
|
223 |
||
224 |
val (bns, bn_tys) = split_list (map (fn (bn, i, _) => (bn, i)) bn_info) |
|
225 |
val bn_names = map (fn bn => Long_Name.base_name (fst (dest_Const bn))) bns |
|
226 |
val alpha_bn_names = map (prefix "alpha_") bn_names |
|
227 |
val alpha_bn_arg_tys = map (fn i => nth_dtyp descr sorts i) bn_tys |
|
228 |
val alpha_bn_tys = map (fn ty => [ty, ty] ---> @{typ "bool"}) alpha_bn_arg_tys |
|
229 |
val alpha_bn_frees = map Free (alpha_bn_names ~~ alpha_bn_tys) |
|
230 |
val alpha_bn_map = bns ~~ alpha_bn_frees |
|
231 |
||
232 |
val constrs_info = all_dtyp_constrs_types descr sorts |
|
233 |
||
234 |
val alpha_intros = map2 (map2 (mk_alpha_intros lthy alpha_map alpha_bn_map)) constrs_info bclausesss |
|
235 |
val alpha_bn_intros = map (mk_alpha_bn_intros lthy alpha_map alpha_bn_map constrs_info bclausesss) bn_info |
|
236 |
||
2299 | 237 |
val all_alpha_names = map (fn (a, ty) => ((Binding.name a, ty), NoSyn)) |
238 |
(alpha_names @ alpha_bn_names ~~ alpha_tys @ alpha_bn_tys) |
|
2297 | 239 |
val all_alpha_intros = map (pair Attrib.empty_binding) (flat alpha_intros @ flat alpha_bn_intros) |
240 |
||
241 |
val (alphas, lthy') = Inductive.add_inductive_i |
|
242 |
{quiet_mode = true, verbose = false, alt_name = Binding.empty, |
|
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
243 |
coind = false, no_elim = false, no_ind = false, skip_mono = false, fork_mono = false} |
2297 | 244 |
all_alpha_names [] all_alpha_intros [] lthy |
245 |
||
2298 | 246 |
val all_alpha_trms_loc = #preds alphas; |
2297 | 247 |
val alpha_induct_loc = #raw_induct alphas; |
248 |
val alpha_intros_loc = #intrs alphas; |
|
249 |
val alpha_cases_loc = #elims alphas; |
|
250 |
val phi = ProofContext.export_morphism lthy' lthy; |
|
251 |
||
2298 | 252 |
val all_alpha_trms = map (Morphism.term phi) all_alpha_trms_loc; |
2297 | 253 |
val alpha_induct = Morphism.thm phi alpha_induct_loc; |
254 |
val alpha_intros = map (Morphism.thm phi) alpha_intros_loc |
|
255 |
val alpha_cases = map (Morphism.thm phi) alpha_cases_loc |
|
2298 | 256 |
|
257 |
val (alpha_trms, alpha_bn_trms) = chop (length fvs) all_alpha_trms |
|
2297 | 258 |
in |
2298 | 259 |
(alpha_trms, alpha_bn_trms, alpha_intros, alpha_cases, alpha_induct, lthy') |
2297 | 260 |
end |
261 |
||
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
262 |
|
2316 | 263 |
|
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
264 |
(** produces the distinctness theorems **) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
265 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
266 |
(* transforms the distinctness theorems of the constructors |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
267 |
to "not-alphas" of the constructors *) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
268 |
fun mk_alpha_distinct_goal alpha neq = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
269 |
let |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
270 |
val (lhs, rhs) = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
271 |
neq |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
272 |
|> HOLogic.dest_Trueprop |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
273 |
|> HOLogic.dest_not |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
274 |
|> HOLogic.dest_eq |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
275 |
in |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
276 |
alpha $ lhs $ rhs |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
277 |
|> HOLogic.mk_not |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
278 |
|> HOLogic.mk_Trueprop |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
279 |
end |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
280 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
281 |
fun distinct_tac cases distinct_thms = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
282 |
rtac notI THEN' eresolve_tac cases |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
283 |
THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps distinct_thms) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
284 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
285 |
fun mk_alpha_distinct ctxt cases_thms (distinct_thm, alpha) = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
286 |
let |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
287 |
val ((_, thms), ctxt') = Variable.import false distinct_thm ctxt |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
288 |
val goals = map (mk_alpha_distinct_goal alpha o prop_of) thms |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
289 |
val nrels = map (fn t => Goal.prove ctxt' [] [] t (K (distinct_tac cases_thms distinct_thm 1))) goals |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
290 |
in |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
291 |
Variable.export ctxt' ctxt nrels |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
292 |
end |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
293 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
294 |
fun mk_alpha_distincts ctxt alpha_cases constrs_distinct_thms alpha_trms alpha_bn_trms bn_infos = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
295 |
let |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
296 |
val alpha_distincts = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
297 |
map (mk_alpha_distinct ctxt alpha_cases) (constrs_distinct_thms ~~ alpha_trms) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
298 |
val distinc_thms = map |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
299 |
val alpha_bn_distincts_aux = map (fn (_, i, _) => nth constrs_distinct_thms i) bn_infos |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
300 |
val alpha_bn_distincts = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
301 |
map (mk_alpha_distinct ctxt alpha_cases) (alpha_bn_distincts_aux ~~ alpha_bn_trms) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
302 |
in |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
303 |
(flat alpha_distincts, flat alpha_bn_distincts) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
304 |
end |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
305 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
306 |
|
2316 | 307 |
|
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
308 |
(** produces the alpha_eq_iff simplification rules **) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
309 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
310 |
(* in case a theorem is of the form (C.. = C..), it will be |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
311 |
rewritten to ((C.. = C..) = True) *) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
312 |
fun mk_simp_rule thm = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
313 |
case (prop_of thm) of |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
314 |
@{term "Trueprop"} $ (Const (@{const_name "op ="}, _) $ _ $ _) => @{thm eqTrueI} OF [thm] |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
315 |
| _ => thm |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
316 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
317 |
fun alpha_eq_iff_tac dist_inj intros elims = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
318 |
SOLVED' (asm_full_simp_tac (HOL_ss addsimps intros)) ORELSE' |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
319 |
(rtac @{thm iffI} THEN' |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
320 |
RANGE [eresolve_tac elims THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps dist_inj), |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
321 |
asm_full_simp_tac (HOL_ss addsimps intros)]) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
322 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
323 |
fun mk_alpha_eq_iff_goal thm = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
324 |
let |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
325 |
val prop = prop_of thm; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
326 |
val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop); |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
327 |
val hyps = map HOLogic.dest_Trueprop (Logic.strip_imp_prems prop); |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
328 |
fun list_conj l = foldr1 HOLogic.mk_conj l; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
329 |
in |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
330 |
if hyps = [] then HOLogic.mk_Trueprop concl |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
331 |
else HOLogic.mk_Trueprop (HOLogic.mk_eq (concl, list_conj hyps)) |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
332 |
end; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
333 |
|
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
334 |
fun mk_alpha_eq_iff ctxt alpha_intros distinct_thms inject_thms alpha_elims = |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
335 |
let |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
336 |
val ((_, thms_imp), ctxt') = Variable.import false alpha_intros ctxt; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
337 |
val goals = map mk_alpha_eq_iff_goal thms_imp; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
338 |
val tac = alpha_eq_iff_tac (distinct_thms @ inject_thms) alpha_intros alpha_elims 1; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
339 |
val thms = map (fn goal => Goal.prove ctxt' [] [] goal (K tac)) goals; |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
340 |
in |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
341 |
Variable.export ctxt' ctxt thms |
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
342 |
|> `(map mk_simp_rule) |
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
343 |
end |
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
344 |
|
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
345 |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
346 |
(** proof by induction over the alpha-definitions **) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
347 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
348 |
fun is_true @{term "Trueprop True"} = true |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
349 |
| is_true _ = false |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
350 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
351 |
fun alpha_prove alphas props alpha_induct_thm cases_tac ctxt = |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
352 |
let |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
353 |
val arg_tys = map (domain_type o fastype_of) alphas |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
354 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
355 |
val ((arg_names1, arg_names2), ctxt') = |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
356 |
ctxt |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
357 |
|> Variable.variant_fixes (replicate (length alphas) "x") |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
358 |
||>> Variable.variant_fixes (replicate (length alphas) "y") |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
359 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
360 |
val args1 = map2 (curry Free) arg_names1 arg_tys |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
361 |
val args2 = map2 (curry Free) arg_names2 arg_tys |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
362 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
363 |
val true_trms = replicate (length alphas) (K @{term True}) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
364 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
365 |
fun apply_all x fs = map (fn f => f x) fs |
2391 | 366 |
val goals_rhs = |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
367 |
group (props @ (alphas ~~ true_trms)) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
368 |
|> map snd |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
369 |
|> map2 apply_all (args1 ~~ args2) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
370 |
|> map fold_conj |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
371 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
372 |
fun apply_trm_pair t (ar1, ar2) = t $ ar1 $ ar2 |
2391 | 373 |
val goals_lhs = map2 apply_trm_pair alphas (args1 ~~ args2) |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
374 |
|
2391 | 375 |
val goals = |
376 |
(map2 (curry HOLogic.mk_imp) goals_lhs goals_rhs) |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
377 |
|> foldr1 HOLogic.mk_conj |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
378 |
|> HOLogic.mk_Trueprop |
2391 | 379 |
|
380 |
fun tac ctxt = |
|
381 |
HEADGOAL |
|
382 |
(DETERM o (rtac alpha_induct_thm) |
|
383 |
THEN_ALL_NEW FIRST' [rtac @{thm TrueI}, cases_tac ctxt]) |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
384 |
in |
2391 | 385 |
Goal.prove ctxt' [] [] goals (fn {context, ...} => tac context) |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
386 |
|> singleton (ProofContext.export ctxt' ctxt) |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
387 |
|> Datatype_Aux.split_conj_thm |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
388 |
|> map (fn th => th RS mp) |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
389 |
|> map Datatype_Aux.split_conj_thm |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
390 |
|> flat |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
391 |
|> map zero_var_indexes |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
392 |
|> filter_out (is_true o concl_of) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
393 |
end |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
394 |
|
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
395 |
|
2316 | 396 |
(** reflexivity proof for the alphas **) |
397 |
||
398 |
val exi_zero = @{lemma "P (0::perm) ==> (? x. P x)" by auto} |
|
399 |
||
400 |
fun cases_tac intros = |
|
401 |
let |
|
402 |
val prod_simps = @{thms split_conv prod_alpha_def prod_rel.simps} |
|
403 |
||
404 |
val unbound_tac = REPEAT o (etac @{thm conjE}) THEN' atac |
|
405 |
||
406 |
val bound_tac = |
|
407 |
EVERY' [ rtac exi_zero, |
|
2385
fe25a3ffeb14
cleaned up a bit Abs.thy
Christian Urban <urbanc@in.tum.de>
parents:
2375
diff
changeset
|
408 |
resolve_tac @{thms alpha_refl}, |
2316 | 409 |
asm_full_simp_tac (HOL_ss addsimps prod_simps) ] |
410 |
in |
|
411 |
REPEAT o FIRST' [rtac @{thm conjI}, |
|
412 |
resolve_tac intros THEN_ALL_NEW FIRST' [rtac @{thm refl}, unbound_tac, bound_tac]] |
|
413 |
end |
|
414 |
||
415 |
fun raw_prove_refl alpha_trms alpha_bns alpha_intros raw_dt_induct ctxt = |
|
416 |
let |
|
417 |
val arg_tys = |
|
418 |
alpha_trms |
|
419 |
|> map fastype_of |
|
420 |
|> map domain_type |
|
421 |
val arg_bn_tys = |
|
422 |
alpha_bns |
|
423 |
|> map fastype_of |
|
424 |
|> map domain_type |
|
425 |
val arg_names = Datatype_Prop.make_tnames arg_tys |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
426 |
val arg_bn_names = map (lookup (arg_tys ~~ arg_names)) arg_bn_tys |
2316 | 427 |
val args = map Free (arg_names ~~ arg_tys) |
428 |
val arg_bns = map Free (arg_bn_names ~~ arg_bn_tys) |
|
429 |
val goal = |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
430 |
group ((arg_bns ~~ alpha_bns) @ (args ~~ alpha_trms)) |
2316 | 431 |
|> map (fn (ar, cnsts) => map (fn c => c $ ar $ ar) cnsts) |
432 |
|> map (foldr1 HOLogic.mk_conj) |
|
433 |
|> foldr1 HOLogic.mk_conj |
|
434 |
|> HOLogic.mk_Trueprop |
|
435 |
in |
|
436 |
Goal.prove ctxt arg_names [] goal |
|
437 |
(fn {context, ...} => |
|
438 |
HEADGOAL (DETERM o (rtac raw_dt_induct) THEN_ALL_NEW cases_tac alpha_intros)) |
|
439 |
|> Datatype_Aux.split_conj_thm |
|
440 |
|> map Datatype_Aux.split_conj_thm |
|
441 |
|> flat |
|
442 |
end |
|
443 |
||
444 |
||
445 |
||
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
446 |
(** symmetry proof for the alphas **) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
447 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
448 |
val exi_neg = @{lemma "(EX (p::perm). P p) ==> (!!q. P q ==> Q (- q)) ==> EX p. Q p" |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
449 |
by (erule exE, rule_tac x="-p" in exI, auto)} |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
450 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
451 |
(* for premises that contain binders *) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
452 |
fun prem_bound_tac pred_names ctxt = |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
453 |
let |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
454 |
fun trans_prem_tac pred_names ctxt = |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
455 |
SUBPROOF (fn {prems, context, ...} => |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
456 |
let |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
457 |
val prems' = map (transform_prem1 context pred_names) prems |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
458 |
in |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
459 |
resolve_tac prems' 1 |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
460 |
end) ctxt |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
461 |
val prod_simps = @{thms split_conv permute_prod.simps prod_alpha_def prod_rel.simps alphas} |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
462 |
in |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
463 |
EVERY' |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
464 |
[ etac exi_neg, |
2385
fe25a3ffeb14
cleaned up a bit Abs.thy
Christian Urban <urbanc@in.tum.de>
parents:
2375
diff
changeset
|
465 |
resolve_tac @{thms alpha_sym_eqvt}, |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
466 |
asm_full_simp_tac (HOL_ss addsimps prod_simps), |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
467 |
Nominal_Permeq.eqvt_tac ctxt [] [] THEN' rtac @{thm refl}, |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
468 |
trans_prem_tac pred_names ctxt ] |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
469 |
end |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
470 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
471 |
fun raw_prove_sym alpha_trms alpha_intros alpha_induct ctxt = |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
472 |
let |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
473 |
val props = map (fn t => fn (x, y) => t $ y $ x) alpha_trms |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
474 |
|
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
475 |
fun tac ctxt = |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
476 |
let |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
477 |
val alpha_names = map (fst o dest_Const) alpha_trms |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
478 |
in |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
479 |
resolve_tac alpha_intros THEN_ALL_NEW |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
480 |
FIRST' [atac, rtac @{thm sym} THEN' atac, prem_bound_tac alpha_names ctxt] |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
481 |
end |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
482 |
in |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
483 |
alpha_prove alpha_trms (alpha_trms ~~ props) alpha_induct tac ctxt |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
484 |
end |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
485 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
486 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
487 |
(** transitivity proof for alphas **) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
488 |
|
2314 | 489 |
(* applies cases rules and resolves them with the last premise *) |
2313
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
490 |
fun ecases_tac cases = |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
491 |
Subgoal.FOCUS (fn {prems, ...} => |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
492 |
HEADGOAL (resolve_tac cases THEN' rtac (List.last prems))) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
493 |
|
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
494 |
fun aatac pred_names = |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
495 |
SUBPROOF (fn {prems, context, ...} => |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
496 |
HEADGOAL (resolve_tac (map (transform_prem1 context pred_names) prems))) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
497 |
|
2314 | 498 |
(* instantiates exI with the permutation p + q *) |
2313
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
499 |
val perm_inst_tac = |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
500 |
Subgoal.FOCUS (fn {params, ...} => |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
501 |
let |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
502 |
val (p, q) = pairself snd (last2 params) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
503 |
val pq_inst = foldl1 (uncurry Thm.capply) [@{cterm "plus::perm => perm => perm"}, p, q] |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
504 |
val exi_inst = Drule.instantiate' [SOME (@{ctyp "perm"})] [NONE, SOME pq_inst] @{thm exI} |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
505 |
in |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
506 |
HEADGOAL (rtac exi_inst) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
507 |
end) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
508 |
|
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
509 |
fun non_trivial_cases_tac pred_names intros ctxt = |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
510 |
let |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
511 |
val prod_simps = @{thms split_conv alphas permute_prod.simps prod_alpha_def prod_rel.simps} |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
512 |
in |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
513 |
resolve_tac intros |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
514 |
THEN_ALL_NEW (asm_simp_tac HOL_basic_ss THEN' |
2314 | 515 |
TRY o EVERY' (* if binders are present *) |
2313
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
516 |
[ etac @{thm exE}, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
517 |
etac @{thm exE}, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
518 |
perm_inst_tac ctxt, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
519 |
resolve_tac @{thms alpha_trans_eqvt}, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
520 |
atac, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
521 |
aatac pred_names ctxt, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
522 |
Nominal_Permeq.eqvt_tac ctxt [] [] THEN' rtac @{thm refl}, |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
523 |
asm_full_simp_tac (HOL_ss addsimps prod_simps) ]) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
524 |
end |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
525 |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
526 |
fun prove_trans_tac pred_names raw_dt_thms intros cases ctxt = |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
527 |
let |
2313
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
528 |
fun all_cases ctxt = |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
529 |
asm_full_simp_tac (HOL_basic_ss addsimps raw_dt_thms) |
25d2cdf7d7e4
transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents:
2311
diff
changeset
|
530 |
THEN' TRY o non_trivial_cases_tac pred_names intros ctxt |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
531 |
in |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
532 |
EVERY' [ rtac @{thm allI}, rtac @{thm impI}, |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
533 |
ecases_tac cases ctxt THEN_ALL_NEW all_cases ctxt ] |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
534 |
end |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
535 |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
536 |
fun prep_trans_goal alpha_trm (arg1, arg2) = |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
537 |
let |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
538 |
val arg_ty = fastype_of arg1 |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
539 |
val mid = alpha_trm $ arg2 $ (Bound 0) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
540 |
val rhs = alpha_trm $ arg1 $ (Bound 0) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
541 |
in |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
542 |
HOLogic.all_const arg_ty $ Abs ("z", arg_ty, HOLogic.mk_imp (mid, rhs)) |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
543 |
end |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
544 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
545 |
fun raw_prove_trans alpha_trms raw_dt_thms alpha_intros alpha_induct alpha_cases ctxt = |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
546 |
let |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
547 |
val alpha_names = map (fst o dest_Const) alpha_trms |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
548 |
val props = map prep_trans_goal alpha_trms |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
549 |
val norm = @{lemma "A ==> (!x. B x --> C x) ==> (!!x. [|A; B x|] ==> C x)" by simp} |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
550 |
in |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
551 |
alpha_prove alpha_trms (alpha_trms ~~ props) alpha_induct |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
552 |
(prove_trans_tac alpha_names raw_dt_thms alpha_intros alpha_cases) ctxt |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
553 |
end |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2300
diff
changeset
|
554 |
|
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
555 |
|
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
556 |
(** proves the equivp predicate for all alphas **) |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
557 |
|
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
558 |
val equivp_intro = |
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2387
diff
changeset
|
559 |
@{lemma "[|!x. R x x; !x y. R x y --> R y x; !x y. R x y --> (!z. R y z --> R x z)|] ==> equivp R" |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
560 |
by (rule equivpI, unfold reflp_def symp_def transp_def, blast+)} |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
561 |
|
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
562 |
fun raw_prove_equivp alphas refl symm trans ctxt = |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
563 |
let |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
564 |
val atomize = Conv.fconv_rule Object_Logic.atomize o forall_intr_vars |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
565 |
val refl' = map atomize refl |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
566 |
val symm' = map atomize symm |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
567 |
val trans' = map atomize trans |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
568 |
fun prep_goal t = |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
569 |
HOLogic.mk_Trueprop (Const (@{const_name "equivp"}, fastype_of t --> @{typ bool}) $ t) |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
570 |
in |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
571 |
Goal.prove_multi ctxt [] [] (map prep_goal alphas) |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
572 |
(K (HEADGOAL (Goal.conjunction_tac THEN_ALL_NEW (rtac equivp_intro THEN' |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
573 |
RANGE [resolve_tac refl', resolve_tac symm', resolve_tac trans'])))) |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
574 |
end |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
575 |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
576 |
|
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
577 |
(* proves that alpha_raw implies alpha_bn *) |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
578 |
|
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
579 |
fun raw_prove_bn_imp_tac pred_names alpha_intros ctxt = |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
580 |
SUBPROOF (fn {prems, context, ...} => |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
581 |
let |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
582 |
val prems' = flat (map Datatype_Aux.split_conj_thm prems) |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
583 |
val prems'' = map (transform_prem1 context pred_names) prems' |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
584 |
in |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
585 |
HEADGOAL |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
586 |
(REPEAT_ALL_NEW |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
587 |
(FIRST' [ rtac @{thm TrueI}, |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
588 |
rtac @{thm conjI}, |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
589 |
resolve_tac prems', |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
590 |
resolve_tac prems'', |
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2320
diff
changeset
|
591 |
resolve_tac alpha_intros ])) |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
592 |
end) ctxt |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
593 |
|
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
594 |
fun raw_prove_bn_imp alpha_trms alpha_bn_trms alpha_intros alpha_induct ctxt = |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
595 |
let |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
596 |
val arg_ty = domain_type o fastype_of |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
597 |
val alpha_names = map (fst o dest_Const) alpha_trms |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
598 |
val ty_assoc = map (fn t => (arg_ty t, t)) alpha_trms |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
599 |
val props = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => t $ x $ y)) alpha_bn_trms |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
600 |
in |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
601 |
alpha_prove (alpha_trms @ alpha_bn_trms) props alpha_induct |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
602 |
(raw_prove_bn_imp_tac alpha_names alpha_intros) ctxt |
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
603 |
end |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
604 |
|
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
605 |
|
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
606 |
(* helper lemmas for respectfulness for fv_raw / bn_raw *) |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
607 |
|
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
608 |
fun raw_fv_bn_rsp_aux alpha_trms alpha_bn_trms fvs bns fv_bns alpha_induct simps ctxt = |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
609 |
let |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
610 |
val arg_ty = domain_type o fastype_of |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
611 |
val ty_assoc = map (fn t => (arg_ty t, t)) alpha_trms |
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
612 |
|
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
613 |
val prop1 = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => HOLogic.mk_eq (t $ x, t $ y))) fvs |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
614 |
val prop2 = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => HOLogic.mk_eq (t $ x, t $ y))) bns |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
615 |
val prop3 = map2 (fn t1 => fn t2 => (t1, fn (x, y) => HOLogic.mk_eq (t2 $ x, t2 $ y))) alpha_bn_trms fv_bns |
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
616 |
|
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
617 |
val ss = HOL_ss addsimps (simps @ @{thms alphas prod_fv.simps set.simps append.simps} |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
618 |
@ @{thms Un_assoc Un_insert_left Un_empty_right Un_empty_left}) |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
619 |
in |
2390
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
620 |
alpha_prove (alpha_trms @ alpha_bn_trms) (prop1 @ prop2 @ prop3) alpha_induct |
920366e646b0
further simplification with alpha_prove
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
621 |
(K (asm_full_simp_tac ss)) ctxt |
2387
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
622 |
end |
082d9fd28f89
helper lemmas for rsp-lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2385
diff
changeset
|
623 |
|
2297 | 624 |
end (* structure *) |
625 |