src/Pure/display.ML
author berghofe
Mon Oct 21 17:04:47 2002 +0200 (2002-10-21)
changeset 13658 c9ad3e64ddcf
parent 12831 a2a3896f9c48
child 14178 14a12da7288e
permissions -rw-r--r--
Changed handling of flex-flex constraints: now stored in separate
tpairs field of theorem record.
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
berghofe@13658
    31
  val pretty_flexpair: (term -> Pretty.T) -> term * term -> Pretty.T
wenzelm@12081
    32
  val pretty_thm_aux: (sort -> Pretty.T) * (term -> Pretty.T) -> 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@12081
    47
  val pretty_goals_aux: (sort -> Pretty.T) * (typ -> Pretty.T) * (term -> Pretty.T)
wenzelm@12081
    48
    -> string -> bool * bool -> int -> thm -> Pretty.T list
wenzelm@11883
    49
  val pretty_goals: int -> thm -> Pretty.T list
wenzelm@11883
    50
  val print_goals: int -> thm -> unit
wenzelm@11883
    51
  val current_goals_markers: (string * string * string) ref
wenzelm@12418
    52
  val pretty_current_goals: int -> int -> thm -> Pretty.T list
wenzelm@12418
    53
  val print_current_goals_default: int -> int -> thm -> unit
wenzelm@12418
    54
  val print_current_goals_fn: (int -> int -> thm -> unit) ref
wenzelm@4950
    55
end;
paulson@1591
    56
wenzelm@4950
    57
structure Display: DISPLAY =
paulson@1591
    58
struct
paulson@1591
    59
wenzelm@11883
    60
wenzelm@6087
    61
(** print thm **)
wenzelm@6087
    62
wenzelm@12081
    63
val goals_limit = ref 10;       (*max number of goals to print -- set by user*)
wenzelm@12831
    64
val show_hyps = ref false;      (*false: print meta-hypotheses as dots*)
wenzelm@11883
    65
val show_tags = ref false;      (*false: suppress tags*)
wenzelm@6087
    66
wenzelm@8402
    67
fun pretty_tag (name, args) = Pretty.strs (name :: map quote args);
wenzelm@6087
    68
val pretty_tags = Pretty.list "[" "]" o map pretty_tag;
paulson@1591
    69
berghofe@13658
    70
fun pretty_flexpair pretty_term (t, u) = Pretty.block
berghofe@13658
    71
  [pretty_term t, Pretty.str " =?=", Pretty.brk 1, pretty_term u];
berghofe@13658
    72
wenzelm@12081
    73
fun pretty_thm_aux (pretty_sort, pretty_term) quote th =
paulson@1591
    74
  let
berghofe@13658
    75
    val {hyps, tpairs, prop, der = (ora, _), ...} = rep_thm th;
wenzelm@6087
    76
    val xshyps = Thm.extra_shyps th;
wenzelm@6087
    77
    val (_, tags) = Thm.get_name_tags th;
wenzelm@6087
    78
berghofe@13658
    79
    val q = if quote then Pretty.quote else I;
berghofe@13658
    80
    val prt_term = q o pretty_term;
wenzelm@6279
    81
berghofe@13658
    82
    val hlen = length xshyps + length hyps + length tpairs;
paulson@1591
    83
    val hsymbs =
wenzelm@9500
    84
      if hlen = 0 andalso not ora then []
paulson@1591
    85
      else if ! show_hyps then
paulson@1591
    86
        [Pretty.brk 2, Pretty.list "[" "]"
berghofe@13658
    87
          (map (q o pretty_flexpair pretty_term) tpairs @ map prt_term hyps @
berghofe@13658
    88
           map pretty_sort xshyps @
wenzelm@9500
    89
            (if ora then [Pretty.str "!"] else []))]
wenzelm@6889
    90
      else [Pretty.brk 2, Pretty.str ("[" ^ implode (replicate hlen ".") ^
wenzelm@9500
    91
        (if ora then "!" else "") ^ "]")];
wenzelm@6087
    92
    val tsymbs =
wenzelm@6087
    93
      if null tags orelse not (! show_tags) then []
