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