| author | wenzelm | 
| Tue, 08 Mar 2022 17:09:09 +0100 | |
| changeset 75247 | 4a9809ee1a85 | 
| parent 74156 | ecf80e37ed1a | 
| child 76061 | 0982d0220b31 | 
| permissions | -rw-r--r-- | 
| 17369 | 1 | (* Title: Pure/Isar/proof_display.ML | 
| 2 | Author: Makarius | |
| 3 | ||
| 19432 
cae7cc072994
added print_theorems/theory, print_theorems_diff (from pure_thy.ML);
 wenzelm parents: 
18799diff
changeset | 4 | Printing of theorems, goals, results etc. | 
| 17369 | 5 | *) | 
| 6 | ||
| 7 | signature PROOF_DISPLAY = | |
| 8 | sig | |
| 30628 | 9 | val pp_context: Proof.context -> Pretty.T | 
| 60937 | 10 | val pp_thm: (unit -> theory) -> thm -> Pretty.T | 
| 11 | val pp_typ: (unit -> theory) -> typ -> Pretty.T | |
| 12 | val pp_term: (unit -> theory) -> term -> Pretty.T | |
| 13 | val pp_ctyp: (unit -> theory) -> ctyp -> Pretty.T | |
| 14 | val pp_cterm: (unit -> theory) -> cterm -> Pretty.T | |
| 61267 | 15 | val pretty_theory: bool -> Proof.context -> Pretty.T | 
| 61252 | 16 | val pretty_definitions: bool -> Proof.context -> Pretty.T | 
| 61266 | 17 | val pretty_theorems_diff: bool -> theory list -> Proof.context -> Pretty.T list | 
| 18 | val pretty_theorems: bool -> Proof.context -> Pretty.T list | |
| 20311 | 19 | val string_of_rule: Proof.context -> string -> thm -> string | 
| 49860 | 20 | val pretty_goal_header: thm -> Pretty.T | 
| 21 | val string_of_goal: Proof.context -> thm -> string | |
| 51584 | 22 | val pretty_goal_facts: Proof.context -> string -> thm list -> Pretty.T | 
| 49866 | 23 | val method_error: string -> Position.T -> | 
| 24 |     {context: Proof.context, facts: thm list, goal: thm} -> 'a Seq.result
 | |
| 74156 | 25 | val show_results: bool Config.T | 
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 26 | val print_results: bool -> Position.T -> Proof.context -> | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 27 | ((string * string) * (string * thm list) list) -> unit | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 28 | val print_consts: bool -> Position.T -> Proof.context -> | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 29 | (string * typ -> bool) -> (string * typ) list -> unit | 
| 17369 | 30 | end | 
| 31 | ||
| 33389 | 32 | structure Proof_Display: PROOF_DISPLAY = | 
| 17369 | 33 | struct | 
| 34 | ||
| 61252 | 35 | (** toplevel pretty printing **) | 
| 20211 | 36 | |
| 30628 | 37 | fun pp_context ctxt = | 
| 42717 
0bbb56867091
proper configuration options Proof_Context.debug and Proof_Context.verbose;
 wenzelm parents: 
42360diff
changeset | 38 | (if Config.get ctxt Proof_Context.debug then | 
| 42360 | 39 | Pretty.quote (Pretty.big_list "proof context:" (Proof_Context.pretty_context ctxt)) | 
| 20211 | 40 | else Pretty.str "<context>"); | 
| 41 | ||
| 60937 | 42 | fun default_context mk_thy = | 
| 62889 | 43 | (case Context.get_generic_context () of | 
| 45269 
6f8949e6c71a
more robust ML pretty printing (cf. b6c527c64789);
 wenzelm parents: 
44240diff
changeset | 44 | SOME (Context.Proof ctxt) => ctxt | 
| 
6f8949e6c71a
more robust ML pretty printing (cf. b6c527c64789);
 wenzelm parents: 
44240diff
changeset | 45 | | SOME (Context.Theory thy) => | 
| 
6f8949e6c71a
more robust ML pretty printing (cf. b6c527c64789);
 wenzelm parents: 
44240diff
changeset | 46 | (case try Syntax.init_pretty_global thy of | 
| 
6f8949e6c71a
more robust ML pretty printing (cf. b6c527c64789);
 wenzelm parents: 
44240diff
changeset | 47 | SOME ctxt => ctxt | 
| 60937 | 48 | | NONE => Syntax.init_pretty_global (mk_thy ())) | 
| 49 | | NONE => Syntax.init_pretty_global (mk_thy ())); | |
| 50 | ||
| 51 | fun pp_thm mk_thy th = | |
| 61268 | 52 |   Thm.pretty_thm_raw (default_context mk_thy) {quote = true, show_hyps = false} th;
 | 
