src/HOL/Nominal/nominal_atoms.ML
author berghofe
Thu Sep 13 18:08:08 2007 +0200 (2007-09-13)
changeset 24569 c80e1871098b
parent 24527 888d56a8d9d3
child 24677 c6295d2dce48
permissions -rw-r--r--
Added equivariance lemmas for induct_forall.
berghofe@19494
     1
(*  Title:      HOL/Nominal/nominal_atoms.ML
berghofe@19494
     2
    ID:         $Id$
berghofe@19494
     3
    Author:     Christian Urban and Stefan Berghofer, TU Muenchen
berghofe@19494
     4
berghofe@19494
     5
Declaration of atom types to be used in nominal datatypes.
berghofe@19494
     6
*)
berghofe@18068
     7
berghofe@18068
     8
signature NOMINAL_ATOMS =
berghofe@18068
     9
sig
berghofe@18068
    10
  val create_nom_typedecls : string list -> theory -> theory
urbanc@22418
    11
  type atom_info
urbanc@22418
    12
  val get_atom_infos : theory -> atom_info Symtab.table
urbanc@22418
    13
  val get_atom_info : theory -> string -> atom_info option
berghofe@18068
    14
  val atoms_of : theory -> string list
berghofe@18068
    15
  val mk_permT : typ -> typ
berghofe@18068
    16
end
berghofe@18068
    17
berghofe@18068
    18
structure NominalAtoms : NOMINAL_ATOMS =
berghofe@18068
    19
struct
berghofe@18068
    20
wenzelm@23894
    21
val finite_emptyI = @{thm "finite.emptyI"};
wenzelm@23894
    22
val Collect_const = @{thm "Collect_const"};
wenzelm@21669
    23
berghofe@24569
    24
val inductive_forall_def = @{thm "induct_forall_def"};
berghofe@24569
    25
wenzelm@21669
    26
wenzelm@22846
    27
(* theory data *)
berghofe@18068
    28
urbanc@22418
    29
type atom_info =
urbanc@22418
    30
  {pt_class : string,
urbanc@22418
    31
   fs_class : string,
urbanc@22418
    32
   cp_classes : (string * string) list};
urbanc@22418
    33
wenzelm@22846
    34
structure NominalData = TheoryDataFun
wenzelm@22846
    35
(
urbanc@22418
    36
  type T = atom_info Symtab.table;
berghofe@18068
    37
  val empty = Symtab.empty;
berghofe@18068
    38
  val copy = I;
berghofe@18068
    39
  val extend = I;
berghofe@18068
    40
  fun merge _ x = Symtab.merge (K true) x;
wenzelm@22846
    41
);
berghofe@18068
    42
urbanc@22418
    43
fun make_atom_info ((pt_class, fs_class), cp_classes) =
urbanc@22418
    44
  {pt_class = pt_class,
urbanc@22418
    45
   fs_class = fs_class,
urbanc@22418
    46
   cp_classes = cp_classes};
urbanc@22418
    47
urbanc@22418
    48
val get_atom_infos = NominalData.get;
urbanc@22418
    49
val get_atom_info = Symtab.lookup o NominalData.get;
urbanc@22418
    50
berghofe@18068
    51
fun atoms_of thy = map fst (Symtab.dest (NominalData.get thy));
berghofe@18068
    52
webertj@20097
    53
fun mk_permT T = HOLogic.listT (HOLogic.mk_prodT (T, T));
berghofe@18068
    54
berghofe@18068
    55
fun mk_Cons x xs =
berghofe@18068
    56
  let val T = fastype_of x
webertj@20097
    57
  in Const ("List.list.Cons", T --> HOLogic.listT T --> HOLogic.listT T) $ x $ xs end;
berghofe@18068
    58
berghofe@18068
    59
berghofe@18068
    60
(* this function sets up all matters related to atom-  *)
berghofe@18068
    61
(* kinds; the user specifies a list of atom-kind names *)
berghofe@18068
    62
(* atom_decl <ak1> ... <akn>                           *)
berghofe@18068
    63
fun create_nom_typedecls ak_names thy =
berghofe@18068
    64
  let
urbanc@24527
    65
    
berghofe@18068
    66
    (* declares a type-decl for every atom-kind: *) 
berghofe@18068
    67
    (* that is typedecl <ak>                     *)
berghofe@18068
    68
    val thy1 = TypedefPackage.add_typedecls (map (fn x => (x,[],NoSyn)) ak_names) thy;
berghofe@18068
    69
    
berghofe@18068
    70
    (* produces a list consisting of pairs:         *)
berghofe@18068
    71
    (*  fst component is the atom-kind name         *)
berghofe@18068
    72
    (*  snd component is its type                   *)
urbanc@21289
    73
    val full_ak_names = map (Sign.intern_type thy1) ak_names;
berghofe@18068
    74
    val ak_names_types = ak_names ~~ map (Type o rpair []) full_ak_names;
berghofe@18068
    75
     
berghofe@18068
    76
    (* adds for every atom-kind an axiom             *)
berghofe@18068
    77
    (* <ak>_infinite: infinite (UNIV::<ak_type> set) *)
urbanc@18381
    78
    val (inf_axs,thy2) = PureThy.add_axioms_i (map (fn (ak_name, T) =>
berghofe@18068
    79
      let 
haftmann@20179
    80
    val name = ak_name ^ "_infinite"
berghofe@18068
    81
        val axiom = HOLogic.mk_Trueprop (HOLogic.mk_not
berghofe@22274
    82
                    (Const ("Finite_Set.finite", HOLogic.mk_setT T --> HOLogic.boolT) $
berghofe@22274
    83
                       HOLogic.mk_UNIV T))
berghofe@18068
    84
      in
haftmann@20179
    85
        ((name, axiom), []) 
berghofe@18068
    86
      end) ak_names_types) thy1;
berghofe@18068
    87
    
berghofe@18068
    88
    (* declares a swapping function for every atom-kind, it is         *)
berghofe@18068
    89
    (* const swap_<ak> :: <akT> * <akT> => <akT> => <akT>              *)
berghofe@18068
    90
    (* swap_<ak> (a,b) c = (if a=c then b (else if b=c then a else c)) *)
berghofe@18068
    91
    (* overloades then the general swap-function                       *) 
haftmann@20179
    92
    val (swap_eqs, thy3) = fold_map (fn (ak_name, T) => fn thy =>
berghofe@18068
    93
      let
berghofe@18068
    94
        val swapT = HOLogic.mk_prodT (T, T) --> T --> T;
urbanc@21289
    95
        val swap_name = Sign.full_name thy ("swap_" ^ ak_name);
berghofe@18068
    96
        val a = Free ("a", T);
berghofe@18068
    97
        val b = Free ("b", T);
berghofe@18068
    98
        val c = Free ("c", T);
berghofe@18068
    99
        val ab = Free ("ab", HOLogic.mk_prodT (T, T))
berghofe@18068
   100
        val cif = Const ("HOL.If", HOLogic.boolT --> T --> T --> T);
berghofe@18068
   101
        val cswap_akname = Const (swap_name, swapT);
berghofe@19494
   102
        val cswap = Const ("Nominal.swap", swapT)
berghofe@18068
   103
berghofe@18068
   104
        val name = "swap_"^ak_name^"_def";
berghofe@18068
   105
        val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq
haftmann@20179
   106
                (cswap_akname $ HOLogic.mk_prod (a,b) $ c,
berghofe@18068
   107
                    cif $ HOLogic.mk_eq (a,c) $ b $ (cif $ HOLogic.mk_eq (b,c) $ a $ c)))
berghofe@18068
   108
        val def2 = Logic.mk_equals (cswap $ ab $ c, cswap_akname $ ab $ c)
berghofe@18068
   109
      in
berghofe@18068
   110
        thy |> Theory.add_consts_i [("swap_" ^ ak_name, swapT, NoSyn)] 
haftmann@20179
   111
            |> PureThy.add_defs_unchecked_i true [((name, def2),[])]
haftmann@20179
   112
            |> snd
haftmann@20179
   113
            |> PrimrecPackage.add_primrec_unchecked_i "" [(("", def1),[])]
haftmann@20179
   114
      end) ak_names_types thy2;
berghofe@18068
   115
    
berghofe@18068
   116
    (* declares a permutation function for every atom-kind acting  *)
berghofe@18068
   117
    (* on such atoms                                               *)
berghofe@18068
   118
    (* const <ak>_prm_<ak> :: (<akT> * <akT>)list => akT => akT    *)
berghofe@18068
   119
    (* <ak>_prm_<ak> []     a = a                                  *)
