src/Pure/display.ML
author wenzelm
Thu, 09 Mar 2000 22:57:39 +0100
changeset 8402 84ff2d1f9a2c
parent 7635 4c1d2eb68db8
child 8458 883b28065841
permissions -rw-r--r--
quote tag arguments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     1
(*  Title:      Pure/display.ML
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     2
    ID:         $Id$
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     5
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     6
Printing of theories, theorems, etc.
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     7
*)
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     8
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
     9
signature DISPLAY =
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    10
sig
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    11
  val show_hyps		: bool ref
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    12
  val show_tags		: bool ref
6976
3895ba31db71 removed pretty_thm_no_hyps (again);
wenzelm
parents: 6926
diff changeset
    13
  val pretty_thm_no_quote: thm -> Pretty.T
6926
7ffc131909e5 added pretty_thm_no_hyps;
wenzelm
parents: 6894
diff changeset
    14
  val pretty_thm	: thm -> Pretty.T
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    15
  val pretty_thms	: thm list -> Pretty.T
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    16
  val string_of_thm	: thm -> string
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    17
  val pprint_thm	: thm -> pprint_args -> unit
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    18
  val print_thm		: thm -> unit
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    19
  val print_thms	: thm list -> unit
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    20
  val prth		: thm -> thm
4270
957c887b89b5 changed Sequence interface (now Seq, in seq.ML);
wenzelm
parents: 4256
diff changeset
    21
  val prthq		: thm Seq.seq -> thm Seq.seq
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    22
  val prths		: thm list -> thm list
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    23
  val pretty_ctyp	: ctyp -> Pretty.T
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    24
  val pprint_ctyp	: ctyp -> pprint_args -> unit
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    25
  val string_of_ctyp	: ctyp -> string
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    26
  val print_ctyp	: ctyp -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    27
  val pretty_cterm	: cterm -> Pretty.T
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    28
  val pprint_cterm	: cterm -> pprint_args -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    29
  val string_of_cterm	: cterm -> string
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    30
  val print_cterm	: cterm -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    31
  val pretty_theory	: theory -> Pretty.T
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    32
  val pprint_theory	: theory -> pprint_args -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    33
  val print_syntax	: theory -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    34
  val print_theory	: theory -> unit
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    35
  val pretty_name_space : string * NameSpace.T -> Pretty.T
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    36
  val show_consts	: bool ref
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    37
end;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    38
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    39
structure Display: DISPLAY =
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    40
struct
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    41
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    42
(** print thm **)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    43
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    44
val show_hyps = ref true;	(*false: print meta-hypotheses as dots*)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    45
val show_tags = ref false;	(*false: suppress tags*)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    46
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    47
local
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    48
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
    49
fun pretty_tag (name, args) = Pretty.strs (name :: map quote args);
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    50
val pretty_tags = Pretty.list "[" "]" o map pretty_tag;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    51
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    52
fun is_oracle (Thm.Oracle _) = true
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    53
  | is_oracle _ = false;
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    54
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    55
fun ex_oracle (Join (der, ders)) = is_oracle der orelse exists ex_oracle ders;
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    56
6314
47c801a77f32 pretty_thm_no_quote;
wenzelm
parents: 6279
diff changeset
    57
fun pretty_thm_aux quote th =
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    58
  let
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    59
    val {sign, hyps, prop, der, ...} = rep_thm th;
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    60
    val xshyps = Thm.extra_shyps th;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    61
    val (_, tags) = Thm.get_name_tags th;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    62
6314
47c801a77f32 pretty_thm_no_quote;
wenzelm
parents: 6279
diff changeset
    63
    val prt_term = (if quote then Pretty.quote else I) o Sign.pretty_term sign;
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    64
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    65
    val hlen = length xshyps + length hyps;
6894
wenzelm
parents: 6889
diff changeset
    66
    val ex_ora = ex_oracle der;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    67
    val hsymbs =
6894
wenzelm
parents: 6889
diff changeset
    68
      if hlen = 0 andalso not ex_ora then []
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    69
      else if ! show_hyps then
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    70
        [Pretty.brk 2, Pretty.list "[" "]"
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    71
          (map prt_term hyps @ map (Sign.pretty_sort sign) xshyps @
6894
wenzelm
parents: 6889
diff changeset
    72
            (if ex_ora then [Pretty.str "!"] else []))]
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    73
      else [Pretty.brk 2, Pretty.str ("[" ^ implode (replicate hlen ".") ^
6894
wenzelm
parents: 6889
diff changeset
    74
        (if ex_ora then "!" else "") ^ "]")];
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    75
    val tsymbs =
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    76
      if null tags orelse not (! show_tags) then []
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    77
      else [Pretty.brk 1, pretty_tags tags];
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    78
  in Pretty.block (prt_term prop :: (hsymbs @ tsymbs)) end;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    79
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    80
in
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    81
6926
7ffc131909e5 added pretty_thm_no_hyps;
wenzelm
parents: 6894
diff changeset
    82
