src/Pure/display.ML
author obua
Sun May 29 12:39:12 2005 +0200 (2005-05-29)
changeset 16108 cf468b93a02e
parent 15574 b1d1b5bfc464
child 16127 549fff1d0fc6
permissions -rw-r--r--
Implement cycle-free overloading, so that definitions cannot harm consistency any more (except of course via interaction with axioms).
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
paulson@1591
     6
Printing of theories, theorems, 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@14876
    31
  val pretty_flexpair: Pretty.pp -> term * term -> Pretty.T
wenzelm@14876
    32
  val pretty_thm_aux: Pretty.pp -> bool -> thm -> Pretty.T
wenzelm@6976
    33
  val pretty_thm_no_quote: thm -> Pretty.T
wenzelm@11883
    34
  val pretty_thm: thm -> Pretty.T
wenzelm@11883
    35
  val pretty_thms: thm list -> Pretty.T
wenzelm@11883
    36
  val pretty_thm_sg: Sign.sg -> thm -> Pretty.T
wenzelm@11883
    37
  val pretty_thms_sg: Sign.sg -> thm list -> Pretty.T
wenzelm@11883
    38
  val pprint_thm: thm -> pprint_args -> unit
wenzelm@11883
    39
  val pretty_ctyp: ctyp -> Pretty.T
wenzelm@11883
    40
  val pprint_ctyp: ctyp -> pprint_args -> unit
wenzelm@11883
    41
  val pretty_cterm: cterm -> Pretty.T
wenzelm@11883
    42
  val pprint_cterm: cterm -> pprint_args -> unit
wenzelm@11883
    43
  val pretty_theory: theory -> Pretty.T
wenzelm@11883
    44
  val pprint_theory: theory -> pprint_args -> unit
wenzelm@8720
    45
  val pretty_full_theory: theory -> Pretty.T list
wenzelm@11883
    46
  val pretty_name_space: string * NameSpace.T -> Pretty.T
wenzelm@14876
    47
  val pretty_goals_aux: Pretty.pp -> string -> bool * bool -> int -> thm -> Pretty.T list
wenzelm@11883
    48
  val pretty_goals: int -> thm -> Pretty.T list
wenzelm@11883
    49
  val print_goals: int -> thm -> unit
wenzelm@11883
    50
  val current_goals_markers: (string * string * string) ref
wenzelm@12418
    51
  val pretty_current_goals: int -> int -> thm -> Pretty.T list
wenzelm@12418
    52
  val print_current_goals_default: int -> int -> thm -> unit
wenzelm@12418
    53
  val print_current_goals_fn: (int -> int -> thm -> unit) ref
wenzelm@4950
    54
end;
paulson@1591
    55
wenzelm@4950
    56
structure Display: DISPLAY =
paulson@1591
    57
struct
paulson@1591
    58
wenzelm@11883
    59
wenzelm@6087
    60
(** print thm **)
wenzelm@6087
    61
wenzelm@12081
    62
val goals_limit = ref 10;       (*max number of goals to print -- set by user*)
wenzelm@12831
    63
val show_hyps = ref false;      (*false: print meta-hypotheses as dots*)
wenzelm@11883
    64
val show_tags = ref false;      (*false: suppress tags*)
wenzelm@6087
    65
berghofe@14598
    66
fun pretty_tag (name, args) = Pretty.strs (name :: map Library.quote args);
wenzelm@6087
    67
val pretty_tags = Pretty.list "[" "]" o map pretty_tag;
paulson@1591
    68
wenzelm@14876
    69
fun pretty_flexpair pp (t, u) = Pretty.block
wenzelm@14876
    70
  [Pretty.term pp t, Pretty.str " =?=", Pretty.brk 1, Pretty.term pp u];
berghofe@13658
    71
wenzelm@14876
    72
fun pretty_thm_aux pp quote th =
paulson@1591
    73
  let
berghofe@13658
    74
    val {hyps, tpairs, prop, der = (ora, _), ...} = rep_thm th;
wenzelm@6087
    75
    val xshyps = Thm.extra_shyps th;
wenzelm@6087
    76
    val (_, tags) = Thm.get_name_tags th;
wenzelm@6087
    77
berghofe@13658
    78
    val q = if quote then Pretty.quote else I;
wenzelm@14876
    79
    val prt_term = q o (Pretty.term pp);
wenzelm@6279
    80
berghofe@13658
    81
    val hlen = length xshyps + length hyps + length tpairs;
paulson@1591
    82
    val hsymbs =
wenzelm@9500
    83
      if hlen = 0 andalso not ora then []
