src/Pure/display.ML
author wenzelm
Tue Oct 09 00:20:13 2007 +0200 (2007-10-09)
changeset 24920 2a45e400fdad
parent 24848 5dbbd33c3236
child 25405 7ac8c93be624
permissions -rw-r--r--
generic Syntax.pretty/string_of operations;
paulson@1591
     1
(*  Title:      Pure/display.ML
paulson@1591
     2
    ID:         $Id$
paulson@1591
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1591
     4
    Copyright   1993  University of Cambridge
paulson@1591
     5
wenzelm@19420
     6
Printing of theorems, goals, results etc.
paulson@1591
     7
*)
paulson@1591
     8
wenzelm@11883
     9
signature BASIC_DISPLAY =
wenzelm@11883
    10
sig
wenzelm@12081
    11
  val goals_limit: int ref
wenzelm@11883
    12
  val show_hyps: bool ref
wenzelm@11883
    13
  val show_tags: bool ref
wenzelm@11883
    14
  val string_of_thm: thm -> string
wenzelm@11883
    15
  val print_thm: thm -> unit
wenzelm@11883
    16
  val print_thms: thm list -> unit
wenzelm@11883
    17
  val prth: thm -> thm
wenzelm@11883
    18
  val prthq: thm Seq.seq -> thm Seq.seq
wenzelm@11883
    19
  val prths: thm list -> thm list
wenzelm@11883
    20
  val string_of_ctyp: ctyp -> string
wenzelm@11883
    21
  val print_ctyp: ctyp -> unit
wenzelm@11883
    22
  val string_of_cterm: cterm -> string
wenzelm@11883
    23
  val print_cterm: cterm -> unit
wenzelm@11883
    24
  val print_syntax: theory -> unit
wenzelm@11883
    25
  val show_consts: bool ref
wenzelm@11883
    26
end;
wenzelm@11883
    27
paulson@1591
    28
signature DISPLAY =
wenzelm@4950
    29
sig
wenzelm@11883
    30
  include BASIC_DISPLAY
wenzelm@19591
    31
  val raw_string_of_sort: sort -> string
wenzelm@19591
    32
  val raw_string_of_typ: typ -> string
wenzelm@19591
    33
  val raw_string_of_term: term -> string
wenzelm@14876
    34
  val pretty_flexpair: Pretty.pp -> term * term -> Pretty.T
wenzelm@17447
    35
  val pretty_thm_aux: Pretty.pp -> bool -> bool -> term list -> thm -> Pretty.T
wenzelm@11883
    36
  val pretty_thm: thm -> Pretty.T
wenzelm@11883
    37
  val pretty_thms: thm list -> Pretty.T
wenzelm@16437
    38
  val pretty_thm_sg: theory -> thm -> Pretty.T
wenzelm@16437
    39
  val pretty_thms_sg: theory -> thm list -> Pretty.T
wenzelm@11883
    40
  val pretty_ctyp: ctyp -> Pretty.T
wenzelm@11883
    41
  val pretty_cterm: cterm -> Pretty.T
wenzelm@20629
    42
  val pretty_full_theory: bool -> theory -> Pretty.T list
wenzelm@23634
    43
  val pretty_goals_aux: Pretty.pp -> Markup.T -> bool * bool -> int -> thm -> Pretty.T list
wenzelm@11883
    44
  val pretty_goals: int -> thm -> Pretty.T list
wenzelm@11883
    45
  val print_goals: int -> thm -> unit
wenzelm@4950
    46
end;
paulson@1591
    47
wenzelm@4950
    48
structure Display: DISPLAY =
paulson@1591
    49
struct
paulson@1591
    50
wenzelm@19591
    51
(** raw output **)
wenzelm@19591
    52
wenzelm@19591
    53
val raw_string_of_sort = Sign.string_of_sort ProtoPure.thy;
wenzelm@19591
    54
