src/Pure/sign.ML
author wenzelm
Thu Jun 09 11:02:14 1994 +0200 (1994-06-09)
changeset 418 ab09293bccc7
parent 410 c8171ee32744
child 421 95e1d4faa863
permissions -rw-r--r--
workaround bug in Type.expand_typ;
     1 (*  Title:      Pure/sign.ML
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson and Markus Wenzel
     4 
     5 The abstract type "sg" of signatures.
     6 
     7 TODO:
     8   pure sign: elim Syntax.constrainC
     9 *)
    10 
    11 signature SIGN =
    12 sig
    13   structure Symtab: SYMTAB
    14   structure Syntax: SYNTAX
    15   structure Type: TYPE
    16   sharing Symtab = Type.Symtab
    17   local open Type Syntax Syntax.Mixfix in
    18     type sg
    19     val rep_sg: sg ->
    20       {tsig: type_sig,
    21        const_tab: typ Symtab.table,
    22        syn: syntax,
    23        stamps: string ref list}
    24     val subsig: sg * sg -> bool
    25     val eq_sg: sg * sg -> bool
    26     val is_draft: sg -> bool
    27     val const_type: sg -> string -> typ option
    28     val classes: sg -> class list
    29     val subsort: sg -> sort * sort -> bool      (* FIXME move? *)
    30     val norm_sort: sg -> sort -> sort           (* FIXME move? *)
    31     val print_sg: sg -> unit
    32     val pprint_sg: sg -> pprint_args -> unit
    33     val pretty_term: sg -> term -> Pretty.T
    34     val pretty_typ: sg -> typ -> Pretty.T
    35     val string_of_term: sg -> term -> string
    36     val string_of_typ: sg -> typ -> string
    37     val pprint_term: sg -> term -> pprint_args -> unit
    38     val pprint_typ: sg -> typ -> pprint_args -> unit
    39     val certify_typ: sg -> typ -> typ
    40     val certify_term: sg -> term -> term * typ * int
    41     val read_typ: sg * (indexname -> sort option) -> string -> typ
    42     val add_classes: (class list * class * class list) list -> sg -> sg
    43     val add_defsort: sort -> sg -> sg
    44     val add_types: (string * int * mixfix) list -> sg -> sg
    45     val add_tyabbrs: (string * string list * string * mixfix) list -> sg -> sg
    46     val add_tyabbrs_i: (string * string list * typ * mixfix) list -> sg -> sg
    47     val add_arities: (string * sort list * sort) list -> sg -> sg
    48     val add_consts: (string * string * mixfix) list -> sg -> sg
    49     val add_consts_i: (string * typ * mixfix) list -> sg -> sg
    50     val add_syntax: (string * string * mixfix) list -> sg -> sg
    51     val add_syntax_i: (string * typ * mixfix) list -> sg -> sg
    52     val add_trfuns:
    53       (string * (ast list -> ast)) list *
    54       (string * (term list -> term)) list *
    55       (string * (term list -> term)) list *
    56       (string * (ast list -> ast)) list -> sg -> sg
    57     val add_trrules: xrule list -> sg -> sg
    58     val add_name: string -> sg -> sg
    59     val make_draft: sg -> sg
    60     val extend: sg -> string ->
    61       (class * class list) list * class list *
    62       (string list * int) list *
    63       (string * string list * string) list *
    64       (string list * (sort list * class)) list *
    65       (string list * string) list * sext option -> sg
    66     val merge: sg * sg -> sg
    67     val pure: sg
    68     val const_of_class: class -> string
    69     val class_of_const: string -> class
    70   end
    71 end;
    72 
    73 functor SignFun(structure Syntax: SYNTAX and Type: TYPE): SIGN =
    74 struct
    75 
    76 structure Symtab = Type.Symtab;
    77 structure Syntax = Syntax;
    78 structure BasicSyntax: BASIC_SYNTAX = Syntax;
    79 structure Pretty = Syntax.Pretty;
    80 structure Type = Type;
    81 open BasicSyntax Type;
    82 open Syntax.Mixfix;   (* FIXME *)
    83 
    84 
    85 (** datatype sg **)
    86 
    87 (*the "ref" in stamps ensures that no two signatures are identical -- it is
    88   impossible to forge a signature*)
    89 
    90 datatype sg =
    91   Sg of {
    92     tsig: type_sig,                 (*order-sorted signature of types*)
    93     const_tab: typ Symtab.table,    (*types of constants*)
    94     syn: Syntax.syntax,             (*syntax for parsing and printing*)
    95     stamps: string ref list};       (*unique theory indentifier*)
    96 
    97 fun rep_sg (Sg args) = args;
    98 val tsig_of = #tsig o rep_sg;
    99 
   100 
   101 (* stamps *)
   102 
   103 fun is_draft (Sg {stamps = ref "#" :: _, ...}) = true
   104   | is_draft _ = false;
   105 
   106 fun subsig (Sg {stamps = s1, ...}, Sg {stamps = s2, ...}) = s1 subset s2;
   107 
   108 fun eq_sg (Sg {stamps = s1, ...}, Sg {stamps = s2, ...}) = eq_set (s1, s2);
   109 
   110 
   111 (* consts *)
   112 
   113 fun const_type (Sg {const_tab, ...}) c =
   114   Symtab.lookup (const_tab, c);
   115 
   116 
   117 (* classes *)
   118 
   119 val classes = #classes o Type.rep_tsig o tsig_of;
   120 
   121 val subsort = Type.subsort o tsig_of;
   122 val norm_sort = Type.norm_sort o tsig_of;
   123 
   124 
   125 
   126 (** print signature **)
   127 
   128 val stamp_names = rev o map !;
   129 
   130 fun print_sg sg =
   131   let
   132     fun prt_typ syn ty = Pretty.quote (Syntax.pretty_typ syn ty);
   133 
   134     fun pretty_sort [cl] = Pretty.str cl
   135       | pretty_sort cls = Pretty.str_list "{" "}" cls;
   136 
   137     fun pretty_subclass (cl, cls) = Pretty.block
   138       [Pretty.str (cl ^ " <"), Pretty.brk 1, pretty_sort cls];
   139 
   140     fun pretty_default cls = Pretty.block
   141       [Pretty.str "default:", Pretty.brk 1, pretty_sort cls];
   142 
   143     fun pretty_arg (ty, n) = Pretty.str (ty ^ " " ^ string_of_int n);
   144 
   145     fun pretty_abbr syn (ty, (vs, rhs)) = Pretty.block
   146       [prt_typ syn (Type (ty, map (fn v => TVar (v, [])) vs)),
   147         Pretty.str " =", Pretty.brk 1, prt_typ syn rhs];
   148 
   149     fun pretty_arity ty (cl, []) = Pretty.block
   150           [Pretty.str (ty ^ " ::"), Pretty.brk 1, Pretty.str cl]
   151       | pretty_arity ty (cl, srts) = Pretty.block
   152           [Pretty.str (ty ^ " ::"), Pretty.brk 1,
   153             Pretty.list "(" ")" (map pretty_sort srts),
   154             Pretty.brk 1, Pretty.str cl];
   155 
   156     fun pretty_coreg (ty, ars) = map (pretty_arity ty) ars;
   157 
   158     fun pretty_const syn (c, ty) = Pretty.block
   159       [Pretty.str (quote c ^ " ::"), Pretty.brk 1, prt_typ syn ty];
   160 
   161 
   162     val Sg {tsig, const_tab, syn, stamps} = sg;
   163     val {classes, subclass, default, args, abbrs, coreg} = rep_tsig tsig;
   164   in
   165     Pretty.writeln (Pretty.strs ("stamps:" :: stamp_names stamps));
   166     Pretty.writeln (Pretty.strs ("classes:" :: classes));
   167     Pretty.writeln (Pretty.big_list "subclass:" (map pretty_subclass subclass));
   168     Pretty.writeln (pretty_default default);
   169     Pretty.writeln (Pretty.big_list "types:" (map pretty_arg args));
   170     Pretty.writeln (Pretty.big_list "abbrs:" (map (pretty_abbr syn) abbrs));
   171     Pretty.writeln (Pretty.big_list "coreg:" (flat (map pretty_coreg coreg)));
   172     Pretty.writeln (Pretty.big_list "consts:"
   173       (map (pretty_const syn) (Symtab.dest const_tab)))
   174   end;
   175 
   176 
   177 fun pprint_sg (Sg {stamps, ...}) =
   178   Pretty.pprint (Pretty.str_list "{" "}" (stamp_names stamps));
   179 
   180 
   181 
   182 (** pretty printing of terms and types **)
   183 
   184 fun pretty_term (Sg {syn, ...}) = Syntax.pretty_term syn;
   185 fun pretty_typ (Sg {syn, ...}) = Syntax.pretty_typ syn;
   186 
   187 fun string_of_term (Sg {syn, ...}) = Syntax.string_of_term syn;
   188 fun string_of_typ (Sg {syn, ...}) = Syntax.string_of_typ syn;
   189 
   190 fun pprint_term sg = Pretty.pprint o Pretty.quote o (pretty_term sg);
   191 fun pprint_typ sg = Pretty.pprint o Pretty.quote o (pretty_typ sg);
   192 
   193 
   194 
   195 (** certify types and terms **)   (*exception TYPE*)
   196 
   197 fun certify_typ (Sg {tsig, ...}) ty = cert_typ tsig ty;
   198 
   199 
   200 fun mapfilt_atoms f (Abs (_, _, t)) = mapfilt_atoms f t
   201   | mapfilt_atoms f (t $ u) = mapfilt_atoms f t @ mapfilt_atoms f u
   202   | mapfilt_atoms f a = (case f a of Some y => [y] | None => []);
   203 
   204 fun certify_term (sg as Sg {tsig, ...}) tm =
   205   let
   206     fun valid_const a T =
   207       (case const_type sg a of
   208         Some U => typ_instance (tsig, T, U)
   209       | _ => false);
   210 
   211     fun atom_err (Const (a, T)) =
   212           if valid_const a T then None
   213           else Some ("Illegal type for constant " ^ quote a ^ " :: " ^
   214             quote (string_of_typ sg T))
   215       | atom_err (Var ((x, i), _)) =
   216           if i < 0 then Some ("Negative index for Var " ^ quote x) else None
   217       | atom_err _ = None;
   218 
   219     val norm_tm =
   220       (case it_term_types (typ_errors tsig) (tm, []) of
   221         [] => map_term_types (norm_typ tsig) tm
   222       | errs => raise_type (cat_lines errs) [] [tm]);
   223   in
   224     (case mapfilt_atoms atom_err norm_tm of
   225       [] => (norm_tm, type_of norm_tm, maxidx_of_term norm_tm)
   226     | errs => raise_type (cat_lines errs) [] [norm_tm])
   227   end;
   228 
   229 
   230 
   231 (** read types **)    (*exception ERROR*)
   232 
   233 (* FIXME rd_typ vs. read_raw_typ (?) *)
   234 
   235 fun rd_typ tsig syn sort_of s =
   236   let
   237     val def_sort = defaultS tsig;
   238     val raw_ty =        (*this may raise ERROR, too!*)
   239       Syntax.read_typ syn (fn x => if_none (sort_of x) def_sort) s;
   240   in
   241     cert_typ tsig raw_ty
   242       handle TYPE (msg, _, _) => error msg
   243   end
   244   handle ERROR => error ("The error(s) above occurred in type " ^ quote s);
   245 
   246 fun read_typ (Sg {tsig, syn, ...}, sort_of) s = rd_typ tsig syn sort_of s;
   247 
   248 
   249 
   250 (** extend signature **)    (*exception ERROR*)
   251 
   252 (* FIXME -> type.ML *)
   253 
   254 (* FIXME replace? *)
   255 fun varify_typ (Type (t, tys)) = Type (t, map varify_typ tys)
   256   | varify_typ (TFree (a, s)) = TVar ((a, 0), s)
   257   | varify_typ (ty as TVar _) =
   258       raise_type "Illegal schematic type variable" [ty] [];
   259 
   260 
   261 (* fake newstyle interfaces *) (* FIXME -> type.ML *)
   262 
   263 fun ext_tsig_classes tsig classes =
   264   if exists (fn ([], _, _) => false | _ => true) classes then
   265     sys_error "FIXME ext_tsig_classes"
   266   else
   267     extend_tsig tsig (map (fn (_, c, cs) => (c, cs)) classes, [], [], []);
   268 
   269 fun ext_tsig_defsort tsig defsort =
   270   extend_tsig tsig ([], defsort, [], []);
   271 
   272 fun ext_tsig_types tsig types =
   273   extend_tsig tsig ([], [], map (fn (t, n) => ([t], n)) types, []);
   274 
   275 (* FIXME varify_typ, rem_sorts; norm_typ (?) *)
   276 fun ext_tsig_abbrs tsig abbrs = Type.ext_tsig_abbrs tsig
   277   (map (fn (t, vs, rhs) => (t, (map (rpair 0) vs, varifyT rhs))) abbrs);
   278 
   279 fun ext_tsig_arities tsig arities = extend_tsig tsig
   280   ([], [], [], flat (map (fn (t, ss, cs) => map (fn c => ([t], (ss, c))) cs) arities));
   281 
   282 
   283 
   284 (** read types **)  (*exception ERROR*)
   285 
   286 fun err_in_type s =
   287   error ("The error(s) above occurred in type " ^ quote s);
   288 
   289 fun read_raw_typ syn tsig sort_of str =
   290   Syntax.read_typ syn (fn x => if_none (sort_of x) (defaultS tsig)) str
   291     handle ERROR => err_in_type str;
   292 
   293 (*read and certify typ wrt a signature*)
   294 fun read_typ (Sg {tsig, syn, ...}, sort_of) str =
   295   cert_typ tsig (read_raw_typ syn tsig sort_of str)
   296     handle TYPE (msg, _, _) => (writeln msg; err_in_type str);
   297 
   298 
   299 
   300 (** extension functions **)  (*exception ERROR*)
   301 
   302 fun decls_of name_of mfixs =
   303   map (fn (x, y, mx) => (name_of x mx, y)) mfixs;
   304 
   305 
   306 (* add default sort *)
   307 
   308 fun ext_defsort (syn, tsig, ctab) defsort =
   309   (syn, ext_tsig_defsort tsig defsort, ctab);
   310 
   311 
   312 (* add type constructors *)
   313 
   314 fun ext_types (syn, tsig, ctab) types =
   315   (Syntax.extend_type_gram syn types,
   316     ext_tsig_types tsig (decls_of type_name types),
   317     ctab);
   318 
   319 
   320 (* add type abbreviations *)
   321 
   322 fun read_abbr syn tsig (t, vs, rhs_src) =
   323   (t, vs, read_raw_typ syn tsig (K None) rhs_src)
   324     handle ERROR => error ("in type abbreviation " ^ t);
   325 
   326 fun ext_abbrs rd_abbr (syn, tsig, ctab) abbrs =
   327   let
   328     fun mfix_of (t, vs, _, mx) = (t, length vs, mx);
   329     val syn1 = Syntax.extend_type_gram syn (map mfix_of abbrs);
   330 
   331     fun decl_of (t, vs, rhs, mx) =
   332       rd_abbr syn1 tsig (type_name t mx, vs, rhs);
   333   in
   334     (syn1, ext_tsig_abbrs tsig (map decl_of abbrs), ctab)
   335   end;
   336 
   337 val ext_tyabbrs_i = ext_abbrs (K (K I));
   338 val ext_tyabbrs = ext_abbrs read_abbr;
   339 
   340 
   341 (* add type arities *)
   342 
   343 fun ext_arities (syn, tsig, ctab) arities =
   344   let
   345     val tsig1 = ext_tsig_arities tsig arities;
   346     val log_types = logical_types tsig1;
   347   in
   348     (Syntax.extend_log_types syn log_types, tsig1, ctab)
   349   end;
   350 
   351 
   352 (* add term constants and syntax *)
   353 
   354 fun err_in_const c =
   355   error ("in declaration of constant " ^ quote c);
   356 
   357 fun err_dup_consts cs =
   358   error ("Duplicate declaration of constant(s) " ^ commas_quote cs);
   359 
   360 
   361 fun read_const syn tsig (c, ty_src, mx) =
   362   (c, read_raw_typ syn tsig (K None) ty_src, mx)
   363     handle ERROR => err_in_const (const_name c mx);
   364 
   365 (* FIXME move *)
   366 fun no_tvars ty =
   367   if null (typ_tvars ty) then ty
   368   else raise_type "Illegal schematic type variable(s)" [ty] [];
   369 
   370 fun ext_cnsts rd_const syn_only (syn, tsig, ctab) raw_consts =
   371   let
   372     (* FIXME clean *)
   373     fun prep_const (c, ty, mx) = (c, varify_typ (cert_typ tsig (no_tvars ty)), mx)
   374       handle TYPE (msg, _, _) => (writeln msg; err_in_const (const_name c mx));
   375 
   376     val consts = map (prep_const o rd_const syn tsig) raw_consts;
   377     val decls =
   378       if syn_only then []
   379       else filter_out (equal "" o fst) (decls_of const_name consts);
   380   in
   381     (Syntax.extend_const_gram syn consts, tsig,
   382       Symtab.extend_new (ctab, decls)
   383         handle Symtab.DUPS cs => err_dup_consts cs)
   384   end;
   385 
   386 val ext_consts_i = ext_cnsts (K (K I)) false;
   387 val ext_consts = ext_cnsts read_const false;
   388 val ext_syntax_i = ext_cnsts (K (K I)) true;
   389 val ext_syntax = ext_cnsts read_const true;
   390 
   391 
   392 (* add type classes *)
   393 
   394 fun const_of_class c = c ^ "_class";
   395 
   396 fun class_of_const c_class =
   397   let
   398     val c = implode (take (size c_class - 6, explode c_class));
   399   in
   400     if const_of_class c = c_class then c
   401     else raise_term ("class_of_const: bad name " ^ quote c_class) []
   402   end;
   403 
   404 
   405 fun ext_classes (syn, tsig, ctab) classes =
   406   let
   407     val names = map (fn (_, c, _) => c) classes;
   408     val consts =
   409       map (fn c => (const_of_class c, a_itselfT --> propT, NoSyn)) names;
   410   in
   411     ext_consts_i
   412       (Syntax.extend_consts syn names, ext_tsig_classes tsig classes, ctab)
   413       consts
   414   end;
   415 
   416 
   417 (* add syntactic translations *)
   418 
   419 fun ext_trfuns (syn, tsig, ctab) trfuns =
   420   (Syntax.extend_trfuns syn trfuns, tsig, ctab);
   421 
   422 fun ext_trrules (syn, tsig, ctab) xrules =
   423   (Syntax.extend_trrules syn xrules, tsig, ctab);
   424 
   425 
   426 (* build signature *)
   427 
   428 fun ext_stamps stamps name =
   429   let
   430     val stmps = (case stamps of ref "#" :: ss => ss | ss => ss);
   431   in
   432     if exists (equal name o !) stmps then
   433       error ("Theory already contains a " ^ quote name ^ " component")
   434     else ref name :: stmps
   435   end;
   436 
   437 fun make_sign (syn, tsig, ctab) stamps name =
   438   Sg {tsig = tsig, const_tab = ctab, syn = syn,
   439     stamps = ext_stamps stamps name};
   440 
   441 fun extend_sign extfun name decls (Sg {tsig, const_tab, syn, stamps}) =
   442   make_sign (extfun (syn, tsig, const_tab) decls) stamps name;
   443 
   444 
   445 (* the external interfaces *)
   446 
   447 val add_classes   = extend_sign ext_classes "#";
   448 val add_defsort   = extend_sign ext_defsort "#";
   449 val add_types     = extend_sign ext_types "#";
   450 val add_tyabbrs   = extend_sign ext_tyabbrs "#";
   451 val add_tyabbrs_i = extend_sign ext_tyabbrs_i "#";
   452 val add_arities   = extend_sign ext_arities "#";
   453 val add_consts    = extend_sign ext_consts "#";
   454 val add_consts_i  = extend_sign ext_consts_i "#";
   455 val add_syntax    = extend_sign ext_syntax "#";
   456 val add_syntax_i  = extend_sign ext_syntax_i "#";
   457 val add_trfuns    = extend_sign ext_trfuns "#";
   458 val add_trrules   = extend_sign ext_trrules "#";
   459 
   460 fun add_name name sg = extend_sign K name () sg;
   461 val make_draft = add_name "#";
   462 
   463 
   464 
   465 (** extend signature (old) **)      (* FIXME remove *)
   466 
   467 fun extend sg name (classes, default, types, abbrs, arities, consts, opt_sext) =
   468   let
   469     fun read_abbr syn (c, vs, rhs_src) =
   470       (c, (map (rpair 0) vs, varifyT (Syntax.read_typ syn (K []) rhs_src)))
   471         handle ERROR => error ("The error(s) above occurred in the rhs " ^
   472           quote rhs_src ^ "\nof type abbreviation " ^ quote c);
   473 
   474     (*reset TVar indices to 0, renaming to preserve distinctness*)
   475     fun zero_tvar_idxs T =
   476       let
   477         val inxSs = typ_tvars T;
   478         val nms' = variantlist (map (#1 o #1) inxSs, []);
   479         val tye = map2 (fn ((v, S), a) => (v, TVar ((a, 0), S))) (inxSs, nms');
   480       in
   481         typ_subst_TVars tye T
   482       end;
   483 
   484     (*read and check the type mentioned in a const declaration; zero type var
   485       indices because type inference requires it*)
   486     fun read_const tsig syn (c, s) =
   487       (c, zero_tvar_idxs (varifyT (rd_typ tsig syn (K None) s)))
   488         handle ERROR => error ("in declaration of constant " ^ quote c);
   489 
   490 
   491     val Sg {tsig, const_tab, syn, stamps} = sg;
   492     val xconsts = map #1 classes @ flat (map #1 types) @ map #1 abbrs @
   493       flat (map #1 consts);
   494     val sext = if_none opt_sext Syntax.empty_sext;
   495 
   496     val tsig' = extend_tsig tsig (classes, default, types, arities);
   497     val tsig1 = Type.ext_tsig_abbrs tsig' (map (read_abbr syn) abbrs);
   498 
   499     val syn1 = Syntax.extend syn (rd_typ tsig1 syn (K None))
   500       (logical_types tsig1, xconsts, sext);
   501 
   502     val all_consts = flat (map (fn (cs, s) => map (rpair s) cs)
   503       (Syntax.constants sext @ consts));
   504 
   505     val const_tab1 =
   506       Symtab.extend_new (const_tab, map (read_const tsig1 syn) all_consts)
   507         handle Symtab.DUPS cs => err_dup_consts cs;
   508 
   509     val stamps1 = ext_stamps stamps name;
   510   in
   511     Sg {tsig = tsig1, const_tab = const_tab1, syn = syn1, stamps = stamps1}
   512   end;
   513 
   514 
   515 
   516 (** merge signatures **)    (*exception TERM*)
   517 
   518 fun merge (sg1, sg2) =
   519   if subsig (sg2, sg1) then sg1
   520   else if subsig (sg1, sg2) then sg2
   521   else if is_draft sg1 orelse is_draft sg2 then
   522     raise_term "Illegal merge of draft signatures" []
   523   else
   524     (*neither is union already; must form union*)
   525     let
   526       val Sg {tsig = tsig1, const_tab = const_tab1, syn = syn1,
   527         stamps = stamps1} = sg1;
   528       val Sg {tsig = tsig2, const_tab = const_tab2, syn = syn2,
   529         stamps = stamps2} = sg2;
   530 
   531 
   532       val stamps = merge_rev_lists stamps1 stamps2;
   533       val _ =
   534         (case duplicates (stamp_names stamps) of
   535           [] => ()
   536         | dups => raise_term ("Attempt to merge different versions of theories "
   537             ^ commas_quote dups) []);
   538 
   539       val tsig = merge_tsigs (tsig1, tsig2);
   540 
   541       val const_tab = Symtab.merge (op =) (const_tab1, const_tab2)
   542         handle Symtab.DUPS cs =>
   543           raise_term ("Incompatible types for constant(s) " ^ commas_quote cs) [];
   544 
   545       val syn = Syntax.merge_syntaxes syn1 syn2;
   546     in
   547       Sg {tsig = tsig, const_tab = const_tab, syn = syn, stamps = stamps}
   548     end;
   549 
   550 
   551 
   552 (** the Pure signature **)
   553 
   554 val pure =
   555   make_sign (Syntax.type_syn, tsig0, Symtab.null) [] "#"
   556   |> add_types
   557    (("fun", 2, NoSyn) ::
   558     ("prop", 0, NoSyn) ::
   559     ("itself", 1, NoSyn) ::
   560     Syntax.Mixfix.pure_types)
   561   |> add_classes [([], logicC, [])]
   562   |> add_defsort logicS
   563   |> add_arities
   564    [("fun", [logicS, logicS], logicS),
   565     ("prop", [], logicS),
   566     ("itself", [logicS], logicS)]
   567   |> add_syntax Syntax.Mixfix.pure_syntax
   568   |> add_trfuns Syntax.pure_trfuns
   569   |> add_consts
   570    [("==", "['a::{}, 'a] => prop", Mixfix ("(_ ==/ _)", [3, 2], 2)),
   571     ("=?=", "['a::{}, 'a] => prop", Mixfix ("(_ =?=/ _)", [3, 2], 2)),
   572     ("==>", "[prop, prop] => prop", Mixfix ("(_ ==>/ _)", [2, 1], 1)),
   573     ("all", "('a => prop) => prop", Binder ("!!", 0)),
   574     ("TYPE", "'a itself", NoSyn),
   575     (Syntax.constrainC, "'a::{} => 'a", NoSyn)]
   576   |> add_name "Pure";
   577 
   578 
   579 end;
   580