berghofe@18068
   120
    (* <ak>_prm_<ak> (x#xs) a = swap_<ak> x (perm xs a)            *)
haftmann@20179
   121
    val (prm_eqs, thy4) = fold_map (fn (ak_name, T) => fn thy =>
berghofe@18068
   122
      let
berghofe@18068
   123
        val swapT = HOLogic.mk_prodT (T, T) --> T --> T;
urbanc@21289
   124
        val swap_name = Sign.full_name thy ("swap_" ^ ak_name)
berghofe@18068
   125
        val prmT = mk_permT T --> T --> T;
berghofe@18068
   126
        val prm_name = ak_name ^ "_prm_" ^ ak_name;
urbanc@21289
   127
        val qu_prm_name = Sign.full_name thy prm_name;
berghofe@18068
   128
        val x  = Free ("x", HOLogic.mk_prodT (T, T));
berghofe@18068
   129
        val xs = Free ("xs", mk_permT T);
berghofe@18068
   130
        val a  = Free ("a", T) ;
berghofe@18068
   131
berghofe@18068
   132
        val cnil  = Const ("List.list.Nil", mk_permT T);
berghofe@18068
   133
        
berghofe@18068
   134
        val def1 = HOLogic.mk_Trueprop (HOLogic.mk_eq (Const (qu_prm_name, prmT) $ cnil $ a, a));
berghofe@18068
   135
berghofe@18068
   136
        val def2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
berghofe@18068
   137
                   (Const (qu_prm_name, prmT) $ mk_Cons x xs $ a,
berghofe@18068
   138
                    Const (swap_name, swapT) $ x $ (Const (qu_prm_name, prmT) $ xs $ a)));
berghofe@18068
   139
      in
berghofe@18068
   140
        thy |> Theory.add_consts_i [(prm_name, mk_permT T --> T --> T, NoSyn)] 
wenzelm@19635
   141
            |> PrimrecPackage.add_primrec_unchecked_i "" [(("", def1), []),(("", def2), [])]
haftmann@20179
   142
      end) ak_names_types thy3;
berghofe@18068
   143
    
berghofe@18068
   144
    (* defines permutation functions for all combinations of atom-kinds; *)
berghofe@18068
   145
    (* there are a trivial cases and non-trivial cases                   *)
berghofe@18068
   146
    (* non-trivial case:                                                 *)
berghofe@18068
   147
    (* <ak>_prm_<ak>_def:  perm pi a == <ak>_prm_<ak> pi a               *)
berghofe@18068
   148
    (* trivial case with <ak> != <ak'>                                   *)
berghofe@18068
   149
    (* <ak>_prm<ak'>_def[simp]:  perm pi a == a                          *)
berghofe@18068
   150
    (*                                                                   *)
berghofe@18068
   151
    (* the trivial cases are added to the simplifier, while the non-     *)
berghofe@18068
   152
    (* have their own rules proved below                                 *)  
berghofe@18366
   153
    val (perm_defs, thy5) = fold_map (fn (ak_name, T) => fn thy =>
berghofe@18366
   154
      fold_map (fn (ak_name', T') => fn thy' =>
berghofe@18068
   155
        let
berghofe@18068
   156
          val perm_def_name = ak_name ^ "_prm_" ^ ak_name';
berghofe@18068
   157
          val pi = Free ("pi", mk_permT T);
berghofe@18068
   158
          val a  = Free ("a", T');
berghofe@19494
   159
          val cperm = Const ("Nominal.perm", mk_permT T --> T' --> T');
urbanc@21289
   160
          val cperm_def = Const (Sign.full_name thy' perm_def_name, mk_permT T --> T' --> T');
berghofe@18068
   161
berghofe@18068
   162
          val name = ak_name ^ "_prm_" ^ ak_name' ^ "_def";
berghofe@18068
   163
          val def = Logic.mk_equals
berghofe@18068
   164
                    (cperm $ pi $ a, if ak_name = ak_name' then cperm_def $ pi $ a else a)
berghofe@18068
   165
        in
wenzelm@19635
   166
          PureThy.add_defs_unchecked_i true [((name, def),[])] thy'
berghofe@18366
   167
        end) ak_names_types thy) ak_names_types thy4;
berghofe@18068
   168
    
berghofe@18068
   169
    (* proves that every atom-kind is an instance of at *)
berghofe@18068
   170
    (* lemma at_<ak>_inst:                              *)
berghofe@18068
   171
    (* at TYPE(<ak>)                                    *)
urbanc@18381
   172
    val (prm_cons_thms,thy6) = 
berghofe@18068
   173
      thy5 |> PureThy.add_thms (map (fn (ak_name, T) =>
berghofe@18068
   174
      let
urbanc@21289
   175
        val ak_name_qu = Sign.full_name thy5 (ak_name);
berghofe@18068
   176
        val i_type = Type(ak_name_qu,[]);
berghofe@19494
   177
	val cat = Const ("Nominal.at",(Term.itselfT i_type)  --> HOLogic.boolT);
berghofe@18068
   178
        val at_type = Logic.mk_type i_type;
urbanc@24527
   179
        val simp_s = HOL_ss addsimps PureThy.get_thmss thy5
berghofe@18068
   180
                                  [Name "at_def",
berghofe@18068
   181
                                   Name (ak_name ^ "_prm_" ^ ak_name ^ "_def"),
berghofe@18068
   182
                                   Name (ak_name ^ "_prm_" ^ ak_name ^ ".simps"),
berghofe@18068
   183
                                   Name ("swap_" ^ ak_name ^ "_def"),
berghofe@18068
   184
                                   Name ("swap_" ^ ak_name ^ ".simps"),
berghofe@18068
   185
                                   Name (ak_name ^ "_infinite")]
berghofe@18068
   186
	    
berghofe@18068
   187
	val name = "at_"^ak_name^ "_inst";
berghofe@18068
   188
        val statement = HOLogic.mk_Trueprop (cat $ at_type);
berghofe@18068
   189
urbanc@24527
   190
        val proof = fn _ => simp_tac simp_s 1
berghofe@18068
   191
berghofe@18068
   192
      in 
wenzelm@20046
   193
        ((name, Goal.prove_global thy5 [] [] statement proof), []) 
berghofe@18068
   194
      end) ak_names_types);
berghofe@18068
   195
berghofe@18068
   196
    (* declares a perm-axclass for every atom-kind               *)
berghofe@18068
   197
    (* axclass pt_<ak>                                           *)
berghofe@18068
   198
    (* pt_<ak>1[simp]: perm [] x = x                             *)
berghofe@18068
   199
    (* pt_<ak>2:       perm (pi1@pi2) x = perm pi1 (perm pi2 x)  *)
berghofe@18068
   200
    (* pt_<ak>3:       pi1 ~ pi2 ==> perm pi1 x = perm pi2 x     *)
urbanc@18438
   201
     val (pt_ax_classes,thy7) =  fold_map (fn (ak_name, T) => fn thy =>
berghofe@18068
   202
      let 
berghofe@18068
   203
	  val cl_name = "pt_"^ak_name;
berghofe@18068
   204
          val ty = TFree("'a",["HOL.type"]);
berghofe@18068
   205
          val x   = Free ("x", ty);
berghofe@18068
   206
          val pi1 = Free ("pi1", mk_permT T);
berghofe@18068
   207
          val pi2 = Free ("pi2", mk_permT T);
berghofe@19494
   208
          val cperm = Const ("Nominal.perm", mk_permT T --> ty --> ty);
berghofe@18068
   209
          val cnil  = Const ("List.list.Nil", mk_permT T);
haftmann@23029
   210
          val cappend = Const ("List.append",mk_permT T --> mk_permT T --> mk_permT T);
berghofe@19494
   211
          val cprm_eq = Const ("Nominal.prm_eq",mk_permT T --> mk_permT T --> HOLogic.boolT);
berghofe@18068
   212
          (* nil axiom *)
berghofe@18068
   213
          val axiom1 = HOLogic.mk_Trueprop (HOLogic.mk_eq 
berghofe@18068
   214
                       (cperm $ cnil $ x, x));
berghofe@18068
   215
          (* append axiom *)
berghofe@18068
   216
          val axiom2 = HOLogic.mk_Trueprop (HOLogic.mk_eq
berghofe@18068
   217
                       (cperm $ (cappend $ pi1 $ pi2) $ x, cperm $ pi1 $ (cperm $ pi2 $ x)));
berghofe@18068
   218
          (* perm-eq axiom *)
berghofe@18068
   219
          val axiom3 = Logic.mk_implies
berghofe@18068
   220
                       (HOLogic.mk_Trueprop (cprm_eq $ pi1 $ pi2),
berghofe@18068
   221
                        HOLogic.mk_Trueprop (HOLogic.mk_eq (cperm $ pi1 $ x, cperm $ pi2 $ x)));
berghofe@18068
   222
      in
haftmann@22745
   223
          AxClass.define_class (cl_name, ["HOL.type"]) []
berghofe@19488
   224
                [((cl_name ^ "1", [Simplifier.simp_add]), [axiom1]),
berghofe@19488
   225
                 ((cl_name ^ "2", []), [axiom2]),                           
berghofe@19488
   226
                 ((cl_name ^ "3", []), [axiom3])] thy                          
urbanc@18438
   227
      end) ak_names_types thy6;
berghofe@18068
   228
berghofe@18068
   229
    (* proves that every pt_<ak>-type together with <ak>-type *)
berghofe@18068
   230
    (* instance of pt                                         *)
berghofe@18068
   231
    (* lemma pt_<ak>_inst:                                    *)
berghofe@18068
   232
    (* pt TYPE('x::pt_<ak>) TYPE(<ak>)                        *)
urbanc@18381
   233
    val (prm_inst_thms,thy8) = 
berghofe@18068
   234
      thy7 |> PureThy.add_thms (map (fn (ak_name, T) =>
berghofe@18068
   235
      let
urbanc@21289
   236
        val ak_name_qu = Sign.full_name thy7 ak_name;
urbanc@21289
   237
        val pt_name_qu = Sign.full_name thy7 ("pt_"^ak_name);
berghofe@18068
   238
        val i_type1 = TFree("'x",[pt_name_qu]);
berghofe@18068
   239
        val i_type2 = Type(ak_name_qu,[]);
berghofe@19494
   240
	val cpt = Const ("Nominal.pt",(Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
berghofe@18068
   241
        val pt_type = Logic.mk_type i_type1;
berghofe@18068
   242
        val at_type = Logic.mk_type i_type2;
urbanc@24527
   243
        val simp_s = HOL_ss addsimps PureThy.get_thmss thy7
berghofe@18068
   244
                                  [Name "pt_def",
berghofe@18068
   245
                                   Name ("pt_" ^ ak_name ^ "1"),
berghofe@18068
   246
                                   Name ("pt_" ^ ak_name ^ "2"),
berghofe@18068
   247
                                   Name ("pt_" ^ ak_name ^ "3")];
berghofe@18068
   248
berghofe@18068
   249
	val name = "pt_"^ak_name^ "_inst";
berghofe@18068
   250
        val statement = HOLogic.mk_Trueprop (cpt $ pt_type $ at_type);
berghofe@18068
   251
urbanc@24527
   252
        val proof = fn _ => simp_tac simp_s 1;
berghofe@18068
   253
      in 
wenzelm@20046
   254
        ((name, Goal.prove_global thy7 [] [] statement proof), []) 
berghofe@18068
   255
      end) ak_names_types);
berghofe@18068
   256
berghofe@18068
   257
     (* declares an fs-axclass for every atom-kind       *)
berghofe@18068
   258
     (* axclass fs_<ak>                                  *)
berghofe@18068
   259
     (* fs_<ak>1: finite ((supp x)::<ak> set)            *)
urbanc@18438
   260
     val (fs_ax_classes,thy11) =  fold_map (fn (ak_name, T) => fn thy =>
berghofe@18068
   261
       let 
berghofe@18068
   262
	  val cl_name = "fs_"^ak_name;
urbanc@21289
   263
	  val pt_name = Sign.full_name thy ("pt_"^ak_name);
berghofe@18068
   264
          val ty = TFree("'a",["HOL.type"]);
berghofe@18068
   265
          val x   = Free ("x", ty);
berghofe@19494
   266
          val csupp    = Const ("Nominal.supp", ty --> HOLogic.mk_setT T);
berghofe@22274
   267
          val cfinite  = Const ("Finite_Set.finite", HOLogic.mk_setT T --> HOLogic.boolT)
berghofe@18068
   268
          
berghofe@22274
   269
          val axiom1   = HOLogic.mk_Trueprop (cfinite $ (csupp $ x));
berghofe@18068
   270
berghofe@18068
   271
       in  
haftmann@22745
   272
        AxClass.define_class (cl_name, [pt_name]) [] [((cl_name ^ "1", []), [axiom1])] thy            
urbanc@18438
   273
       end) ak_names_types thy8; 
urbanc@22418
   274
	 
berghofe@18068
   275
     (* proves that every fs_<ak>-type together with <ak>-type   *)
berghofe@18068
   276
     (* instance of fs-type                                      *)
berghofe@18068
   277
     (* lemma abst_<ak>_inst:                                    *)
berghofe@18068
   278
     (* fs TYPE('x::pt_<ak>) TYPE (<ak>)                         *)
urbanc@18381
   279
     val (fs_inst_thms,thy12) = 
berghofe@18068
   280
       thy11 |> PureThy.add_thms (map (fn (ak_name, T) =>
berghofe@18068
   281
       let
urbanc@21289
   282
         val ak_name_qu = Sign.full_name thy11 ak_name;
urbanc@21289
   283
         val fs_name_qu = Sign.full_name thy11 ("fs_"^ak_name);
berghofe@18068
   284
         val i_type1 = TFree("'x",[fs_name_qu]);
berghofe@18068
   285
         val i_type2 = Type(ak_name_qu,[]);
berghofe@19494
   286
 	 val cfs = Const ("Nominal.fs", 
berghofe@18068
   287
                                 (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
berghofe@18068
   288
         val fs_type = Logic.mk_type i_type1;
berghofe@18068
   289
         val at_type = Logic.mk_type i_type2;
urbanc@24527
   290
	 val simp_s = HOL_ss addsimps PureThy.get_thmss thy11
berghofe@18068
   291
                                   [Name "fs_def",
berghofe@18068
   292
                                    Name ("fs_" ^ ak_name ^ "1")];
berghofe@18068
   293
    
berghofe@18068
   294
	 val name = "fs_"^ak_name^ "_inst";
berghofe@18068
   295
         val statement = HOLogic.mk_Trueprop (cfs $ fs_type $ at_type);
berghofe@18068
   296
urbanc@24527
   297
         val proof = fn _ => simp_tac simp_s 1;
berghofe@18068
   298
       in 
wenzelm@20046
   299
         ((name, Goal.prove_global thy11 [] [] statement proof), []) 
berghofe@18068
   300
       end) ak_names_types);
berghofe@18068
   301
berghofe@18068
   302
       (* declares for every atom-kind combination an axclass            *)
berghofe@18068
   303
       (* cp_<ak1>_<ak2> giving a composition property                   *)
berghofe@18068
   304
       (* cp_<ak1>_<ak2>1: pi1 o pi2 o x = (pi1 o pi2) o (pi1 o x)       *)
urbanc@22418
   305
        val (cp_ax_classes,thy12b) = fold_map (fn (ak_name, T) => fn thy =>
urbanc@18438
   306
	 fold_map (fn (ak_name', T') => fn thy' =>
berghofe@18068
   307
	     let
berghofe@18068
   308
	       val cl_name = "cp_"^ak_name^"_"^ak_name';
berghofe@18068
   309
	       val ty = TFree("'a",["HOL.type"]);
berghofe@18068
   310
               val x   = Free ("x", ty);
berghofe@18068
   311
               val pi1 = Free ("pi1", mk_permT T);
berghofe@18068
   312
	       val pi2 = Free ("pi2", mk_permT T');                  
berghofe@19494
   313
	       val cperm1 = Const ("Nominal.perm", mk_permT T  --> ty --> ty);
berghofe@19494
   314
               val cperm2 = Const ("Nominal.perm", mk_permT T' --> ty --> ty);
berghofe@19494
   315
               val cperm3 = Const ("Nominal.perm", mk_permT T  --> mk_permT T' --> mk_permT T');
berghofe@18068
   316
berghofe@18068
   317
               val ax1   = HOLogic.mk_Trueprop 
berghofe@18068
   318
			   (HOLogic.mk_eq (cperm1 $ pi1 $ (cperm2 $ pi2 $ x), 
berghofe@18068
   319
                                           cperm2 $ (cperm3 $ pi1 $ pi2) $ (cperm1 $ pi1 $ x)));
berghofe@18068
   320
	       in  
haftmann@22745
   321
		 AxClass.define_class (cl_name, ["HOL.type"]) [] [((cl_name ^ "1", []), [ax1])] thy'  
urbanc@18438
   322
	       end) ak_names_types thy) ak_names_types thy12;
berghofe@18068
   323
berghofe@18068
   324
        (* proves for every <ak>-combination a cp_<ak1>_<ak2>_inst theorem;     *)
berghofe@18068
   325
        (* lemma cp_<ak1>_<ak2>_inst:                                           *)
berghofe@18068
   326
        (* cp TYPE('a::cp_<ak1>_<ak2>) TYPE(<ak1>) TYPE(<ak2>)                  *)
urbanc@18381
   327
        val (cp_thms,thy12c) = fold_map (fn (ak_name, T) => fn thy =>
urbanc@18381
   328
	 fold_map (fn (ak_name', T') => fn thy' =>
berghofe@18068
   329
           let
urbanc@21289
   330
             val ak_name_qu  = Sign.full_name thy' (ak_name);
urbanc@21289
   331
	     val ak_name_qu' = Sign.full_name thy' (ak_name');
urbanc@21289
   332
             val cp_name_qu  = Sign.full_name thy' ("cp_"^ak_name^"_"^ak_name');
berghofe@18068
   333
             val i_type0 = TFree("'a",[cp_name_qu]);
berghofe@18068
   334
             val i_type1 = Type(ak_name_qu,[]);
berghofe@18068
   335
             val i_type2 = Type(ak_name_qu',[]);
berghofe@19494
   336
	     val ccp = Const ("Nominal.cp",
berghofe@18068
   337
                             (Term.itselfT i_type0)-->(Term.itselfT i_type1)-->
berghofe@18068
   338
                                                      (Term.itselfT i_type2)-->HOLogic.boolT);
berghofe@18068
   339
             val at_type  = Logic.mk_type i_type1;
berghofe@18068
   340
             val at_type' = Logic.mk_type i_type2;
berghofe@18068
   341
	     val cp_type  = Logic.mk_type i_type0;
berghofe@18068
   342
             val simp_s   = HOL_basic_ss addsimps PureThy.get_thmss thy' [(Name "cp_def")];
berghofe@18068
   343
	     val cp1      = PureThy.get_thm thy' (Name ("cp_"^ak_name^"_"^ak_name'^"1"));
berghofe@18068
   344
berghofe@18068
   345
	     val name = "cp_"^ak_name^ "_"^ak_name'^"_inst";
berghofe@18068
   346
             val statement = HOLogic.mk_Trueprop (ccp $ cp_type $ at_type $ at_type');
berghofe@18068
   347
urbanc@24527
   348
             val proof = fn _ => EVERY [simp_tac simp_s 1, 
urbanc@24527
   349
                                        rtac allI 1, rtac allI 1, rtac allI 1,
urbanc@24527
   350
                                        rtac cp1 1];
berghofe@18068
   351
	   in
wenzelm@20046
   352
	     PureThy.add_thms [((name, Goal.prove_global thy' [] [] statement proof), [])] thy'
berghofe@18068
   353
	   end) 
urbanc@18381
   354
           ak_names_types thy) ak_names_types thy12b;
berghofe@18068
   355
       
berghofe@18068
   356
        (* proves for every non-trivial <ak>-combination a disjointness   *)
berghofe@18068
   357
        (* theorem; i.e. <ak1> != <ak2>                                   *)
berghofe@18068
   358
        (* lemma ds_<ak1>_<ak2>:                                          *)
berghofe@18068
   359
        (* dj TYPE(<ak1>) TYPE(<ak2>)                                     *)
urbanc@18381
   360
        val (dj_thms, thy12d) = fold_map (fn (ak_name,T) => fn thy =>
urbanc@18381
   361
	  fold_map (fn (ak_name',T') => fn thy' =>
berghofe@18068
   362
          (if not (ak_name = ak_name') 
berghofe@18068
   363
           then 
berghofe@18068
   364
	       let
urbanc@21289
   365
		 val ak_name_qu  = Sign.full_name thy' ak_name;
urbanc@21289
   366
	         val ak_name_qu' = Sign.full_name thy' ak_name';
berghofe@18068
   367
                 val i_type1 = Type(ak_name_qu,[]);
berghofe@18068
   368
                 val i_type2 = Type(ak_name_qu',[]);
berghofe@19494
   369
	         val cdj = Const ("Nominal.disjoint",
berghofe@18068
   370
                           (Term.itselfT i_type1)-->(Term.itselfT i_type2)-->HOLogic.boolT);
berghofe@18068
   371
                 val at_type  = Logic.mk_type i_type1;
berghofe@18068
   372
                 val at_type' = Logic.mk_type i_type2;
urbanc@24527
   373
                 val simp_s = HOL_ss addsimps PureThy.get_thmss thy' 
berghofe@18068
   374
					   [Name "disjoint_def",
berghofe@18068
   375
                                            Name (ak_name^"_prm_"^ak_name'^"_def"),
berghofe@18068
   376
                                            Name (ak_name'^"_prm_"^ak_name^"_def")];
berghofe@18068
   377
berghofe@18068
   378
	         val name = "dj_"^ak_name^"_"^ak_name';
berghofe@18068
   379
                 val statement = HOLogic.mk_Trueprop (cdj $ at_type $ at_type');
berghofe@18068
   380
urbanc@24527
   381
                 val proof = fn _ => simp_tac simp_s 1;
berghofe@18068
   382
	       in
wenzelm@20046
   383
		PureThy.add_thms [((name, Goal.prove_global thy' [] [] statement proof), [])] thy'
berghofe@18068
   384
	       end
berghofe@18068
   385
           else 
urbanc@18381
   386
            ([],thy')))  (* do nothing branch, if ak_name = ak_name' *) 
urbanc@18381
   387
	    ak_names_types thy) ak_names_types thy12c;
berghofe@18068
   388
webertj@20097
   389
     (********  pt_<ak> class instances  ********)
berghofe@18068
   390
     (*=========================================*)
urbanc@18279
   391
     (* some abbreviations for theorems *)
wenzelm@23894
   392
      val pt1           = @{thm "pt1"};
wenzelm@23894
   393
      val pt2           = @{thm "pt2"};
wenzelm@23894
   394
      val pt3           = @{thm "pt3"};
wenzelm@23894
   395
      val at_pt_inst    = @{thm "at_pt_inst"};
wenzelm@23894
   396
      val pt_set_inst   = @{thm "pt_set_inst"}; 
wenzelm@23894
   397
      val pt_unit_inst  = @{thm "pt_unit_inst"};
wenzelm@23894
   398
      val pt_prod_inst  = @{thm "pt_prod_inst"}; 
wenzelm@23894
   399
      val pt_nprod_inst = @{thm "pt_nprod_inst"}; 
wenzelm@23894
   400
      val pt_list_inst  = @{thm "pt_list_inst"};
wenzelm@23894
   401
      val pt_optn_inst  = @{thm "pt_option_inst"};
wenzelm@23894
   402
      val pt_noptn_inst = @{thm "pt_noption_inst"};
wenzelm@23894
   403
      val pt_fun_inst   = @{thm "pt_fun_inst"};
berghofe@18068
   404
urbanc@18435
   405
     (* for all atom-kind combinations <ak>/<ak'> show that        *)
urbanc@18435
   406
     (* every <ak> is an instance of pt_<ak'>; the proof for       *)
urbanc@18435
   407
     (* ak!=ak' is by definition; the case ak=ak' uses at_pt_inst. *)
urbanc@18431
   408
     val thy13 = fold (fn ak_name => fn thy =>
urbanc@18431
   409
	fold (fn ak_name' => fn thy' =>
urbanc@18431
   410
         let
urbanc@21289
   411
           val qu_name =  Sign.full_name thy' ak_name';
urbanc@21289
   412
           val cls_name = Sign.full_name thy' ("pt_"^ak_name);
urbanc@18431
   413
           val at_inst  = PureThy.get_thm thy' (Name ("at_"^ak_name'^"_inst")); 
urbanc@18431
   414
haftmann@24218
   415
           val proof1 = EVERY [Class.intro_classes_tac [],
berghofe@18068
   416
                                 rtac ((at_inst RS at_pt_inst) RS pt1) 1,
berghofe@18068
   417
                                 rtac ((at_inst RS at_pt_inst) RS pt2) 1,
berghofe@18068
   418
                                 rtac ((at_inst RS at_pt_inst) RS pt3) 1,
berghofe@18068
   419
                                 atac 1];
urbanc@18431
   420
           val simp_s = HOL_basic_ss addsimps 
urbanc@18431
   421
                        PureThy.get_thmss thy' [Name (ak_name^"_prm_"^ak_name'^"_def")];  
haftmann@24218
   422
           val proof2 = EVERY [Class.intro_classes_tac [], REPEAT (asm_simp_tac simp_s 1)];
urbanc@18431
   423
urbanc@18431
   424
         in
urbanc@18431
   425
           thy'
berghofe@19275
   426
           |> AxClass.prove_arity (qu_name,[],[cls_name])
urbanc@18431
   427
              (if ak_name = ak_name' then proof1 else proof2)
urbanc@18431
   428
         end) ak_names thy) ak_names thy12c;
berghofe@18068
   429
urbanc@18430
   430
     (* show that                       *)
urbanc@18430
   431
     (*      fun(pt_<ak>,pt_<ak>)       *)
urbanc@18579
   432
     (*      noption(pt_<ak>)           *)
urbanc@18430
   433
     (*      option(pt_<ak>)            *)
urbanc@18430
   434
     (*      list(pt_<ak>)              *)
urbanc@18430
   435
     (*      *(pt_<ak>,pt_<ak>)         *)
urbanc@18600
   436
     (*      nprod(pt_<ak>,pt_<ak>)     *)
urbanc@18430
   437
     (*      unit                       *)
urbanc@18430
   438
     (*      set(pt_<ak>)               *)
urbanc@18430
   439
     (* are instances of pt_<ak>        *)
urbanc@18431
   440
     val thy18 = fold (fn ak_name => fn thy =>
berghofe@18068
   441
       let
urbanc@21289
   442
          val cls_name = Sign.full_name thy ("pt_"^ak_name);
berghofe@18068
   443
          val at_thm   = PureThy.get_thm thy (Name ("at_"^ak_name^"_inst"));
berghofe@18068
   444
          val pt_inst  = PureThy.get_thm thy (Name ("pt_"^ak_name^"_inst"));
webertj@20097
   445
urbanc@18430
   446
          fun pt_proof thm = 
haftmann@24218
   447
              EVERY [Class.intro_classes_tac [],
urbanc@18430
   448
                     rtac (thm RS pt1) 1, rtac (thm RS pt2) 1, rtac (thm RS pt3) 1, atac 1];
urbanc@18430
   449
urbanc@18430
   450
          val pt_thm_fun   = at_thm RS (pt_inst RS (pt_inst RS pt_fun_inst));
urbanc@18430
   451
          val pt_thm_noptn = pt_inst RS pt_noptn_inst; 
urbanc@18430
   452
          val pt_thm_optn  = pt_inst RS pt_optn_inst; 
urbanc@18430
   453
          val pt_thm_list  = pt_inst RS pt_list_inst;
urbanc@18430
   454
          val pt_thm_prod  = pt_inst RS (pt_inst RS pt_prod_inst);
urbanc@18600
   455
          val pt_thm_nprod = pt_inst RS (pt_inst RS pt_nprod_inst);
urbanc@18430
   456
          val pt_thm_unit  = pt_unit_inst;
urbanc@18430
   457
          val pt_thm_set   = pt_inst RS pt_set_inst
webertj@20097
   458
       in
webertj@20097
   459
        thy
webertj@20097
   460
        |> AxClass.prove_arity ("fun",[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_fun)
berghofe@19494
   461
        |> AxClass.prove_arity ("Nominal.noption",[[cls_name]],[cls_name]) (pt_proof pt_thm_noptn) 
haftmann@24194
   462
        |> AxClass.prove_arity ("Datatype.option",[[cls_name]],[cls_name]) (pt_proof pt_thm_optn)
berghofe@19275
   463
        |> AxClass.prove_arity ("List.list",[[cls_name]],[cls_name]) (pt_proof pt_thm_list)
berghofe@19275
   464
        |> AxClass.prove_arity ("*",[[cls_name],[cls_name]],[cls_name]) (pt_proof pt_thm_prod)
berghofe@19494
   465
        |> AxClass.prove_arity ("Nominal.nprod",[[cls_name],[cls_name]],[cls_name]) 
urbanc@18600
   466
                                    (pt_proof pt_thm_nprod)
berghofe@19275
   467
        |> AxClass.prove_arity ("Product_Type.unit",[],[cls_name]) (pt_proof pt_thm_unit)
berghofe@19275
   468
        |> AxClass.prove_arity ("set",[[cls_name]],[cls_name]) (pt_proof pt_thm_set)
urbanc@18430
   469
     end) ak_names thy13; 
berghofe@18068
   470
webertj@20097
   471
       (********  fs_<ak> class instances  ********)
berghofe@18068
   472
       (*=========================================*)
urbanc@18279
   473
       (* abbreviations for some lemmas *)
wenzelm@23894
   474
       val fs1            = @{thm "fs1"};
wenzelm@23894
   475
       val fs_at_inst     = @{thm "fs_at_inst"};
wenzelm@23894
   476
       val fs_unit_inst   = @{thm "fs_unit_inst"};
wenzelm@23894
   477
       val fs_prod_inst   = @{thm "fs_prod_inst"};
wenzelm@23894
   478
       val fs_nprod_inst  = @{thm "fs_nprod_inst"};
wenzelm@23894
   479
       val fs_list_inst   = @{thm "fs_list_inst"};
wenzelm@23894
   480
       val fs_option_inst = @{thm "fs_option_inst"};
wenzelm@23894
   481
       val dj_supp        = @{thm "dj_supp"};
berghofe@18068
   482
berghofe@18068
   483
       (* shows that <ak> is an instance of fs_<ak>     *)
berghofe@18068
   484
       (* uses the theorem at_<ak>_inst                 *)
urbanc@18431
   485
       val thy20 = fold (fn ak_name => fn thy =>
webertj@20097
   486
        fold (fn ak_name' => fn thy' =>
urbanc@18437
   487
        let
urbanc@21289
   488
           val qu_name =  Sign.full_name thy' ak_name';
urbanc@21289
   489
           val qu_class = Sign.full_name thy' ("fs_"^ak_name);
webertj@20097
   490
           val proof =
webertj@20097
   491
               (if ak_name = ak_name'
webertj@20097
   492
                then
webertj@20097
   493
                  let val at_thm = PureThy.get_thm thy' (Name ("at_"^ak_name^"_inst"));
haftmann@24218
   494
                  in  EVERY [Class.intro_classes_tac [],
urbanc@18437
   495
                             rtac ((at_thm RS fs_at_inst) RS fs1) 1] end
urbanc@18437
   496
                else
webertj@20097
   497
                  let val dj_inst = PureThy.get_thm thy' (Name ("dj_"^ak_name'^"_"^ak_name));
berghofe@22274
   498
                      val simp_s = HOL_basic_ss addsimps [dj_inst RS dj_supp, finite_emptyI];
haftmann@24218
   499
                  in EVERY [Class.intro_classes_tac [], asm_simp_tac simp_s 1] end)
webertj@20097
   500
        in
webertj@20097
   501
         AxClass.prove_arity (qu_name,[],[qu_class]) proof thy'
urbanc@18437
   502
        end) ak_names thy) ak_names thy18;
berghofe@18068
   503
urbanc@18431
   504
       (* shows that                  *)
urbanc@18431
   505
       (*    unit                     *)
urbanc@18431
   506
       (*    *(fs_<ak>,fs_<ak>)       *)
urbanc@18600
   507
       (*    nprod(fs_<ak>,fs_<ak>)   *)
urbanc@18431
   508
       (*    list(fs_<ak>)            *)
urbanc@18431
   509
       (*    option(fs_<ak>)          *) 
urbanc@18431
   510
       (* are instances of fs_<ak>    *)
berghofe@18068
   511
urbanc@18431
   512
       val thy24 = fold (fn ak_name => fn thy => 
urbanc@18431
   513
        let
urbanc@21289
   514
          val cls_name = Sign.full_name thy ("fs_"^ak_name);
berghofe@18068
   515
          val fs_inst  = PureThy.get_thm thy (Name ("fs_"^ak_name^"_inst"));
haftmann@24218
   516
          fun fs_proof thm = EVERY [Class.intro_classes_tac [], rtac (thm RS fs1) 1];
berghofe@18068
   517
urbanc@18600
   518
          val fs_thm_unit  = fs_unit_inst;
urbanc@18600
   519
          val fs_thm_prod  = fs_inst RS (fs_inst RS fs_prod_inst);
urbanc@18600
   520
          val fs_thm_nprod = fs_inst RS (fs_inst RS fs_nprod_inst);
urbanc@18600
   521
          val fs_thm_list  = fs_inst RS fs_list_inst;
urbanc@18600
   522
          val fs_thm_optn  = fs_inst RS fs_option_inst;
urbanc@18431
   523
        in 
webertj@20097
   524
         thy
berghofe@19275
   525
         |> AxClass.prove_arity ("Product_Type.unit",[],[cls_name]) (fs_proof fs_thm_unit) 
berghofe@19275
   526
         |> AxClass.prove_arity ("*",[[cls_name],[cls_name]],[cls_name]) (fs_proof fs_thm_prod) 
berghofe@19494
   527
         |> AxClass.prove_arity ("Nominal.nprod",[[cls_name],[cls_name]],[cls_name]) 
urbanc@18600
   528
                                     (fs_proof fs_thm_nprod) 
berghofe@19275
   529
         |> AxClass.prove_arity ("List.list",[[cls_name]],[cls_name]) (fs_proof fs_thm_list)
haftmann@24194
   530
         |> AxClass.prove_arity ("Datatype.option",[[cls_name]],[cls_name]) (fs_proof fs_thm_optn)
webertj@20097
   531
        end) ak_names thy20;
urbanc@18431
   532
webertj@20097
   533
       (********  cp_<ak>_<ai> class instances  ********)
berghofe@18068
   534
       (*==============================================*)
urbanc@18279
   535
       (* abbreviations for some lemmas *)
wenzelm@23894
   536
       val cp1             = @{thm "cp1"};
wenzelm@23894
   537
       val cp_unit_inst    = @{thm "cp_unit_inst"};
wenzelm@23894
   538
       val cp_bool_inst    = @{thm "cp_bool_inst"};
wenzelm@23894
   539
       val cp_prod_inst    = @{thm "cp_prod_inst"};
wenzelm@23894
   540
       val cp_list_inst    = @{thm "cp_list_inst"};
wenzelm@23894
   541
       val cp_fun_inst     = @{thm "cp_fun_inst"};
wenzelm@23894
   542
       val cp_option_inst  = @{thm "cp_option_inst"};
wenzelm@23894
   543
       val cp_noption_inst = @{thm "cp_noption_inst"};
wenzelm@23894
   544
       val cp_set_inst     = @{thm "cp_set_inst"};
wenzelm@23894
   545
       val pt_perm_compose = @{thm "pt_perm_compose"};
webertj@20097
   546
wenzelm@23894
   547
       val dj_pp_forget    = @{thm "dj_perm_perm_forget"};
berghofe@18068
   548
berghofe@18068
   549
       (* shows that <aj> is an instance of cp_<ak>_<ai>  *)
urbanc@18432
   550
       (* for every  <ak>/<ai>-combination                *)
webertj@20097
   551
       val thy25 = fold (fn ak_name => fn thy =>
webertj@20097
   552
         fold (fn ak_name' => fn thy' =>
webertj@20097
   553
          fold (fn ak_name'' => fn thy'' =>
berghofe@18068
   554
            let
urbanc@21289
   555
              val name =  Sign.full_name thy'' ak_name;
urbanc@21289
   556
              val cls_name = Sign.full_name thy'' ("cp_"^ak_name'^"_"^ak_name'');
berghofe@18068
   557
              val proof =
berghofe@18068
   558
                (if (ak_name'=ak_name'') then 
webertj@20097
   559
                  (let
berghofe@18068
   560
                    val pt_inst  = PureThy.get_thm thy'' (Name ("pt_"^ak_name''^"_inst"));
webertj@20097
   561
                    val at_inst  = PureThy.get_thm thy'' (Name ("at_"^ak_name''^"_inst"));
webertj@20097
   562
                  in
haftmann@24218
   563
		   EVERY [Class.intro_classes_tac [],
berghofe@18068
   564
                          rtac (at_inst RS (pt_inst RS pt_perm_compose)) 1]
berghofe@18068
   565
                  end)
berghofe@18068
   566
		else
webertj@20097
   567
		  (let
berghofe@18068
   568
                     val dj_inst  = PureThy.get_thm thy'' (Name ("dj_"^ak_name''^"_"^ak_name'));
webertj@20097
   569
		     val simp_s = HOL_basic_ss addsimps
berghofe@18068
   570
                                        ((dj_inst RS dj_pp_forget)::
webertj@20097
   571
                                         (PureThy.get_thmss thy''
webertj@20097
   572
                                           [Name (ak_name' ^"_prm_"^ak_name^"_def"),
webertj@20097
   573
                                            Name (ak_name''^"_prm_"^ak_name^"_def")]));
webertj@20097
   574
                  in
haftmann@24218
   575
                    EVERY [Class.intro_classes_tac [], simp_tac simp_s 1]
berghofe@18068
   576
                  end))
webertj@20097
   577
              in
berghofe@19275
   578
                AxClass.prove_arity (name,[],[cls_name]) proof thy''
webertj@20097
   579
              end) ak_names thy') ak_names thy) ak_names thy24;
webertj@20097
   580
urbanc@18432
   581
       (* shows that                                                    *) 
urbanc@18432
   582
       (*      units                                                    *) 
urbanc@18432
   583
       (*      products                                                 *)
urbanc@18432
   584
       (*      lists                                                    *)
urbanc@18432
   585
       (*      functions                                                *)
urbanc@18432
   586
       (*      options                                                  *)
urbanc@18432
   587
       (*      noptions                                                 *)
urbanc@22536
   588
       (*      sets                                                     *)
urbanc@18432
   589
       (* are instances of cp_<ak>_<ai> for every <ak>/<ai>-combination *)
urbanc@18432
   590
       val thy26 = fold (fn ak_name => fn thy =>
urbanc@18432
   591
	fold (fn ak_name' => fn thy' =>
urbanc@18432
   592
        let
urbanc@21289
   593
            val cls_name = Sign.full_name thy' ("cp_"^ak_name^"_"^ak_name');
berghofe@18068
   594
            val cp_inst  = PureThy.get_thm thy' (Name ("cp_"^ak_name^"_"^ak_name'^"_inst"));
berghofe@18068
   595
            val pt_inst  = PureThy.get_thm thy' (Name ("pt_"^ak_name^"_inst"));
berghofe@18068
   596
            val at_inst  = PureThy.get_thm thy' (Name ("at_"^ak_name^"_inst"));
urbanc@18432
   597
haftmann@24218
   598
            fun cp_proof thm  = EVERY [Class.intro_classes_tac [],rtac (thm RS cp1) 1];
urbanc@18432
   599
	  
urbanc@18432
   600
            val cp_thm_unit = cp_unit_inst;
urbanc@18432
   601
            val cp_thm_prod = cp_inst RS (cp_inst RS cp_prod_inst);
urbanc@18432
   602
            val cp_thm_list = cp_inst RS cp_list_inst;
urbanc@18432
   603
            val cp_thm_fun  = at_inst RS (pt_inst RS (cp_inst RS (cp_inst RS cp_fun_inst)));
urbanc@18432
   604
            val cp_thm_optn = cp_inst RS cp_option_inst;
urbanc@18432
   605
            val cp_thm_noptn = cp_inst RS cp_noption_inst;
urbanc@22536
   606
            val cp_thm_set = cp_inst RS cp_set_inst;
urbanc@18432
   607
        in
urbanc@18432
   608
         thy'
berghofe@19275
   609
         |> AxClass.prove_arity ("Product_Type.unit",[],[cls_name]) (cp_proof cp_thm_unit)
berghofe@19275
   610
	 |> AxClass.prove_arity ("*",[[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_prod)
berghofe@19275
   611
         |> AxClass.prove_arity ("List.list",[[cls_name]],[cls_name]) (cp_proof cp_thm_list)
berghofe@19275
   612
         |> AxClass.prove_arity ("fun",[[cls_name],[cls_name]],[cls_name]) (cp_proof cp_thm_fun)
haftmann@24194
   613
         |> AxClass.prove_arity ("Datatype.option",[[cls_name]],[cls_name]) (cp_proof cp_thm_optn)
berghofe@19494
   614
         |> AxClass.prove_arity ("Nominal.noption",[[cls_name]],[cls_name]) (cp_proof cp_thm_noptn)
urbanc@22536
   615
         |> AxClass.prove_arity ("set",[[cls_name]],[cls_name]) (cp_proof cp_thm_set)
urbanc@18432
   616
        end) ak_names thy) ak_names thy25;
webertj@20097
   617
webertj@20097
   618
     (* show that discrete nominal types are permutation types, finitely     *)
urbanc@18432
   619
     (* supported and have the commutation property                          *)
urbanc@18432
   620
     (* discrete types have a permutation operation defined as pi o x = x;   *)
webertj@20097
   621
     (* which renders the proofs to be simple "simp_all"-proofs.             *)
urbanc@18432
   622
     val thy32 =
webertj@20097
   623
        let
webertj@20097
   624
	  fun discrete_pt_inst discrete_ty defn =
urbanc@18432
   625
	     fold (fn ak_name => fn thy =>
urbanc@18432
   626
	     let
urbanc@21289
   627
	       val qu_class = Sign.full_name thy ("pt_"^ak_name);
urbanc@18432
   628
	       val simp_s = HOL_basic_ss addsimps [defn];
haftmann@24218
   629
               val proof = EVERY [Class.intro_classes_tac [], REPEAT (asm_simp_tac simp_s 1)];
webertj@20097
   630
             in 
berghofe@19275
   631
	       AxClass.prove_arity (discrete_ty,[],[qu_class]) proof thy
urbanc@18432
   632
             end) ak_names;
berghofe@18068
   633
urbanc@18432
   634
          fun discrete_fs_inst discrete_ty defn = 
urbanc@18432
   635
	     fold (fn ak_name => fn thy =>
urbanc@18432
   636
	     let
urbanc@21289
   637
	       val qu_class = Sign.full_name thy ("fs_"^ak_name);
wenzelm@23894
   638
	       val supp_def = @{thm "Nominal.supp_def"};
berghofe@22274
   639
               val simp_s = HOL_ss addsimps [supp_def,Collect_const,finite_emptyI,defn];
haftmann@24218
   640
               val proof = EVERY [Class.intro_classes_tac [], asm_simp_tac simp_s 1];
webertj@20097
   641
             in 
berghofe@19275
   642
	       AxClass.prove_arity (discrete_ty,[],[qu_class]) proof thy
webertj@20097
   643
             end) ak_names;
berghofe@18068
   644
urbanc@18432
   645
          fun discrete_cp_inst discrete_ty defn = 
urbanc@18432
   646
	     fold (fn ak_name' => (fold (fn ak_name => fn thy =>
urbanc@18432
   647
	     let
urbanc@21289
   648
	       val qu_class = Sign.full_name thy ("cp_"^ak_name^"_"^ak_name');
wenzelm@23894
   649
	       val supp_def = @{thm "Nominal.supp_def"};
urbanc@18432
   650
               val simp_s = HOL_ss addsimps [defn];
haftmann@24218
   651
               val proof = EVERY [Class.intro_classes_tac [], asm_simp_tac simp_s 1];
webertj@20097
   652
             in
berghofe@19275
   653
	       AxClass.prove_arity (discrete_ty,[],[qu_class]) proof thy
webertj@20097
   654
             end) ak_names)) ak_names;
webertj@20097
   655
urbanc@18432
   656
        in
urbanc@18432
   657
         thy26
wenzelm@23894
   658
         |> discrete_pt_inst "nat"  @{thm "perm_nat_def"}
wenzelm@23894
   659
         |> discrete_fs_inst "nat"  @{thm "perm_nat_def"}
wenzelm@23894
   660
         |> discrete_cp_inst "nat"  @{thm "perm_nat_def"}
wenzelm@23894
   661
         |> discrete_pt_inst "bool" @{thm "perm_bool"}
wenzelm@23894
   662
         |> discrete_fs_inst "bool" @{thm "perm_bool"}
wenzelm@23894
   663
         |> discrete_cp_inst "bool" @{thm "perm_bool"}
wenzelm@23894
   664
         |> discrete_pt_inst "IntDef.int" @{thm "perm_int_def"}
wenzelm@23894
   665
         |> discrete_fs_inst "IntDef.int" @{thm "perm_int_def"}
wenzelm@23894
   666
         |> discrete_cp_inst "IntDef.int" @{thm "perm_int_def"}
wenzelm@23894
   667
         |> discrete_pt_inst "List.char" @{thm "perm_char_def"}
wenzelm@23894
   668
         |> discrete_fs_inst "List.char" @{thm "perm_char_def"}
wenzelm@23894
   669
         |> discrete_cp_inst "List.char" @{thm "perm_char_def"}
urbanc@18432
   670
        end;
urbanc@18432
   671
webertj@20097
   672
urbanc@18262
   673
       (* abbreviations for some lemmas *)
urbanc@18262
   674
       (*===============================*)
wenzelm@23894
   675
       val abs_fun_pi          = @{thm "Nominal.abs_fun_pi"};
wenzelm@23894
   676
       val abs_fun_pi_ineq     = @{thm "Nominal.abs_fun_pi_ineq"};
wenzelm@23894
   677
       val abs_fun_eq          = @{thm "Nominal.abs_fun_eq"};
wenzelm@23894
   678
       val abs_fun_eq'         = @{thm "Nominal.abs_fun_eq'"};
wenzelm@23894
   679
       val abs_fun_fresh       = @{thm "Nominal.abs_fun_fresh"};
wenzelm@23894
   680
       val abs_fun_fresh'      = @{thm "Nominal.abs_fun_fresh'"};
wenzelm@23894
   681
       val dj_perm_forget      = @{thm "Nominal.dj_perm_forget"};
wenzelm@23894
   682
       val dj_pp_forget        = @{thm "Nominal.dj_perm_perm_forget"};
wenzelm@23894
   683
       val fresh_iff           = @{thm "Nominal.fresh_abs_fun_iff"};
wenzelm@23894
   684
       val fresh_iff_ineq      = @{thm "Nominal.fresh_abs_fun_iff_ineq"};
wenzelm@23894
   685
       val abs_fun_supp        = @{thm "Nominal.abs_fun_supp"};
wenzelm@23894
   686
       val abs_fun_supp_ineq   = @{thm "Nominal.abs_fun_supp_ineq"};
wenzelm@23894
   687
       val pt_swap_bij         = @{thm "Nominal.pt_swap_bij"};
wenzelm@23894
   688
       val pt_swap_bij'        = @{thm "Nominal.pt_swap_bij'"};
wenzelm@23894
   689
       val pt_fresh_fresh      = @{thm "Nominal.pt_fresh_fresh"};
wenzelm@23894
   690
       val pt_bij              = @{thm "Nominal.pt_bij"};
wenzelm@23894
   691
       val pt_perm_compose     = @{thm "Nominal.pt_perm_compose"};
wenzelm@23894
   692
       val pt_perm_compose'    = @{thm "Nominal.pt_perm_compose'"};
wenzelm@23894
   693
       val perm_app            = @{thm "Nominal.pt_fun_app_eq"};
wenzelm@23894
   694
       val at_fresh            = @{thm "Nominal.at_fresh"};
wenzelm@23894
   695
       val at_fresh_ineq       = @{thm "Nominal.at_fresh_ineq"};
wenzelm@23894
   696
       val at_calc             = @{thms "Nominal.at_calc"};
wenzelm@23894
   697
       val at_swap_simps       = @{thms "Nominal.at_swap_simps"};
wenzelm@23894
   698
       val at_supp             = @{thm "Nominal.at_supp"};
wenzelm@23894
   699
       val dj_supp             = @{thm "Nominal.dj_supp"};
wenzelm@23894
   700
       val fresh_left_ineq     = @{thm "Nominal.pt_fresh_left_ineq"};
wenzelm@23894
   701
       val fresh_left          = @{thm "Nominal.pt_fresh_left"};
wenzelm@23894
   702
       val fresh_right_ineq    = @{thm "Nominal.pt_fresh_right_ineq"};
wenzelm@23894
   703
       val fresh_right         = @{thm "Nominal.pt_fresh_right"};
wenzelm@23894
   704
       val fresh_bij_ineq      = @{thm "Nominal.pt_fresh_bij_ineq"};
wenzelm@23894
   705
       val fresh_bij           = @{thm "Nominal.pt_fresh_bij"};
wenzelm@23894
   706
       val fresh_eqvt          = @{thm "Nominal.pt_fresh_eqvt"};
wenzelm@23894
   707
       val fresh_eqvt_ineq     = @{thm "Nominal.pt_fresh_eqvt_ineq"};
wenzelm@23894
   708
       val set_diff_eqvt       = @{thm "Nominal.pt_set_diff_eqvt"};
wenzelm@23894
   709
       val in_eqvt             = @{thm "Nominal.pt_in_eqvt"};
wenzelm@23894
   710
       val eq_eqvt             = @{thm "Nominal.pt_eq_eqvt"};
wenzelm@23894
   711
       val all_eqvt            = @{thm "Nominal.pt_all_eqvt"};
wenzelm@23894
   712
       val ex_eqvt             = @{thm "Nominal.pt_ex_eqvt"};
wenzelm@23894
   713
       val pt_pi_rev           = @{thm "Nominal.pt_pi_rev"};
wenzelm@23894
   714
       val pt_rev_pi           = @{thm "Nominal.pt_rev_pi"};
wenzelm@23894
   715
       val at_exists_fresh     = @{thm "Nominal.at_exists_fresh"};
wenzelm@23894
   716
       val at_exists_fresh'    = @{thm "Nominal.at_exists_fresh'"};
wenzelm@23894
   717
       val fresh_perm_app_ineq = @{thm "Nominal.pt_fresh_perm_app_ineq"};
wenzelm@23894
   718
       val fresh_perm_app      = @{thm "Nominal.pt_fresh_perm_app"};	
wenzelm@23894
   719
       val fresh_aux           = @{thm "Nominal.pt_fresh_aux"};  
wenzelm@23894
   720
       val pt_perm_supp_ineq   = @{thm "Nominal.pt_perm_supp_ineq"};
wenzelm@23894
   721
       val pt_perm_supp        = @{thm "Nominal.pt_perm_supp"};
narboux@22786
   722
urbanc@18262
   723
       (* Now we collect and instantiate some lemmas w.r.t. all atom      *)
urbanc@18262
   724
       (* types; this allows for example to use abs_perm (which is a      *)
urbanc@18262
   725
       (* collection of theorems) instead of thm abs_fun_pi with explicit *)
urbanc@18262
   726
       (* instantiations.                                                 *)
webertj@20097
   727
       val (_, thy33) =
webertj@20097
   728
         let
urbanc@18651
   729
urbanc@18279
   730
             (* takes a theorem thm and a list of theorems [t1,..,tn]            *)
urbanc@18279
   731
             (* produces a list of theorems of the form [t1 RS thm,..,tn RS thm] *) 
urbanc@18262
   732
             fun instR thm thms = map (fn ti => ti RS thm) thms;
berghofe@18068
   733
urbanc@18262
   734
             (* takes two theorem lists (hopefully of the same length ;o)                *)
urbanc@18262
   735
             (* produces a list of theorems of the form                                  *)
urbanc@18262
   736
             (* [t1 RS m1,..,tn RS mn] where [t1,..,tn] is thms1 and [m1,..,mn] is thms2 *) 
urbanc@18279
   737
             fun inst_zip thms1 thms2 = map (fn (t1,t2) => t1 RS t2) (thms1 ~~ thms2);
berghofe@18068
   738
urbanc@18262
   739
             (* takes a theorem list of the form [l1,...,ln]              *)
urbanc@18262
   740
             (* and a list of theorem lists of the form                   *)
urbanc@18262
   741
             (* [[h11,...,h1m],....,[hk1,....,hkm]                        *)
urbanc@18262
   742
             (* produces the list of theorem lists                        *)
urbanc@18262
   743
             (* [[l1 RS h11,...,l1 RS h1m],...,[ln RS hk1,...,ln RS hkm]] *)
urbanc@18279
   744
             fun inst_mult thms thmss = map (fn (t,ts) => instR t ts) (thms ~~ thmss);
urbanc@18279
   745
urbanc@18279
   746
             (* FIXME: these lists do not need to be created dynamically again *)
urbanc@18262
   747
urbanc@22418
   748
             
berghofe@18068
   749
             (* list of all at_inst-theorems *)
urbanc@18262
   750
             val ats = map (fn ak => PureThy.get_thm thy32 (Name ("at_"^ak^"_inst"))) ak_names
berghofe@18068
   751
             (* list of all pt_inst-theorems *)
urbanc@18262
   752
             val pts = map (fn ak => PureThy.get_thm thy32 (Name ("pt_"^ak^"_inst"))) ak_names
urbanc@18262
   753
             (* list of all cp_inst-theorems as a collection of lists*)
berghofe@18068
   754
             val cps = 
urbanc@18262
   755
		 let fun cps_fun ak1 ak2 = PureThy.get_thm thy32 (Name ("cp_"^ak1^"_"^ak2^"_inst"))
urbanc@18262
   756
		 in map (fn aki => (map (cps_fun aki) ak_names)) ak_names end; 
urbanc@18262
   757
             (* list of all cp_inst-theorems that have different atom types *)
urbanc@18262
   758
             val cps' = 
urbanc@18262
   759
		let fun cps'_fun ak1 ak2 = 
urbanc@18262
   760
		if ak1=ak2 then NONE else SOME(PureThy.get_thm thy32 (Name ("cp_"^ak1^"_"^ak2^"_inst")))
urbanc@18262
   761
		in map (fn aki => (List.mapPartial I (map (cps'_fun aki) ak_names))) ak_names end;
berghofe@18068
   762
             (* list of all dj_inst-theorems *)
berghofe@18068
   763
             val djs = 
berghofe@18068
   764
	       let fun djs_fun (ak1,ak2) = 
urbanc@18262
   765
		     if ak1=ak2 then NONE else SOME(PureThy.get_thm thy32 (Name ("dj_"^ak2^"_"^ak1)))
urbanc@18262
   766
	       in List.mapPartial I (map djs_fun (Library.product ak_names ak_names)) end;
urbanc@18262
   767
             (* list of all fs_inst-theorems *)
urbanc@18262
   768
             val fss = map (fn ak => PureThy.get_thm thy32 (Name ("fs_"^ak^"_inst"))) ak_names
urbanc@22418
   769
             (* list of all at_inst-theorems *)
urbanc@22418
   770
             val fs_axs = map (fn ak => PureThy.get_thm thy32 (Name ("fs_"^ak^"1"))) ak_names
webertj@20097
   771
webertj@20097
   772
             fun inst_pt thms = Library.flat (map (fn ti => instR ti pts) thms);
webertj@20097
   773
             fun inst_at thms = Library.flat (map (fn ti => instR ti ats) thms);
urbanc@18262
   774
             fun inst_fs thms = Library.flat (map (fn ti => instR ti fss) thms);
webertj@20097
   775
             fun inst_cp thms cps = Library.flat (inst_mult thms cps);
webertj@20097
   776
	     fun inst_pt_at thms = inst_zip ats (inst_pt thms);
webertj@20097
   777
             fun inst_dj thms = Library.flat (map (fn ti => instR ti djs) thms);
urbanc@18436
   778
	     fun inst_pt_pt_at_cp thms = inst_cp (inst_zip ats (inst_zip pts (inst_pt thms))) cps;
urbanc@18262
   779
             fun inst_pt_at_fs thms = inst_zip (inst_fs [fs1]) (inst_zip ats (inst_pt thms));
webertj@20097
   780
	     fun inst_pt_pt_at_cp thms =
urbanc@18279
   781
		 let val i_pt_pt_at = inst_zip ats (inst_zip pts (inst_pt thms));
urbanc@18436
   782
                     val i_pt_pt_at_cp = inst_cp i_pt_pt_at cps';
urbanc@18396
   783
		 in i_pt_pt_at_cp end;
urbanc@18396
   784
             fun inst_pt_pt_at_cp_dj thms = inst_zip djs (inst_pt_pt_at_cp thms);
berghofe@18068
   785
           in
urbanc@18262
   786
            thy32 
urbanc@18652
   787
	    |>   PureThy.add_thmss [(("alpha", inst_pt_at [abs_fun_eq]),[])]
urbanc@19562
   788
            ||>> PureThy.add_thmss [(("alpha'", inst_pt_at [abs_fun_eq']),[])]
urbanc@23158
   789
            ||>> PureThy.add_thmss [(("alpha_fresh", inst_pt_at [abs_fun_fresh]),[])]
urbanc@23158
   790
            ||>> PureThy.add_thmss [(("alpha_fresh'", inst_pt_at [abs_fun_fresh']),[])]
urbanc@22557
   791
            ||>> PureThy.add_thmss [(("perm_swap", inst_pt_at [pt_swap_bij] @ inst_pt_at [pt_swap_bij']),[])]
urbanc@22610
   792
            ||>> PureThy.add_thmss [(("swap_simps", inst_at at_swap_simps),[])]	 
urbanc@19139
   793
            ||>> PureThy.add_thmss 
urbanc@19139
   794
	      let val thms1 = inst_pt_at [pt_pi_rev];
urbanc@19139
   795
		  val thms2 = inst_pt_at [pt_rev_pi];
urbanc@19139
   796
              in [(("perm_pi_simp",thms1 @ thms2),[])] end
urbanc@18381
   797
            ||>> PureThy.add_thmss [(("perm_fresh_fresh", inst_pt_at [pt_fresh_fresh]),[])]
urbanc@18381
   798
            ||>> PureThy.add_thmss [(("perm_bij", inst_pt_at [pt_bij]),[])]
urbanc@18436
   799
            ||>> PureThy.add_thmss 
urbanc@18436
   800
	      let val thms1 = inst_pt_at [pt_perm_compose];
urbanc@18436
   801
		  val thms2 = instR cp1 (Library.flat cps');
urbanc@18436
   802
              in [(("perm_compose",thms1 @ thms2),[])] end
urbanc@19139
   803
            ||>> PureThy.add_thmss [(("perm_compose'",inst_pt_at [pt_perm_compose']),[])] 
urbanc@19139
   804
            ||>> PureThy.add_thmss [(("perm_app", inst_pt_at [perm_app]),[])]
urbanc@18381
   805
            ||>> PureThy.add_thmss [(("supp_atm", (inst_at [at_supp]) @ (inst_dj [dj_supp])),[])]
urbanc@19972
   806
            ||>> PureThy.add_thmss [(("exists_fresh", inst_at [at_exists_fresh]),[])]
urbanc@21377
   807
            ||>> PureThy.add_thmss [(("exists_fresh'", inst_at [at_exists_fresh']),[])]
berghofe@24569
   808
            ||>> PureThy.add_thmss
berghofe@24569
   809
              let
berghofe@24569
   810
                val thms1 = inst_pt_at [all_eqvt];
berghofe@24569
   811
                val thms2 = map (fold_rule [inductive_forall_def]) thms1
berghofe@24569
   812
              in
berghofe@24569
   813
                [(("all_eqvt", thms1 @ thms2), [NominalThmDecls.eqvt_force_add])]
berghofe@24569
   814
              end
urbanc@22715
   815
            ||>> PureThy.add_thmss [(("ex_eqvt", inst_pt_at [ex_eqvt]),[NominalThmDecls.eqvt_force_add])]
urbanc@19972
   816
            ||>> PureThy.add_thmss 
urbanc@19972
   817
	      let val thms1 = inst_at [at_fresh]
urbanc@19972
   818
		  val thms2 = inst_dj [at_fresh_ineq]
urbanc@19972
   819
	      in [(("fresh_atm", thms1 @ thms2),[])] end
urbanc@19992
   820
            ||>> PureThy.add_thmss
berghofe@20377
   821
	      let val thms1 = filter
berghofe@20377
   822
                (fn th => case prop_of th of _ $ _ $ Var _ => true | _ => false)
berghofe@20377
   823
                (List.concat (List.concat perm_defs))
urbanc@19993
   824
              in [(("calc_atm", (inst_at at_calc) @ thms1),[])] end
urbanc@18381
   825
            ||>> PureThy.add_thmss
urbanc@18279
   826
	      let val thms1 = inst_pt_at [abs_fun_pi]
urbanc@18279
   827
		  and thms2 = inst_pt_pt_at_cp [abs_fun_pi_ineq]
urbanc@22557
   828
	      in [(("abs_perm", thms1 @ thms2),[NominalThmDecls.eqvt_add])] end
urbanc@18381
   829
            ||>> PureThy.add_thmss
urbanc@18279
   830
	      let val thms1 = inst_dj [dj_perm_forget]
urbanc@18279
   831
		  and thms2 = inst_dj [dj_pp_forget]
urbanc@18279
   832
              in [(("perm_dj", thms1 @ thms2),[])] end
urbanc@18381
   833
            ||>> PureThy.add_thmss
urbanc@18279
   834
	      let val thms1 = inst_pt_at_fs [fresh_iff]
urbanc@18626
   835
                  and thms2 = inst_pt_at [fresh_iff]
urbanc@18626
   836
		  and thms3 = inst_pt_pt_at_cp_dj [fresh_iff_ineq]
urbanc@18626
   837
	    in [(("abs_fresh", thms1 @ thms2 @ thms3),[])] end
urbanc@18381
   838
	    ||>> PureThy.add_thmss
urbanc@18279
   839
	      let val thms1 = inst_pt_at [abs_fun_supp]
urbanc@18279
   840
		  and thms2 = inst_pt_at_fs [abs_fun_supp]
urbanc@18279
   841
		  and thms3 = inst_pt_pt_at_cp_dj [abs_fun_supp_ineq]
urbanc@18279
   842
	      in [(("abs_supp", thms1 @ thms2 @ thms3),[])] end
urbanc@18396
   843
            ||>> PureThy.add_thmss
urbanc@18396
   844
	      let val thms1 = inst_pt_at [fresh_left]
urbanc@18396
   845
		  and thms2 = inst_pt_pt_at_cp [fresh_left_ineq]
urbanc@18396
   846
	      in [(("fresh_left", thms1 @ thms2),[])] end
urbanc@18426
   847
            ||>> PureThy.add_thmss
urbanc@19548
   848
	      let val thms1 = inst_pt_at [fresh_right]
urbanc@19548
   849
		  and thms2 = inst_pt_pt_at_cp [fresh_right_ineq]
urbanc@19548
   850
	      in [(("fresh_right", thms1 @ thms2),[])] end
urbanc@19548
   851
            ||>> PureThy.add_thmss
urbanc@18426
   852
	      let val thms1 = inst_pt_at [fresh_bij]
urbanc@22418
   853
 		  and thms2 = inst_pt_pt_at_cp [fresh_bij_ineq]
urbanc@19972
   854
	      in [(("fresh_bij", thms1 @ thms2),[])] end
urbanc@19972
   855
            ||>> PureThy.add_thmss
urbanc@19972
   856
	      let val thms1 = inst_pt_at [fresh_eqvt]
urbanc@22535
   857
                  and thms2 = inst_pt_pt_at_cp_dj [fresh_eqvt_ineq]
urbanc@22535
   858
	      in [(("fresh_eqvt", thms1 @ thms2),[NominalThmDecls.eqvt_add])] end
urbanc@22418
   859
            ||>> PureThy.add_thmss
urbanc@22418
   860
	      let val thms1 = inst_pt_at [in_eqvt]
urbanc@22418
   861
	      in [(("in_eqvt", thms1),[NominalThmDecls.eqvt_add])] end
urbanc@22418
   862
  	    ||>> PureThy.add_thmss
urbanc@22418
   863
	      let val thms1 = inst_pt_at [eq_eqvt]
urbanc@22418
   864
	      in [(("eq_eqvt", thms1),[NominalThmDecls.eqvt_add])] end
urbanc@22418
   865
	    ||>> PureThy.add_thmss
urbanc@22418
   866
	      let val thms1 = inst_pt_at [set_diff_eqvt]
urbanc@22418
   867
	      in [(("set_diff_eqvt", thms1),[NominalThmDecls.eqvt_add])] end
urbanc@19638
   868
            ||>> PureThy.add_thmss
urbanc@19638
   869
	      let val thms1 = inst_pt_at [fresh_aux]
narboux@22786
   870
		  and thms2 = inst_pt_pt_at_cp_dj [fresh_perm_app_ineq] 
narboux@22786
   871
	      in  [(("fresh_aux", thms1 @ thms2),[])] end  
narboux@22785
   872
            ||>> PureThy.add_thmss
narboux@22785
   873
	      let val thms1 = inst_pt_at [fresh_perm_app]
narboux@22786
   874
		  and thms2 = inst_pt_pt_at_cp_dj [fresh_perm_app_ineq] 
narboux@22794
   875
	      in  [(("fresh_perm_app", thms1 @ thms2),[])] end 
narboux@22794
   876
            ||>> PureThy.add_thmss
narboux@22794
   877
	      let val thms1 = inst_pt_at [pt_perm_supp]
narboux@22794
   878
		  and thms2 = inst_pt_pt_at_cp [pt_perm_supp_ineq] 
narboux@22794
   879
	      in  [(("supp_eqvt", thms1 @ thms2),[NominalThmDecls.eqvt_add])] end  
urbanc@22418
   880
            ||>> PureThy.add_thmss [(("fin_supp",fs_axs),[])]
berghofe@18068
   881
	   end;
berghofe@18068
   882
urbanc@22418
   883
    in 
urbanc@22418
   884
      NominalData.map (fold Symtab.update (full_ak_names ~~ map make_atom_info
urbanc@22418
   885
        (pt_ax_classes ~~
urbanc@22418
   886
         fs_ax_classes ~~
urbanc@22418
   887
         map (fn cls => full_ak_names ~~ cls) cp_ax_classes))) thy33
berghofe@18068
   888
    end;
berghofe@18068
   889
berghofe@18068
   890
berghofe@18068
   891
(* syntax und parsing *)
berghofe@18068
   892
structure P = OuterParse and K = OuterKeyword;
berghofe@18068
   893
berghofe@18068
   894
val atom_declP =
berghofe@18068
   895
  OuterSyntax.command "atom_decl" "Declare new kinds of atoms" K.thy_decl
berghofe@18068
   896
    (Scan.repeat1 P.name >> (Toplevel.theory o create_nom_typedecls));
berghofe@18068
   897
berghofe@18068
   898
val _ = OuterSyntax.add_parsers [atom_declP];
berghofe@18068
   899
berghofe@18068
   900
end;