# HG changeset patch # User Cezary Kaliszyk # Date 1267548536 -3600 # Node ID a8627c3bdd0ccfd1e4e694daf85f7cb4c2a53c8a # Parent 0577afdb1732920190b7dc5f7c76d52d9629c060# Parent da44ef9a7df22e60a5aad5016226dd14387720d5 merge diff -r da44ef9a7df2 -r a8627c3bdd0c Nominal/Lift.thy --- a/Nominal/Lift.thy Tue Mar 02 16:04:48 2010 +0100 +++ b/Nominal/Lift.thy Tue Mar 02 17:48:56 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} \ (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; diff -r da44ef9a7df2 -r a8627c3bdd0c Nominal/Nominal2_Eqvt.thy --- a/Nominal/Nominal2_Eqvt.thy Tue Mar 02 16:04:48 2010 +0100 +++ b/Nominal/Nominal2_Eqvt.thy Tue Mar 02 17:48:56 2010 +0100 @@ -5,7 +5,7 @@ (Contains most, but not all such lemmas.) *) theory Nominal2_Eqvt -imports Nominal2_Base +imports Nominal2_Base Nominal2_Atoms uses ("nominal_thmdecls.ML") ("nominal_permeq.ML") begin @@ -248,7 +248,9 @@ (* sets *) empty_eqvt UNIV_eqvt union_eqvt inter_eqvt mem_eqvt - Diff_eqvt Compl_eqvt insert_eqvt Collect_eqvt + Diff_eqvt Compl_eqvt insert_eqvt Collect_eqvt image_eqvt + + atom_eqvt thm eqvts thm eqvts_raw @@ -301,4 +303,4 @@ oops -end \ No newline at end of file +end diff -r da44ef9a7df2 -r a8627c3bdd0c Nominal/Parser.thy --- a/Nominal/Parser.thy Tue Mar 02 16:04:48 2010 +0100 +++ b/Nominal/Parser.thy Tue Mar 02 17:48:56 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 *} diff -r da44ef9a7df2 -r a8627c3bdd0c Nominal/Rsp.thy --- a/Nominal/Rsp.thy Tue Mar 02 16:04:48 2010 +0100 +++ b/Nominal/Rsp.thy Tue Mar 02 17:48:56 2010 +0100 @@ -132,7 +132,7 @@ val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map eqvtc (funs ~~ (args ~~ perms)))) fun tac _ = (Datatype_Aux.indtac induct indnames THEN_ALL_NEW (asm_full_simp_tac (HOL_ss addsimps - (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ simps)))) 1 + (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ (Nominal_ThmDecls.get_eqvts_raw_thms ctxt) @ simps)))) 1 val thm = Goal.prove ctxt ("p" :: indnames) [] gl tac val thms = HOLogic.conj_elims thm in @@ -161,14 +161,14 @@ fun tac _ = (((rtac impI THEN' etac induct) ORELSE' rtac induct) THEN_ALL_NEW ( (asm_full_simp_tac (HOL_ss addsimps - (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ simps))) + ((Nominal_ThmDecls.get_eqvts_thms ctxt) @ (Nominal_ThmDecls.get_eqvts_raw_thms ctxt) @ simps))) THEN_ALL_NEW (REPEAT o etac conjE THEN' etac @{thm exi[of _ _ "p"]} 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_eqvt[of _ _ _ _ "p"]}) THEN_ALL_NEW (asm_full_simp_tac (HOL_ss addsimps - (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ simps))))) 1 + ((Nominal_ThmDecls.get_eqvts_thms ctxt) @ (Nominal_ThmDecls.get_eqvts_raw_thms ctxt) @ simps))))) 1 val thm = Goal.prove ctxt ("p" :: indnames @ indnames2) [] gl tac in map (fn x => mp OF [x]) (HOLogic.conj_elims thm) diff -r da44ef9a7df2 -r a8627c3bdd0c Nominal/Test.thy --- a/Nominal/Test.thy Tue Mar 02 16:04:48 2010 +0100 +++ b/Nominal/Test.thy Tue Mar 02 17:48:56 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 *)