wenzelm@6087
    94
      else [Pretty.brk 1, pretty_tags tags];
wenzelm@6279
    95
  in Pretty.block (prt_term prop :: (hsymbs @ tsymbs)) end;
paulson@1591
    96
wenzelm@12067
    97
fun gen_pretty_thm quote th =
wenzelm@12067
    98
  let val sg = Thm.sign_of_thm th
wenzelm@12081
    99
  in pretty_thm_aux (Sign.pretty_sort sg, Sign.pretty_term sg) quote th end;
wenzelm@6889
   100
wenzelm@12067
   101
val pretty_thm = gen_pretty_thm true;
wenzelm@12067
   102
val pretty_thm_no_quote = gen_pretty_thm false;
wenzelm@6889
   103
wenzelm@6889
   104
paulson@1591
   105
val string_of_thm = Pretty.string_of o pretty_thm;
wenzelm@6279
   106
val pprint_thm = Pretty.pprint o pretty_thm;
paulson@1591
   107
wenzelm@6087
   108
fun pretty_thms [th] = pretty_thm th
wenzelm@6087
   109
  | pretty_thms ths = Pretty.block (Pretty.fbreaks (map pretty_thm ths));
paulson@1591
   110
wenzelm@10010
   111
val pretty_thm_sg = pretty_thm oo Thm.transfer_sg;
wenzelm@10010
   112
val pretty_thms_sg = pretty_thms oo (map o Thm.transfer_sg);
wenzelm@10010
   113
wenzelm@6087
   114
wenzelm@6087
   115
(* top-level commands for printing theorems *)
wenzelm@6087
   116
wenzelm@6087
   117
val print_thm = Pretty.writeln o pretty_thm;
wenzelm@6087
   118
val print_thms = Pretty.writeln o pretty_thms;
paulson@1591
   119
paulson@1591
   120
fun prth th = (print_thm th; th);
paulson@1591
   121
paulson@1591
   122
(*Print and return a sequence of theorems, separated by blank lines. *)
paulson@1591
   123
fun prthq thseq =
wenzelm@4270
   124
  (Seq.print (fn _ => print_thm) 100000 thseq; thseq);
paulson@1591
   125
paulson@1591
   126
(*Print and return a list of theorems, separated by blank lines. *)
wenzelm@4210
   127
fun prths ths = (seq (fn th => (print_thm th; writeln "")) ths; ths);
paulson@1591
   128
paulson@1591
   129
paulson@1591
   130
(* other printing commands *)
paulson@1591
   131
wenzelm@4126
   132
fun pretty_ctyp cT =
wenzelm@4126
   133
  let val {sign, T} = rep_ctyp cT in Sign.pretty_typ sign T end;
wenzelm@4126
   134
paulson@1591
   135
fun pprint_ctyp cT =
paulson@1591
   136
  let val {sign, T} = rep_ctyp cT in Sign.pprint_typ sign T end;
paulson@1591
   137
paulson@1591
   138
fun string_of_ctyp cT =
paulson@1591
   139
  let val {sign, T} = rep_ctyp cT in Sign.string_of_typ sign T end;
paulson@1591
   140
paulson@1591
   141
val print_ctyp = writeln o string_of_ctyp;
paulson@1591
   142
wenzelm@3547
   143
fun pretty_cterm ct =
wenzelm@3547
   144
  let val {sign, t, ...} = rep_cterm ct in Sign.pretty_term sign t end;
wenzelm@3547
   145
paulson@1591
   146
fun pprint_cterm ct =
paulson@1591
   147
  let val {sign, t, ...} = rep_cterm ct in Sign.pprint_term sign t end;
paulson@1591
   148
paulson@1591
   149
fun string_of_cterm ct =
paulson@1591
   150
  let val {sign, t, ...} = rep_cterm ct in Sign.string_of_term sign t end;
paulson@1591
   151
paulson@1591
   152
val print_cterm = writeln o string_of_cterm;
paulson@1591
   153
paulson@1591
   154
wenzelm@4250
   155
wenzelm@4250
   156
(** print theory **)
paulson@1591
   157
wenzelm@6390
   158