val pretty_thm = pretty_thm_aux true;
6314
47c801a77f32 pretty_thm_no_quote;
wenzelm
parents: 6279
diff changeset
    83
val pretty_thm_no_quote = pretty_thm_aux false;
47c801a77f32 pretty_thm_no_quote;
wenzelm
parents: 6279
diff changeset
    84
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    85
end;
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    86
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    87
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    88
val string_of_thm = Pretty.string_of o pretty_thm;
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    89
val pprint_thm = Pretty.pprint o pretty_thm;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    90
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    91
fun pretty_thms [th] = pretty_thm th
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    92
  | pretty_thms ths = Pretty.block (Pretty.fbreaks (map pretty_thm ths));
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    93
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    94
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    95
(* top-level commands for printing theorems *)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    96
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    97
val print_thm = Pretty.writeln o pretty_thm;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    98
val print_thms = Pretty.writeln o pretty_thms;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    99
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   100
fun prth th = (print_thm th; th);
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   101
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   102
(*Print and return a sequence of theorems, separated by blank lines. *)
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   103
fun prthq thseq =
4270
957c887b89b5 changed Sequence interface (now Seq, in seq.ML);
wenzelm
parents: 4256
diff changeset
   104
  (Seq.print (fn _ => print_thm) 100000 thseq; thseq);
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   105
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   106
(*Print and return a list of theorems, separated by blank lines. *)
4210
abce78c8a931 tuned prths;
wenzelm
parents: 4126
diff changeset
   107