paulson@1591
    84
      else if ! show_hyps then
paulson@1591
    85
        [Pretty.brk 2, Pretty.list "[" "]"
wenzelm@14876
    86
          (map (q o pretty_flexpair pp) tpairs @ map prt_term hyps @
wenzelm@14876
    87
           map (Pretty.sort pp) xshyps @
wenzelm@9500
    88
            (if ora then [Pretty.str "!"] else []))]
wenzelm@6889
    89
      else [Pretty.brk 2, Pretty.str ("[" ^ implode (replicate hlen ".") ^
wenzelm@9500
    90
        (if ora then "!" else "") ^ "]")];
wenzelm@6087
    91
    val tsymbs =
wenzelm@6087
    92
      if null tags orelse not (! show_tags) then []
wenzelm@6087
    93
      else [Pretty.brk 1, pretty_tags tags];
wenzelm@6279
    94
  in Pretty.block (prt_term prop :: (hsymbs @ tsymbs)) end;
paulson@1591
    95
wenzelm@12067
    96
fun gen_pretty_thm quote th =
wenzelm@14876
    97
  pretty_thm_aux (Sign.pp (Thm.sign_of_thm th)) quote th;
wenzelm@6889
    98
wenzelm@12067
    99
val pretty_thm = gen_pretty_thm true;
wenzelm@12067
   100
val pretty_thm_no_quote = gen_pretty_thm false;
wenzelm@6889
   101
wenzelm@6889
   102
paulson@1591
   103
val string_of_thm = Pretty.string_of o pretty_thm;
wenzelm@6279
   104
val pprint_thm = Pretty.pprint o pretty_thm;
paulson@1591
   105
wenzelm@6087
   106
fun pretty_thms [th] = pretty_thm th
wenzelm@6087
   107
  | pretty_thms ths = Pretty.block (Pretty.fbreaks (map pretty_thm ths));
paulson@1591
   108
wenzelm@10010
   109
val pretty_thm_sg = pretty_thm oo Thm.transfer_sg;
wenzelm@10010
   110
val pretty_thms_sg = pretty_thms oo (map o Thm.transfer_sg);
wenzelm@10010
   111
wenzelm@6087
   112
wenzelm@6087
   113
(* top-level commands for printing theorems *)
wenzelm@6087
   114
wenzelm@6087
   115
val print_thm = Pretty.writeln o pretty_thm;
wenzelm@6087
   116
val print_thms = Pretty.writeln o pretty_thms;
paulson@1591
   117
paulson@1591
   118
fun prth th = (print_thm th; th);
paulson@1591
   119
paulson@1591
   120
(*Print and return a sequence of theorems, separated by blank lines. *)
paulson@1591
   121
fun prthq thseq =
wenzelm@4270
   122
  (Seq.print (fn _ => print_thm) 100000 thseq; thseq);
paulson@1591
   123
paulson@1591
   124
(*Print and return a list of theorems, separated by blank lines. *)
skalberg@15570
   125
fun prths ths = (List.app (fn th => (print_thm th; writeln "")) ths; ths);
paulson@1591
   126
paulson@1591
   127
paulson@1591
   128
(* other printing commands *)
paulson@1591
   129
wenzelm@4126
   130
fun pretty_ctyp cT =
wenzelm@4126
   131
  let val {sign, T} = rep_ctyp cT in Sign.pretty_typ sign T end;
wenzelm@4126
   132
paulson@1591
   133
fun pprint_ctyp cT =
paulson@1591
   134
  let val {sign, T} = rep_ctyp cT in Sign.pprint_typ sign T end;
paulson@1591
   135
paulson@1591
   136
fun string_of_ctyp cT =
paulson@1591
   137
  let val {sign, T} = rep_ctyp cT in Sign.string_of_typ sign T end;
paulson@1591
   138
paulson@1591
   139
val print_ctyp = writeln o string_of_ctyp;
paulson@1591
   140
wenzelm@3547
   141
fun pretty_cterm ct =
wenzelm@3547
   142
  let val {sign, t, ...} = rep_cterm ct in Sign.pretty_term sign t end;
wenzelm@3547
   143
paulson@1591
   144
fun pprint_cterm ct =
paulson@1591
   145
  let val {sign, t, ...} = rep_cterm ct in Sign.pprint_term sign t end;
paulson@1591
   146
paulson@1591
   147
fun string_of_cterm ct =
paulson@1591
   148
  let val {sign, t, ...} = rep_cterm ct in Sign.string_of_term sign t end;
paulson@1591
   149
paulson@1591
   150
val print_cterm = writeln o string_of_cterm;
paulson@1591
   151
