Working bv_eqvt
authorCezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 02 Mar 2010 15:11:41 +0100
changeset 1309 b395b902cf0d
parent 1308 80dabcaafc38
child 1310 c668d65fd988
Working bv_eqvt
Nominal/Lift.thy
Nominal/Parser.thy
Nominal/Test.thy
--- a/Nominal/Lift.thy	Tue Mar 02 15:10:47 2010 +0100
+++ b/Nominal/Lift.thy	Tue Mar 02 15:11:41 2010 +0100
@@ -82,7 +82,6 @@
 val all_typs = map (fn i => typ_of_dtyp descr sorts (DtRec i)) nos
 val typs = List.take (all_typs, number)
 val all_full_tnames = map (fn (_, (n, _, _)) => n) descr;
-val full_tnames = List.take (all_full_tnames, number);
 val induct = #induct info;
 val inducts = #inducts info;
 val infos = map (Datatype.the_info thy1) all_full_tnames;
@@ -106,10 +105,7 @@
 val morphism = ProofContext.export_morphism lthy2 lthy1
 val fv_ts = map (Morphism.term morphism) fv_ts_loc
 val alpha_ts = map (Morphism.term morphism) alpha_ts_loc
-fun build_bv_eqvt (t, n) =
-  build_eqvts Binding.empty [t] [nth perms n]
-    (bv_simps @ raw_perm_def) (nth inducts n)
-val (bv_eqvts, lthy3) = fold_map build_bv_eqvt bvs lthy2;
+val (bv_eqvts, lthy3) = fold_map (build_bv_eqvt perms (bv_simps @ raw_perm_def) inducts)  bvs lthy2;
 val (fv_eqvts, lthy4) = build_eqvts Binding.empty fv_ts_loc perms (fv_def_loc @ raw_perm_def) induct lthy3;
 val alpha_eqvt_loc = build_alpha_eqvts alpha_ts_loc perms (raw_perm_def @ alpha_inj_loc) alpha_induct_loc lthy4;
 val alpha_eqvt = ProofContext.export lthy4 lthy1 alpha_eqvt_loc;
--- a/Nominal/Parser.thy	Tue Mar 02 15:10:47 2010 +0100
+++ b/Nominal/Parser.thy	Tue Mar 02 15:11:41 2010 +0100
@@ -1,5 +1,5 @@
 theory Parser
-imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Perm" "Fv"
+imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Perm" "Fv" "Rsp"
 begin
 
 atom_decl name
@@ -215,13 +215,30 @@
   val (((raw_dt_names, (raw_bn_funs, raw_bn_eqs)), raw_binds), lthy2) =
     raw_nominal_decls dts bn_funs bn_eqs binds lthy
   val dtinfo = Datatype.the_info (ProofContext.theory_of lthy2) (hd raw_dt_names);
+  val descr = #descr dtinfo;
+  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 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 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;
 
 in
-  ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy4)
+  ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy5)
 end
 *}
 
--- a/Nominal/Test.thy	Tue Mar 02 15:10:47 2010 +0100
+++ b/Nominal/Test.thy	Tue Mar 02 15:11:41 2010 +0100
@@ -24,7 +24,7 @@
 thm permute_lam_raw_permute_bp_raw.simps
 thm alpha_lam_raw_alpha_bp_raw.intros
 thm fv_lam_raw_fv_bp_raw.simps
-
+thm eqvts
 
 print_theorems
 
@@ -332,8 +332,6 @@
  "bv (K s ts vs) = (atoms (set (map fst ts))) \<union> (atoms (set (map fst vs)))"
 *)
 
-thm bv_raw.simps
-
 end