fun prths ths = (seq (fn th => (print_thm th; writeln "")) ths; ths);
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   108
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   109
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   110
(* other printing commands *)
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   111
4126
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   112
fun pretty_ctyp cT =
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   113
  let val {sign, T} = rep_ctyp cT in Sign.pretty_typ sign T end;
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   114
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   115
fun pprint_ctyp cT =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   116
  let val {sign, T} = rep_ctyp cT in Sign.pprint_typ sign T end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   117
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   118
fun string_of_ctyp cT =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   119
  let val {sign, T} = rep_ctyp cT in Sign.string_of_typ sign T end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   120
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   121
val print_ctyp = writeln o string_of_ctyp;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   122
3547
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   123
fun pretty_cterm ct =
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   124
  let val {sign, t, ...} = rep_cterm ct in Sign.pretty_term sign t end;
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   125
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   126
fun pprint_cterm ct =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   127
  let val {sign, t, ...} = rep_cterm ct in Sign.pprint_term sign t end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   128
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   129
fun string_of_cterm ct =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   130
  let val {sign, t, ...} = rep_cterm ct in Sign.string_of_term sign t end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   131
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   132
val print_cterm = writeln o string_of_cterm;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   133
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   134
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   135
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   136
(** print theory **)
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   137
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   138
val pretty_theory = Sign.pretty_sg o Theory.sign_of;
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   139
val pprint_theory = Sign.pprint_sg o Theory.sign_of;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   140
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   141
val print_syntax = Syntax.print_syntax o Theory.syn_of;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   142
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   143
4498
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   144
(* pretty_name_space  *)
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   145
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   146
fun pretty_name_space (kind, space) =
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   147
  let
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   148
    fun prt_entry (name, accs) = Pretty.block
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   149
      (Pretty.str (quote name ^ " =") :: Pretty.brk 1 ::
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   150
        Pretty.commas (map (Pretty.str o quote) accs));
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   151
  in
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   152
    Pretty.fbreaks (Pretty.str (kind ^ ":") :: map prt_entry (NameSpace.dest space))
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   153
    |> Pretty.block
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   154
  end;
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   155
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   156
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   157
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   158
(* print signature *)
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   159
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   160
fun print_sign sg =
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   161
  let
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   162
    fun prt_cls c = Sign.pretty_sort sg [c];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   163
    fun prt_sort S = Sign.pretty_sort sg S;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   164
    fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   165
    fun prt_typ ty = Pretty.quote (Sign.pretty_typ sg ty);
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   166
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   167
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   168
    fun pretty_classes cs = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   169
      (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   170
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   171
    fun pretty_classrel (c, cs) = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   172
      (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   173
        Pretty.commas (map prt_cls cs));
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   174
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   175
    fun pretty_default S = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   176
      [Pretty.str "default:", Pretty.brk 1, prt_sort S];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   177
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   178
    fun pretty_ty (t, n) = Pretty.block
7067
601f930d3739 replace assoc lists by Symtab.table;
wenzelm
parents: 6976
diff changeset
   179
      [Pretty.str t, Pretty.spc 1, Pretty.str (string_of_int n)];
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   180
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   181
    fun pretty_log_types ts = Pretty.block
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   182
      (Pretty.breaks (Pretty.str "logical types:" :: map Pretty.str ts));
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   183
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   184
    fun pretty_witness None = Pretty.str "universal non-emptiness witness: --"
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   185
      | pretty_witness (Some (T, S)) = Pretty.block
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   186
          [Pretty.str "universal non-emptiness witness:", Pretty.brk 1, prt_typ T,
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   187
            Pretty.brk 1, prt_sort S];
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   188
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   189
    fun pretty_abbr (t, (vs, rhs)) = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   190
      [prt_typ (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   191
        Pretty.str " =", Pretty.brk 1, prt_typ rhs];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   192
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   193
    fun pretty_arities (t, ars) = map (prt_arity t) ars;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   194
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   195
    fun pretty_const (c, ty) = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   196
      [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ ty];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   197
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   198
    val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   199
    val spaces' = Library.sort_wrt fst spaces;
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   200
    val {classes, classrel, default, tycons = type_tab, log_types, univ_witness, abbrs, arities} =
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   201
      Type.rep_tsig tsig;
7067
601f930d3739 replace assoc lists by Symtab.table;
wenzelm
parents: 6976
diff changeset
   202
    val tycons = Sign.cond_extern_table sg Sign.typeK type_tab;
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   203
    val consts = Sign.cond_extern_table sg Sign.constK const_tab;
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   204
  in
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   205
    Pretty.writeln (Pretty.strs ("stamps:" :: Sign.stamp_names_of sg));
4256
e768c42069bb removed data.ML (made part of sign.ML);
wenzelm
parents: 4250
diff changeset
   206
    Pretty.writeln (Pretty.strs ("data:" :: Sign.data_kinds data));
4782
9c0b31da51c6 tuned comments;
wenzelm
parents: 4498
diff changeset
   207
    Pretty.writeln (Pretty.strs ["name prefix:", NameSpace.pack path]);
4498
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   208
    Pretty.writeln (Pretty.big_list "name spaces:" (map pretty_name_space spaces'));
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   209
    Pretty.writeln (pretty_classes classes);
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   210
    Pretty.writeln (Pretty.big_list "class relation:"
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   211
      (map pretty_classrel (Symtab.dest classrel)));
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   212
    Pretty.writeln (pretty_default default);
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   213
    Pretty.writeln (pretty_log_types log_types);
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   214
    Pretty.writeln (pretty_witness univ_witness);
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   215
    Pretty.writeln (Pretty.big_list "type constructors:" (map pretty_ty tycons));
7067
601f930d3739 replace assoc lists by Symtab.table;
wenzelm
parents: 6976
diff changeset
   216
    Pretty.writeln (Pretty.big_list "type abbreviations:" (map pretty_abbr (Symtab.dest abbrs)));
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   217
    Pretty.writeln (Pretty.big_list "type arities:"
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   218
      (flat (map pretty_arities (Symtab.dest arities))));
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   219
    Pretty.writeln (Pretty.big_list "consts:" (map pretty_const consts))
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   220
  end;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   221
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   222
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   223
(* print axioms, oracles, theorems *)
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   224
3811
ec27ddb5104c print_theory: added oracles;
wenzelm
parents: 3785
diff changeset
   225
fun print_thy thy =
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   226
  let
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   227
    val {sign, axioms, oracles, ...} = Theory.rep_theory thy;
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   228
    fun cond_externs kind = Sign.cond_extern_table sign kind;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   229
3936
1954255c29ef tuned output;
wenzelm
parents: 3879
diff changeset
   230
    fun prt_axm (a, t) = Pretty.block
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   231
      [Pretty.str (a ^ ":"), Pretty.brk 1, Pretty.quote (Sign.pretty_term sign t)];
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   232
  in
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   233
    Pretty.writeln (Pretty.big_list "axioms:" (map prt_axm (cond_externs Theory.axiomK axioms)));
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   234
    Pretty.writeln (Pretty.strs ("oracles:" :: (map #1 (cond_externs Theory.oracleK oracles))))
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   235
  end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   236
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   237
fun print_theory thy = (print_sign (Theory.sign_of thy); print_thy thy);
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   238
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   239
(*also show consts in case of showing types?*)
3851
fe9932a7cd46 print_goals: optional output of const types (set show_consts);
wenzelm
parents: 3811
diff changeset
   240
val show_consts = ref false;
fe9932a7cd46 print_goals: optional output of const types (set show_consts);
wenzelm
parents: 3811
diff changeset
   241
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   242
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   243
end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   244
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   245
open Display;