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