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