val pretty_theory = Sign.pretty_sg o Theory.sign_of;
wenzelm@6390
   159
val pprint_theory = Sign.pprint_sg o Theory.sign_of;
paulson@1591
   160
wenzelm@6390
   161
val print_syntax = Syntax.print_syntax o Theory.syn_of;
paulson@1591
   162
wenzelm@4250
   163
wenzelm@4498
   164
(* pretty_name_space  *)
wenzelm@4498
   165
wenzelm@4498
   166
fun pretty_name_space (kind, space) =
wenzelm@4498
   167
  let
wenzelm@4498
   168
    fun prt_entry (name, accs) = Pretty.block
wenzelm@4498
   169
      (Pretty.str (quote name ^ " =") :: Pretty.brk 1 ::
wenzelm@4498
   170
        Pretty.commas (map (Pretty.str o quote) accs));
wenzelm@4498
   171
  in
wenzelm@4498
   172
    Pretty.fbreaks (Pretty.str (kind ^ ":") :: map prt_entry (NameSpace.dest space))
wenzelm@4498
   173
    |> Pretty.block
wenzelm@4498
   174
  end;
wenzelm@4498
   175
wenzelm@4498
   176
wenzelm@11883
   177
(* pretty_full_theory *)
wenzelm@4250
   178
wenzelm@8720
   179
fun pretty_full_theory thy =
wenzelm@4250
   180
  let
wenzelm@8720
   181
    val sg = Theory.sign_of thy;
wenzelm@8720
   182
wenzelm@4250
   183
    fun prt_cls c = Sign.pretty_sort sg [c];
wenzelm@4250
   184
    fun prt_sort S = Sign.pretty_sort sg S;
wenzelm@4250
   185
    fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
