merged
authorChristian Urban <urbanc@in.tum.de>
Thu, 04 Mar 2010 15:31:34 +0100
changeset 1352 cad5f3851569
parent 1351 cffc5d78ab7f (current diff)
parent 1340 f201eb6acafc (diff)
child 1353 3727e234fe6b
merged
Nominal/Test.thy
--- a/Nominal/Fv.thy	Thu Mar 04 15:31:21 2010 +0100
+++ b/Nominal/Fv.thy	Thu Mar 04 15:31:34 2010 +0100
@@ -1,5 +1,5 @@
 theory Fv
-imports "Nominal2_Atoms" "Abs" "Perm" (* For testing *)
+imports "Nominal2_Atoms" "Abs" "Perm" "Rsp"
 begin
 
 (* Bindings are given as a list which has a length being equal
@@ -184,8 +184,8 @@
               val pi_supps = map ((curry op $) @{term "supp :: perm \<Rightarrow> atom set"}) rpis;
               val pi_supps_eq = HOLogic.mk_eq (mk_inter pi_supps, @{term "{} :: atom set"})
             in
-              if length pi_supps > 1 then
-                HOLogic.mk_conj (alpha_gen, pi_supps_eq) else alpha_gen
+              (*if length pi_supps > 1 then
+                HOLogic.mk_conj (alpha_gen, pi_supps_eq) else*) alpha_gen
             (* TODO Add some test that is makes sense *)
             end else @{term "True"}
         end
@@ -312,29 +312,34 @@
 *}
 
 ML {*
-fun reflp_tac induct inj =
+fun reflp_tac induct inj ctxt =
   rtac induct THEN_ALL_NEW
-  asm_full_simp_tac (HOL_ss addsimps inj) THEN_ALL_NEW
-(*  TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI) THEN_ALL_NEW*)
-  (rtac @{thm exI[of _ "0 :: perm"]} THEN'
-   asm_full_simp_tac (HOL_ss addsimps
-     @{thms alpha_gen fresh_star_def fresh_zero_perm permute_zero ball_triv}))
+  simp_tac ((mk_minimal_ss ctxt) addsimps inj) THEN_ALL_NEW
+  split_conjs THEN_ALL_NEW REPEAT o rtac @{thm exI[of _ "0 :: perm"]}
+  THEN_ALL_NEW split_conjs THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps
+     @{thms alpha_gen fresh_star_def fresh_zero_perm permute_zero ball_triv
+       add_0_left supp_zero_perm Int_empty_left})
 *}
 
