author | Christian Urban <urbanc@in.tum.de> |
Mon, 19 Apr 2010 16:55:36 +0200 | |
changeset 1896 | 996d4411e95e |
parent 1871 | c704d129862b |
child 1899 | 8e0bfb14f6bf |
permissions | -rw-r--r-- |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory Perm |
1774
c34347ec7ab3
separated general nominal theory into separate folder
Christian Urban <urbanc@in.tum.de>
parents:
1683
diff
changeset
|
2 |
imports "../Nominal-General/Nominal2_Atoms" |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
5 |
ML {* |
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
6 |
fun quotient_lift_consts_export qtys spec ctxt = |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
7 |
let |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
8 |
val (result, ctxt') = fold_map (Quotient_Def.quotient_lift_const qtys) spec ctxt; |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
9 |
val (ts_loc, defs_loc) = split_list result; |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
10 |
val morphism = ProofContext.export_morphism ctxt' ctxt; |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
11 |
val ts = map (Morphism.term morphism) ts_loc |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
12 |
val defs = Morphism.fact morphism defs_loc |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
13 |
in |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
14 |
(ts, defs, ctxt') |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
15 |
end |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
16 |
*} |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
17 |
|
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
18 |
ML {* |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
19 |
fun prove_perm_empty lthy induct perm_def perm_frees = |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
20 |
let |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
21 |
val perm_types = map fastype_of perm_frees; |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
22 |
val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); |
1256
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
23 |
fun glc ((perm, T), x) = |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
24 |
HOLogic.mk_eq (perm $ @{term "0::perm"} $ Free (x, T), Free (x, T)) |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
25 |
val gl = |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
26 |
HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
1256
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
27 |
(map glc (perm_frees ~~ map body_type perm_types ~~ perm_indnames))); |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
28 |
fun tac _ = |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
29 |
EVERY [ |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
30 |
Datatype_Aux.indtac induct perm_indnames 1, |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
31 |
ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_zero} :: perm_def))) |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
32 |
]; |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
33 |
in |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
34 |
Datatype_Aux.split_conj_thm (Goal.prove lthy perm_indnames [] gl tac) |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
35 |
end; |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
36 |
*} |
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
37 |
|
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
38 |
ML {* |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
39 |
fun prove_perm_append lthy induct perm_def perm_frees = |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
40 |
let |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
41 |
val pi1 = Free ("pi1", @{typ perm}); |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
42 |
val pi2 = Free ("pi2", @{typ perm}); |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
43 |
val perm_types = map fastype_of perm_frees |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
44 |
val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); |
1256
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
45 |
fun glc ((perm, T), x) = |
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
46 |
HOLogic.mk_eq ( |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
47 |
perm $ (mk_plus pi1 pi2) $ Free (x, T), |
1256
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
48 |
perm $ pi1 $ (perm $ pi2 $ Free (x, T))) |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
49 |
val goal = |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
50 |
(HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
1256
6c938f84880c
Restructuring the code in Perm
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1253
diff
changeset
|
51 |
(map glc (perm_frees ~~ map body_type perm_types ~~ perm_indnames)))) |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
52 |
fun tac _ = |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
53 |
EVERY [ |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
54 |
Datatype_Aux.indtac induct perm_indnames 1, |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
55 |
ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_plus} :: perm_def))) |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
56 |
] |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
57 |
in |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
58 |
Datatype_Aux.split_conj_thm (Goal.prove lthy ("pi1" :: "pi2" :: perm_indnames) [] goal tac) |
1248
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
59 |
end; |
705afaaf6fb4
More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1247
diff
changeset
|
60 |
*} |
1247
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
61 |
|
a728e199851d
Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1189
diff
changeset
|
62 |
ML {* |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
63 |
fun define_raw_perms (dt_info : Datatype_Aux.info) number thy = |
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
64 |
let |
1277
6eacf60ce41d
Permutation and FV_Alpha interface change.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1259
diff
changeset
|
65 |
val {descr, induct, sorts, ...} = dt_info; |
6eacf60ce41d
Permutation and FV_Alpha interface change.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1259
diff
changeset
|
66 |
val all_full_tnames = map (fn (_, (n, _, _)) => n) descr; |
6eacf60ce41d
Permutation and FV_Alpha interface change.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1259
diff
changeset
|
67 |
val full_tnames = List.take (all_full_tnames, number); |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
68 |
fun nth_dtyp i = Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec i); |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
69 |
val perm_names' = Datatype_Prop.indexify_names (map (fn (i, _) => |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
70 |
"permute_" ^ Datatype_Aux.name_of_typ (nth_dtyp i)) descr); |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
val perm_types = map (fn (i, _) => |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
let val T = nth_dtyp i |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
73 |
in @{typ perm} --> T --> T end) descr; |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
74 |
val perm_names_types' = perm_names' ~~ perm_types; |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
75 |
val pi = Free ("pi", @{typ perm}); |
1164 | 76 |
fun perm_eq_constr i (cname, dts) = |
77 |
let |
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
78 |
val Ts = map (Datatype_Aux.typ_of_dtyp descr sorts) dts; |
1164 | 79 |
val names = Name.variant_list ["pi"] (Datatype_Prop.make_tnames Ts); |
80 |
val args = map Free (names ~~ Ts); |
|
81 |
val c = Const (cname, Ts ---> (nth_dtyp i)); |
|
82 |
fun perm_arg (dt, x) = |
|
83 |
let val T = type_of x |
|
84 |
in |
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
85 |
if Datatype_Aux.is_rec_type dt then |
1164 | 86 |
let val (Us, _) = strip_type T |
87 |
in list_abs (map (pair "x") Us, |
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
88 |
Free (nth perm_names_types' (Datatype_Aux.body_index dt)) $ pi $ |
1164 | 89 |
list_comb (x, map (fn (i, U) => |
1871
c704d129862b
moved some general function into nominal_library.ML
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
90 |
(mk_perm_ty U (mk_minus pi) (Bound i))) |
1164 | 91 |
((length Us - 1 downto 0) ~~ Us))) |
92 |
end |
|
1871
c704d129862b
moved some general function into nominal_library.ML
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
93 |
else (mk_perm_ty T pi x) |
1164 | 94 |
end; |
95 |
in |
|
96 |
(Attrib.empty_binding, HOLogic.mk_Trueprop (HOLogic.mk_eq |
|
97 |
(Free (nth perm_names_types' i) $ |
|
98 |
Free ("pi", @{typ perm}) $ list_comb (c, args), |
|
99 |
list_comb (c, map perm_arg (dts ~~ args))))) |
|
100 |
end; |
|
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
101 |
fun perm_eq (i, (_, _, constrs)) = map (perm_eq_constr i) constrs; |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
102 |
val perm_eqs = maps perm_eq descr; |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
103 |
val lthy = |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
104 |
Theory_Target.instantiation (full_tnames, [], @{sort pt}) thy; |
1257 | 105 |
val ((perm_frees, perm_ldef), lthy') = |
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
106 |
Primrec.add_primrec |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
107 |
(map (fn s => (Binding.name s, NONE, NoSyn)) perm_names') perm_eqs lthy; |
1277
6eacf60ce41d
Permutation and FV_Alpha interface change.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1259
diff
changeset
|
108 |
val perm_empty_thms = List.take (prove_perm_empty lthy' induct perm_ldef perm_frees, number); |
6eacf60ce41d
Permutation and FV_Alpha interface change.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1259
diff
changeset
|
109 |
val perm_append_thms = List.take (prove_perm_append lthy' induct perm_ldef perm_frees, number) |
1249
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
110 |
val perms_name = space_implode "_" perm_names' |
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
111 |
val perms_zero_bind = Binding.name (perms_name ^ "_zero") |
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
112 |
val perms_append_bind = Binding.name (perms_name ^ "_append") |
1257 | 113 |
fun tac _ (_, simps, _) = |
1253 | 114 |
(Class.intro_classes_tac []) THEN (ALLGOALS (resolve_tac simps)); |
1257 | 115 |
fun morphism phi (dfs, simps, fvs) = |
116 |
(map (Morphism.thm phi) dfs, map (Morphism.thm phi) simps, map (Morphism.term phi) fvs); |
|
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
117 |
in |
1249
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
118 |
lthy' |
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
119 |
|> snd o (Local_Theory.note ((perms_zero_bind, []), perm_empty_thms)) |
ea6a52a4f5bf
Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1248
diff
changeset
|
120 |
|> snd o (Local_Theory.note ((perms_append_bind, []), perm_append_thms)) |
1871
c704d129862b
moved some general function into nominal_library.ML
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
121 |
|> Class_Target.prove_instantiation_exit_result morphism tac |
c704d129862b
moved some general function into nominal_library.ML
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
122 |
(perm_ldef, (perm_empty_thms @ perm_append_thms), perm_frees) |
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
123 |
end |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
124 |
|
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
125 |
*} |
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
126 |
|
1253 | 127 |
ML {* |
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
128 |
fun define_lifted_perms qtys full_tnames name_term_pairs thms thy = |
1253 | 129 |
let |
130 |
val lthy = |
|
131 |
Theory_Target.instantiation (full_tnames, [], @{sort pt}) thy; |
|
1683
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
132 |
val (_, _, lthy') = quotient_lift_consts_export qtys name_term_pairs lthy; |
f78c820f67c3
Automatically lift theorems and constants only using the new quotient types. Requires new Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1503
diff
changeset
|
133 |
val lifted_thms = map (Quotient_Tacs.lifted qtys lthy') thms; |
1253 | 134 |
fun tac _ = |
135 |
Class.intro_classes_tac [] THEN |
|
136 |
(ALLGOALS (resolve_tac lifted_thms)) |
|
137 |
val lthy'' = Class.prove_instantiation_instance tac lthy' |
|
138 |
in |
|
139 |
Local_Theory.exit_global lthy'' |
|
140 |
end |
|
141 |
*} |
|
142 |
||
1342 | 143 |
ML {* |
144 |
fun neq_to_rel r neq = |
|
145 |
let |
|
146 |
val neq = HOLogic.dest_Trueprop (prop_of neq) |
|
147 |
val eq = HOLogic.dest_not neq |
|
148 |
val (lhs, rhs) = HOLogic.dest_eq eq |
|
149 |
val rel = r $ lhs $ rhs |
|
150 |
val nrel = HOLogic.mk_not rel |
|
151 |
in |
|
152 |
HOLogic.mk_Trueprop nrel |
|
153 |
end |
|
154 |
*} |
|
155 |
||
156 |
ML {* |
|
157 |
fun neq_to_rel_tac cases distinct = |
|
158 |
rtac notI THEN' eresolve_tac cases THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps distinct) |
|
159 |
*} |
|
160 |
||
161 |
ML {* |
|
162 |
fun distinct_rel ctxt cases (dists, rel) = |
|
163 |
let |
|
164 |
val ((_, thms), ctxt') = Variable.import false dists ctxt |
|
165 |
val terms = map (neq_to_rel rel) thms |
|
166 |
val nrels = map (fn t => Goal.prove ctxt' [] [] t (fn _ => neq_to_rel_tac cases dists 1)) terms |
|
167 |
in |
|
168 |
Variable.export ctxt' ctxt nrels |
|
169 |
end |
|
170 |
*} |
|
171 |
||
172 |
||
173 |
||
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
174 |
(* Test |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
175 |
atom_decl name |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
176 |
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
177 |
datatype trm = |
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
178 |
Var "name" |
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
179 |
| App "trm" "trm list" |
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
180 |
| Lam "name" "trm" |
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
181 |
| Let "bp" "trm" "trm" |
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
182 |
and bp = |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
183 |
BUnit |
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
184 |
| BVar "name" |
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
185 |
| BPair "bp" "bp" |
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
186 |
|
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
187 |
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents:
1871
diff
changeset
|
188 |
setup {* snd o define_raw_perms ["trm", "bp"] ["Perm.trm", "Perm.bp"] *} |
1170
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
189 |
print_theorems |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
190 |
*) |
a7b4160ef463
Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1164
diff
changeset
|
191 |
|
1159
3c6bee89d826
Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
192 |
end |