paulson@1591
   152
wenzelm@4250
   153
wenzelm@4250
   154
(** print theory **)
paulson@1591
   155
wenzelm@6390
   156
val pretty_theory = Sign.pretty_sg o Theory.sign_of;
wenzelm@6390
   157
val pprint_theory = Sign.pprint_sg o Theory.sign_of;
paulson@1591
   158
wenzelm@6390
   159
val print_syntax = Syntax.print_syntax o Theory.syn_of;
paulson@1591
   160
wenzelm@4250
   161
wenzelm@4498
   162
(* pretty_name_space  *)
wenzelm@4498
   163
wenzelm@4498
   164
fun pretty_name_space (kind, space) =
wenzelm@4498
   165
  let
wenzelm@4498
   166
    fun prt_entry (name, accs) = Pretty.block
berghofe@14598
   167
      (Pretty.str (Library.quote name ^ " =") :: Pretty.brk 1 ::
berghofe@14598
   168
        Pretty.commas (map (Pretty.quote o Pretty.str) accs));
wenzelm@4498
   169
  in
wenzelm@4498
   170
    Pretty.fbreaks (Pretty.str (kind ^ ":") :: map prt_entry (NameSpace.dest space))
wenzelm@4498
   171
    |> Pretty.block
wenzelm@4498
   172
  end;
wenzelm@4498
   173
wenzelm@4498
   174
wenzelm@11883
   175
(* pretty_full_theory *)
wenzelm@4250
   176
wenzelm@8720
   177
fun pretty_full_theory thy =
wenzelm@4250
   178
  let
wenzelm@8720
   179
    val sg = Theory.sign_of thy;
wenzelm@8720
   180
wenzelm@4250
   181
    fun prt_cls c = Sign.pretty_sort sg [c];
wenzelm@4250
   182
    fun prt_sort S = Sign.pretty_sort sg S;
wenzelm@4250
   183
    fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
wenzelm@14996
   184
    fun prt_typ ty = Pretty.quote (Sign.pretty_typ sg ty);
wenzelm@14996
   185
    val prt_typ_no_tvars = prt_typ o #1 o Type.freeze_thaw_type;
wenzelm@8720
   186
    fun prt_term t = Pretty.quote (Sign.pretty_term sg t);
wenzelm@4250
   187
wenzelm@14794
   188
    fun pretty_classrel (c, []) = prt_cls c
wenzelm@14794
   189
      | pretty_classrel (c, cs) = Pretty.block
wenzelm@14794
   190
          (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
wenzelm@14794
   191
            Pretty.commas (map prt_cls cs));
wenzelm@4250
   192
wenzelm@4250
   193
    fun pretty_default S = Pretty.block
wenzelm@14794
   194
      [Pretty.str "default sort:", Pretty.brk 1, prt_sort S];
wenzelm@4250
   195
skalberg@15531
   196
    fun pretty_witness NONE = Pretty.str "universal non-emptiness witness: -"
skalberg@15531
   197
      | pretty_witness (SOME (T, S)) = Pretty.block
wenzelm@14794
   198
          [Pretty.str "universal non-emptiness witness:", Pretty.brk 1,
wenzelm@14794
   199
            prt_typ_no_tvars T, Pretty.str " ::", Pretty.brk 1, prt_sort S];
wenzelm@14794
   200
wenzelm@14996
   201
    val tfrees = map (fn v => TFree (v, []));
wenzelm@15000
   202
    fun pretty_type syn (t, Type.LogicalType n) =
skalberg@15531
   203
          if syn then NONE
skalberg@15531
   204
          else SOME (prt_typ (Type (t, tfrees (Term.invent_names [] "'a" n))))
