src/Pure/display.ML
author wenzelm
Tue, 06 Nov 2001 19:25:24 +0100
changeset 12067 b2f5fbb39f14
parent 11883 7b9522995a78
child 12081 f9735aad76dc
permissions -rw-r--r--
export pretty_thm_aux;
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
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
     9
signature BASIC_DISPLAY =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    10
sig
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    11
  val show_hyps: bool ref
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    12
  val show_tags: bool ref
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    13
  val string_of_thm: thm -> string
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    14
  val print_thm: thm -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    15
  val print_thms: thm list -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    16
  val prth: thm -> thm
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    17
  val prthq: thm Seq.seq -> thm Seq.seq
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    18
  val prths: thm list -> thm list
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    19
  val string_of_ctyp: ctyp -> string
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    20
  val print_ctyp: ctyp -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    21
  val string_of_cterm: cterm -> string
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    22
  val print_cterm: cterm -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    23
  val print_syntax: theory -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    24
  val show_consts: bool ref
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    25
end;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    26
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    27
signature DISPLAY =
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    28
sig
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    29
  include BASIC_DISPLAY
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    30
  val pretty_thm_aux: (sort -> Pretty.T) -> (term -> Pretty.T) -> bool -> thm -> Pretty.T
6976
3895ba31db71 removed pretty_thm_no_hyps (again);
wenzelm
parents: 6926
diff changeset
    31
  val pretty_thm_no_quote: thm -> Pretty.T
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    32
  val pretty_thm: thm -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    33
  val pretty_thms: thm list -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    34
  val pretty_thm_sg: Sign.sg -> thm -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    35
  val pretty_thms_sg: Sign.sg -> thm list -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    36
  val pprint_thm: thm -> pprint_args -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    37
  val pretty_ctyp: ctyp -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    38
  val pprint_ctyp: ctyp -> pprint_args -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    39
  val pretty_cterm: cterm -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    40
  val pprint_cterm: cterm -> pprint_args -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    41
  val pretty_theory: theory -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    42
  val pprint_theory: theory -> pprint_args -> unit
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
    43
  val pretty_full_theory: theory -> Pretty.T list
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    44
  val pretty_name_space: string * NameSpace.T -> Pretty.T
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    45
  val pretty_goals_marker: string -> int -> thm -> Pretty.T list
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    46
  val pretty_goals: int -> thm -> Pretty.T list
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    47
  val pretty_sub_goals: bool -> int -> thm -> Pretty.T list
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    48
  val print_goals_marker: string -> int -> thm -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    49
  val print_goals: int -> thm -> unit
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    50
  val current_goals_markers: (string * string * string) ref
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    51
  val print_current_goals_default: (int -> int -> thm -> unit)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    52
  val print_current_goals_fn : (int -> int -> thm -> unit) ref
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    53
end;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    54
4950
226f2cde9f4d tuned signature;
wenzelm
parents: 4782
diff changeset
    55
structure Display: DISPLAY =
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    56
struct
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    57
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    58
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    59
(** print thm **)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    60
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    61
val show_hyps = ref true;       (*false: print meta-hypotheses as dots*)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
    62
val show_tags = ref false;      (*false: suppress tags*)
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    63
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
    64
fun pretty_tag (name, args) = Pretty.strs (name :: map quote args);
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    65
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
    66
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    67
fun pretty_thm_aux pretty_sort pretty_term quote th =
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    68
  let
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    69
    val {hyps, prop, der = (ora, _), ...} = rep_thm th;
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    70
    val xshyps = Thm.extra_shyps th;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    71
    val (_, tags) = Thm.get_name_tags th;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    72
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    73
    val prt_term = (if quote then Pretty.quote else I) o pretty_term;
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    74
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    75
    val hlen = length xshyps + length hyps;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    76
    val hsymbs =
