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