val raw_string_of_typ = Sign.string_of_typ ProtoPure.thy;
wenzelm@19591
    55
val raw_string_of_term = Sign.string_of_term ProtoPure.thy;
wenzelm@19591
    56
wenzelm@19591
    57
wenzelm@11883
    58
wenzelm@6087
    59
(** print thm **)
wenzelm@6087
    60
wenzelm@16534
    61
val goals_limit = ref 10;       (*max number of goals to print*)
wenzelm@12831
    62
val show_hyps = ref false;      (*false: print meta-hypotheses as dots*)
wenzelm@11883
    63
val show_tags = ref false;      (*false: suppress tags*)
wenzelm@6087
    64
wenzelm@23657
    65
fun pretty_tag (name, arg) = Pretty.strs [name, Library.quote arg];
wenzelm@6087
    66
val pretty_tags = Pretty.list "[" "]" o map pretty_tag;
paulson@1591
    67
wenzelm@14876
    68
fun pretty_flexpair pp (t, u) = Pretty.block
wenzelm@14876
    69
  [Pretty.term pp t, Pretty.str " =?=", Pretty.brk 1, Pretty.term pp u];
berghofe@13658
    70
wenzelm@17447
    71
fun pretty_thm_aux pp quote show_hyps' asms raw_th =
paulson@1591
    72
  let
wenzelm@17447
    73
    val th = Thm.strip_shyps raw_th;
wenzelm@16290
    74
    val {hyps, tpairs, prop, der = (ora, _), ...} = Thm.rep_thm th;
wenzelm@6087
    75
    val xshyps = Thm.extra_shyps th;
wenzelm@21646
    76
    val tags = Thm.get_tags th;
wenzelm@6087
    77
berghofe@13658
    78
    val q = if quote then Pretty.quote else I;
wenzelm@22878
    79
    val prt_term = q o Pretty.term pp;
wenzelm@6279
    80
wenzelm@19300
    81
    val hyps' = if ! show_hyps then hyps else subtract (op aconv) asms hyps;
wenzelm@17475
    82
    val ora' = ora andalso (! show_hyps orelse not (! quick_and_dirty));
wenzelm@17447
    83
    val hlen = length xshyps + length hyps' + length tpairs;
paulson@1591
    84
    val hsymbs =
wenzelm@17475
    85
      if hlen = 0 andalso not ora' then []
wenzelm@17447
    86
      else if ! show_hyps orelse show_hyps' then
