author | Christian Urban <urbanc@in.tum.de> |
Mon, 17 May 2010 12:46:51 +0100 | |
changeset 2144 | e900526e95c4 |
parent 2015 | 3e7969262809 |
child 2296 | 45a69c9cc4cc |
child 2325 | 29532d69111c |
permissions | -rw-r--r-- |
1274
d867021d8ac1
Preparing the generalized lifting procedure
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory Lift |
2015
3e7969262809
Move old fv_alpha_export to Fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2008
diff
changeset
|
2 |
imports "../Nominal-General/Nominal2_Atoms" |
3e7969262809
Move old fv_alpha_export to Fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2008
diff
changeset
|
3 |
"../Nominal-General/Nominal2_Eqvt" |
3e7969262809
Move old fv_alpha_export to Fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2008
diff
changeset
|
4 |
"../Nominal-General/Nominal2_Supp" |
3e7969262809
Move old fv_alpha_export to Fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2008
diff
changeset
|
5 |
"Abs" "Perm" "Equivp" "Rsp" |
1274
d867021d8ac1
Preparing the generalized lifting procedure
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
begin |
d867021d8ac1
Preparing the generalized lifting procedure
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
|
1681
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
8 |
|
1316
0577afdb1732
Porting from Lift to Parser; until defining the Quotient type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1309
diff
changeset
|
9 |
ML {* |
1681
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
10 |
fun define_quotient_types binds tys alphas equivps ctxt = |
1656
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
11 |
let |
1681
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
12 |
fun def_ty ((b, ty), (alpha, equivp)) ctxt = |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
13 |
Quotient_Type.add_quotient_type ((([], b, NoSyn), (ty, alpha)), equivp) ctxt; |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
14 |
val alpha_equivps = List.take (equivps, length alphas) |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
15 |
val (thms, ctxt') = fold_map def_ty ((binds ~~ tys) ~~ (alphas ~~ alpha_equivps)) ctxt; |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
16 |
val quot_thms = map fst thms; |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
17 |
val quots = map (HOLogic.dest_Trueprop o prop_of) quot_thms; |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
18 |
val reps = map (hd o rev o snd o strip_comb) quots; |
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
19 |
val qtys = map (domain_type o fastype_of) reps; |
1656
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
20 |
in |
1681
b8a07a3c1692
Get lifted types information from the quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1656
diff
changeset
|
21 |
(qtys, ctxt') |
1656
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
22 |
end |
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
23 |
*} |
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
24 |
|
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
25 |
(* Renames schematic variables in a theorem *) |
c9d3dda79fe3
Removed remaining cheats + some cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1553
diff
changeset
|
26 |
ML {* |
1498
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
27 |
fun rename_vars fnctn thm = |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
28 |
let |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
29 |
val vars = Term.add_vars (prop_of thm) [] |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
30 |
val nvars = map (Var o ((apfst o apfst) fnctn)) vars |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
31 |
in |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
32 |
Thm.certify_instantiate ([], (vars ~~ nvars)) thm |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
33 |
end |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
34 |
*} |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
35 |
|
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
36 |
ML {* |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
37 |
fun un_raws name = |
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1342
diff
changeset
|
38 |
let |
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1342
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>
parents:
1342
diff
changeset
|
40 |
fun add_under names = hd names :: (map (prefix "_") (tl names)) |
1498
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
41 |
in |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
42 |
implode (map un_raw (add_under (space_explode "_" name))) |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
43 |
end |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
44 |
*} |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
45 |
|
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
46 |
(* Similar to Tools/IsaPlanner/rw_tools.ML *) |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
47 |
ML {* |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
48 |
fun rename_term_bvars (Abs(s, ty, t)) = (Abs(un_raws s, ty, rename_term_bvars t)) |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
49 |
| rename_term_bvars (a $ b) = (rename_term_bvars a) $ (rename_term_bvars b) |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
50 |
| rename_term_bvars x = x; |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
51 |
|
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
52 |
fun rename_thm_bvars th = |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
53 |
let |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
54 |
val t = Thm.prop_of th |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
55 |
in |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
56 |
Thm.rename_boundvars t (rename_term_bvars t) th |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
57 |
end; |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
58 |
*} |
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
59 |
|
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
60 |
ML {* |
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1681
diff
changeset
|
61 |
fun lift_thm qtys ctxt thm = |
1498
2ff84b1f551f
Rename bound variables + minor cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1497
diff
changeset
|
62 |
let |
1494
923413256cbb
Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1342
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>
parents:
1342
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>
parents:
1681
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>
parents:
1342
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>
parents:
1274
diff
changeset
|
67 |
*} |
1274
d867021d8ac1
Preparing the generalized lifting procedure
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
68 |
|
1280
1f057f8da8aa
Progress with general lifting procedure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1277
diff
changeset
|
69 |
end |
1274
d867021d8ac1
Preparing the generalized lifting procedure
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
70 |