src/HOL/Nominal/nominal_atoms.ML
changeset 69597 ff784d5a5bfb
parent 63352 4eaf35781b23
child 74561 8e6c973003c8
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
    84 
    84 
    85 fun mk_permT T = HOLogic.listT (HOLogic.mk_prodT (T, T));
    85 fun mk_permT T = HOLogic.listT (HOLogic.mk_prodT (T, T));
    86 
    86 
    87 fun mk_Cons x xs =
    87 fun mk_Cons x xs =
    88   let val T = fastype_of x
    88   let val T = fastype_of x
    89   in Const (@{const_name Cons}, T --> HOLogic.listT T --> HOLogic.listT T) $ x $ xs end;
    89   in Const (\<^const_name>\<open>Cons\<close>, T --> HOLogic.listT T --> HOLogic.listT T) $ x $ xs end;
    90 
    90 
    91 fun add_thms_string args = Global_Theory.add_thms ((map o apfst o apfst) Binding.name args);
    91 fun add_thms_string args = Global_Theory.add_thms ((map o apfst o apfst) Binding.name args);
    92 fun add_thmss_string args = Global_Theory.add_thmss ((map o apfst o apfst) Binding.name args);
    92 fun add_thmss_string args = Global_Theory.add_thmss ((map o apfst o apfst) Binding.name args);
    93 
    93 
    94 (* this function sets up all matters related to atom-  *)
    94 (* this function sets up all matters related to atom-  *)
    97 fun create_nom_typedecls ak_names thy =
    97 fun create_nom_typedecls ak_names thy =
    98   let
    98   let
    99     
    99     
   100     val (_,thy1) = 
   100     val (_,thy1) = 
   101     fold_map (fn ak => fn thy => 
   101     fold_map (fn ak => fn thy => 
   102           let val dt = ((Binding.name ak, [], NoSyn), [(Binding.name ak, [@{typ nat}], NoSyn)])
   102           let val dt = ((Binding.name ak, [], NoSyn), [(Binding.name ak, [\<^typ>\<open>nat\<close>], NoSyn)])
   103               val (dt_names, thy1) = BNF_LFP_Compat.add_datatype [BNF_LFP_Compat.Kill_Type_Args] [dt] thy;
   103               val (dt_names, thy1) = BNF_LFP_Compat.add_datatype [BNF_LFP_Compat.Kill_Type_Args] [dt] thy;
   104             
   104             
   105               val injects = maps (#inject o BNF_LFP_Compat.the_info thy1 []) dt_names;
   105               val injects = maps (#inject o BNF_LFP_Compat.the_info thy1 []) dt_names;
   106               val ak_type = Type (Sign.intern_type thy1 ak,[])
   106               val ak_type = Type (Sign.intern_type thy1 ak,[])
   107               val ak_sign = Sign.intern_const thy1 ak 
   107               val ak_sign = Sign.intern_const thy1 ak 
   108               
   108               
   109               val inj_type = @{typ nat} --> ak_type
   109               val inj_type = \<^typ>\<open>nat\<close> --> ak_type
   110               val inj_on_type = inj_type --> @{typ "nat set"} --> @{typ bool}
   110               val inj_on_type = inj_type --> \<^typ>\<open>nat set\<close> --> \<^typ>\<open>bool\<close>
   111 
   111 
   112               (* first statement *)
   112               (* first statement *)
   113               val stmnt1 = HOLogic.mk_Trueprop 
   113               val stmnt1 = HOLogic.mk_Trueprop 
   114                   (Const (@{const_name "inj_on"},inj_on_type) $ 
   114                   (Const (\<^const_name>\<open>inj_on\<close>,inj_on_type) $ 
   115                          Const (ak_sign,inj_type) $ HOLogic.mk_UNIV @{typ nat})
   115                          Const (ak_sign,inj_type) $ HOLogic.mk_UNIV \<^typ>\<open>nat\<close>)
   116 
   116 
   117               val simp1 = @{thm inj_on_def} :: injects;
   117               val simp1 = @{thm inj_on_def} :: injects;
   118               
   118               
   119               fun proof1 ctxt = EVERY [simp_tac (put_simpset HOL_basic_ss ctxt addsimps simp1) 1,
   119               fun proof1 ctxt = EVERY [simp_tac (put_simpset HOL_basic_ss ctxt addsimps simp1) 1,
   120                 resolve_tac ctxt @{thms ballI} 1,
   120                 resolve_tac ctxt @{thms ballI} 1,
   126                    add_thms_string [((ak^"_inj",Goal.prove_global thy1 [] [] stmnt1 (proof1 o #context)), [])] thy1
   126                    add_thms_string [((ak^"_inj",Goal.prove_global thy1 [] [] stmnt1 (proof1 o #context)), [])] thy1
   127               
   127               
   128               (* second statement *)
   128               (* second statement *)
   129               val y = Free ("y",ak_type)  
   129               val y = Free ("y",ak_type)  
   130               val stmnt2 = HOLogic.mk_Trueprop
   130               val stmnt2 = HOLogic.mk_Trueprop
   131                   (HOLogic.mk_exists ("x",@{typ nat},HOLogic.mk_eq (y,Const (ak_sign,inj_type) $ Bound 0)))
   131                   (HOLogic.mk_exists ("x",\<^typ>\<open>nat\<close>,HOLogic.mk_eq (y,Const (ak_sign,inj_type) $ Bound 0)))
   132 
   132 
   133               val proof2 = fn {prems, context = ctxt} =>
   133               val proof2 = fn {prems, context = ctxt} =>
   134                 Induct_Tacs.case_tac ctxt "y" [] NONE 1 THEN
   134                 Induct_Tacs.case_tac ctxt "y" [] NONE 1 THEN
   135                 asm_simp_tac (put_simpset HOL_basic_ss ctxt addsimps simp1) 1 THEN
   135                 asm_simp_tac (put_simpset HOL_basic_ss ctxt addsimps simp1) 1 THEN
   136                 resolve_tac ctxt @{thms exI} 1 THEN
   136                 resolve_tac ctxt @{thms exI} 1 THEN
   140               val (inject_thm,thy3) =
   140               val (inject_thm,thy3) =
   141                   add_thms_string [((ak^"_injection",Goal.prove_global thy2 [] [] stmnt2 proof2), [])] thy2
   141                   add_thms_string [((ak^"_injection",Goal.prove_global thy2 [] [] stmnt2 proof2), [])] thy2
   142   
   142   
   143               val stmnt3 = HOLogic.mk_Trueprop
   143               val stmnt3 = HOLogic.mk_Trueprop
   144                            (HOLogic.mk_not
   144                            (HOLogic.mk_not
   145                               (Const (@{const_name finite}, HOLogic.mk_setT ak_type --> HOLogic.boolT) $
   145                               (Const (\<^const_name>\<open>finite\<close>, HOLogic.mk_setT ak_type --> HOLogic.boolT) $
   146                                   HOLogic.mk_UNIV ak_type))
   146                                   HOLogic.mk_UNIV ak_type))
   147              
   147              
   148               val simp2 = [@{thm image_def},@{thm bex_UNIV}]@inject_thm
   148               val simp2 = [@{thm image_def},@{thm bex_UNIV}]@inject_thm
   149               val simp3 = [@{thm UNIV_def}]
   149               val simp3 = [@{thm UNIV_def}]
   150 
   150 
   177         val full_swap_name = Sign.full_bname thy' swap_name;
   177         val full_swap_name = Sign.full_bname thy' swap_name;
   178         val a = Free ("a", T);
   178         val a = Free ("a", T);
   179         val b = Free ("b", T);
   179         val b = Free ("b", T);
   180         val c = Free ("c", T);
   180         val c = Free ("c", T);
   181         val ab = Free ("ab", HOLogic.mk_prodT (T, T))
   181         val ab = Free ("ab", HOLogic.mk_prodT (T, T))
   182         val cif = Const (@{const_name If}, HOLogic.boolT --> T --> T --> T);
   182         val cif = Const (\<^const_name>\<open>If\<close>, HOLogic.boolT --> T --> T --> T);
   183         val cswap_akname = Const (full_swap_name, swapT);
   183         val cswap_akname = Const (full_swap_name, swapT);
   184         val cswap = Const (@{const_name Nominal.swap}, swapT)
   184         val cswap = Const (\<^const_name>\<open>Nominal.swap\<close>, swapT)
   185 
   185 
   186         val name = swap_name ^ "_def";
   186         val name = swap_name ^ "_def";
   187         val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   187         val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   188                 (Free (swap_name, swapT) $ HOLogic.mk_prod (a,b) $ c,
   188                 (Free (swap_name, swapT) $ HOLogic.mk_prod (a,b) $ c,
   189                     cif $ HOLogic.mk_eq (a,c) $ b $ (cif $ HOLogic.mk_eq (b,c) $ a $ c)))
   189                     cif $ HOLogic.mk_eq (a,c) $ b $ (cif $ HOLogic.mk_eq (b,c) $ a $ c)))
   213         val prm = Free (prm_name, prmT);
   213         val prm = Free (prm_name, prmT);
   214         val x  = Free ("x", HOLogic.mk_prodT (T, T));
   214         val x  = Free ("x", HOLogic.mk_prodT (T, T));
   215         val xs = Free ("xs", mk_permT T);
   215         val xs = Free ("xs", mk_permT T);
   216         val a  = Free ("a", T) ;
   216         val a  = Free ("a", T) ;
   217 
   217 
   218         val cnil  = Const (@{const_name Nil}, mk_permT T);
   218         val cnil  = Const (\<^const_name>\<open>Nil\<close>, mk_permT T);
   219         
   219         
   220         val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq (prm $ cnil $ a, a));
   220         val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq (prm $ cnil $ a, a));
   221 
   221 
   222         val def2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   222         val def2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   223                    (prm $ mk_Cons x xs $ a,
   223                    (prm $ mk_Cons x xs $ a,
   243       fold_map (fn (ak_name', T') => fn thy' =>
   243       fold_map (fn (ak_name', T') => fn thy' =>
   244         let
   244         let
   245           val perm_def_name = ak_name ^ "_prm_" ^ ak_name';
   245           val perm_def_name = ak_name ^ "_prm_" ^ ak_name';
   246           val pi = Free ("pi", mk_permT T);
   246           val pi = Free ("pi", mk_permT T);
   247           val a  = Free ("a", T');
   247           val a  = Free ("a", T');
   248           val cperm = Const (@{const_name Nominal.perm}, mk_permT T --> T' --> T');
   248           val cperm = Const (\<^const_name>\<open>Nominal.perm\<close>, mk_permT T --> T' --> T');
   249           val thy'' = Sign.add_path "rec" thy'
   249           val thy'' = Sign.add_path "rec" thy'
   250           val cperm_def = Const (Sign.full_bname thy'' perm_def_name, mk_permT T --> T' --> T');
   250           val cperm_def = Const (Sign.full_bname thy'' perm_def_name, mk_permT T --> T' --> T');
   251           val thy''' = Sign.parent_path thy'';
   251           val thy''' = Sign.parent_path thy'';
   252 
   252 
   253           val name = ak_name ^ "_prm_" ^ ak_name' ^ "_def";
   253           val name = ak_name ^ "_prm_" ^ ak_name' ^ "_def";
   263     val (prm_cons_thms,thy6) = 
   263     val (prm_cons_thms,thy6) = 
   264       thy5 |> add_thms_string (map (fn (ak_name, T) =>
   264       thy5 |> add_thms_string (map (fn (ak_name, T) =>
   265       let
   265       let
   266         val ak_name_qu = Sign.full_bname thy5 (ak_name);
   266         val ak_name_qu = Sign.full_bname thy5 (ak_name);
   267         val i_type = Type(ak_name_qu,[]);
   267         val i_type = Type(ak_name_qu,[]);
   268         val cat = Const (@{const_name Nominal.at}, Term.itselfT i_type --> HOLogic.boolT);
   268         val cat = Const (\<^const_name>\<open>Nominal.at\<close>, Term.itselfT i_type --> HOLogic.boolT);
   269         val at_type = Logic.mk_type i_type;
   269         val at_type = Logic.mk_type i_type;
   270         fun proof ctxt =
   270         fun proof ctxt =
   271           simp_tac (put_simpset HOL_ss ctxt
   271           simp_tac (put_simpset HOL_ss ctxt
   272             addsimps maps (Global_Theory.get_thms thy5)
   272             addsimps maps (Global_Theory.get_thms thy5)
   273                                   ["at_def",
   273                                   ["at_def",
   288     (* pt_<ak>2:       perm (pi1@pi2) x = perm pi1 (perm pi2 x)  *)
   288     (* pt_<ak>2:       perm (pi1@pi2) x = perm pi1 (perm pi2 x)  *)
   289     (* pt_<ak>3:       pi1 ~ pi2 ==> perm pi1 x = perm pi2 x     *)
   289     (* pt_<ak>3:       pi1 ~ pi2 ==> perm pi1 x = perm pi2 x     *)
   290      val (pt_ax_classes,thy7) =  fold_map (fn (ak_name, T) => fn thy =>
   290      val (pt_ax_classes,thy7) =  fold_map (fn (ak_name, T) => fn thy =>
   291       let 
   291       let 
   292           val cl_name = "pt_"^ak_name;
   292           val cl_name = "pt_"^ak_name;
   293           val ty = TFree("'a", @{sort type});
   293           val ty = TFree("'a", \<^sort>\<open>type\<close>);
   294           val x   = Free ("x", ty);
   294           val x   = Free ("x", ty);
   295           val pi1 = Free ("pi1", mk_permT T);
   295           val pi1 = Free ("pi1", mk_permT T);
   296           val pi2 = Free ("pi2", mk_permT T);
   296           val pi2 = Free ("pi2", mk_permT T);
   297           val cperm = Const (@{const_name Nominal.perm}, mk_permT T --> ty --> ty);
   297           val cperm = Const (\<^const_name>\<open>Nominal.perm\<close>, mk_permT T --> ty --> ty);
   298           val cnil  = Const (@{const_name Nil}, mk_permT T);
   298           val cnil  = Const (\<^const_name>\<open>Nil\<close>, mk_permT T);
   299           val cappend = Const (@{const_name append}, mk_permT T --> mk_permT T --> mk_permT T);
   299           val cappend = Const (\<^const_name>\<open>append\<close>, mk_permT T --> mk_permT T --> mk_permT T);
   300           val cprm_eq = Const (@{const_name Nominal.prm_eq}, mk_permT T --> mk_permT T --> HOLogic.boolT);
   300           val cprm_eq = Const (\<^const_name>\<open>Nominal.prm_eq\<close>, mk_permT T --> mk_permT T --> HOLogic.boolT);
   301           (* nil axiom *)
   301           (* nil axiom *)
   302           val axiom1 = HOLogic.mk_Trueprop (HOLogic.mk_eq 
   302           val axiom1 = HOLogic.mk_Trueprop (HOLogic.mk_eq 
   303                        (cperm $ cnil $ x, x));
   303                        (cperm $ cnil $ x, x));
   304           (* append axiom *)
   304           (* append axiom *)
   305           val axiom2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   305           val axiom2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
   307           (* perm-eq axiom *)
   307           (* perm-eq axiom *)
   308           val axiom3 = Logic.mk_implies
   308           val axiom3 = Logic.mk_implies
   309                        (HOLogic.mk_Trueprop (cprm_eq $ pi1 $ pi2),
   309                        (HOLogic.mk_Trueprop (cprm_eq $ pi1 $ pi2),
   310                         HOLogic.mk_Trueprop (HOLogic.mk_eq (cperm $ pi1 $ x, cperm $ pi2 $ x)));
   310                         HOLogic.mk_Trueprop (HOLogic.mk_eq (cperm $ pi1 $ x, cperm $ pi2 $ x)));
   311       in
   311       in
   312           Axclass.define_class (Binding.name cl_name, @{sort type}) []
   312           Axclass.define_class (Binding.name cl_name, \<^sort>\<open>type\<close>) []
   313                 [((Binding.name (cl_name ^ "1"), [Simplifier.simp_add]), [axiom1]),
   313                 [((Binding.name (cl_name ^ "1"), [Simplifier.simp_add]), [axiom1]),
   314                  ((Binding.name (cl_name ^ "2"), []), [axiom2]),                           
   314                  ((Binding.name (cl_name ^ "2"), []), [axiom2]),                           
   315                  ((Binding.name (cl_name ^ "3"), []), [axiom3])] thy
   315                  ((Binding.name (cl_name ^ "3"), []), [axiom3])] thy
   316       end) ak_names_types thy6;
   316       end) ak_names_types thy6;
   317 
   317 
   325         val ak_name_qu = Sign.full_bname thy7 ak_name;
   325         val ak_name_qu = Sign.full_bname thy7 ak_name;
   326         val pt_name_qu = Sign.full_bname thy7 ("pt_"^ak_name);
   326         val pt_name_qu = Sign.full_bname thy7 ("pt_"^ak_name);
   327         val i_type1 = TFree("'x",[pt_name_qu]);
   327         val i_type1 = TFree("'x",[pt_name_qu]);
   328         val i_type2 = Type(ak_name_qu,[]);
   328         val i_type2 = Type(ak_name_qu,[]);
   329         val cpt =
   329         val cpt =
   330           Const (@{const_name Nominal.pt}, (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   330           Const (\<^const_name>\<open>Nominal.pt\<close>, (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   331         val pt_type = Logic.mk_type i_type1;
   331         val pt_type = Logic.mk_type i_type1;
   332         val at_type = Logic.mk_type i_type2;
   332         val at_type = Logic.mk_type i_type2;
   333         fun proof ctxt =
   333         fun proof ctxt =
   334           simp_tac (put_simpset HOL_ss ctxt addsimps maps (Global_Theory.get_thms thy7)
   334           simp_tac (put_simpset HOL_ss ctxt addsimps maps (Global_Theory.get_thms thy7)
   335                                   ["pt_def",
   335                                   ["pt_def",
   348      (* fs_<ak>1: finite ((supp x)::<ak> set)            *)
   348      (* fs_<ak>1: finite ((supp x)::<ak> set)            *)
   349      val (fs_ax_classes,thy11) =  fold_map (fn (ak_name, T) => fn thy =>
   349      val (fs_ax_classes,thy11) =  fold_map (fn (ak_name, T) => fn thy =>
   350        let 
   350        let 
   351           val cl_name = "fs_"^ak_name;
   351           val cl_name = "fs_"^ak_name;
   352           val pt_name = Sign.full_bname thy ("pt_"^ak_name);
   352           val pt_name = Sign.full_bname thy ("pt_"^ak_name);
   353           val ty = TFree("'a",@{sort type});
   353           val ty = TFree("'a",\<^sort>\<open>type\<close>);
   354           val x   = Free ("x", ty);
   354           val x   = Free ("x", ty);
   355           val csupp    = Const (@{const_name Nominal.supp}, ty --> HOLogic.mk_setT T);
   355           val csupp    = Const (\<^const_name>\<open>Nominal.supp\<close>, ty --> HOLogic.mk_setT T);
   356           val cfinite  = Const (@{const_name finite}, HOLogic.mk_setT T --> HOLogic.boolT)
   356           val cfinite  = Const (\<^const_name>\<open>finite\<close>, HOLogic.mk_setT T --> HOLogic.boolT)
   357           
   357           
   358           val axiom1   = HOLogic.mk_Trueprop (cfinite $ (csupp $ x));
   358           val axiom1   = HOLogic.mk_Trueprop (cfinite $ (csupp $ x));
   359 
   359 
   360        in  
   360        in  
   361         Axclass.define_class (Binding.name cl_name, [pt_name]) []
   361         Axclass.define_class (Binding.name cl_name, [pt_name]) []
   371        let
   371        let
   372          val ak_name_qu = Sign.full_bname thy11 ak_name;
   372          val ak_name_qu = Sign.full_bname thy11 ak_name;
   373          val fs_name_qu = Sign.full_bname thy11 ("fs_"^ak_name);
   373          val fs_name_qu = Sign.full_bname thy11 ("fs_"^ak_name);
   374          val i_type1 = TFree("'x",[fs_name_qu]);
   374          val i_type1 = TFree("'x",[fs_name_qu]);
   375          val i_type2 = Type(ak_name_qu,[]);
   375          val i_type2 = Type(ak_name_qu,[]);
   376          val cfs = Const (@{const_name Nominal.fs},
   376          val cfs = Const (\<^const_name>\<open>Nominal.fs\<close>,
   377                                  (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   377                                  (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   378          val fs_type = Logic.mk_type i_type1;
   378          val fs_type = Logic.mk_type i_type1;
   379          val at_type = Logic.mk_type i_type2;
   379          val at_type = Logic.mk_type i_type2;
   380          fun proof ctxt =
   380          fun proof ctxt =
   381           simp_tac (put_simpset HOL_ss ctxt addsimps maps (Global_Theory.get_thms thy11)
   381           simp_tac (put_simpset HOL_ss ctxt addsimps maps (Global_Theory.get_thms thy11)
   393        (* cp_<ak1>_<ak2>1: pi1 o pi2 o x = (pi1 o pi2) o (pi1 o x)       *)
   393        (* cp_<ak1>_<ak2>1: pi1 o pi2 o x = (pi1 o pi2) o (pi1 o x)       *)
   394         val (cp_ax_classes,thy12b) = fold_map (fn (ak_name, T) => fn thy =>
   394         val (cp_ax_classes,thy12b) = fold_map (fn (ak_name, T) => fn thy =>
   395          fold_map (fn (ak_name', T') => fn thy' =>
   395          fold_map (fn (ak_name', T') => fn thy' =>
   396              let
   396              let
   397                val cl_name = "cp_"^ak_name^"_"^ak_name';
   397                val cl_name = "cp_"^ak_name^"_"^ak_name';
   398                val ty = TFree("'a",@{sort type});
   398                val ty = TFree("'a",\<^sort>\<open>type\<close>);
   399                val x   = Free ("x", ty);
   399                val x   = Free ("x", ty);
   400                val pi1 = Free ("pi1", mk_permT T);
   400                val pi1 = Free ("pi1", mk_permT T);
   401                val pi2 = Free ("pi2", mk_permT T');                  
   401                val pi2 = Free ("pi2", mk_permT T');                  
   402                val cperm1 = Const (@{const_name Nominal.perm}, mk_permT T  --> ty --> ty);
   402                val cperm1 = Const (\<^const_name>\<open>Nominal.perm\<close>, mk_permT T  --> ty --> ty);
   403                val cperm2 = Const (@{const_name Nominal.perm}, mk_permT T' --> ty --> ty);
   403                val cperm2 = Const (\<^const_name>\<open>Nominal.perm\<close>, mk_permT T' --> ty --> ty);
   404                val cperm3 = Const (@{const_name Nominal.perm}, mk_permT T  --> mk_permT T' --> mk_permT T');
   404                val cperm3 = Const (\<^const_name>\<open>Nominal.perm\<close>, mk_permT T  --> mk_permT T' --> mk_permT T');
   405 
   405 
   406                val ax1   = HOLogic.mk_Trueprop 
   406                val ax1   = HOLogic.mk_Trueprop 
   407                            (HOLogic.mk_eq (cperm1 $ pi1 $ (cperm2 $ pi2 $ x), 
   407                            (HOLogic.mk_eq (cperm1 $ pi1 $ (cperm2 $ pi2 $ x), 
   408                                            cperm2 $ (cperm3 $ pi1 $ pi2) $ (cperm1 $ pi1 $ x)));
   408                                            cperm2 $ (cperm3 $ pi1 $ pi2) $ (cperm1 $ pi1 $ x)));
   409                in  
   409                in  
   410                  Axclass.define_class (Binding.name cl_name, @{sort type}) []
   410                  Axclass.define_class (Binding.name cl_name, \<^sort>\<open>type\<close>) []
   411                    [((Binding.name (cl_name ^ "1"), []), [ax1])] thy'  
   411                    [((Binding.name (cl_name ^ "1"), []), [ax1])] thy'  
   412                end) ak_names_types thy) ak_names_types thy12;
   412                end) ak_names_types thy) ak_names_types thy12;
   413 
   413 
   414         (* proves for every <ak>-combination a cp_<ak1>_<ak2>_inst theorem;     *)
   414         (* proves for every <ak>-combination a cp_<ak1>_<ak2>_inst theorem;     *)
   415         (* lemma cp_<ak1>_<ak2>_inst:                                           *)
   415         (* lemma cp_<ak1>_<ak2>_inst:                                           *)
   421              val ak_name_qu' = Sign.full_bname thy' (ak_name');
   421              val ak_name_qu' = Sign.full_bname thy' (ak_name');
   422              val cp_name_qu  = Sign.full_bname thy' ("cp_"^ak_name^"_"^ak_name');
   422              val cp_name_qu  = Sign.full_bname thy' ("cp_"^ak_name^"_"^ak_name');
   423              val i_type0 = TFree("'a",[cp_name_qu]);
   423              val i_type0 = TFree("'a",[cp_name_qu]);
   424              val i_type1 = Type(ak_name_qu,[]);
   424              val i_type1 = Type(ak_name_qu,[]);
   425              val i_type2 = Type(ak_name_qu',[]);
   425              val i_type2 = Type(ak_name_qu',[]);
   426              val ccp = Const (@{const_name Nominal.cp},
   426              val ccp = Const (\<^const_name>\<open>Nominal.cp\<close>,
   427                              (Term.itselfT i_type0)-->(Term.itselfT i_type1)-->
   427                              (Term.itselfT i_type0)-->(Term.itselfT i_type1)-->
   428                                                       (Term.itselfT i_type2)-->HOLogic.boolT);
   428                                                       (Term.itselfT i_type2)-->HOLogic.boolT);
   429              val at_type  = Logic.mk_type i_type1;
   429              val at_type  = Logic.mk_type i_type1;
   430              val at_type' = Logic.mk_type i_type2;
   430              val at_type' = Logic.mk_type i_type2;
   431              val cp_type  = Logic.mk_type i_type0;
   431              val cp_type  = Logic.mk_type i_type0;
   458                let
   458                let
   459                  val ak_name_qu  = Sign.full_bname thy' ak_name;
   459                  val ak_name_qu  = Sign.full_bname thy' ak_name;
   460                  val ak_name_qu' = Sign.full_bname thy' ak_name';
   460                  val ak_name_qu' = Sign.full_bname thy' ak_name';
   461                  val i_type1 = Type(ak_name_qu,[]);
   461                  val i_type1 = Type(ak_name_qu,[]);
   462                  val i_type2 = Type(ak_name_qu',[]);
   462                  val i_type2 = Type(ak_name_qu',[]);
   463                  val cdj = Const (@{const_name Nominal.disjoint},
   463                  val cdj = Const (\<^const_name>\<open>Nominal.disjoint\<close>,
   464                            (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   464                            (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
   465                  val at_type  = Logic.mk_type i_type1;
   465                  val at_type  = Logic.mk_type i_type1;
   466                  val at_type' = Logic.mk_type i_type2;
   466                  val at_type' = Logic.mk_type i_type2;
   467                  fun proof ctxt =
   467                  fun proof ctxt =
   468                   simp_tac (put_simpset HOL_ss ctxt
   468                   simp_tac (put_simpset HOL_ss ctxt
   553           val pt_thm_prod  = pt_inst RS (pt_inst RS pt_prod_inst);
   553           val pt_thm_prod  = pt_inst RS (pt_inst RS pt_prod_inst);
   554           val pt_thm_nprod = pt_inst RS (pt_inst RS pt_nprod_inst);
   554           val pt_thm_nprod = pt_inst RS (pt_inst RS pt_nprod_inst);
   555           val pt_thm_unit  = pt_unit_inst;
   555           val pt_thm_unit  = pt_unit_inst;
   556        in
   556        in
   557         thy
   557         thy
   558         |> Axclass.prove_arity (@{type_name fun},[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_fun)
   558         |> Axclass.prove_arity (\<^type_name>\<open>fun\<close>,[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_fun)
   559         |> Axclass.prove_arity (@{type_name set},[[cls_name]],[cls_name]) (pt_proof pt_thm_set)
   559         |> Axclass.prove_arity (\<^type_name>\<open>set\<close>,[[cls_name]],[cls_name]) (pt_proof pt_thm_set)
   560         |> Axclass.prove_arity (@{type_name noption},[[cls_name]],[cls_name]) (pt_proof pt_thm_noptn) 
   560         |> Axclass.prove_arity (\<^type_name>\<open>noption\<close>,[[cls_name]],[cls_name]) (pt_proof pt_thm_noptn) 
   561         |> Axclass.prove_arity (@{type_name option},[[cls_name]],[cls_name]) (pt_proof pt_thm_optn)
   561         |> Axclass.prove_arity (\<^type_name>\<open>option\<close>,[[cls_name]],[cls_name]) (pt_proof pt_thm_optn)
   562         |> Axclass.prove_arity (@{type_name list},[[cls_name]],[cls_name]) (pt_proof pt_thm_list)
   562         |> Axclass.prove_arity (\<^type_name>\<open>list\<close>,[[cls_name]],[cls_name]) (pt_proof pt_thm_list)
   563         |> Axclass.prove_arity (@{type_name prod},[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_prod)
   563         |> Axclass.prove_arity (\<^type_name>\<open>prod\<close>,[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_prod)
   564         |> Axclass.prove_arity (@{type_name nprod},[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_nprod)
   564         |> Axclass.prove_arity (\<^type_name>\<open>nprod\<close>,[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_nprod)
   565         |> Axclass.prove_arity (@{type_name unit},[],[cls_name]) (pt_proof pt_thm_unit)
   565         |> Axclass.prove_arity (\<^type_name>\<open>unit\<close>,[],[cls_name]) (pt_proof pt_thm_unit)
   566      end) ak_names thy13; 
   566      end) ak_names thy13; 
   567 
   567 
   568        (********  fs_<ak> class instances  ********)
   568        (********  fs_<ak> class instances  ********)
   569        (*=========================================*)
   569        (*=========================================*)
   570        (* abbreviations for some lemmas *)
   570        (* abbreviations for some lemmas *)
   620           val fs_thm_nprod = fs_inst RS (fs_inst RS fs_nprod_inst);
   620           val fs_thm_nprod = fs_inst RS (fs_inst RS fs_nprod_inst);
   621           val fs_thm_list  = fs_inst RS fs_list_inst;
   621           val fs_thm_list  = fs_inst RS fs_list_inst;
   622           val fs_thm_optn  = fs_inst RS fs_option_inst;
   622           val fs_thm_optn  = fs_inst RS fs_option_inst;
   623         in 
   623         in 
   624          thy
   624          thy
   625          |> Axclass.prove_arity (@{type_name unit},[],[cls_name]) (fs_proof fs_thm_unit) 
   625          |> Axclass.prove_arity (\<^type_name>\<open>unit\<close>,[],[cls_name]) (fs_proof fs_thm_unit) 
   626          |> Axclass.prove_arity (@{type_name prod},[[cls_name],[cls_name]],[cls_name]) (fs_proof fs_thm_prod) 
   626          |> Axclass.prove_arity (\<^type_name>\<open>prod\<close>,[[cls_name],[cls_name]],[cls_name]) (fs_proof fs_thm_prod) 
   627          |> Axclass.prove_arity (@{type_name nprod},[[cls_name],[cls_name]],[cls_name]) (fs_proof fs_thm_nprod)
   627          |> Axclass.prove_arity (\<^type_name>\<open>nprod\<close>,[[cls_name],[cls_name]],[cls_name]) (fs_proof fs_thm_nprod)
   628          |> Axclass.prove_arity (@{type_name list},[[cls_name]],[cls_name]) (fs_proof fs_thm_list)
   628          |> Axclass.prove_arity (\<^type_name>\<open>list\<close>,[[cls_name]],[cls_name]) (fs_proof fs_thm_list)
   629          |> Axclass.prove_arity (@{type_name option},[[cls_name]],[cls_name]) (fs_proof fs_thm_optn)
   629          |> Axclass.prove_arity (\<^type_name>\<open>option\<close>,[[cls_name]],[cls_name]) (fs_proof fs_thm_optn)
   630         end) ak_names thy20;
   630         end) ak_names thy20;
   631 
   631 
   632        (********  cp_<ak>_<ai> class instances  ********)
   632        (********  cp_<ak>_<ai> class instances  ********)
   633        (*==============================================*)
   633        (*==============================================*)
   634        (* abbreviations for some lemmas *)
   634        (* abbreviations for some lemmas *)
   704             val cp_thm_optn = cp_inst RS cp_option_inst;
   704             val cp_thm_optn = cp_inst RS cp_option_inst;
   705             val cp_thm_noptn = cp_inst RS cp_noption_inst;
   705             val cp_thm_noptn = cp_inst RS cp_noption_inst;
   706             val cp_thm_set = cp_inst RS cp_set_inst;
   706             val cp_thm_set = cp_inst RS cp_set_inst;
   707         in
   707         in
   708          thy'
   708          thy'
   709          |> Axclass.prove_arity (@{type_name unit},[],[cls_name]) (cp_proof cp_thm_unit)
   709          |> Axclass.prove_arity (\<^type_name>\<open>unit\<close>,[],[cls_name]) (cp_proof cp_thm_unit)
   710          |> Axclass.prove_arity (@{type_name Product_Type.prod}, [[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_prod)
   710          |> Axclass.prove_arity (\<^type_name>\<open>Product_Type.prod\<close>, [[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_prod)
   711          |> Axclass.prove_arity (@{type_name list},[[cls_name]],[cls_name]) (cp_proof cp_thm_list)
   711          |> Axclass.prove_arity (\<^type_name>\<open>list\<close>,[[cls_name]],[cls_name]) (cp_proof cp_thm_list)
   712          |> Axclass.prove_arity (@{type_name fun},[[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_fun)
   712          |> Axclass.prove_arity (\<^type_name>\<open>fun\<close>,[[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_fun)
   713          |> Axclass.prove_arity (@{type_name option},[[cls_name]],[cls_name]) (cp_proof cp_thm_optn)
   713          |> Axclass.prove_arity (\<^type_name>\<open>option\<close>,[[cls_name]],[cls_name]) (cp_proof cp_thm_optn)
   714          |> Axclass.prove_arity (@{type_name noption},[[cls_name]],[cls_name]) (cp_proof cp_thm_noptn)
   714          |> Axclass.prove_arity (\<^type_name>\<open>noption\<close>,[[cls_name]],[cls_name]) (cp_proof cp_thm_noptn)
   715          |> Axclass.prove_arity (@{type_name set},[[cls_name]],[cls_name]) (cp_proof cp_thm_set)
   715          |> Axclass.prove_arity (\<^type_name>\<open>set\<close>,[[cls_name]],[cls_name]) (cp_proof cp_thm_set)
   716         end) ak_names thy) ak_names thy25;
   716         end) ak_names thy) ak_names thy25;
   717 
   717 
   718      (* show that discrete nominal types are permutation types, finitely     *)
   718      (* show that discrete nominal types are permutation types, finitely     *)
   719      (* supported and have the commutation property                          *)
   719      (* supported and have the commutation property                          *)
   720      (* discrete types have a permutation operation defined as pi o x = x;   *)
   720      (* discrete types have a permutation operation defined as pi o x = x;   *)
   757                Axclass.prove_arity (discrete_ty, [], [qu_class]) proof thy
   757                Axclass.prove_arity (discrete_ty, [], [qu_class]) proof thy
   758              end) ak_names)) ak_names;
   758              end) ak_names)) ak_names;
   759 
   759 
   760         in
   760         in
   761          thy26
   761          thy26
   762          |> discrete_pt_inst @{type_name nat} @{thm perm_nat_def}
   762          |> discrete_pt_inst \<^type_name>\<open>nat\<close> @{thm perm_nat_def}
   763          |> discrete_fs_inst @{type_name nat} @{thm perm_nat_def}
   763          |> discrete_fs_inst \<^type_name>\<open>nat\<close> @{thm perm_nat_def}
   764          |> discrete_cp_inst @{type_name nat} @{thm perm_nat_def}
   764          |> discrete_cp_inst \<^type_name>\<open>nat\<close> @{thm perm_nat_def}
   765          |> discrete_pt_inst @{type_name bool} @{thm perm_bool_def}
   765          |> discrete_pt_inst \<^type_name>\<open>bool\<close> @{thm perm_bool_def}
   766          |> discrete_fs_inst @{type_name bool} @{thm perm_bool_def}
   766          |> discrete_fs_inst \<^type_name>\<open>bool\<close> @{thm perm_bool_def}
   767          |> discrete_cp_inst @{type_name bool} @{thm perm_bool_def}
   767          |> discrete_cp_inst \<^type_name>\<open>bool\<close> @{thm perm_bool_def}
   768          |> discrete_pt_inst @{type_name int} @{thm perm_int_def}
   768          |> discrete_pt_inst \<^type_name>\<open>int\<close> @{thm perm_int_def}
   769          |> discrete_fs_inst @{type_name int} @{thm perm_int_def}
   769          |> discrete_fs_inst \<^type_name>\<open>int\<close> @{thm perm_int_def}
   770          |> discrete_cp_inst @{type_name int} @{thm perm_int_def}
   770          |> discrete_cp_inst \<^type_name>\<open>int\<close> @{thm perm_int_def}
   771          |> discrete_pt_inst @{type_name char} @{thm perm_char_def}
   771          |> discrete_pt_inst \<^type_name>\<open>char\<close> @{thm perm_char_def}
   772          |> discrete_fs_inst @{type_name char} @{thm perm_char_def}
   772          |> discrete_fs_inst \<^type_name>\<open>char\<close> @{thm perm_char_def}
   773          |> discrete_cp_inst @{type_name char} @{thm perm_char_def}
   773          |> discrete_cp_inst \<^type_name>\<open>char\<close> @{thm perm_char_def}
   774         end;
   774         end;
   775 
   775 
   776 
   776 
   777        (* abbreviations for some lemmas *)
   777        (* abbreviations for some lemmas *)
   778        (*===============================*)
   778        (*===============================*)
  1025 
  1025 
  1026 
  1026 
  1027 (* syntax und parsing *)
  1027 (* syntax und parsing *)
  1028 
  1028 
  1029 val _ =
  1029 val _ =
  1030   Outer_Syntax.command @{command_keyword atom_decl} "declare new kinds of atoms"
  1030   Outer_Syntax.command \<^command_keyword>\<open>atom_decl\<close> "declare new kinds of atoms"
  1031     (Scan.repeat1 Parse.name >> (Toplevel.theory o create_nom_typedecls));
  1031     (Scan.repeat1 Parse.name >> (Toplevel.theory o create_nom_typedecls));
  1032 
  1032 
  1033 end;
  1033 end;