| 44240 
4b1a63678839
improved default context for ML toplevel pretty-printing;
 wenzelm parents: 
44192diff
changeset | 53 | |
| 60937 | 54 | fun pp_typ mk_thy T = Pretty.quote (Syntax.pretty_typ (default_context mk_thy) T); | 
| 55 | fun pp_term mk_thy t = Pretty.quote (Syntax.pretty_term (default_context mk_thy) t); | |
| 20211 | 56 | |
| 60937 | 57 | fun pp_ctyp mk_thy cT = pp_typ mk_thy (Thm.typ_of cT); | 
| 58 | fun pp_cterm mk_thy ct = pp_term mk_thy (Thm.term_of ct); | |
| 20211 | 59 | |
| 19432 
cae7cc072994
added print_theorems/theory, print_theorems_diff (from pure_thy.ML);
 wenzelm parents: 
18799diff
changeset | 60 | |
| 61252 | 61 | |
| 62 | (** theory content **) | |
| 63 | ||
| 61266 | 64 | fun pretty_theory verbose ctxt = | 
| 65 | let | |
| 66 | val thy = Proof_Context.theory_of ctxt; | |
| 67 | ||
| 68 | fun prt_cls c = Syntax.pretty_sort ctxt [c]; | |
| 69 | fun prt_sort S = Syntax.pretty_sort ctxt S; | |
| 70 | fun prt_arity t (c, Ss) = Syntax.pretty_arity ctxt (t, Ss, [c]); | |
| 71 | fun prt_typ ty = Pretty.quote (Syntax.pretty_typ ctxt ty); | |
| 72 | val prt_typ_no_tvars = prt_typ o Logic.unvarifyT_global; | |
| 73 | fun prt_term t = Pretty.quote (Syntax.pretty_term ctxt t); | |
| 74 | val prt_term_no_vars = prt_term o Logic.unvarify_global; | |
| 75 | fun prt_const (c, ty) = [Pretty.mark_str c, Pretty.str " ::", Pretty.brk 1, prt_typ_no_tvars ty]; | |
| 76 | ||
| 77 | fun pretty_classrel (c, []) = prt_cls c | |
| 78 | | pretty_classrel (c, cs) = Pretty.block | |
| 79 | (prt_cls c :: Pretty.str " <" :: Pretty.brk 1 :: Pretty.commas (map prt_cls cs)); | |
| 80 | ||
| 81 | fun pretty_default S = Pretty.block | |
| 82 | [Pretty.str "default sort:", Pretty.brk 1, prt_sort S]; | |
| 83 | ||
| 84 | val tfrees = map (fn v => TFree (v, [])); | |
| 85 | fun pretty_type syn (t, Type.LogicalType n) = | |
| 86 | if syn then NONE | |
| 87 | else SOME (prt_typ (Type (t, tfrees (Name.invent Name.context Name.aT n)))) | |
| 88 | | pretty_type syn (t, Type.Abbreviation (vs, U, syn')) = | |
| 89 | if syn <> syn' then NONE | |
| 90 | else SOME (Pretty.block | |
| 91 | [prt_typ (Type (t, tfrees vs)), Pretty.str " =", Pretty.brk 1, prt_typ U]) | |
| 92 | | pretty_type syn (t, Type.Nonterminal) = | |
| 93 | if not syn then NONE | |
| 94 | else SOME (prt_typ (Type (t, []))); | |
| 95 | ||
| 96 | val pretty_arities = maps (fn (t, ars) => map (prt_arity t) ars); | |
| 97 | ||
| 98 | fun pretty_abbrev (c, (ty, t)) = Pretty.block | |
| 64596 | 99 | (prt_const (c, ty) @ [Pretty.str " \<equiv>", Pretty.brk 1, prt_term_no_vars t]); | 
| 19432 
cae7cc072994
added print_theorems/theory, print_theorems_diff (from pure_thy.ML);
 wenzelm parents: 
18799diff
changeset | 100 | |
| 61266 | 101 | fun pretty_axm (a, t) = | 
| 102 | Pretty.block [Pretty.mark_str a, Pretty.str ":", Pretty.brk 1, prt_term_no_vars t]; | |
| 103 | ||
| 104 | val tsig = Sign.tsig_of thy; | |
| 105 | val consts = Sign.consts_of thy; | |
| 106 |     val {const_space, constants, constraints} = Consts.dest consts;
 | |
| 107 |     val {classes, default, types, ...} = Type.rep_tsig tsig;
 | |
| 108 | val type_space = Type.type_space tsig; | |
| 109 | val (class_space, class_algebra) = classes; | |
| 110 | val classes = Sorts.classes_of class_algebra; | |
| 111 | val arities = Sorts.arities_of class_algebra; | |
| 112 | ||
| 113 | val clsses = | |
| 114 | Name_Space.extern_entries verbose ctxt class_space | |
| 115 | (map (fn ((c, _), cs) => (c, Sign.minimize_sort thy cs)) (Graph.dest classes)) | |
| 116 | |> map (apfst #1); | |
| 117 | val tdecls = Name_Space.extern_table verbose ctxt types |> map (apfst #1); | |
| 118 | val arties = | |
| 119 | Name_Space.extern_entries verbose ctxt type_space (Symtab.dest arities) | |
| 120 | |> map (apfst #1); | |
| 121 | ||
| 122 | val cnsts = Name_Space.markup_entries verbose ctxt const_space constants; | |
| 123 | val log_cnsts = map_filter (fn (c, (ty, NONE)) => SOME (c, ty) | _ => NONE) cnsts; | |
| 124 | val abbrevs = map_filter (fn (c, (ty, SOME t)) => SOME (c, (ty, t)) | _ => NONE) cnsts; | |
| 125 | val cnstrs = Name_Space.markup_entries verbose ctxt const_space constraints; | |
| 126 | in | |
| 61267 | 127 | Pretty.chunks | 
| 128 | [Pretty.big_list "classes:" (map pretty_classrel clsses), | |
| 61266 | 129 | pretty_default default, | 
| 130 | Pretty.big_list "syntactic types:" (map_filter (pretty_type true) tdecls), | |
| 131 | Pretty.big_list "logical types:" (map_filter (pretty_type false) tdecls), | |
| 132 | Pretty.big_list "type arities:" (pretty_arities arties), | |
| 133 | Pretty.big_list "logical consts:" (map (Pretty.block o prt_const) log_cnsts), | |
| 134 | Pretty.big_list "abbreviations:" (map pretty_abbrev abbrevs), | |
| 135 | Pretty.big_list "constraints:" (map (Pretty.block o prt_const) cnstrs), | |
| 136 | Pretty.block | |
| 137 | (Pretty.breaks (Pretty.str "oracles:" :: | |
| 61267 | 138 | map Pretty.mark_str (Thm.extern_oracles verbose ctxt)))] | 
| 139 | end; | |
| 140 | ||
| 141 | ||
| 142 | (* theorems *) | |
| 143 | ||
| 144 | fun pretty_theorems_diff verbose prev_thys ctxt = | |
| 145 | let | |
| 146 | val pretty_fact = Proof_Context.pretty_fact ctxt; | |
| 147 | val facts = Global_Theory.facts_of (Proof_Context.theory_of ctxt); | |
| 148 | val thmss = Facts.dest_static verbose (map Global_Theory.facts_of prev_thys) facts; | |
| 149 | val prts = map #1 (sort_by (#1 o #2) (map (`pretty_fact) thmss)); | |
| 150 | in if null prts then [] else [Pretty.big_list "theorems:" prts] end; | |
| 151 | ||
| 152 | fun pretty_theorems verbose ctxt = | |
| 153 | pretty_theorems_diff verbose (Theory.parents_of (Proof_Context.theory_of ctxt)) ctxt; | |
| 20621 | 154 | |
| 61252 | 155 | |
| 156 | (* definitions *) | |
| 157 | ||
| 158 | fun pretty_definitions verbose ctxt = | |
| 159 | let | |
| 160 | val thy = Proof_Context.theory_of ctxt; | |
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 161 | val context = Proof_Context.defs_context ctxt; | 
| 61252 | 162 | |
| 61253 | 163 | val const_space = Proof_Context.const_space ctxt; | 
| 164 | val type_space = Proof_Context.type_space ctxt; | |
| 61256 | 165 | val item_space = fn Defs.Const => const_space | Defs.Type => type_space; | 
| 61253 | 166 | fun prune_item (k, c) = not verbose andalso Name_Space.is_concealed (item_space k) c; | 
| 167 | ||
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 168 | fun extern_item (kind, name) = | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 169 | let val xname = Name_Space.extern ctxt (item_space kind) name | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 170 | in (xname, (kind, name)) end; | 
| 61253 | 171 | |
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 172 | fun extern_item_ord ((xname1, (kind1, _)), (xname2, (kind2, _))) = | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 173 | (case Defs.item_kind_ord (kind1, kind2) of | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 174 | EQUAL => string_ord (xname1, xname2) | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 175 | | ord => ord); | 
| 61253 | 176 | |
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 177 | fun sort_items f = sort (extern_item_ord o apply2 f); | 
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 178 | |
| 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 179 | fun pretty_entry ((_: string, item), args) = Defs.pretty_entry context (item, args); | 
| 61252 | 180 | |
| 181 | fun pretty_reduct (lhs, rhs) = Pretty.block | |
| 61253 | 182 | ([pretty_entry lhs, Pretty.str " ->", Pretty.brk 2] @ | 
| 183 | Pretty.commas (map pretty_entry (sort_items fst rhs))); | |
| 61252 | 184 | |
| 61253 | 185 | fun pretty_restrict (entry, name) = | 
| 186 |       Pretty.block ([pretty_entry entry, Pretty.brk 2, Pretty.str ("(from " ^ quote name ^ ")")]);
 | |
| 61252 | 187 | |
| 188 | val defs = Theory.defs_of thy; | |
| 189 |     val {restricts, reducts} = Defs.dest defs;
 | |
| 22335 | 190 | |
| 61257 | 191 | val (reds1, reds2) = | 
| 61253 | 192 | filter_out (prune_item o #1 o #1) reducts | 
| 61252 | 193 | |> map (fn (lhs, rhs) => | 
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 194 | (apfst extern_item lhs, map (apfst extern_item) (filter_out (prune_item o fst) rhs))) | 
| 61253 | 195 | |> sort_items (#1 o #1) | 
| 61257 | 196 | |> filter_out (null o #2) | 
| 197 | |> List.partition (Defs.plain_args o #2 o #1); | |
| 61253 | 198 | |
| 61261 
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
 wenzelm parents: 
61258diff
changeset | 199 | val rests = restricts |> map (apfst (apfst extern_item)) |> sort_items (#1 o #1); | 
| 61252 | 200 | in | 
| 201 | Pretty.big_list "definitions:" | |
| 61258 | 202 | (map (Pretty.text_fold o single) | 
| 203 | [Pretty.big_list "non-overloaded LHS:" (map pretty_reduct reds1), | |
| 204 | Pretty.big_list "overloaded LHS:" (map pretty_reduct reds2), | |
| 205 | Pretty.big_list "pattern restrictions due to incomplete LHS:" (map pretty_restrict rests)]) | |
| 61252 | 206 | end; | 
| 207 | ||
| 208 | ||
| 209 | ||
| 210 | (** proof items **) | |
| 19432 
cae7cc072994
added print_theorems/theory, print_theorems_diff (from pure_thy.ML);
 wenzelm parents: 
18799diff
changeset | 211 | |
| 17369 | 212 | (* refinement rule *) | 
| 213 | ||
| 214 | fun pretty_rule ctxt s thm = | |
| 215 | Pretty.block [Pretty.str (s ^ " attempt to solve goal by exported rule:"), | |
| 61268 | 216 | Pretty.fbrk, Thm.pretty_thm ctxt thm]; | 
| 17369 | 217 | |
| 218 | val string_of_rule = Pretty.string_of ooo pretty_rule; | |
| 219 | ||
| 220 | ||
| 49860 | 221 | (* goals *) | 
| 222 | ||
| 223 | local | |
| 224 | ||
| 225 | fun subgoals 0 = [] | |
| 226 | | subgoals 1 = [Pretty.brk 1, Pretty.str "(1 subgoal)"] | |
| 227 |   | subgoals n = [Pretty.brk 1, Pretty.str ("(" ^ string_of_int n ^ " subgoals)")];
 | |
| 228 | ||
| 229 | in | |
| 230 | ||
| 231 | fun pretty_goal_header goal = | |
| 55763 | 232 | Pretty.block ([Pretty.keyword1 "goal"] @ subgoals (Thm.nprems_of goal) @ [Pretty.str ":"]); | 
| 49860 | 233 | |
| 234 | end; | |
| 235 | ||
| 236 | fun string_of_goal ctxt goal = | |
| 51958 
bca32217b304
retain goal display options when printing error messages, to avoid breakdown for huge goals;
 wenzelm parents: 
51601diff
changeset | 237 | Pretty.string_of (Pretty.chunks [pretty_goal_header goal, Goal_Display.pretty_goal ctxt goal]); | 
| 49860 | 238 | |
| 239 | ||
| 51584 | 240 | (* goal facts *) | 
| 241 | ||
| 242 | fun pretty_goal_facts ctxt s ths = | |
| 243 | (Pretty.block o Pretty.fbreaks) | |
| 51601 | 244 | [if s = "" then Pretty.str "this:" | 
| 55763 | 245 | else Pretty.block [Pretty.keyword1 s, Pretty.brk 1, Pretty.str "this:"], | 
| 51601 | 246 |      Proof_Context.pretty_fact ctxt ("", ths)];
 | 
| 51584 | 247 | |
| 248 | ||
| 49860 | 249 | (* method_error *) | 
| 250 | ||
| 49866 | 251 | fun method_error kind pos {context = ctxt, facts, goal} = Seq.Error (fn () =>
 | 
| 49860 | 252 | let | 
| 49866 | 253 | val pr_header = | 
| 254 | "Failed to apply " ^ (if kind = "" then "" else kind ^ " ") ^ | |
| 255 | "proof method" ^ Position.here pos ^ ":\n"; | |
| 49860 | 256 | val pr_facts = | 
| 257 | if null facts then "" | |
| 51584 | 258 | else Pretty.string_of (pretty_goal_facts ctxt "using" facts) ^ "\n"; | 
| 49860 | 259 | val pr_goal = string_of_goal ctxt goal; | 
| 260 | in pr_header ^ pr_facts ^ pr_goal end); | |
| 261 | ||
| 262 | ||
| 17369 | 263 | (* results *) | 
| 264 | ||
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 265 | fun position_markup pos = Pretty.mark (Position.markup pos Markup.position); | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 266 | |
| 74156 | 267 | val interactive = | 
| 268 |   Config.declare_bool ("interactive", \<^here>) (K false);
 | |
| 269 | ||
| 270 | val show_results = | |
| 271 |   Config.declare_bool ("show_results", \<^here>) (fn context => Config.get_generic context interactive);
 | |
| 272 | ||
| 273 | fun no_print int ctxt = not (Config.get (Config.put interactive int ctxt) show_results); | |
| 274 | ||
| 28092 | 275 | local | 
| 276 | ||
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 277 | fun pretty_fact_name pos (kind, "") = position_markup pos (Pretty.keyword1 kind) | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 278 | | pretty_fact_name pos (kind, name) = | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 279 | Pretty.block [position_markup pos (Pretty.keyword1 kind), Pretty.brk 1, | 
| 41551 | 280 | Pretty.str (Long_Name.base_name name), Pretty.str ":"]; | 
| 28087 
a9cccdd9d521
pretty_fact/results: display base only, since results now come with full names (note that Facts.extern is not really well-defined unless we present the real target context);
 wenzelm parents: 
27857diff
changeset | 281 | |
| 17369 | 282 | fun pretty_facts ctxt = | 
| 55763 | 283 | flat o (separate [Pretty.fbrk, Pretty.keyword2 "and", Pretty.str " "]) o | 
| 50126 
3dec88149176
theorem status about oracles/futures is no longer printed by default;
 wenzelm parents: 
49867diff
changeset | 284 | map (single o Proof_Context.pretty_fact ctxt); | 
| 17369 | 285 | |
| 27857 | 286 | in | 
| 287 | ||
| 74156 | 288 | fun print_results int pos ctxt ((kind, name), facts) = | 
| 289 | if kind = "" orelse no_print int ctxt then () | |
| 28092 | 290 | else if name = "" then | 
| 59184 
830bb7ddb3ab
explicit message channels for "state", "information";
 wenzelm parents: 
57605diff
changeset | 291 | (Output.state o Pretty.string_of) | 
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 292 | (Pretty.block (position_markup pos (Pretty.keyword1 kind) :: Pretty.brk 1 :: | 
| 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 293 | pretty_facts ctxt facts)) | 
| 46728 
85f8e3932712
display proof results as "state", to suppress odd squiggles in the Prover IDE (see also 9240be8c8c69);
 wenzelm parents: 
45269diff
changeset | 294 | else | 
| 59184 
830bb7ddb3ab
explicit message channels for "state", "information";
 wenzelm parents: 
57605diff
changeset | 295 | (Output.state o Pretty.string_of) | 
| 46728 
85f8e3932712
display proof results as "state", to suppress odd squiggles in the Prover IDE (see also 9240be8c8c69);
 wenzelm parents: 
45269diff
changeset | 296 | (case facts of | 
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 297 | [fact] => Pretty.blk (1, [pretty_fact_name pos (kind, name), Pretty.fbrk, | 
| 50126 
3dec88149176
theorem status about oracles/futures is no longer printed by default;
 wenzelm parents: 
49867diff
changeset | 298 | Proof_Context.pretty_fact ctxt fact]) | 
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 299 | | _ => Pretty.blk (1, [pretty_fact_name pos (kind, name), Pretty.fbrk, | 
| 46728 
85f8e3932712
display proof results as "state", to suppress odd squiggles in the Prover IDE (see also 9240be8c8c69);
 wenzelm parents: 
45269diff
changeset | 300 |           Pretty.blk (1, Pretty.str "(" :: pretty_facts ctxt facts @ [Pretty.str ")"])]));
 | 
| 17369 | 301 | |
| 302 | end; | |
| 303 | ||
| 20889 | 304 | |
| 305 | (* consts *) | |
| 306 | ||
| 307 | local | |
| 308 | ||
| 309 | fun pretty_var ctxt (x, T) = | |
| 310 | Pretty.block [Pretty.str x, Pretty.str " ::", Pretty.brk 1, | |
| 24920 | 311 | Pretty.quote (Syntax.pretty_typ ctxt T)]; | 
| 20889 | 312 | |
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 313 | fun pretty_vars pos ctxt kind vs = | 
| 62188 | 314 | Pretty.block | 
| 315 | (Pretty.fbreaks (position_markup pos (Pretty.mark_str kind) :: map (pretty_var ctxt) vs)); | |
| 316 | ||
| 317 | val fixes = (Markup.keyword2, "fixes"); | |
| 318 | val consts = (Markup.keyword1, "consts"); | |
| 20889 | 319 | |
| 56932 
11a4001b06c6
more position markup to help locating the query context, e.g. from "Info" dockable;
 wenzelm parents: 
56897diff
changeset | 320 | fun pretty_consts pos ctxt pred cs = | 
| 42360 | 321 | (case filter pred (#1 (Proof_Context.inferred_fixes ctxt)) of | 
| 62188 | 322 | [] => pretty_vars pos ctxt consts cs | 
| 323 | | ps => Pretty.chunks [pretty_vars pos ctxt fixes ps, pretty_vars pos ctxt consts cs]); | |
| 20889 | 324 | |
| 44192 
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
 wenzelm parents: 
42717diff
changeset | 325 | in | 
| 
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
 wenzelm parents: 
42717diff
changeset | 326 | |
| 74156 | 327 | fun print_consts int pos ctxt pred cs = | 
| 328 | if null cs orelse no_print int ctxt then () | |
| 59184 
830bb7ddb3ab
explicit message channels for "state", "information";
 wenzelm parents: 
57605diff
changeset | 329 | else Output.state (Pretty.string_of (pretty_consts pos ctxt pred cs)); | 
| 44192 
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
 wenzelm parents: 
42717diff
changeset | 330 | |
| 20889 | 331 | end; | 
| 332 | ||
| 17369 | 333 | end; |