1274
|
1 |
theory Lift
|
1774
|
2 |
imports "../Nominal-General/Nominal2_Atoms"
|
|
3 |
"../Nominal-General/Nominal2_Eqvt"
|
1837
|
4 |
"../Nominal-General/Nominal2_Supp"
|
1830
|
5 |
"Abs" "Perm" "Equivp" "Rsp"
|
1274
|
6 |
begin
|
|
7 |
|
1681
|
8 |
|
1316
0577afdb1732
Porting from Lift to Parser; until defining the Quotient type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
9 |
ML {*
|
1681
|
10 |
fun define_quotient_types binds tys alphas equivps ctxt =
|
1656
|
11 |
let
|
1681
|
12 |
fun def_ty ((b, ty), (alpha, equivp)) ctxt =
|
|
13 |
Quotient_Type.add_quotient_type ((([], b, NoSyn), (ty, alpha)), equivp) ctxt;
|
|
14 |
val alpha_equivps = List.take (equivps, length alphas)
|
|
15 |
val (thms, ctxt') = fold_map def_ty ((binds ~~ tys) ~~ (alphas ~~ alpha_equivps)) ctxt;
|
|
16 |
val quot_thms = map fst thms;
|
|
17 |
val quots = map (HOLogic.dest_Trueprop o prop_of) quot_thms;
|
|
18 |
val reps = map (hd o rev o snd o strip_comb) quots;
|
|
19 |
val qtys = map (domain_type o fastype_of) reps;
|
1656
|
20 |
in
|
1681
|
21 |
(qtys, ctxt')
|
1656
|
22 |
end
|
|
23 |
*}
|
|
24 |
|
|
25 |
(* Renames schematic variables in a theorem *)
|
|
26 |
ML {*
|
1498
|
27 |
fun rename_vars fnctn thm =
|
|
28 |
let
|
|
29 |
val vars = Term.add_vars (prop_of thm) []
|
|
30 |
val nvars = map (Var o ((apfst o apfst) fnctn)) vars
|
|
31 |
in
|
|
32 |
Thm.certify_instantiate ([], (vars ~~ nvars)) thm
|
|
33 |
end
|
|
34 |
*}
|
|
35 |
|
|
36 |
ML {*
|
|
37 |
fun un_raws name =
|
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
38 |
let
|
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
39 |
fun un_raw name = unprefix "_raw" name handle Fail _ => name
|
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
40 |
fun add_under names = hd names :: (map (prefix "_") (tl names))
|
1498
|
41 |
in
|
|
42 |
implode (map un_raw (add_under (space_explode "_" name)))
|
|
43 |
end
|
|
44 |
*}
|
|
45 |
|
|
46 |
(* Similar to Tools/IsaPlanner/rw_tools.ML *)
|
|
47 |
ML {*
|
|
48 |
fun rename_term_bvars (Abs(s, ty, t)) = (Abs(un_raws s, ty, rename_term_bvars t))
|
|
49 |
| rename_term_bvars (a $ b) = (rename_term_bvars a) $ (rename_term_bvars b)
|
|
50 |
| rename_term_bvars x = x;
|
|
51 |
|
|
52 |
fun rename_thm_bvars th =
|
|
53 |
let
|
|
54 |
val t = Thm.prop_of th
|
|
55 |
in
|
|
56 |
Thm.rename_boundvars t (rename_term_bvars t) th
|
|
57 |
end;
|
|
58 |
*}
|
|
59 |
|
|
60 |
ML {*
|
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
61 |
fun lift_thm qtys ctxt thm =
|
1498
|
62 |
let
|
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
63 |
val un_raw_names = rename_vars un_raws
|
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
64 |
in
|
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
65 |
rename_thm_bvars (un_raw_names (Quotient_Tacs.lifted qtys ctxt thm))
|
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
66 |
end
|
1276
3365fce80f0f
To call quotient it is enough to export the alpha frees to proper constants and their respective equivp theorems.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
67 |
*}
|
1274
|
68 |
|
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
69 |
ML {*
|
1497
|
70 |
fun define_fv_alpha_export dt binds bns ctxt =
|
|
71 |
let
|
1838
|
72 |
val (((fv_ts_loc, fv_def_loc), ord_fv_ts_loc), ctxt') =
|
|
73 |
define_fv dt binds bns ctxt;
|
|
74 |
val (alpha, ctxt'') =
|
1843
|
75 |
define_alpha dt binds bns fv_ts_loc ctxt';
|
1497
|
76 |
val alpha_ts_loc = #preds alpha
|
|
77 |
val alpha_induct_loc = #induct alpha
|
|
78 |
val alpha_intros_loc = #intrs alpha;
|
|
79 |
val alpha_cases_loc = #elims alpha
|
1838
|
80 |
val morphism = ProofContext.export_morphism ctxt'' ctxt;
|
1497
|
81 |
val fv_ts = map (Morphism.term morphism) fv_ts_loc;
|
1553
4355eb3b7161
Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
82 |
val ord_fv_ts = map (Morphism.term morphism) ord_fv_ts_loc;
|
1497
|
83 |
val fv_def = Morphism.fact morphism fv_def_loc;
|
|
84 |
val alpha_ts = map (Morphism.term morphism) alpha_ts_loc;
|
|
85 |
val alpha_induct = Morphism.thm morphism alpha_induct_loc;
|
|
86 |
val alpha_intros = Morphism.fact morphism alpha_intros_loc
|
|
87 |
val alpha_cases = Morphism.fact morphism alpha_cases_loc
|
|
88 |
in
|
1838
|
89 |
((((fv_ts, ord_fv_ts), fv_def), ((alpha_ts, alpha_intros), (alpha_cases, alpha_induct))), ctxt'')
|
1497
|
90 |
end;
|
|
91 |
*}
|
|
92 |
|
1280
|
93 |
end
|
1274
|
94 |
|