# HG changeset patch # User Christian Urban # Date 1267557261 -3600 # Node ID 12ce0167318801f32598268af7b0aebe64477ac9 # Parent bfd9af005e23b9e136ab2a7bfc01ff04e744c0af# Parent cce1b6d1b7618585d66db9ffcd58dd61027b63ef merged diff -r bfd9af005e23 -r 12ce01673188 Nominal/Lift.thy --- a/Nominal/Lift.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Lift.thy Tue Mar 02 20:14:21 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 bfd9af005e23 -r 12ce01673188 Nominal/Nominal2_Eqvt.thy --- a/Nominal/Nominal2_Eqvt.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Nominal2_Eqvt.thy Tue Mar 02 20:14:21 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 bfd9af005e23 -r 12ce01673188 Nominal/Parser.thy --- a/Nominal/Parser.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Parser.thy Tue Mar 02 20:14:21 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 bfd9af005e23 -r 12ce01673188 Nominal/Rsp.thy --- a/Nominal/Rsp.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Rsp.thy Tue Mar 02 20:14:21 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 bfd9af005e23 -r 12ce01673188 Nominal/Term4.thy --- a/Nominal/Term4.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Term4.thy Tue Mar 02 20:14:21 2010 +0100 @@ -1,5 +1,5 @@ theory Term4 -imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "Rsp" "../Attic/Prove" +imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "Rsp" "../Attic/Prove" "Quotient_List" begin atom_decl name @@ -33,14 +33,32 @@ [[[], [], [(NONE, 0,1)]], [[], []] ] *} print_theorems +lemma fix2: "alpha_rtrm4_list = list_rel alpha_rtrm4" +apply (rule ext)+ +apply (induct_tac x xa rule: list_induct2') +apply (simp_all add: alpha_rtrm4_alpha_rtrm4_list.intros) +apply clarify apply (erule alpha_rtrm4_list.cases) apply(simp_all) +apply clarify apply (erule alpha_rtrm4_list.cases) apply(simp_all) +apply rule +apply (erule alpha_rtrm4_list.cases) +apply simp_all +apply (rule alpha_rtrm4_alpha_rtrm4_list.intros) +apply simp_all +done + +(* We need sth like: +lemma fix3: "fv_rtrm4_list = set o map fv_rtrm4" *) + notation alpha_rtrm4 ("_ \4 _" [100, 100] 100) and alpha_rtrm4_list ("_ \4l _" [100, 100] 100) -thm alpha_rtrm4_alpha_rtrm4_list.intros +thm alpha_rtrm4_alpha_rtrm4_list.intros[simplified fix2] -local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_inj}, []), (build_alpha_inj @{thms alpha_rtrm4_alpha_rtrm4_list.intros} @{thms rtrm4.distinct rtrm4.inject list.distinct list.inject} @{thms alpha_rtrm4.cases alpha_rtrm4_list.cases} ctxt)) ctxt)) *} +local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_inj}, []), (build_alpha_inj @{thms alpha_rtrm4_alpha_rtrm4_list.intros[simplified fix2]} @{thms rtrm4.distinct rtrm4.inject list.distinct list.inject} @{thms alpha_rtrm4.cases[simplified fix2] alpha_rtrm4_list.cases[simplified fix2]} ctxt)) ctxt)) *} thm alpha4_inj -thm alpha_rtrm4_alpha_rtrm4_list.induct + +local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_inj_no}, []), (build_alpha_inj @{thms alpha_rtrm4_alpha_rtrm4_list.intros} @{thms rtrm4.distinct rtrm4.inject list.distinct list.inject} @{thms alpha_rtrm4.cases alpha_rtrm4_list.cases} ctxt)) ctxt)) *} +thm alpha4_inj_no local_setup {* snd o build_eqvts @{binding fv_rtrm4_fv_rtrm4_list_eqvt} [@{term fv_rtrm4}, @{term fv_rtrm4_list}] [@{term "permute :: perm \ rtrm4 \ rtrm4"},@{term "permute :: perm \ rtrm4 list \ rtrm4 list"}] (@{thms fv_rtrm4_fv_rtrm4_list.simps permute_rtrm4_permute_rtrm4_list.simps[simplified repaired]}) @{thm rtrm4.induct} @@ -48,18 +66,56 @@ print_theorems local_setup {* -(fn ctxt => snd (Local_Theory.note ((@{binding alpha4_eqvt}, []), - build_alpha_eqvts [@{term alpha_rtrm4}, @{term alpha_rtrm4_list}] [@{term "permute :: perm \ rtrm4 \ rtrm4"},@{term "permute :: perm \ rtrm4 list \ rtrm4 list"}] @{thms permute_rtrm4_permute_rtrm4_list.simps[simplified repaired] alpha4_inj} @{thm alpha_rtrm4_alpha_rtrm4_list.induct} ctxt) ctxt)) +(fn ctxt => snd (Local_Theory.note ((@{binding alpha4_eqvt_no}, []), + build_alpha_eqvts [@{term alpha_rtrm4}, @{term alpha_rtrm4_list}] [@{term "permute :: perm \ rtrm4 \ rtrm4"},@{term "permute :: perm \ rtrm4 list \ rtrm4 list"}] @{thms permute_rtrm4_permute_rtrm4_list.simps[simplified repaired] alpha4_inj_no} @{thm alpha_rtrm4_alpha_rtrm4_list.induct} ctxt) ctxt)) +*} +lemmas alpha4_eqvt = alpha4_eqvt_no[simplified fix2] + +local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_equivp_no}, []), + (build_equivps [@{term alpha_rtrm4}, @{term alpha_rtrm4_list}] @{thm rtrm4.induct} @{thm alpha_rtrm4_alpha_rtrm4_list.induct} @{thms rtrm4.inject list.inject} @{thms alpha4_inj_no} @{thms rtrm4.distinct list.distinct} @{thms alpha_rtrm4_list.cases alpha_rtrm4.cases} @{thms alpha4_eqvt_no} ctxt)) ctxt)) *} +lemmas alpha4_equivp = alpha4_equivp_no[simplified fix2] + +(*lemma fv_rtrm4_rsp: + "xa \4 ya \ fv_rtrm4 xa = fv_rtrm4 ya" + "x \4l y \ fv_rtrm4_list x = fv_rtrm4_list y" + apply (induct rule: alpha_rtrm4_alpha_rtrm4_list.inducts) + apply (simp_all add: alpha_gen) +done*) + + +quotient_type + trm4 = rtrm4 / alpha_rtrm4 +(*and + trm4list = "rtrm4 list" / alpha_rtrm4_list*) + by (simp_all add: alpha4_equivp) + +local_setup {* +(fn ctxt => ctxt + |> snd o (Quotient_Def.quotient_lift_const ("Vr4", @{term rVr4})) + |> snd o (Quotient_Def.quotient_lift_const ("Ap4", @{term rAp4})) + |> snd o (Quotient_Def.quotient_lift_const ("Lm4", @{term rLm4}))) *} print_theorems -local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_equivp}, []), - (build_equivps [@{term alpha_rtrm4}, @{term alpha_rtrm4_list}] @{thm rtrm4.induct} @{thm alpha_rtrm4_alpha_rtrm4_list.induct} @{thms rtrm4.inject list.inject} @{thms alpha4_inj} @{thms rtrm4.distinct list.distinct} @{thms alpha_rtrm4_list.cases alpha_rtrm4.cases} @{thms alpha4_eqvt} ctxt)) ctxt)) *} -thm alpha4_equivp +local_setup {* snd o prove_const_rsp @{binding fv_rtrm4_rsp} [@{term fv_rtrm4}] + (fn _ => fvbv_rsp_tac @{thm alpha_rtrm4_alpha_rtrm4_list.inducts(1)} @{thms fv_rtrm4_fv_rtrm4_list.simps} 1) *} +print_theorems -quotient_type - qrtrm4 = rtrm4 / alpha_rtrm4 and - qrtrm4list = "rtrm4 list" / alpha_rtrm4_list - by (simp_all add: alpha4_equivp) +local_setup {* snd o prove_const_rsp @{binding rVr4_rsp} [@{term rVr4}] + (fn _ => constr_rsp_tac @{thms alpha4_inj} @{thms fv_rtrm4_rsp} @{thms alpha4_equivp} 1) *} +lemma "(alpha_rtrm4 ===> list_rel alpha_rtrm4 ===> alpha_rtrm4) rAp4 rAp4" +apply simp +apply clarify +apply (simp add: alpha4_inj) + + +local_setup {* snd o prove_const_rsp @{binding rLm4_rsp} [@{term rLm4}] + (fn _ => constr_rsp_tac @{thms alpha4_inj} @{thms fv_rtrm4_rsp} @{thms alpha4_equivp} 1) *} +local_setup {* snd o prove_const_rsp @{binding permute_rtrm4_rsp} + [@{term "permute :: perm \ rtrm4 \ rtrm4"}, @{term "permute :: perm \ rtrm4 list \ rtrm4 list"}] + (fn _ => asm_simp_tac (HOL_ss addsimps @{thms alpha4_eqvt}) 1) *} + +thm rtrm4.induct +lemmas trm1_bp_induct = rtrm4.induct[quot_lifted] end diff -r bfd9af005e23 -r 12ce01673188 Nominal/Test.thy --- a/Nominal/Test.thy Tue Mar 02 20:11:56 2010 +0100 +++ b/Nominal/Test.thy Tue Mar 02 20:14:21 2010 +0100 @@ -71,6 +71,8 @@ text {* example 1 *} +(* ML {* set show_hyps *} *) + nominal_datatype lam = VAR "name" | APP "lam" "lam" @@ -147,11 +149,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 *) @@ -205,6 +209,7 @@ (* 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"