src/Pure/defs.ML
changeset 61253 63875746d82d
parent 61249 8611f408ec13
child 61254 4918c6e52a02
equal deleted inserted replaced
61252:c165f0472d57 61253:63875746d82d
     8 signature DEFS =
     8 signature DEFS =
     9 sig
     9 sig
    10   datatype item_kind = Constant | Type
    10   datatype item_kind = Constant | Type
    11   type item = item_kind * string
    11   type item = item_kind * string
    12   val item_ord: item * item -> order
    12   val item_ord: item * item -> order
    13   val pretty_item: Proof.context -> item * typ list -> Pretty.T
    13   val pretty_args: Proof.context -> typ list -> Pretty.T list
    14   val plain_args: typ list -> bool
    14   val plain_args: typ list -> bool
    15   type T
    15   type T
    16   type spec =
    16   type spec =
    17    {def: string option,
    17    {def: string option,
    18     description: string,
    18     description: string,
    43   | item_kind_ord _ = EQUAL;
    43   | item_kind_ord _ = EQUAL;
    44 
    44 
    45 val item_ord = prod_ord item_kind_ord string_ord;
    45 val item_ord = prod_ord item_kind_ord string_ord;
    46 val fast_item_ord = prod_ord item_kind_ord fast_string_ord;
    46 val fast_item_ord = prod_ord item_kind_ord fast_string_ord;
    47 
    47 
    48 val print_item_kind = fn Constant => "constant" | Type => "type";
    48 fun print_item (k, s) = if k = Constant then s else "type " ^ s;
    49 fun print_item (k, s) = print_item_kind k ^ " " ^ quote s;
       
    50 
    49 
    51 structure Itemtab = Table(type key = item val ord = fast_item_ord);
    50 structure Itemtab = Table(type key = item val ord = fast_item_ord);
    52 
    51 
    53 
    52 
    54 (* type arguments *)
    53 (* type arguments *)
    55 
    54 
    56 type args = typ list;
    55 type args = typ list;
    57 
    56 
    58 fun pretty_item ctxt (c, args) =
    57 fun pretty_args ctxt args =
    59   let
    58   if null args then []
    60     val prt_args =
    59   else [Pretty.list "(" ")" (map (Syntax.pretty_typ ctxt o Logic.unvarifyT_global) args)];
    61       if null args then []
    60 
    62       else [Pretty.list "(" ")" (map (Syntax.pretty_typ ctxt o Logic.unvarifyT_global) args)];
    61 fun pretty_entry ctxt (c, args) =
    63   in Pretty.block (Pretty.str (print_item c) :: prt_args) end;
    62   Pretty.block (Pretty.str (print_item c) :: pretty_args ctxt args);
    64 
    63 
    65 fun plain_args args =
    64 fun plain_args args =
    66   forall Term.is_TVar args andalso not (has_duplicates (op =) args);
    65   forall Term.is_TVar args andalso not (has_duplicates (op =) args);
    67 
    66 
    68 fun disjoint_args (Ts, Us) =
    67 fun disjoint_args (Ts, Us) =
   147 
   146 
   148 (* normalized dependencies: reduction with well-formedness check *)
   147 (* normalized dependencies: reduction with well-formedness check *)
   149 
   148 
   150 local
   149 local
   151 
   150 
   152 val prt = Pretty.string_of oo pretty_item;
   151 val prt = Pretty.string_of oo pretty_entry;
   153 fun err ctxt (c, args) (d, Us) s1 s2 =
   152 fun err ctxt (c, args) (d, Us) s1 s2 =
   154   error (s1 ^ " dependency of " ^ prt ctxt (c, args) ^ " -> " ^ prt ctxt (d, Us) ^ s2);
   153   error (s1 ^ " dependency of " ^ prt ctxt (c, args) ^ " -> " ^ prt ctxt (d, Us) ^ s2);
   155 
   154 
   156 fun acyclic ctxt (c, args) (d, Us) =
   155 fun acyclic ctxt (c, args) (d, Us) =
   157   c <> d orelse
   156   c <> d orelse