wenzelm@10737
   186
    fun prt_typ_no_tvars ty = Pretty.quote (Sign.pretty_typ sg (#1 (Type.freeze_thaw_type ty)));
wenzelm@8720
   187
    fun prt_term t = Pretty.quote (Sign.pretty_term sg t);
wenzelm@4250
   188
wenzelm@4250
   189
    fun pretty_classes cs = Pretty.block
wenzelm@4250
   190
      (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
wenzelm@4250
   191
wenzelm@4250
   192
    fun pretty_classrel (c, cs) = Pretty.block
wenzelm@4250
   193
      (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 ::
wenzelm@4250
   194
        Pretty.commas (map prt_cls cs));
wenzelm@4250
   195
wenzelm@4250
   196
    fun pretty_default S = Pretty.block
wenzelm@4250
   197
      [Pretty.str "default:", Pretty.brk 1, prt_sort S];
wenzelm@4250
   198
wenzelm@4250
   199
    fun pretty_ty (t, n) = Pretty.block
wenzelm@8458
   200
      [Pretty.str t, Pretty.brk 1, Pretty.str (string_of_int n)];
wenzelm@4250
   201
wenzelm@7635
   202
    fun pretty_log_types ts = Pretty.block
wenzelm@7635
   203
      (Pretty.breaks (Pretty.str "logical types:" :: map Pretty.str ts));
wenzelm@7635
   204
wenzelm@7635
   205
    fun pretty_witness None = Pretty.str "universal non-emptiness witness: --"
wenzelm@7635
   206
      | pretty_witness (Some (T, S)) = Pretty.block
wenzelm@10737
   207
          [Pretty.str "universal non-emptiness witness:", Pretty.brk 1, prt_typ_no_tvars T,
wenzelm@8402
   208
            Pretty.brk 1, prt_sort S];
wenzelm@7635
   209
wenzelm@4250
   210
    fun pretty_abbr (t, (vs, rhs)) = Pretty.block
wenzelm@10737
   211
      [prt_typ_no_tvars (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
wenzelm@10737
   212
        Pretty.str " =", Pretty.brk 1, prt_typ_no_tvars rhs];
wenzelm@4250
   213
wenzelm@4250
   214
    fun pretty_arities (t, ars) = map (prt_arity t) ars;
wenzelm@4250
   215
wenzelm@4250
   216
    fun pretty_const (c, ty) = Pretty.block
wenzelm@10737
   217
      [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ_no_tvars ty];
wenzelm@4250
   218
wenzelm@8720
   219
    fun prt_axm (a, t) = Pretty.block [Pretty.str (a ^ ":"), Pretty.brk 1, prt_term t];
wenzelm@8720
   220
wenzelm@8720
   221
wenzelm@4250
   222
    val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
wenzelm@8720
   223
    val {axioms, oracles, ...} = Theory.rep_theory thy;
wenzelm@6846
   224
    val spaces' = Library.sort_wrt fst spaces;
wenzelm@7635
   225
    val {classes, classrel, default, tycons = type_tab, log_types, univ_witness, abbrs, arities} =
wenzelm@4250
   226
      Type.rep_tsig tsig;
wenzelm@7067
   227
    val tycons = Sign.cond_extern_table sg Sign.typeK type_tab;
wenzelm@6846
   228
    val consts = Sign.cond_extern_table sg Sign.constK const_tab;
wenzelm@8720
   229
    val axms = Sign.cond_extern_table sg Theory.axiomK axioms;
wenzelm@8720
   230
    val oras = Sign.cond_extern_table sg Theory.oracleK oracles;
wenzelm@4250
   231
  in
wenzelm@8720
   232
    [Pretty.strs ("stamps:" :: Sign.stamp_names_of sg),
wenzelm@8720
   233
      Pretty.strs ("data:" :: Sign.data_kinds data),
wenzelm@11501
   234
      Pretty.strs ["name prefix:", NameSpace.pack (if_none path ["-"])],
wenzelm@8720
   235
      Pretty.big_list "name spaces:" (map pretty_name_space spaces'),
wenzelm@8720
   236
      pretty_classes classes,
wenzelm@8720
   237
      Pretty.big_list "class relation:" (map pretty_classrel (Symtab.dest classrel)),
wenzelm@8720
   238
      pretty_default default,
wenzelm@8720
   239
      pretty_log_types log_types,
wenzelm@8720
   240
      pretty_witness univ_witness,
wenzelm@8720
   241
      Pretty.big_list "type constructors:" (map pretty_ty tycons),
wenzelm@8720
   242
      Pretty.big_list "type abbreviations:" (map pretty_abbr (Symtab.dest abbrs)),
wenzelm@8720
   243
      Pretty.big_list "type arities:" (flat (map pretty_arities (Symtab.dest arities))),
wenzelm@8720
   244
      Pretty.big_list "consts:" (map pretty_const consts),
wenzelm@8720
   245
      Pretty.big_list "axioms:" (map prt_axm axms),
wenzelm@8720
   246
      Pretty.strs ("oracles:" :: (map #1 oras))]
wenzelm@4250
   247
  end;
wenzelm@4250
   248
wenzelm@4250
   249
wenzelm@11883
   250
wenzelm@11883
   251
(** print_goals **)
wenzelm@11883
   252
wenzelm@11883
   253
(* print_goals etc. *)
wenzelm@11883
   254
wenzelm@8908
   255
(*show consts with types in proof state output?*)
wenzelm@3851
   256
val show_consts = ref false;
wenzelm@3851
   257
paulson@1591
   258
wenzelm@11883
   259
(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
wenzelm@11883
   260
wenzelm@11883
   261
local
wenzelm@11883
   262
wenzelm@12081
   263
fun ins_entry (x, y) [] = [(x, [y])]
wenzelm@12081
   264
  | ins_entry (x, y) ((pair as (x', ys')) :: pairs) =
wenzelm@12081
   265
      if x = x' then (x', y ins ys') :: pairs
wenzelm@12081
   266
      else pair :: ins_entry (x, y) pairs;
wenzelm@12081
   267
wenzelm@12081
   268
fun add_consts (Const (c, T), env) = ins_entry (T, (c, T)) env
wenzelm@12081
   269
  | add_consts (t $ u, env) = add_consts (u, add_consts (t, env))
wenzelm@12081
   270
  | add_consts (Abs (_, _, t), env) = add_consts (t, env)
wenzelm@12081
   271
  | add_consts (_, env) = env;
wenzelm@11883
   272
wenzelm@12081
   273
fun add_vars (Free (x, T), env) = ins_entry (T, (x, ~1)) env
wenzelm@12081
   274
  | add_vars (Var (xi, T), env) = ins_entry (T, xi) env
wenzelm@12081
   275
  | add_vars (Abs (_, _, t), env) = add_vars (t, env)
wenzelm@12081
   276
  | add_vars (t $ u, env) = add_vars (u, add_vars (t, env))
wenzelm@12081
   277
  | add_vars (_, env) = env;
wenzelm@11883
   278
wenzelm@12081
   279
fun add_varsT (Type (_, Ts), env) = foldr add_varsT (Ts, env)
wenzelm@12081
   280
  | add_varsT (TFree (x, S), env) = ins_entry (S, (x, ~1)) env
wenzelm@12081
   281
  | add_varsT (TVar (xi, S), env) = ins_entry (S, xi) env;
wenzelm@11883
   282
wenzelm@12081
   283
fun sort_idxs vs = map (apsnd (sort (prod_ord string_ord int_ord))) vs;
wenzelm@12081
   284
fun sort_cnsts cs = map (apsnd (sort_wrt fst)) cs;
wenzelm@12081
   285
wenzelm@12081
   286
fun consts_of t = sort_cnsts (add_consts (t, []));
wenzelm@12081
   287
fun vars_of t = sort_idxs (add_vars (t, []));
wenzelm@12081
   288
fun varsT_of t = rev (sort_idxs (it_term_types add_varsT (t, [])));
wenzelm@12081
   289
wenzelm@12081
   290
in
wenzelm@11883
   291
wenzelm@12081
   292
fun pretty_goals_aux (prt_sort, prt_typ, prt_term) begin_goal (msg, main) maxgoals state =
wenzelm@12081
   293
  let
wenzelm@12081
   294
    fun prt_atoms prt prtT (X, xs) = Pretty.block
wenzelm@12081
   295
      [Pretty.block (Pretty.commas (map prt xs)), Pretty.str " ::",
wenzelm@12081
   296
        Pretty.brk 1, prtT X];
wenzelm@11883
   297
wenzelm@12081
   298
    fun prt_var (x, ~1) = prt_term (Syntax.free x)
wenzelm@12081
   299
      | prt_var xi = prt_term (Syntax.var xi);
wenzelm@12081
   300
wenzelm@12081
   301
    fun prt_varT (x, ~1) = prt_typ (TFree (x, []))
wenzelm@12081
   302
      | prt_varT xi = prt_typ (TVar (xi, []));
wenzelm@12081
   303
wenzelm@12081
   304
    val prt_consts = prt_atoms (prt_term o Const) prt_typ;
wenzelm@12081
   305
    val prt_vars = prt_atoms prt_var prt_typ;
wenzelm@12081
   306
    val prt_varsT = prt_atoms prt_varT prt_sort;
wenzelm@11883
   307
wenzelm@11883
   308
wenzelm@12081
   309
    fun pretty_list _ _ [] = []
wenzelm@12081
   310
      | pretty_list name prt lst = [Pretty.big_list name (map prt lst)];
wenzelm@11883
   311
wenzelm@12081
   312
    fun pretty_subgoal (n, A) =
wenzelm@12081
   313
      Pretty.blk (0, [Pretty.str (begin_goal ^ " " ^ string_of_int n ^ ". "), prt_term A]);
wenzelm@12081
   314
    fun pretty_subgoals As = map pretty_subgoal (1 upto length As ~~ As);
wenzelm@11883
   315
berghofe@13658
   316
    val pretty_ffpairs = pretty_list "flex-flex pairs:" (pretty_flexpair prt_term);
wenzelm@11883
   317
wenzelm@12081
   318
    val pretty_consts = pretty_list "constants:" prt_consts o consts_of;
wenzelm@12081
   319
    val pretty_vars = pretty_list "variables:" prt_vars o vars_of;
wenzelm@12081
   320
    val pretty_varsT = pretty_list "type variables:" prt_varsT o varsT_of;
wenzelm@11883
   321
wenzelm@11883
   322
berghofe@13658
   323
    val {prop, tpairs, ...} = rep_thm state;
berghofe@13658
   324
    val (As, B) = Logic.strip_horn prop;
wenzelm@12081
   325
    val ngoals = length As;
wenzelm@11883
   326
wenzelm@12081
   327
    fun pretty_gs (types, sorts) =
wenzelm@12081
   328
      (if main then [prt_term B] else []) @
wenzelm@12081
   329
       (if ngoals = 0 then [Pretty.str "No subgoals!"]
wenzelm@12081
   330
        else if ngoals > maxgoals then
wenzelm@12081
   331
          pretty_subgoals (take (maxgoals, As)) @
wenzelm@12081
   332
          (if msg then [Pretty.str ("A total of " ^ string_of_int ngoals ^ " subgoals...")]
wenzelm@12081
   333
           else [])
wenzelm@12081
   334
        else pretty_subgoals As) @
wenzelm@12081
   335
      pretty_ffpairs tpairs @
wenzelm@12081
   336
      (if ! show_consts then pretty_consts prop else []) @
wenzelm@12081
   337
      (if types then pretty_vars prop else []) @
wenzelm@12081
   338
      (if sorts then pretty_varsT prop else []);
wenzelm@12081
   339
  in
wenzelm@12081
   340
    setmp show_no_free_types true
wenzelm@12081
   341
      (setmp show_types (! show_types orelse ! show_sorts)
wenzelm@12081
   342
        (setmp show_sorts false pretty_gs))
wenzelm@12081
   343
   (! show_types orelse ! show_sorts, ! show_sorts)
wenzelm@11883
   344
  end;
wenzelm@11883
   345
wenzelm@12081
   346
fun pretty_goals_marker bg n th =
wenzelm@12081
   347
  let val sg = Thm.sign_of_thm th in
wenzelm@12081
   348
    pretty_goals_aux (Sign.pretty_sort sg, Sign.pretty_typ sg, Sign.pretty_term sg)
wenzelm@12081
   349
      bg (true, true) n th
wenzelm@12081
   350
  end;
wenzelm@12081
   351
wenzelm@12081
   352
val pretty_goals = pretty_goals_marker "";
wenzelm@12418
   353
val print_goals = (Pretty.writeln o Pretty.chunks) oo pretty_goals_marker "";
wenzelm@12081
   354
paulson@1591
   355
end;
paulson@1591
   356
wenzelm@11883
   357
wenzelm@11883
   358
(* print_current_goals *)
wenzelm@11883
   359
wenzelm@11883
   360
val current_goals_markers = ref ("", "", "");
wenzelm@11883
   361
wenzelm@12418
   362
fun pretty_current_goals n m th =
wenzelm@11883
   363
  let
wenzelm@11883
   364
    val ref (begin_state, end_state, begin_goal) = current_goals_markers;
wenzelm@11883
   365
    val ngoals = nprems_of th;
wenzelm@11883
   366
  in
wenzelm@12418
   367
    (if begin_state = "" then [] else [Pretty.str begin_state]) @
wenzelm@12418
   368
    [Pretty.str ("Level " ^ string_of_int n ^
wenzelm@11883
   369
      (if ngoals > 0 then " (" ^ string_of_int ngoals ^ " subgoal" ^
wenzelm@11883
   370
        (if ngoals <> 1 then "s" else "") ^ ")"
wenzelm@12418
   371
      else ""))] @
wenzelm@12418
   372
    pretty_goals_marker begin_goal m th @
wenzelm@12418
   373
    (if end_state = "" then [] else [Pretty.str end_state])
wenzelm@11883
   374
  end;
wenzelm@11883
   375
wenzelm@12418
   376
fun print_current_goals_default n m th =
wenzelm@12418
   377
  Pretty.writeln (Pretty.chunks (pretty_current_goals n m th));
wenzelm@12418
   378
wenzelm@11883
   379
val print_current_goals_fn = ref print_current_goals_default;
wenzelm@11883
   380
wenzelm@11883
   381
end;
wenzelm@11883
   382
wenzelm@11883
   383
structure BasicDisplay: BASIC_DISPLAY = Display;
wenzelm@11883
   384
open BasicDisplay;