paulson@1591
    87
        [Pretty.brk 2, Pretty.list "[" "]"
wenzelm@17447
    88
          (map (q o pretty_flexpair pp) tpairs @ map prt_term hyps' @
wenzelm@14876
    89
           map (Pretty.sort pp) xshyps @
wenzelm@17475
    90
            (if ora' then [Pretty.str "!"] else []))]
wenzelm@6889
    91
      else [Pretty.brk 2, Pretty.str ("[" ^ implode (replicate hlen ".") ^
wenzelm@17475
    92
        (if ora' then "!" else "") ^ "]")];
wenzelm@6087
    93
    val tsymbs =
wenzelm@6087
    94
      if null tags orelse not (! show_tags) then []
wenzelm@6087
    95
      else [Pretty.brk 1, pretty_tags tags];
wenzelm@6279
    96
  in Pretty.block (prt_term prop :: (hsymbs @ tsymbs)) end;
paulson@1591
    97
wenzelm@20226
    98
fun pretty_thm th =
wenzelm@20226
    99
  pretty_thm_aux (Sign.pp (Thm.theory_of_thm th)) true false [] th;
wenzelm@6889
   100
paulson@1591
   101
val string_of_thm = Pretty.string_of o pretty_thm;
paulson@1591
   102
wenzelm@6087
   103
fun pretty_thms [th] = pretty_thm th
wenzelm@6087
   104
  | pretty_thms ths = Pretty.block (Pretty.fbreaks (map pretty_thm ths));
paulson@1591
   105
wenzelm@16437
   106
val pretty_thm_sg = pretty_thm oo Thm.transfer;
wenzelm@16437
   107
val pretty_thms_sg = pretty_thms oo (map o Thm.transfer);
wenzelm@10010
   108
wenzelm@6087
   109
wenzelm@6087
   110
(* top-level commands for printing theorems *)
wenzelm@6087
   111
wenzelm@6087
   112
val print_thm = Pretty.writeln o pretty_thm;
wenzelm@6087
   113
val print_thms = Pretty.writeln o pretty_thms;
paulson@1591
   114
paulson@1591
   115
fun prth th = (print_thm th; th);
wenzelm@16534
   116
fun prthq thq = (Seq.print (K print_thm) 100000 thq; thq);
wenzelm@16534
   117
fun prths ths = (prthq (Seq.of_list ths); ths);
paulson@1591
   118
paulson@1591
   119
paulson@1591
   120
(* other printing commands *)
paulson@1591
   121
wenzelm@4126
   122
fun pretty_ctyp cT =
wenzelm@16437
   123
  let val {thy, T, ...} = rep_ctyp cT in Sign.pretty_typ thy T end;
wenzelm@4126
   124
paulson@1591
   125
fun string_of_ctyp cT =
wenzelm@16437
   126
  let val {thy, T, ...} = rep_ctyp cT in Sign.string_of_typ thy T end;
paulson@1591
   127
paulson@1591
   128
val print_ctyp = writeln o string_of_ctyp;
paulson@1591
   129
wenzelm@3547
   130
fun pretty_cterm ct =
wenzelm@16437
   131
  let val {thy, t, ...} = rep_cterm ct in Sign.pretty_term thy t end;
wenzelm@3547
   132
paulson@1591
   133
fun string_of_cterm ct =
wenzelm@16437
   134
  let val {thy, t, ...} = rep_cterm ct in Sign.string_of_term thy t end;
paulson@1591
   135
paulson@1591
   136
val print_cterm = writeln o string_of_cterm;
paulson@1591
   137
paulson@1591
   138
wenzelm@4250
   139
wenzelm@4250
   140
(** print theory **)
paulson@1591
   141
wenzelm@16437
   142
val print_syntax = Syntax.print_syntax o Sign.syn_of;
wenzelm@4498
   143
wenzelm@4498
   144
wenzelm@11883
   145
(* pretty_full_theory *)
wenzelm@4250
   146
wenzelm@20629
   147
fun pretty_full_theory verbose thy =
wenzelm@4250
   148
  let
wenzelm@24920
   149
    val ctxt = ProofContext.init thy;
wenzelm@24920
   150
wenzelm@24920
   151
    fun prt_cls c = Syntax.pretty_sort ctxt [c];
wenzelm@24920
   152
    fun prt_sort S = Syntax.pretty_sort ctxt S;
wenzelm@24920
   153
    fun prt_arity t (c, (_, Ss)) = Syntax.pretty_arity ctxt (t, Ss, [c]);
wenzelm@24920
   154
    fun prt_typ ty = Pretty.quote (Syntax.pretty_typ ctxt ty);
wenzelm@19806
   155
    val prt_typ_no_tvars = prt_typ o Logic.unvarifyT;
wenzelm@24920
   156
    fun prt_term t = Pretty.quote (Syntax.pretty_term ctxt t);
wenzelm@18936
   157
    val prt_term_no_vars = prt_term o Logic.unvarify;
wenzelm@19698
   158
    fun prt_const (c, ty) = [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ_no_tvars ty];
wenzelm@19698
   159
    val prt_const' = Defs.pretty_const (Sign.pp thy);
wenzelm@4250
   160
wenzelm@14794
   161
    fun pretty_classrel (c, []) = prt_cls c
wenzelm@14794
   162
      | pretty_classrel (c, cs) = Pretty.block
wenzelm@14794
   163
          (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
wenzelm@14794
   164
            Pretty.commas (map prt_cls cs));
wenzelm@4250
   165
wenzelm@4250
   166
    fun pretty_default S = Pretty.block
wenzelm@14794
   167
      [Pretty.str "default sort:", Pretty.brk 1, prt_sort S];
wenzelm@4250
   168
skalberg@15531
   169
    fun pretty_witness NONE = Pretty.str "universal non-emptiness witness: -"
skalberg@15531
   170
      | pretty_witness (SOME (T, S)) = Pretty.block
wenzelm@14794
   171
          [Pretty.str "universal non-emptiness witness:", Pretty.brk 1,
wenzelm@14794
   172
            prt_typ_no_tvars T, Pretty.str " ::", Pretty.brk 1, prt_sort S];
wenzelm@14794
   173
wenzelm@14996
   174
    val tfrees = map (fn v => TFree (v, []));
wenzelm@16364
   175
    fun pretty_type syn (t, (Type.LogicalType n, _)) =
skalberg@15531
   176
          if syn then NONE
wenzelm@24848
   177
          else SOME (prt_typ (Type (t, tfrees (Name.invents Name.context Name.aT n))))
wenzelm@16364
   178
      | pretty_type syn (t, (Type.Abbreviation (vs, U, syn'), _)) =
skalberg@15531
   179
          if syn <> syn' then NONE
skalberg@15531
   180
          else SOME (Pretty.block
wenzelm@14996
   181
            [prt_typ (Type (t, tfrees vs)), Pretty.str " =", Pretty.brk 1, prt_typ U])
wenzelm@16364
   182
      | pretty_type syn (t, (Type.Nonterminal, _)) =
skalberg@15531
   183
          if not syn then NONE
skalberg@15531
   184
          else SOME (prt_typ (Type (t, [])));
wenzelm@4250
   185
wenzelm@19482
   186
    val pretty_arities = maps (fn (t, ars) => map (prt_arity t) ars);
skalberg@14223
   187
wenzelm@19698
   188
    fun pretty_abbrev (c, (ty, t)) = Pretty.block
wenzelm@19698
   189
      (prt_const (c, ty) @ [Pretty.str " ==", Pretty.brk 1, prt_term_no_vars t]);
wenzelm@19698
   190
wenzelm@19698
   191
    fun pretty_axm (a, t) = Pretty.block [Pretty.str (a ^ ":"), Pretty.brk 1, prt_term_no_vars t];
wenzelm@19365
   192
wenzelm@19702
   193
    fun pretty_finals reds = Pretty.block
wenzelm@19703
   194
      (Pretty.str "final:" :: Pretty.brk 1 :: Pretty.commas (map (prt_const' o fst) reds));
wenzelm@19702
   195
wenzelm@19698
   196
    fun pretty_reduct (lhs, rhs) = Pretty.block
wenzelm@19702
   197
      ([prt_const' lhs, Pretty.str "  ->", Pretty.brk 2] @
wenzelm@19702
   198
        Pretty.commas (map prt_const' (sort_wrt #1 rhs)));
wenzelm@4250
   199
wenzelm@19698
   200
    fun pretty_restrict (const, name) =
wenzelm@19698
   201
      Pretty.block ([prt_const' const, Pretty.brk 2, Pretty.str ("(from " ^ quote name ^ ")")]);
wenzelm@8720
   202
wenzelm@24665
   203
    val axioms = (Theory.axiom_space thy, Theory.axiom_table thy);
wenzelm@24665
   204
    val oracles = (Theory.oracle_space thy, Theory.oracle_table thy);
wenzelm@24665
   205
    val defs = Theory.defs_of thy;
wenzelm@19698
   206
    val {restricts, reducts} = Defs.dest defs;
wenzelm@18061
   207
    val {naming, syn = _, tsig, consts} = Sign.rep_sg thy;
wenzelm@18936
   208
    val {constants, constraints} = Consts.dest consts;
wenzelm@19698
   209
    val extern_const = NameSpace.extern (#1 constants);
wenzelm@19698
   210
    val {classes, default, types, witness, ...} = Type.rep_tsig tsig;
wenzelm@19698
   211
    val (class_space, class_algebra) = classes;
wenzelm@19642
   212
    val {classes, arities} = Sorts.rep_algebra class_algebra;
wenzelm@14996
   213
wenzelm@24774
   214
    val clsses = NameSpace.dest_table (class_space, Symtab.make (Graph.dest classes));
wenzelm@24774
   215
    val tdecls = NameSpace.dest_table types;
wenzelm@24774
   216
    val arties = NameSpace.dest_table (Sign.type_space thy, arities);
wenzelm@20629
   217
wenzelm@24774
   218
    fun prune_const c = not verbose andalso
wenzelm@24774
   219
      member (op =) (Consts.the_tags consts c) Markup.property_internal;
wenzelm@24774
   220
    val cnsts = NameSpace.extern_table (#1 constants,
wenzelm@24774
   221
      Symtab.make (filter_out (prune_const o fst) (Symtab.dest (#2 constants))));
wenzelm@24774
   222
wenzelm@19482
   223
    val log_cnsts = map_filter (fn (c, (ty, NONE)) => SOME (c, ty) | _ => NONE) cnsts;
wenzelm@21721
   224
    val abbrevs = map_filter (fn (c, (ty, SOME (t, _))) => SOME (c, (ty, t)) | _ => NONE) cnsts;
wenzelm@24774
   225
    val cnstrs = NameSpace.extern_table constraints;
wenzelm@19698
   226
wenzelm@24774
   227
    val axms = NameSpace.extern_table axioms;
wenzelm@24774
   228
    val oras = NameSpace.extern_table oracles;
wenzelm@24774
   229
wenzelm@24774
   230
    val (reds0, (reds1, reds2)) = filter_out (prune_const o fst o fst) reducts
wenzelm@24774
   231
      |> map (fn (lhs, rhs) =>
wenzelm@24774
   232
        (apfst extern_const lhs, map (apfst extern_const) (filter_out (prune_const o fst) rhs)))
wenzelm@19702
   233
      |> sort_wrt (#1 o #1)
wenzelm@19702
   234
      |> List.partition (null o #2)
wenzelm@19702
   235
      ||> List.partition (Defs.plain_args o #2 o #1);
wenzelm@19698
   236
    val rests = restricts |> map (apfst (apfst extern_const)) |> sort_wrt (#1 o #1);
wenzelm@4250
   237
  in
wenzelm@20629
   238
    [Pretty.strs ("names:" :: Context.names_of thy)] @
wenzelm@20629
   239
    [Pretty.strs ["name prefix:", NameSpace.path_of naming],
wenzelm@16364
   240
      Pretty.big_list "classes:" (map pretty_classrel clsses),
wenzelm@8720
   241
      pretty_default default,
wenzelm@14794
   242
      pretty_witness witness,
wenzelm@19482
   243
      Pretty.big_list "syntactic types:" (map_filter (pretty_type true) tdecls),
wenzelm@19482
   244
      Pretty.big_list "logical types:" (map_filter (pretty_type false) tdecls),
wenzelm@16534
   245
      Pretty.big_list "type arities:" (pretty_arities arties),
wenzelm@19698
   246
      Pretty.big_list "logical consts:" (map (Pretty.block o prt_const) log_cnsts),
wenzelm@19365
   247
      Pretty.big_list "abbreviations:" (map pretty_abbrev abbrevs),
wenzelm@19698
   248
      Pretty.big_list "constraints:" (map (Pretty.block o prt_const) cnstrs),
wenzelm@19698
   249
      Pretty.big_list "axioms:" (map pretty_axm axms),
wenzelm@19702
   250
      Pretty.strs ("oracles:" :: (map #1 oras)),
wenzelm@19698
   251
      Pretty.big_list "definitions:"
wenzelm@19702
   252
        [pretty_finals reds0,
wenzelm@19702
   253
         Pretty.big_list "non-overloaded:" (map pretty_reduct reds1),
wenzelm@19702
   254
         Pretty.big_list "overloaded:" (map pretty_reduct reds2),
wenzelm@19702
   255
         Pretty.big_list "pattern restrictions:" (map pretty_restrict rests)]]
wenzelm@4250
   256
  end;
wenzelm@4250
   257
wenzelm@4250
   258
wenzelm@11883
   259
wenzelm@11883
   260
(** print_goals **)
wenzelm@11883
   261
wenzelm@11883
   262
(* print_goals etc. *)
wenzelm@11883
   263
wenzelm@16534
   264
val show_consts = ref false;  (*true: show consts with types in proof state output*)
wenzelm@3851
   265
paulson@1591
   266
wenzelm@11883
   267
(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
wenzelm@11883
   268
wenzelm@11883
   269
local
wenzelm@11883
   270
wenzelm@18980
   271
fun ins_entry (x, y) =
wenzelm@18980
   272
  AList.default (op =) (x, []) #>
wenzelm@18980
   273
  AList.map_entry (op =) x (insert (op =) y);
wenzelm@12081
   274
wenzelm@18980
   275
val add_consts = Term.fold_aterms
wenzelm@18980
   276
  (fn Const (c, T) => ins_entry (T, (c, T))
wenzelm@18980
   277
    | _ => I);
wenzelm@11883
   278
wenzelm@18980
   279
val add_vars = Term.fold_aterms
wenzelm@18980
   280
  (fn Free (x, T) => ins_entry (T, (x, ~1))
wenzelm@18980
   281
    | Var (xi, T) => ins_entry (T, xi)
wenzelm@18980
   282
    | _ => I);
wenzelm@11883
   283
wenzelm@18980
   284
val add_varsT = Term.fold_atyps
wenzelm@18980
   285
  (fn TFree (x, S) => ins_entry (S, (x, ~1))
wenzelm@18980
   286
    | TVar (xi, S) => ins_entry (S, xi)
wenzelm@18980
   287
    | _ => I);
wenzelm@11883
   288
wenzelm@16490
   289
fun sort_idxs vs = map (apsnd (sort (prod_ord string_ord int_ord))) vs;
wenzelm@12081
   290
fun sort_cnsts cs = map (apsnd (sort_wrt fst)) cs;
wenzelm@12081
   291
wenzelm@18980
   292
fun consts_of t = sort_cnsts (add_consts t []);
wenzelm@18980
   293
fun vars_of t = sort_idxs (add_vars t []);
wenzelm@18980
   294
fun varsT_of t = rev (sort_idxs (Term.fold_types add_varsT t []));
wenzelm@12081
   295
wenzelm@12081
   296
in
wenzelm@11883
   297
wenzelm@23634
   298
fun pretty_goals_aux pp markup (msg, main) maxgoals state =
wenzelm@12081
   299
  let
wenzelm@12081
   300
    fun prt_atoms prt prtT (X, xs) = Pretty.block
wenzelm@12081
   301
      [Pretty.block (Pretty.commas (map prt xs)), Pretty.str " ::",
wenzelm@12081
   302
        Pretty.brk 1, prtT X];
wenzelm@11883
   303
wenzelm@14876
   304
    fun prt_var (x, ~1) = Pretty.term pp (Syntax.free x)
wenzelm@14876
   305
      | prt_var xi = Pretty.term pp (Syntax.var xi);
wenzelm@12081
   306
wenzelm@14876
   307
    fun prt_varT (x, ~1) = Pretty.typ pp (TFree (x, []))
wenzelm@14876
   308
      | prt_varT xi = Pretty.typ pp (TVar (xi, []));
wenzelm@12081
   309
wenzelm@14876
   310
    val prt_consts = prt_atoms (Pretty.term pp o Const) (Pretty.typ pp);
wenzelm@14876
   311
    val prt_vars = prt_atoms prt_var (Pretty.typ pp);
wenzelm@14876
   312
    val prt_varsT = prt_atoms prt_varT (Pretty.sort pp);
wenzelm@11883
   313
wenzelm@11883
   314
wenzelm@12081
   315
    fun pretty_list _ _ [] = []
wenzelm@12081
   316
      | pretty_list name prt lst = [Pretty.big_list name (map prt lst)];
wenzelm@11883
   317
wenzelm@23634
   318
    fun pretty_subgoal (n, A) = Pretty.markup markup
wenzelm@23634
   319
      [Pretty.str (" " ^ string_of_int n ^ ". "), Pretty.term pp A];
wenzelm@12081
   320
    fun pretty_subgoals As = map pretty_subgoal (1 upto length As ~~ As);
wenzelm@11883
   321
wenzelm@14876
   322
    val pretty_ffpairs = pretty_list "flex-flex pairs:" (pretty_flexpair pp);
wenzelm@11883
   323
wenzelm@12081
   324
    val pretty_consts = pretty_list "constants:" prt_consts o consts_of;
wenzelm@12081
   325
    val pretty_vars = pretty_list "variables:" prt_vars o vars_of;
wenzelm@12081
   326
    val pretty_varsT = pretty_list "type variables:" prt_varsT o varsT_of;
wenzelm@11883
   327
wenzelm@11883
   328
wenzelm@16290
   329
    val {prop, tpairs, ...} = Thm.rep_thm state;
berghofe@13658
   330
    val (As, B) = Logic.strip_horn prop;
wenzelm@12081
   331
    val ngoals = length As;
wenzelm@11883
   332
wenzelm@12081
   333
    fun pretty_gs (types, sorts) =
wenzelm@14876
   334
      (if main then [Pretty.term pp B] else []) @
wenzelm@12081
   335
       (if ngoals = 0 then [Pretty.str "No subgoals!"]
wenzelm@12081
   336
        else if ngoals > maxgoals then
skalberg@15570
   337
          pretty_subgoals (Library.take (maxgoals, As)) @
wenzelm@12081
   338
          (if msg then [Pretty.str ("A total of " ^ string_of_int ngoals ^ " subgoals...")]
wenzelm@12081
   339
           else [])
wenzelm@12081
   340
        else pretty_subgoals As) @
wenzelm@12081
   341
      pretty_ffpairs tpairs @
wenzelm@12081
   342
      (if ! show_consts then pretty_consts prop else []) @
wenzelm@12081
   343
      (if types then pretty_vars prop else []) @
wenzelm@12081
   344
      (if sorts then pretty_varsT prop else []);
wenzelm@12081
   345
  in
wenzelm@12081
   346
    setmp show_no_free_types true
skalberg@14178
   347
      (setmp show_types (! show_types orelse ! show_sorts orelse ! show_all_types)
wenzelm@12081
   348
        (setmp show_sorts false pretty_gs))
skalberg@14178
   349
   (! show_types orelse ! show_sorts orelse ! show_all_types, ! show_sorts)
wenzelm@11883
   350
  end;
wenzelm@11883
   351
wenzelm@23634
   352
fun pretty_goals n th =
wenzelm@23634
   353
  pretty_goals_aux (Sign.pp (Thm.theory_of_thm th)) Markup.none (true, true) n th;
wenzelm@12081
   354
wenzelm@23634
   355
val print_goals = (Pretty.writeln o Pretty.chunks) oo pretty_goals;
wenzelm@12081
   356
paulson@1591
   357
end;
paulson@1591
   358
wenzelm@11883
   359
wenzelm@11883
   360
end;
wenzelm@11883
   361
wenzelm@11883
   362
structure BasicDisplay: BASIC_DISPLAY = Display;
wenzelm@11883
   363
open BasicDisplay;