src/Pure/display.ML
changeset 4250 3806a00677ff
parent 4210 abce78c8a931
child 4256 e768c42069bb
     1.1 --- a/src/Pure/display.ML	Thu Nov 20 12:50:57 1997 +0100
     1.2 +++ b/src/Pure/display.ML	Thu Nov 20 12:51:31 1997 +0100
     1.3 @@ -98,13 +98,76 @@
     1.4  val print_cterm = writeln o string_of_cterm;
     1.5  
     1.6  
     1.7 -(* print theory *)
     1.8 +
     1.9 +(** print theory **)
    1.10  
    1.11  val pprint_theory = Sign.pprint_sg o sign_of;
    1.12  
    1.13  val print_syntax = Syntax.print_syntax o syn_of;
    1.14  val print_data = Sign.print_data o sign_of;
    1.15  
    1.16 +
    1.17 +(* print signature *)
    1.18 +
    1.19 +fun print_sign sg =
    1.20 +  let
    1.21 +    fun prt_cls c = Sign.pretty_sort sg [c];
    1.22 +    fun prt_sort S = Sign.pretty_sort sg S;
    1.23 +    fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
    1.24 +    fun prt_typ ty = Pretty.quote (Sign.pretty_typ sg ty);
    1.25 +
    1.26 +    val ext_class = Sign.cond_extern sg Sign.classK;
    1.27 +    val ext_tycon = Sign.cond_extern sg Sign.typeK;
    1.28 +    val ext_const = Sign.cond_extern sg Sign.constK;
    1.29 +
    1.30 +
    1.31 +    fun pretty_space (kind, space) = Pretty.block (Pretty.breaks
    1.32 +      (map Pretty.str (kind ^ ":" :: map quote (NameSpace.dest space))));
    1.33 +
    1.34 +    fun pretty_classes cs = Pretty.block
    1.35 +      (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
    1.36 +
    1.37 +    fun pretty_classrel (c, cs) = Pretty.block
    1.38 +      (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
    1.39 +        Pretty.commas (map prt_cls cs));
    1.40 +
    1.41 +    fun pretty_default S = Pretty.block
    1.42 +      [Pretty.str "default:", Pretty.brk 1, prt_sort S];
    1.43 +
    1.44 +    fun pretty_ty (t, n) = Pretty.block
    1.45 +      [Pretty.str (ext_tycon t), Pretty.str (" " ^ string_of_int n)];
    1.46 +
    1.47 +    fun pretty_abbr (t, (vs, rhs)) = Pretty.block
    1.48 +      [prt_typ (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
    1.49 +        Pretty.str " =", Pretty.brk 1, prt_typ rhs];
    1.50 +
    1.51 +    fun pretty_arities (t, ars) = map (prt_arity t) ars;
    1.52 +
    1.53 +    fun pretty_const (c, ty) = Pretty.block
    1.54 +      [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ ty];
    1.55 +
    1.56 +    val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
    1.57 +    val spaces' = sort (fn ((k1, _), (k2, _)) => k1 < k2) spaces;
    1.58 +    val {classes, classrel, default, tycons, abbrs, arities} =
    1.59 +      Type.rep_tsig tsig;
    1.60 +    val consts = sort_wrt fst (map (apfst ext_const) (Symtab.dest const_tab));
    1.61 +  in
    1.62 +    Pretty.writeln (Pretty.strs ("stamps:" :: Sign.stamp_names_of sg));
    1.63 +    Pretty.writeln (Pretty.strs ("data:" :: Data.kinds data));
    1.64 +    Pretty.writeln (Pretty.strs ["name entry path:", NameSpace.pack path]);
    1.65 +    Pretty.writeln (Pretty.big_list "name spaces:" (map pretty_space spaces'));
    1.66 +    Pretty.writeln (pretty_classes classes);
    1.67 +    Pretty.writeln (Pretty.big_list "class relation:" (map pretty_classrel classrel));
    1.68 +    Pretty.writeln (pretty_default default);
    1.69 +    Pretty.writeln (Pretty.big_list "type constructors:" (map pretty_ty tycons));
    1.70 +    Pretty.writeln (Pretty.big_list "type abbreviations:" (map pretty_abbr abbrs));
    1.71 +    Pretty.writeln (Pretty.big_list "type arities:" (flat (map pretty_arities arities)));
    1.72 +    Pretty.writeln (Pretty.big_list "consts:" (map pretty_const consts))
    1.73 +  end;
    1.74 +
    1.75 +
    1.76 +(* print axioms, oracles, theorems *)
    1.77 +
    1.78  fun print_thy thy =
    1.79    let
    1.80      val {sign, axioms, oracles, ...} = rep_theory thy;
    1.81 @@ -120,13 +183,15 @@
    1.82      print_data thy "theorems"
    1.83    end;
    1.84  
    1.85 -fun print_theory thy = (Sign.print_sg (sign_of thy); print_thy thy);
    1.86 +fun print_theory thy = (print_sign (sign_of thy); print_thy thy);
    1.87  
    1.88  
    1.89  
    1.90 -(** Print thm A1,...,An/B in "goal style" -- premises as numbered subgoals **)
    1.91 +(** print_goals **)
    1.92  
    1.93 -(*show consts in case of showing types?*)
    1.94 +(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
    1.95 +
    1.96 +(*also show consts in case of showing types?*)
    1.97  val show_consts = ref false;
    1.98  
    1.99  
   1.100 @@ -168,8 +233,6 @@
   1.101  
   1.102  in
   1.103  
   1.104 -  (* print_goals *)
   1.105 -
   1.106    fun print_goals maxgoals state =
   1.107      let
   1.108        val {sign, ...} = rep_thm state;