wenzelm@15000
   205
      | pretty_type syn (t, Type.Abbreviation (vs, U, syn')) =
skalberg@15531
   206
          if syn <> syn' then NONE
skalberg@15531
   207
          else SOME (Pretty.block
wenzelm@14996
   208
            [prt_typ (Type (t, tfrees vs)), Pretty.str " =", Pretty.brk 1, prt_typ U])
wenzelm@15000
   209
      | pretty_type syn (t, Type.Nonterminal) =
skalberg@15531
   210
          if not syn then NONE
skalberg@15531
   211
          else SOME (prt_typ (Type (t, [])));
wenzelm@4250
   212
skalberg@15570
   213
    val pretty_arities = List.concat o map (fn (t, ars) => map (prt_arity t) ars);
skalberg@14223
   214
wenzelm@14794
   215
    fun pretty_const (c, (ty, _)) = Pretty.block
wenzelm@10737
   216
      [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ_no_tvars ty];
wenzelm@4250
   217
wenzelm@14996
   218
    fun pretty_final (c, []) = Pretty.str c
wenzelm@14996
   219
      | pretty_final (c, tys) = Pretty.block
wenzelm@14996
   220
          (Pretty.str c :: Pretty.str " ::" :: Pretty.brk 1 ::
wenzelm@14996
   221
             Pretty.commas (map prt_typ_no_tvars tys));
wenzelm@14996
   222
wenzelm@8720
   223
    fun prt_axm (a, t) = Pretty.block [Pretty.str (a ^ ":"), Pretty.brk 1, prt_term t];
wenzelm@8720
   224
wenzelm@8720
   225
wenzelm@14996
   226
    val {sign = _, const_deps = _, final_consts, axioms, oracles,
wenzelm@14996
   227
      parents = _, ancestors = _} = Theory.rep_theory thy;
wenzelm@14794
   228
    val {self = _, tsig, consts, path, spaces, data} = Sign.rep_sg sg;
wenzelm@14794
   229
    val {classes, default, types, arities, log_types = _, witness} = Type.rep_tsig tsig;
wenzelm@14996
   230
wenzelm@14996
   231
    val spcs = Library.sort_wrt #1 spaces;
wenzelm@15000
   232
    val tdecls = Symtab.dest types |> map (fn (t, (d, _)) =>
wenzelm@15000
   233
      (Sign.cond_extern sg Sign.typeK t, (t, d))) |> Library.sort_wrt #1 |> map #2;
wenzelm@14794
   234
    val cnsts = Sign.cond_extern_table sg Sign.constK consts;
wenzelm@14996
   235
    val finals = Sign.cond_extern_table sg Sign.constK final_consts;
wenzelm@8720
   236
    val axms = Sign.cond_extern_table sg Theory.axiomK axioms;
wenzelm@8720
   237
    val oras = Sign.cond_extern_table sg Theory.oracleK oracles;
wenzelm@4250
   238
  in
wenzelm@8720
   239
    [Pretty.strs ("stamps:" :: Sign.stamp_names_of sg),
wenzelm@8720
   240
      Pretty.strs ("data:" :: Sign.data_kinds data),
skalberg@15570
   241
      Pretty.strs ["name prefix:", NameSpace.pack (getOpt (path,["-"]))],
wenzelm@14996
   242
      Pretty.big_list "name spaces:" (map pretty_name_space spcs),
wenzelm@14794
   243
      Pretty.big_list "classes:" (map pretty_classrel (Graph.dest classes)),
wenzelm@8720
   244
      pretty_default default,
wenzelm@14794
   245
      pretty_witness witness,
skalberg@15570
   246
      Pretty.big_list "syntactic types:" (List.mapPartial (pretty_type true) tdecls),
skalberg@15570
   247
      Pretty.big_list "logical types:" (List.mapPartial (pretty_type false) tdecls),
wenzelm@14996
   248
      Pretty.big_list "type arities:" (pretty_arities (Symtab.dest arities)),
wenzelm@14794
   249
      Pretty.big_list "consts:" (map pretty_const cnsts),
wenzelm@14996
   250
      Pretty.big_list "finals consts:" (map pretty_final finals),
wenzelm@8720
   251
      Pretty.big_list "axioms:" (map prt_axm axms),
wenzelm@8720
   252
      Pretty.strs ("oracles:" :: (map #1 oras))]
wenzelm@4250
   253
  end;
wenzelm@4250
   254
wenzelm@4250
   255
wenzelm@11883
   256
wenzelm@11883
   257
(** print_goals **)
wenzelm@11883
   258
wenzelm@11883
   259
(* print_goals etc. *)
wenzelm@11883
   260
wenzelm@8908
   261
(*show consts with types in proof state output?*)
wenzelm@3851
   262
val show_consts = ref false;
wenzelm@3851
   263
paulson@1591
   264
wenzelm@11883
   265
(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
wenzelm@11883
   266
wenzelm@11883
   267
local
wenzelm@11883
   268
wenzelm@12081
   269
fun ins_entry (x, y) [] = [(x, [y])]
wenzelm@12081
   270
  | ins_entry (x, y) ((pair as (x', ys')) :: pairs) =
wenzelm@12081
   271
      if x = x' then (x', y ins ys') :: pairs
wenzelm@12081
   272
      else pair :: ins_entry (x, y) pairs;
wenzelm@12081
   273
wenzelm@12081
   274
fun add_consts (Const (c, T), env) = ins_entry (T, (c, T)) env
wenzelm@12081
   275
  | add_consts (t $ u, env) = add_consts (u, add_consts (t, env))
wenzelm@12081
   276
  | add_consts (Abs (_, _, t), env) = add_consts (t, env)
wenzelm@12081
   277
  | add_consts (_, env) = env;
wenzelm@11883
   278
wenzelm@12081
   279
fun add_vars (Free (x, T), env) = ins_entry (T, (x, ~1)) env
wenzelm@12081
   280
  | add_vars (Var (xi, T), env) = ins_entry (T, xi) env
wenzelm@12081
   281
  | add_vars (Abs (_, _, t), env) = add_vars (t, env)
wenzelm@12081
   282
  | add_vars (t $ u, env) = add_vars (u, add_vars (t, env))
wenzelm@12081
   283
  | add_vars (_, env) = env;
wenzelm@11883
   284
skalberg@15574
   285
fun add_varsT (Type (_, Ts), env) = foldr add_varsT env Ts
wenzelm@12081
   286
  | add_varsT (TFree (x, S), env) = ins_entry (S, (x, ~1)) env
wenzelm@12081
   287
  | add_varsT (TVar (xi, S), env) = ins_entry (S, xi) env;
wenzelm@11883
   288
paulson@14472
   289
fun sort_idxs vs = map (apsnd (sort (prod_ord String.compare Int.compare))) vs;
wenzelm@12081
   290
fun sort_cnsts cs = map (apsnd (sort_wrt fst)) cs;
wenzelm@12081
   291
wenzelm@12081
   292
fun consts_of t = sort_cnsts (add_consts (t, []));
wenzelm@12081
   293
fun vars_of t = sort_idxs (add_vars (t, []));
wenzelm@12081
   294
fun varsT_of t = rev (sort_idxs (it_term_types add_varsT (t, [])));
wenzelm@12081
   295
wenzelm@12081
   296
in
wenzelm@11883
   297
wenzelm@14876
   298
fun pretty_goals_aux pp begin_goal (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@14876
   318
    fun pretty_subgoal (n, A) = Pretty.blk (0,
wenzelm@14876
   319
     [Pretty.str (begin_goal ^ " " ^ 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
berghofe@13658
   329
    val {prop, tpairs, ...} = 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@12081
   352
fun pretty_goals_marker bg n th =
wenzelm@14876
   353
  pretty_goals_aux (Sign.pp (Thm.sign_of_thm th)) bg (true, true) n th;
wenzelm@12081
   354
wenzelm@12081
   355
val pretty_goals = pretty_goals_marker "";
wenzelm@12418
   356
val print_goals = (Pretty.writeln o Pretty.chunks) oo pretty_goals_marker "";
wenzelm@12081
   357
paulson@1591
   358
end;
paulson@1591
   359
wenzelm@11883
   360
wenzelm@11883
   361
(* print_current_goals *)
wenzelm@11883
   362
wenzelm@11883
   363
val current_goals_markers = ref ("", "", "");
wenzelm@11883
   364
wenzelm@12418
   365
fun pretty_current_goals n m th =
wenzelm@11883
   366
  let
wenzelm@11883
   367
    val ref (begin_state, end_state, begin_goal) = current_goals_markers;
wenzelm@11883
   368
    val ngoals = nprems_of th;
wenzelm@11883
   369
  in
wenzelm@12418
   370
    (if begin_state = "" then [] else [Pretty.str begin_state]) @
wenzelm@12418
   371
    [Pretty.str ("Level " ^ string_of_int n ^
wenzelm@11883
   372
      (if ngoals > 0 then " (" ^ string_of_int ngoals ^ " subgoal" ^
wenzelm@11883
   373
        (if ngoals <> 1 then "s" else "") ^ ")"
wenzelm@12418
   374
      else ""))] @
wenzelm@12418
   375
    pretty_goals_marker begin_goal m th @
wenzelm@12418
   376
    (if end_state = "" then [] else [Pretty.str end_state])
wenzelm@11883
   377
  end;
wenzelm@11883
   378
wenzelm@12418
   379
fun print_current_goals_default n m th =
wenzelm@12418
   380
  Pretty.writeln (Pretty.chunks (pretty_current_goals n m th));
wenzelm@12418
   381
wenzelm@11883
   382
val print_current_goals_fn = ref print_current_goals_default;
wenzelm@11883
   383
wenzelm@11883
   384
end;
wenzelm@11883
   385
wenzelm@11883
   386
structure BasicDisplay: BASIC_DISPLAY = Display;
wenzelm@11883
   387
open BasicDisplay;