Porting from Lift to Parser; until defining the Quotient type.
--- a/Nominal/Lift.thy Tue Mar 02 17:11:58 2010 +0100
+++ b/Nominal/Lift.thy Tue Mar 02 17:48:41 2010 +0100
@@ -25,7 +25,7 @@
val ntnames = [@{binding trm2}, @{binding as}]
val ncnames = ["Vr2", "Ap2", "Lt2", "As"] *} *)
-datatype rkind =
+(*datatype rkind =
Type
| KPi "rty" "name" "rkind"
and rty =
@@ -48,9 +48,9 @@
val bv_simps = []
val ntnames = [@{binding kind}, @{binding ty}, @{binding trm}]
-val ncnames = ["TYP", "KPI", "TCONST", "TAPP", "TPI", "CONST", "VAR", "APP", "LAM"]
+val ncnames = ["TYP", "KPI", "TCONST", "TAPP", "TPI", "CONST", "VAR", "APP", "LAM"]*}*)
-(*datatype rtrm5 =
+datatype rtrm5 =
rVr5 "name"
| rAp5 "rtrm5" "rtrm5"
| rLt5 "rlts" "rtrm5" --"bind (bv5 lts) in (rtrm5)"
@@ -64,7 +64,7 @@
"rbv5 rLnil = {}"
| "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
-ML
+ML {*
val thy1 = @{theory};
val info = Datatype.the_info @{theory} "Lift.rtrm5"
val number = 2;
@@ -73,7 +73,7 @@
val bv_simps = @{thms rbv5.simps}
val ntnames = [@{binding trm5}, @{binding lts}]
-val ncnames = ["Vr5", "Ap5", "Lt5", "Lnil", "Lcons"]*)
+val ncnames = ["Vr5", "Ap5", "Lt5", "Lnil", "Lcons"]
val descr = #descr info;
--- a/Nominal/Parser.thy Tue Mar 02 17:11:58 2010 +0100
+++ b/Nominal/Parser.thy Tue Mar 02 17:48:41 2010 +0100
@@ -212,33 +212,51 @@
ML {*
fun nominal_datatype2 dts bn_funs bn_eqs binds lthy =
let
- val (((raw_dt_names, (raw_bn_funs, raw_bn_eqs)), raw_binds), lthy2) =
+ val (((raw_dt_names, (raw_bn_funs_loc, raw_bn_eqs_loc)), raw_binds), lthy2) =
raw_nominal_decls dts bn_funs bn_eqs binds lthy
+ val morphism_2_1 = ProofContext.export_morphism lthy2 lthy
+ val raw_bn_funs = map (Morphism.term morphism_2_1) raw_bn_funs_loc
+ val raw_bn_eqs = ProofContext.export lthy2 lthy raw_bn_eqs_loc
val dtinfo = Datatype.the_info (ProofContext.theory_of lthy2) (hd raw_dt_names);
val descr = #descr dtinfo;
+ val sorts = #sorts dtinfo;
+ val all_typs = map (fn i => typ_of_dtyp descr sorts (DtRec i)) (map fst descr)
val all_full_tnames = map (fn (_, (n, _, _)) => n) descr;
val dtinfos = map (Datatype.the_info (ProofContext.theory_of lthy2)) all_full_tnames;
val inject = flat (map #inject dtinfos);
val distinct = flat (map #distinct dtinfos);
+ val induct = #induct dtinfo;
val inducts = #inducts dtinfo;
val ((raw_perm_def, raw_perm_simps, perms), lthy3) =
Local_Theory.theory_result (define_raw_perms dtinfo (length dts)) lthy2;
val raw_binds_flat = map (map flat) raw_binds;
val (((fv_ts_loc, fv_def_loc), alpha), lthy4) = define_fv_alpha dtinfo raw_binds_flat lthy3;
+ val alpha_ts_loc = #preds alpha
+ val morphism_4_3 = ProofContext.export_morphism lthy4 lthy3;
+ val alpha_ts = map (Morphism.term morphism_4_3) alpha_ts_loc;
+ val alpha_induct_loc = #induct alpha
val dts_names = map (fn (i, (s, _, _)) => (s, i)) (#descr dtinfo);
- val _ = tracing (PolyML.makestring dts_names);
val bn_tys = map (domain_type o fastype_of) raw_bn_funs;
- val _ = tracing (PolyML.makestring bn_tys);
val bn_nos = map (dtyp_no_of_typ dts_names) bn_tys;
- val _ = tracing (PolyML.makestring bn_nos);
val bns = raw_bn_funs ~~ bn_nos;
val alpha_intros = #intrs alpha;
val alpha_cases = #elims alpha
val alpha_inj_loc = build_alpha_inj alpha_intros (inject @ distinct) alpha_cases lthy4
val (bv_eqvts, lthy5) = fold_map (build_bv_eqvt perms (raw_bn_eqs @ raw_perm_def) inducts) bns lthy4;
-
+ val (fv_eqvts, lthy6) = build_eqvts Binding.empty fv_ts_loc perms
+ ((flat (map snd bv_eqvts)) @ fv_def_loc @ raw_perm_def) induct lthy5;
+ val alpha_eqvt_loc = build_alpha_eqvts alpha_ts_loc perms
+ (raw_perm_def @ alpha_inj_loc) alpha_induct_loc lthy6;
+ val alpha_eqvt = ProofContext.export lthy6 lthy2 alpha_eqvt_loc;
+ val alpha_equivp_loc = build_equivps alpha_ts_loc induct alpha_induct_loc
+ inject alpha_inj_loc distinct alpha_cases alpha_eqvt_loc lthy6;
+ val alpha_equivp = ProofContext.export lthy6 lthy2 alpha_equivp_loc;
+ val qty_names = map (fn (_, b, _, _) => b) dts;
+ val lthy7 = define_quotient_type
+ (map (fn ((b, t), alpha) => (([], b, NoSyn), (t, alpha))) ((qty_names ~~ all_typs) ~~ alpha_ts))
+ (ALLGOALS (resolve_tac alpha_equivp)) lthy6;
in
- ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy5)
+ ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy7)
end
*}
--- a/Nominal/Test.thy Tue Mar 02 17:11:58 2010 +0100
+++ b/Nominal/Test.thy Tue Mar 02 17:48:41 2010 +0100
@@ -4,6 +4,8 @@
text {* example 1 *}
+(* ML {* set show_hyps *} *)
+
nominal_datatype lam =
VAR "name"
| APP "lam" "lam"
@@ -77,11 +79,13 @@
All xs::"name list" ty::"t_raw" bind xs in ty
*)
+
+(* alpha_eqvt fails...
nominal_datatype t =
Var "name"
| Fun "t" "t"
and tyS =
- All xs::"name set" ty::"t" bind xs in ty
+ All xs::"name set" ty::"t" bind xs in ty *)
(* example 1 from Terms.thy *)
@@ -135,12 +139,12 @@
(* example 4 from Terms.thy *)
-
+(* fv_eqvt does not work, we need to repaire defined permute functions...
nominal_datatype trm4 =
Vr4 "name"
| Ap4 "trm4" "trm4 list"
| Lm4 x::"name" t::"trm4" bind x in t
-
+*)
(* example 5 from Terms.thy *)