9500
e21a76142269 use oracle flag from derivation;
wenzelm
parents: 8908
diff changeset
    77
      if hlen = 0 andalso not ora then []
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    78
      else if ! show_hyps then
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    79
        [Pretty.brk 2, Pretty.list "[" "]"
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    80
          (map prt_term hyps @ map pretty_sort xshyps @
9500
e21a76142269 use oracle flag from derivation;
wenzelm
parents: 8908
diff changeset
    81
            (if ora then [Pretty.str "!"] else []))]
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    82
      else [Pretty.brk 2, Pretty.str ("[" ^ implode (replicate hlen ".") ^
9500
e21a76142269 use oracle flag from derivation;
wenzelm
parents: 8908
diff changeset
    83
        (if ora then "!" else "") ^ "]")];
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    84
    val tsymbs =
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    85
      if null tags orelse not (! show_tags) then []
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
    86
      else [Pretty.brk 1, pretty_tags tags];
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    87
  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
    88
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    89
fun gen_pretty_thm quote th =
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    90
  let val sg = Thm.sign_of_thm th
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    91
  in pretty_thm_aux (Sign.pretty_sort sg) (Sign.pretty_term sg) quote th end;
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    92
12067
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    93
val pretty_thm = gen_pretty_thm true;
b2f5fbb39f14 export pretty_thm_aux;
wenzelm
parents: 11883
diff changeset
    94
val pretty_thm_no_quote = gen_pretty_thm false;
6889
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    95
adcf91ad5add pretty_thm: include oracles (!) in hyps;
wenzelm
parents: 6846
diff changeset
    96
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    97
val string_of_thm = Pretty.string_of o pretty_thm;
6279
eb4dc43023af pretty_thm: quote terms (separately);
wenzelm
parents: 6087
diff changeset
    98
val pprint_thm = Pretty.pprint o pretty_thm;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
    99
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   100
fun pretty_thms [th] = pretty_thm th
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   101
  | 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
   102
10010
f6ccb6df9cb9 added print_thm(s)_sg;
wenzelm
parents: 9500
diff changeset
   103
val pretty_thm_sg = pretty_thm oo Thm.transfer_sg;
f6ccb6df9cb9 added print_thm(s)_sg;
wenzelm
parents: 9500
diff changeset
   104
val pretty_thms_sg = pretty_thms oo (map o Thm.transfer_sg);
f6ccb6df9cb9 added print_thm(s)_sg;
wenzelm
parents: 9500
diff changeset
   105
6087
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   106
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   107
(* top-level commands for printing theorems *)
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   108
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   109
val print_thm = Pretty.writeln o pretty_thm;
c8ec08fced15 show_tags;
wenzelm
parents: 5902
diff changeset
   110