+
 lemma exi_neg: "\<exists>(pi :: perm). P pi \<Longrightarrow> (\<And>(p :: perm). P p \<Longrightarrow> Q (- p)) \<Longrightarrow> \<exists>pi. Q pi"
 apply (erule exE)
 apply (rule_tac x="-pi" in exI)
 by auto
 
 ML {*
-fun symp_tac induct inj eqvt =
-  (((rtac impI THEN' etac induct) ORELSE' rtac induct) THEN_ALL_NEW
-  asm_full_simp_tac (HOL_ss addsimps inj) THEN_ALL_NEW
-  (REPEAT o etac conjE THEN' etac @{thm exi_neg} THEN' REPEAT o etac conjE THEN'
-  (TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI))) THEN_ALL_NEW
-  (asm_full_simp_tac HOL_ss) THEN_ALL_NEW
-  (etac @{thm alpha_gen_compose_sym} THEN' 
-    (asm_full_simp_tac (HOL_ss addsimps (@{thm atom_eqvt} :: eqvt)))))
+fun symp_tac induct inj eqvt ctxt =
+  ind_tac induct THEN_ALL_NEW
+  simp_tac ((mk_minimal_ss ctxt) addsimps inj) THEN_ALL_NEW split_conjs
+  THEN_ALL_NEW
+  REPEAT o etac @{thm exi_neg}
+  THEN_ALL_NEW
+  split_conjs THEN_ALL_NEW
+  asm_full_simp_tac (HOL_ss addsimps @{thms supp_minus_perm minus_add[symmetric]}) THEN_ALL_NEW
+  (rtac @{thm alpha_gen_compose_sym} THEN' RANGE [
+    (asm_full_simp_tac (HOL_ss addsimps @{thms plus_perm_eq})),
+    (asm_full_simp_tac (HOL_ss addsimps (eqvt @ all_eqvts ctxt)))
+  ])
 *}
 
 ML {*
@@ -367,17 +372,38 @@
 by auto
 
 ML {*
+fun is_ex (Const ("Ex", _) $ Abs _) = true
+  | is_ex _ = false;
+*}
+
+ML {*
+fun eetac rule = Subgoal.FOCUS_PARAMS 
+  (fn (focus) =>
+     let
+       val concl = #concl focus
+       val prems = Logic.strip_imp_prems (term_of concl)
+       val exs = filter (fn x => is_ex (HOLogic.dest_Trueprop x)) prems
+       val cexs = map (SOME o (cterm_of (ProofContext.theory_of (#context focus)))) exs
+       val thins = map (fn cex => Drule.instantiate' [] [cex] Drule.thin_rl) cexs
+     in
+     (etac rule THEN' RANGE[
+        atac,
+        eresolve_tac thins
+     ]) 1
+     end
+  )
+*}
+
+ML {*
 fun transp_tac ctxt induct alpha_inj term_inj distinct cases eqvt =
-  ((rtac impI THEN' etac induct) ORELSE' rtac induct) THEN_ALL_NEW
+  ind_tac induct THEN_ALL_NEW
   (TRY o rtac allI THEN' imp_elim_tac cases ctxt) THEN_ALL_NEW
-  (
-    asm_full_simp_tac (HOL_ss addsimps alpha_inj @ term_inj @ distinct)
-    THEN_ALL_NEW (REPEAT o etac conjE THEN' etac @{thm exi_sum} THEN' RANGE [atac]) THEN_ALL_NEW
-    (REPEAT o etac conjE THEN' (TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI)))
-    THEN_ALL_NEW (asm_full_simp_tac HOL_ss) THEN_ALL_NEW
-    (etac @{thm alpha_gen_compose_trans} THEN' RANGE[atac]) THEN_ALL_NEW
-    (asm_full_simp_tac (HOL_ss addsimps (@{thm atom_eqvt} :: eqvt)))
-  )
+  asm_full_simp_tac ((mk_minimal_ss ctxt) addsimps alpha_inj) THEN_ALL_NEW
+  split_conjs THEN_ALL_NEW REPEAT o (eetac @{thm exi_sum} ctxt) THEN_ALL_NEW split_conjs
+  THEN_ALL_NEW (asm_full_simp_tac (HOL_ss addsimps (term_inj @ distinct)))
+  THEN_ALL_NEW split_conjs THEN_ALL_NEW
+  TRY o (etac @{thm alpha_gen_compose_trans} THEN' RANGE[atac]) THEN_ALL_NEW
+  (asm_full_simp_tac (HOL_ss addsimps (all_eqvts ctxt @ eqvt @ term_inj @ distinct)))
 *}
 
 lemma transp_aux:
@@ -400,8 +426,8 @@
 let
   val ([x, y, z], ctxt') = Variable.variant_fixes ["x","y","z"] ctxt;
   val (reflg, (symg, transg)) = build_alpha_refl_gl alphas (x, y, z)
-  fun reflp_tac' _ = reflp_tac term_induct alpha_inj 1;
-  fun symp_tac' _ = symp_tac alpha_induct alpha_inj eqvt 1;
+  fun reflp_tac' _ = reflp_tac term_induct alpha_inj ctxt 1;
+  fun symp_tac' _ = symp_tac alpha_induct alpha_inj eqvt ctxt 1;
   fun transp_tac' _ = transp_tac ctxt alpha_induct alpha_inj term_inj distinct cases eqvt 1;
   val reflt = Goal.prove ctxt' [] [] reflg reflp_tac';
   val symt = Goal.prove ctxt' [] [] symg symp_tac';
--- a/Nominal/Parser.thy	Thu Mar 04 15:31:21 2010 +0100
+++ b/Nominal/Parser.thy	Thu Mar 04 15:31:34 2010 +0100
@@ -212,6 +212,8 @@
 ML {* 
 fun nominal_datatype2 dts bn_funs bn_eqs binds lthy =
 let
+  val thy = ProofContext.theory_of lthy
+  val thy_name = Context.theory_name thy
   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
@@ -233,8 +235,12 @@
   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 fv_ts = map (Morphism.term morphism_4_3) fv_ts_loc;
   val alpha_ts = map (Morphism.term morphism_4_3) alpha_ts_loc;
   val alpha_induct_loc = #induct alpha
+  val [alpha_induct] = ProofContext.export lthy4 lthy3 [alpha_induct_loc];
+  val alpha_inducts = Project_Rule.projects lthy4 (1 upto (length dts)) alpha_induct
+  val fv_def = ProofContext.export lthy4 lthy3 fv_def_loc;
   val dts_names = map (fn (i, (s, _, _)) => (s, i)) (#descr dtinfo);
   val bn_tys = map (domain_type o fastype_of) raw_bn_funs;
   val bn_nos = map (dtyp_no_of_typ dts_names) bn_tys;
@@ -242,24 +248,64 @@
   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 alpha_inj = ProofContext.export lthy4 lthy3 alpha_inj_loc
   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
+  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 qty_binds = map (fn (_, b, _, _) => b) dts;
+  val qty_names = map Name.of_binding qty_binds;
+  val qty_full_names = map (Long_Name.qualify thy_name) qty_names
   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;*)
+    (map (fn ((b, t), alpha) => (([], b, NoSyn), (t, alpha))) ((qty_binds ~~ all_typs) ~~ alpha_ts))
+    (ALLGOALS (resolve_tac alpha_equivp)) lthy6;
+  val const_names = map Name.of_binding (flat (map (fn (_, _, _, t) => map (fn (b, _, _) => b) t) dts));
+  val raw_consts =
+    flat (map (fn (i, (_, _, l)) =>
+      map (fn (cname, dts) =>
+        Const (cname, map (typ_of_dtyp descr sorts) dts --->
+          typ_of_dtyp descr sorts (DtRec i))) l) descr);
+  val (consts_defs, lthy8) = fold_map Quotient_Def.quotient_lift_const (const_names ~~ raw_consts) lthy7;
+  val (consts, const_defs) = split_list consts_defs;
+  val (bns_rsp_pre, lthy9) = fold_map (
+    fn (bn_t, i) => prove_const_rsp Binding.empty [bn_t]
+      (fn _ => fvbv_rsp_tac (nth alpha_inducts i) raw_bn_eqs 1)) bns lthy8;
+  val bns_rsp = flat (map snd bns_rsp_pre);
+  val ((_, fv_rsp), lthy10) = prove_const_rsp Binding.empty fv_ts
+    (fn _ => fvbv_rsp_tac alpha_induct fv_def 1) lthy9;
+  val (const_rsps, lthy11) = fold_map (fn cnst => prove_const_rsp Binding.empty [cnst]
+    (fn _ => constr_rsp_tac alpha_inj (fv_rsp @ bns_rsp) alpha_equivp 1)) raw_consts lthy10
+  val (perms_rsp, lthy12) = prove_const_rsp Binding.empty perms
+    (fn _ => asm_simp_tac (HOL_ss addsimps alpha_eqvt) 1) lthy11;
+  val qfv_names = map (fn x => "fv_" ^ x) qty_names
+  val (qfv_defs, lthy12a) = fold_map Quotient_Def.quotient_lift_const (qfv_names ~~ fv_ts) lthy12;
+  val qbn_names = map (fn (b, _ , _) => Name.of_binding b) bn_funs
+  val (qbn_defs, lthy12b) = fold_map Quotient_Def.quotient_lift_const (qbn_names ~~ raw_bn_funs) lthy12a;
+  val thy = Local_Theory.exit_global lthy12b;
+  val perm_names = map (fn x => "permute_" ^ x) qty_names
+  val thy' = define_lifted_perms qty_full_names (perm_names ~~ perms) raw_perm_simps thy;
+  val lthy13 = Theory_Target.init NONE thy';
+  val q_name = space_implode "_" qty_names;
+  val q_induct = snd (Quotient_Tacs.lifted_attrib (Context.Proof lthy13, induct));
+  val (_, lthy14) = Local_Theory.note ((Binding.name (q_name ^ "_induct"), []), [q_induct]) lthy13;
+  val q_perm = map (fn th => snd (Quotient_Tacs.lifted_attrib (Context.Proof lthy14, th))) raw_perm_def;
+  val (_, lthy15) = Local_Theory.note ((Binding.name (q_name ^ "_perm"), []), q_perm) lthy14;
+  val q_fv = map (fn th => snd (Quotient_Tacs.lifted_attrib (Context.Proof lthy15, th))) fv_def;
+  val (_, lthy16) = Local_Theory.note ((Binding.name (q_name ^ "_fv"), []), q_fv) lthy15;
+  val q_bn = map (fn th => snd (Quotient_Tacs.lifted_attrib (Context.Proof lthy16, th))) raw_bn_eqs;
+  val (_, lthy17) = Local_Theory.note ((Binding.name (q_name ^ "_bn"), []), q_bn) lthy16;
 in
-  ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy6)
+  ((raw_dt_names, raw_bn_funs, raw_bn_eqs, raw_binds), lthy17)
 end
 *}
 
+ML name_of_typ
+
 ML {* 
 (* parsing the datatypes and declaring *)
 (* constructors in the local theory    *)
--- a/Nominal/Rsp.thy	Thu Mar 04 15:31:21 2010 +0100
+++ b/Nominal/Rsp.thy	Thu Mar 04 15:31:34 2010 +0100
@@ -146,7 +146,9 @@
 by auto
 
 ML {*
-  fun indtac induct = (rtac impI THEN' etac induct) ORELSE' rtac induct
+fun ind_tac induct = (rtac impI THEN' etac induct) ORELSE' rtac induct
+*}
+ML {*
   fun all_eqvts ctxt =
     Nominal_ThmDecls.get_eqvts_thms ctxt @ Nominal_ThmDecls.get_eqvts_raw_thms ctxt
   val split_conjs = REPEAT o etac conjE THEN' TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI)
@@ -161,7 +163,7 @@
 
 ML {*
 fun alpha_eqvt_tac induct simps ctxt =
-  indtac induct THEN_ALL_NEW
+  ind_tac induct THEN_ALL_NEW
   simp_tac ((mk_minimal_ss ctxt) addsimps simps) THEN_ALL_NEW
   REPEAT o etac @{thm exi[of _ _ "p"]} THEN' split_conjs THEN_ALL_NEW
   asm_full_simp_tac (HOL_ss addsimps (all_eqvts ctxt @ simps)) THEN_ALL_NEW
--- a/Nominal/Test.thy	Thu Mar 04 15:31:21 2010 +0100
+++ b/Nominal/Test.thy	Thu Mar 04 15:31:34 2010 +0100
@@ -1,10 +1,10 @@
 theory Test
-imports "Parser"
+imports "Parser" "../Attic/Prove"
 begin
 
 text {* weirdo example from Peter Sewell's bestiary *}
 
-nominal_datatype weird =
+(*nominal_datatype weird =
   WBind x::"name" y::"name" p1::"weird" p2::"weird" p3::"weird"
     bind x in p1, bind x in p2, bind y in p2, bind y in p3
 | WV "name"
@@ -14,6 +14,79 @@
 thm alpha_weird_raw.intros[no_vars]
 thm fv_weird_raw.simps[no_vars]
 
+thm eqvts
+
+local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding weird_inj}, []), (build_alpha_inj @{thms alpha_weird_raw.intros} @{thms weird_raw.distinct weird_raw.inject} @{thms alpha_weird_raw.cases} ctxt)) ctxt)) *}
+thm weird_inj
+
+local_setup {*
+(fn ctxt => snd (Local_Theory.note ((@{binding alpha_eqvt}, []),
+build_alpha_eqvts [@{term alpha_weird_raw}] [@{term "permute :: perm \<Rightarrow> weird_raw \<Rightarrow> weird_raw"}] @{thms permute_weird_raw.simps weird_inj} @{thm alpha_weird_raw.induct} ctxt) ctxt)) *}
+
+(*prove {* (snd o snd) (build_alpha_refl_gl [@{term alpha_weird_raw}] ("x","y","z")) *}
+
+apply (tactic {* transp_tac @{context} @{thm alpha_weird_raw.induct} @{thms weird_inj}  @{thms weird_raw.inject} @{thms weird_raw.distinct} @{thms alpha_weird_raw.cases} @{thms alpha_eqvt} 1 *})
+*)
+lemma "alpha_weird_raw x y \<longrightarrow> (\<forall>z. alpha_weird_raw y z \<longrightarrow> alpha_weird_raw x z)"
+apply (rule impI)
+apply (erule alpha_weird_raw.induct)
+apply (simp_all add: weird_inj)
+defer
+apply (rule allI)
+apply (rule impI)
+apply (erule alpha_weird_raw.cases)
+apply (simp_all add: weird_inj)
+apply (rule allI)
+apply (rule impI)
+apply (erule alpha_weird_raw.cases)
+apply (simp_all add: weird_inj)
+apply (erule conjE)+
+apply (erule exE)+
+apply (erule conjE)+
+apply (erule exE)+
+apply (rule conjI)
+apply (rule_tac x="pica + pic" in exI)
+apply (erule alpha_gen_compose_trans)
+apply assumption
+apply (simp add: alpha_eqvt)
+apply (rule_tac x="pia + pib" in exI)
+apply (rule_tac x="piaa + piba" in exI)
+apply (rule conjI)
+apply (erule alpha_gen_compose_trans)
+apply assumption
+apply (simp add: alpha_eqvt)
+apply (rule conjI)
+defer
+apply (rule_tac x="pid + pi" in exI)
+apply (erule alpha_gen_compose_trans)
+apply assumption
+apply (simp add: alpha_eqvt)
+sorry
+
+lemma "alpha_weird_raw x y \<Longrightarrow> alpha_weird_raw y x"
+apply (erule alpha_weird_raw.induct)
+apply (simp_all add: weird_inj)
+apply (erule conjE)+
+apply (erule exE)+
+apply (erule conjE)+
+apply (erule exE)+
+apply (rule conjI)
+apply (rule_tac x="- pic" in exI)
+apply (erule alpha_gen_compose_sym)
+apply (simp_all add: alpha_eqvt)
+apply (rule_tac x="- pia" in exI)
+apply (rule_tac x="- pib" in exI)
+apply (simp add: minus_add[symmetric])
+apply (rule conjI)
+apply (erule alpha_gen_compose_sym)
+apply (simp_all add: alpha_eqvt)
+apply (rule conjI)
+apply (simp add: supp_minus_perm Int_commute)
+apply (rule_tac x="- pi" in exI)
+apply (erule alpha_gen_compose_sym)
+apply (simp_all add: alpha_eqvt)
+done
+
 
 abbreviation "WBind \<equiv> WBind_raw"
 abbreviation "WP \<equiv> WP_raw"
@@ -45,7 +118,7 @@
 apply(simp add: flip_def fresh_def supp_swap)
 apply(rule alpha_weird_raw.intros)
 apply(simp add: alpha_weird_raw.intros(2))
-done
+done*)
 
 text {* example 1 *}
 
@@ -71,9 +144,10 @@
 thm permute_lam_raw_permute_bp_raw.simps
 thm alpha_lam_raw_alpha_bp_raw.intros[no_vars]
 thm fv_lam_raw_fv_bp_raw.simps[no_vars]
-thm eqvts
-
-print_theorems
+thm lam_bp_induct
+thm lam_bp_perm
+thm lam_bp_fv
+thm lam_bp_bn
 
 text {* example 2 *}
 
@@ -97,6 +171,10 @@
 thm alpha_trm'_raw_alpha_pat'_raw.intros[no_vars]
 thm fv_trm'_raw_fv_pat'_raw.simps[no_vars]
 thm f_raw.simps
+thm trm'_pat'_induct
+thm trm'_pat'_perm
+thm trm'_pat'_fv
+thm trm'_pat'_bn
 
 nominal_datatype trm0 =
   Var0 "name"
@@ -115,6 +193,10 @@
 | "f0 (PD0 p1 p2) = (f0 p1) \<union> (f0 p2)"
 
 thm f0_raw.simps
+thm trm0_pat0_induct
+thm trm0_pat0_perm
+thm trm0_pat0_fv
+thm trm0_pat0_bn
 
 text {* example type schemes *}
 
@@ -214,6 +296,7 @@
 
 (* example 6 from Terms.thy *)
 
+(* BV is not respectful, needs to fail
 nominal_datatype trm6 =
   Vr6 "name"
 | Lm6 x::"name" t::"trm6"         bind x in t
@@ -223,10 +306,11 @@
 where
   "bv6 (Vr6 n) = {}"
 | "bv6 (Lm6 n t) = {atom n} \<union> bv6 t"
-| "bv6 (Lt6 l r) = bv6 l \<union> bv6 r"
+| "bv6 (Lt6 l r) = bv6 l \<union> bv6 r" *)
 
 (* example 7 from Terms.thy *)
 
+(* BV is not respectful, needs to fail
 nominal_datatype trm7 =
   Vr7 "name"
 | Lm7 l::"name" r::"trm7"   bind l in r
@@ -236,7 +320,7 @@
 where
   "bv7 (Vr7 n) = {atom n}"
 | "bv7 (Lm7 n t) = bv7 t - {atom n}"
-| "bv7 (Lt7 l r) = bv7 l \<union> bv7 r"
+| "bv7 (Lt7 l r) = bv7 l \<union> bv7 r" *)
 
 (* example 8 from Terms.thy *)
 
@@ -254,6 +338,7 @@
 
 (* example 9 from Terms.thy *)
 
+(* BV is not respectful, needs to fail
 nominal_datatype lam9 =
   Var9 "name"
 | Lam9 n::"name" l::"lam9" bind n in l
@@ -263,13 +348,13 @@
   bv9
 where
   "bv9 (Var9 x) = {}"
-| "bv9 (Lam9 x b) = {atom x}"
+| "bv9 (Lam9 x b) = {atom x}" *)
 
 (* example from my PHD *)
 
 atom_decl coname
 
-nominal_datatype phd =
+(*nominal_datatype phd =
    Ax "name" "coname"
 |  Cut n::"coname" t1::"phd" c::"coname" t2::"phd"              bind n in t1, bind c in t2
 |  AndR c1::"coname" t1::"phd" c2::"coname" t2::"phd" "coname"  bind c1 in t1, bind c2 in t2
@@ -278,10 +363,9 @@
 |  ImpL c::"coname" t1::"phd" n::"name" t2::"phd" "name"        bind c in t1, bind n in t2
 |  ImpR c::"coname" n::"name" t::"phd" "coname"                 bind n in t, bind c in t
 
-(* PROBLEM?: why does it create for the Cut AndR ImpL cases
-two permutations, but only one is used *)
 thm alpha_phd_raw.intros[no_vars]
 thm fv_phd_raw.simps[no_vars]
+*)
 
 (* example form Leroy 96 about modules; OTT *)
 
@@ -320,9 +404,9 @@
 and trmtrm =
   Tref1 "name"
 | Tref2 "path" "name"
-| Lam v::"name" "tyty" M::"trmtrm"  bind v in M
-| App "trmtrm" "trmtrm"
-| Let "body" "trmtrm"
+| Lam' v::"name" "tyty" M::"trmtrm"  bind v in M
+| App' "trmtrm" "trmtrm"
+| Let' "body" "trmtrm"
 binder
     cbinders :: "defn \<Rightarrow> atom set"
 and Cbinders :: "spec \<Rightarrow> atom set"
@@ -337,6 +421,7 @@
 | "Cbinders (SVal v T) = {atom v}"  
 
 (* core haskell *)
+print_theorems
 
 atom_decl var
 atom_decl tvar
@@ -399,10 +484,10 @@
 
 (* example 3 from Peter Sewell's bestiary *)
 nominal_datatype exp =
-  Var "name"
-| App "exp" "exp"
-| Lam x::"name" e::"exp" bind x in e
-| Let x::"name" p::"pat" e1::"exp" e2::"exp" bind x in e2, bind "bp p" in e1
+  VarP "name"
+| AppP "exp" "exp"
+| LamP x::"name" e::"exp" bind x in e
+| LetP x::"name" p::"pat" e1::"exp" e2::"exp" bind x in e2, bind "bp p" in e1
 and pat =
   PVar "name"
 | PUnit
@@ -414,24 +499,25 @@
 | "bp (PUnit) = {}"
 | "bp (PPair p1 p2) = bp p1 \<union> bp p2"
 
+thm quot_respect
 (* example 6 from Peter Sewell's bestiary *)
-nominal_datatype exp6 =
+(*nominal_datatype exp6 =
   EVar name
 | EPair exp6 exp6
 | ELetRec x::name p::pat6 e1::exp6 e2::exp6 bind x in e1, bind x in e2, bind "bp6 p" in e1
 and pat6 =
-  PVar name
-| PUnit
-| PPair pat6 pat6
+  PVar' name
+| PUnit'
+| PPair' pat6 pat6
 binder
   bp6 :: "pat6 \<Rightarrow> atom set"
 where
-  "bp6 (PVar x) = {atom x}"
-| "bp6 (PUnit) = {}"
-| "bp6 (PPair p1 p2) = bp6 p1 \<union> bp6 p2"
+  "bp6 (PVar' x) = {atom x}"
+| "bp6 (PUnit') = {}"
+| "bp6 (PPair' p1 p2) = bp6 p1 \<union> bp6 p2"*)
 
 (* example 7 from Peter Sewell's bestiary *)
-nominal_datatype exp7 =
+(*nominal_datatype exp7 =
   EVar name
 | EUnit
 | EPair exp7 exp7
@@ -447,10 +533,10 @@
 where
   "b7 (Assign x e) = {atom x}"
 | "b7s (Single a) = b7 a"
-| "b7s (More a as) = (b7 a) \<union> (b7s as)"
+| "b7s (More a as) = (b7 a) \<union> (b7s as)"*)
 
 (* example 8 from Peter Sewell's bestiary *)
-nominal_datatype exp8 =
+(*nominal_datatype exp8 =
   EVar name
 | EUnit
 | EPair exp8 exp8
@@ -484,7 +570,7 @@
 | "b_fnclauses (S fc) = (b_fnclause fc)"
 | "b_fnclauses (ORs fc fcs) = (b_fnclause fc) \<union> (b_fnclauses fcs)"
 | "b_lrb8 (Clause fcs) = (b_fnclauses fcs)"
-| "b_fnclause (K x pat exp8) = {atom x}"
+| "b_fnclause (K x pat exp8) = {atom x}"*)