val print_thms = Pretty.writeln o pretty_thms;
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   111
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   112
fun prth th = (print_thm th; th);
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   113
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   114
(*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
   115
fun prthq thseq =
4270
957c887b89b5 changed Sequence interface (now Seq, in seq.ML);
wenzelm
parents: 4256
diff changeset
   116
  (Seq.print (fn _ => print_thm) 100000 thseq; thseq);
1591
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
(*Print and return a list of theorems, separated by blank lines. *)
4210
abce78c8a931 tuned prths;
wenzelm
parents: 4126
diff changeset
   119
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
   120
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   121
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   122
(* other printing commands *)
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   123
4126
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   124
fun pretty_ctyp cT =
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   125
  let val {sign, T} = rep_ctyp cT in Sign.pretty_typ sign T end;
c41846a38e20 added pretty_ctyp;
wenzelm
parents: 3990
diff changeset
   126
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   127
fun pprint_ctyp cT =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   128
  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
   129
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   130
fun string_of_ctyp cT =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   131
  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
   132
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   133
val print_ctyp = writeln o string_of_ctyp;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   134
3547
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   135
fun pretty_cterm ct =
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   136
  let val {sign, t, ...} = rep_cterm ct in Sign.pretty_term sign t end;
977d58464d7f added pretty_cterm;
wenzelm
parents: 3531
diff changeset
   137
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   138
fun pprint_cterm ct =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   139
  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
   140
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   141
fun string_of_cterm ct =
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   142
  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
   143
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   144
val print_cterm = writeln o string_of_cterm;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   145
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   146
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   147
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   148
(** print theory **)
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   149
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   150
val pretty_theory = Sign.pretty_sg o Theory.sign_of;
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   151
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
   152
6390
5d58c100ca3f qualify Theory.sign_of etc.;
wenzelm
parents: 6314
diff changeset
   153
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
   154
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   155
4498
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   156
(* pretty_name_space  *)
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   157
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   158
fun pretty_name_space (kind, space) =
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   159
  let
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   160
    fun prt_entry (name, accs) = Pretty.block
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   161
      (Pretty.str (quote name ^ " =") :: Pretty.brk 1 ::
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   162
        Pretty.commas (map (Pretty.str o quote) accs));
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   163
  in
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   164
    Pretty.fbreaks (Pretty.str (kind ^ ":") :: map prt_entry (NameSpace.dest space))
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   165
    |> Pretty.block
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   166
  end;
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   167
a088ec3e4f5e pretty_name_space;
wenzelm
parents: 4440
diff changeset
   168
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   169
(* pretty_full_theory *)
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   170
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   171
fun pretty_full_theory thy =
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   172
  let
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   173
    val sg = Theory.sign_of thy;
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   174
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   175
    fun prt_cls c = Sign.pretty_sort sg [c];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   176
    fun prt_sort S = Sign.pretty_sort sg S;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   177
    fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
10737
c130eb1e863f tuned output;
wenzelm
parents: 10010
diff changeset
   178
    fun prt_typ_no_tvars ty = Pretty.quote (Sign.pretty_typ sg (#1 (Type.freeze_thaw_type ty)));
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   179
    fun prt_term t = Pretty.quote (Sign.pretty_term sg t);
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   180
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   181
    fun pretty_classes cs = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   182
      (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   183
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   184
    fun pretty_classrel (c, cs) = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   185
      (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   186
        Pretty.commas (map prt_cls cs));
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   187
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   188
    fun pretty_default S = Pretty.block
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   189
      [Pretty.str "default:", Pretty.brk 1, prt_sort S];
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   190
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   191
    fun pretty_ty (t, n) = Pretty.block
8458
883b28065841 removed Pretty.spc;
wenzelm
parents: 8402
diff changeset
   192
      [Pretty.str t, Pretty.brk 1, Pretty.str (string_of_int n)];
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   193
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   194
    fun pretty_log_types ts = Pretty.block
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   195
      (Pretty.breaks (Pretty.str "logical types:" :: map Pretty.str ts));
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   196
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   197
    fun pretty_witness None = Pretty.str "universal non-emptiness witness: --"
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   198
      | pretty_witness (Some (T, S)) = Pretty.block
10737
c130eb1e863f tuned output;
wenzelm
parents: 10010
diff changeset
   199
          [Pretty.str "universal non-emptiness witness:", Pretty.brk 1, prt_typ_no_tvars T,
8402
84ff2d1f9a2c quote tag arguments;
wenzelm
parents: 7635
diff changeset
   200
            Pretty.brk 1, prt_sort S];
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   201
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   202
    fun pretty_abbr (t, (vs, rhs)) = Pretty.block
10737
c130eb1e863f tuned output;
wenzelm
parents: 10010
diff changeset
   203
      [prt_typ_no_tvars (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
c130eb1e863f tuned output;
wenzelm
parents: 10010
diff changeset
   204
        Pretty.str " =", Pretty.brk 1, prt_typ_no_tvars rhs];
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   205
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   206
    fun pretty_arities (t, ars) = map (prt_arity t) ars;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   207
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   208
    fun pretty_const (c, ty) = Pretty.block
10737
c130eb1e863f tuned output;
wenzelm
parents: 10010
diff changeset
   209
      [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ_no_tvars ty];
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   210
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   211
    fun prt_axm (a, t) = Pretty.block [Pretty.str (a ^ ":"), Pretty.brk 1, prt_term t];
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   212
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   213
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   214
    val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   215
    val {axioms, oracles, ...} = Theory.rep_theory thy;
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   216
    val spaces' = Library.sort_wrt fst spaces;
7635
4c1d2eb68db8 new tsig components;
wenzelm
parents: 7067
diff changeset
   217
    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
   218
      Type.rep_tsig tsig;
7067
601f930d3739 replace assoc lists by Symtab.table;
wenzelm
parents: 6976
diff changeset
   219
    val tycons = Sign.cond_extern_table sg Sign.typeK type_tab;
6846
f2380295d4dd cond_extern_table;
wenzelm
parents: 6390
diff changeset
   220
    val consts = Sign.cond_extern_table sg Sign.constK const_tab;
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   221
    val axms = Sign.cond_extern_table sg Theory.axiomK axioms;
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   222
    val oras = Sign.cond_extern_table sg Theory.oracleK oracles;
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   223
  in
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   224
    [Pretty.strs ("stamps:" :: Sign.stamp_names_of sg),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   225
      Pretty.strs ("data:" :: Sign.data_kinds data),
11501
3b6415035d1a support for absolute namespace entry paths;
wenzelm
parents: 10737
diff changeset
   226
      Pretty.strs ["name prefix:", NameSpace.pack (if_none path ["-"])],
8720
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   227
      Pretty.big_list "name spaces:" (map pretty_name_space spaces'),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   228
      pretty_classes classes,
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   229
      Pretty.big_list "class relation:" (map pretty_classrel (Symtab.dest classrel)),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   230
      pretty_default default,
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   231
      pretty_log_types log_types,
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   232
      pretty_witness univ_witness,
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   233
      Pretty.big_list "type constructors:" (map pretty_ty tycons),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   234
      Pretty.big_list "type abbreviations:" (map pretty_abbr (Symtab.dest abbrs)),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   235
      Pretty.big_list "type arities:" (flat (map pretty_arities (Symtab.dest arities))),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   236
      Pretty.big_list "consts:" (map pretty_const consts),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   237
      Pretty.big_list "axioms:" (map prt_axm axms),
840c75ab2a7f Pretty.chunks;
wenzelm
parents: 8458
diff changeset
   238
      Pretty.strs ("oracles:" :: (map #1 oras))]
4250
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   239
  end;
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   240
3806a00677ff moved Sign.print_sg to display.ML;
wenzelm
parents: 4210
diff changeset
   241
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   242
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   243
(** print_goals **)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   244
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   245
(* print_goals etc. *)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   246
8908
25f2bdc02123 show_consts no longer requires show_types;
wenzelm
parents: 8720
diff changeset
   247
(*show consts with types in proof state output?*)
3851
fe9932a7cd46 print_goals: optional output of const types (set show_consts);
wenzelm
parents: 3811
diff changeset
   248
val show_consts = ref false;
fe9932a7cd46 print_goals: optional output of const types (set show_consts);
wenzelm
parents: 3811
diff changeset
   249
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   250
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   251
(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   252
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   253
local
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   254
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   255
  (* utils *)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   256
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   257
  fun ins_entry (x, y) [] = [(x, [y])]
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   258
    | ins_entry (x, y) ((pair as (x', ys')) :: pairs) =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   259
        if x = x' then (x', y ins ys') :: pairs
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   260
        else pair :: ins_entry (x, y) pairs;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   261
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   262
  fun add_consts (Const (c, T), env) = ins_entry (T, (c, T)) env
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   263
    | add_consts (t $ u, env) = add_consts (u, add_consts (t, env))
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   264
    | add_consts (Abs (_, _, t), env) = add_consts (t, env)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   265
    | add_consts (_, env) = env;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   266
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   267
  fun add_vars (Free (x, T), env) = ins_entry (T, (x, ~1)) env
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   268
    | add_vars (Var (xi, T), env) = ins_entry (T, xi) env
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   269
    | add_vars (Abs (_, _, t), env) = add_vars (t, env)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   270
    | add_vars (t $ u, env) = add_vars (u, add_vars (t, env))
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   271
    | add_vars (_, env) = env;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   272
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   273
  fun add_varsT (Type (_, Ts), env) = foldr add_varsT (Ts, env)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   274
    | add_varsT (TFree (x, S), env) = ins_entry (S, (x, ~1)) env
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   275
    | add_varsT (TVar (xi, S), env) = ins_entry (S, xi) env;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   276
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   277
  fun sort_idxs vs = map (apsnd (sort (prod_ord string_ord int_ord))) vs;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   278
  fun sort_cnsts cs = map (apsnd (sort_wrt fst)) cs;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   279
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   280
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   281
  (* prepare atoms *)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   282
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   283
  fun consts_of t = sort_cnsts (add_consts (t, []));
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   284
  fun vars_of t = sort_idxs (add_vars (t, []));
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   285
  fun varsT_of t = rev (sort_idxs (it_term_types add_varsT (t, [])));
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   286
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   287
  fun pretty_goals_marker_aux begin_goal print_msg print_goal maxgoals state =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   288
    let
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   289
      val {sign, ...} = rep_thm state;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   290
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   291
      val prt_term = Sign.pretty_term sign;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   292
      val prt_typ = Sign.pretty_typ sign;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   293
      val prt_sort = Sign.pretty_sort sign;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   294
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   295
      fun prt_atoms prt prtT (X, xs) = Pretty.block
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   296
        [Pretty.block (Pretty.commas (map prt xs)), Pretty.str " ::",
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   297
          Pretty.brk 1, prtT X];
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   298
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   299
      fun prt_var (x, ~1) = prt_term (Syntax.free x)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   300
        | prt_var xi = prt_term (Syntax.var xi);
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   301
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   302
      fun prt_varT (x, ~1) = prt_typ (TFree (x, []))
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   303
        | prt_varT xi = prt_typ (TVar (xi, []));
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   304
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   305
      val prt_consts = prt_atoms (prt_term o Const) prt_typ;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   306
      val prt_vars = prt_atoms prt_var prt_typ;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   307
      val prt_varsT = prt_atoms prt_varT prt_sort;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   308
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   309
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   310
      fun pretty_list _ _ [] = []
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   311
        | pretty_list name prt lst = [Pretty.big_list name (map prt lst)];
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   312
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   313
      fun pretty_subgoal (n, A) =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   314
        Pretty.blk (0, [Pretty.str (begin_goal ^ " " ^ string_of_int n ^ ". "), prt_term A]);
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   315
      fun pretty_subgoals As = map pretty_subgoal (1 upto length As ~~ As);
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   316
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   317
      val pretty_ffpairs = pretty_list "flex-flex pairs:" (prt_term o Logic.mk_flexpair);
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   318
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   319
      val pretty_consts = pretty_list "constants:" prt_consts o consts_of;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   320
      val pretty_vars = pretty_list "variables:" prt_vars o vars_of;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   321
      val pretty_varsT = pretty_list "type variables:" prt_varsT o varsT_of;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   322
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   323
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   324
      val {prop, ...} = rep_thm state;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   325
      val (tpairs, As, B) = Logic.strip_horn prop;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   326
      val ngoals = length As;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   327
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   328
      fun pretty_gs (types, sorts) =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   329
        (if print_goal then [prt_term B] else []) @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   330
         (if ngoals = 0 then [Pretty.str "No subgoals!"]
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   331
          else if ngoals > maxgoals then
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   332
            pretty_subgoals (take (maxgoals, As)) @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   333
            (if print_msg then
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   334
                [Pretty.str ("A total of " ^ string_of_int ngoals ^ " subgoals...")]
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   335
             else [])
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   336
          else pretty_subgoals As) @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   337
        pretty_ffpairs tpairs @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   338
        (if ! show_consts then pretty_consts prop else []) @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   339
        (if types then pretty_vars prop else []) @
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   340
        (if sorts then pretty_varsT prop else []);
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   341
    in
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   342
      setmp show_no_free_types true
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   343
        (setmp show_types (! show_types orelse ! show_sorts)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   344
          (setmp show_sorts false pretty_gs))
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   345
     (! show_types orelse ! show_sorts, ! show_sorts)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   346
  end;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   347
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   348
in
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   349
  fun pretty_goals_marker bg = pretty_goals_marker_aux bg true true;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   350
  val print_goals_marker = (Pretty.writeln o Pretty.chunks) ooo pretty_goals_marker;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   351
  val pretty_sub_goals = pretty_goals_marker_aux "" false;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   352
  val pretty_goals = pretty_goals_marker "";
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   353
  val print_goals = print_goals_marker "";
1591
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   354
end;
7fa0265dcd13 New module for display/printing operations, taken from drule.ML
paulson
parents:
diff changeset
   355
11883
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   356
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   357
(* print_current_goals *)
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   358
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   359
val current_goals_markers = ref ("", "", "");
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   360
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   361
fun print_current_goals_default n max th =
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   362
  let
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   363
    val ref (begin_state, end_state, begin_goal) = current_goals_markers;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   364
    val ngoals = nprems_of th;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   365
  in
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   366
    if begin_state = "" then () else writeln begin_state;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   367
    writeln ("Level " ^ string_of_int n ^
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   368
      (if ngoals > 0 then " (" ^ string_of_int ngoals ^ " subgoal" ^
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   369
        (if ngoals <> 1 then "s" else "") ^ ")"
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   370
      else ""));
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   371
    print_goals_marker begin_goal max th;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   372
    if end_state = "" then () else writeln end_state
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   373
  end;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   374
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   375
val print_current_goals_fn = ref print_current_goals_default;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   376
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   377
end;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   378
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   379
structure BasicDisplay: BASIC_DISPLAY = Display;
7b9522995a78 print_goals stuff is back (from locale.ML);
wenzelm
parents: 11501
diff changeset
   380
open BasicDisplay;