20 val pretty_goal_header: thm -> Pretty.T |
20 val pretty_goal_header: thm -> Pretty.T |
21 val string_of_goal: Proof.context -> thm -> string |
21 val string_of_goal: Proof.context -> thm -> string |
22 val pretty_goal_facts: Proof.context -> string -> thm list -> Pretty.T |
22 val pretty_goal_facts: Proof.context -> string -> thm list -> Pretty.T |
23 val method_error: string -> Position.T -> |
23 val method_error: string -> Position.T -> |
24 {context: Proof.context, facts: thm list, goal: thm} -> 'a Seq.result |
24 {context: Proof.context, facts: thm list, goal: thm} -> 'a Seq.result |
25 val print_results: bool -> Proof.context -> ((string * string) * (string * thm list) list) -> unit |
25 val print_results: bool -> Position.T -> Proof.context -> |
26 val print_consts: bool -> Proof.context -> (string * typ -> bool) -> (string * typ) list -> unit |
26 ((string * string) * (string * thm list) list) -> unit |
|
27 val print_consts: bool -> Position.T -> Proof.context -> |
|
28 (string * typ -> bool) -> (string * typ) list -> unit |
27 end |
29 end |
28 |
30 |
29 structure Proof_Display: PROOF_DISPLAY = |
31 structure Proof_Display: PROOF_DISPLAY = |
30 struct |
32 struct |
31 |
33 |
125 in pr_header ^ pr_facts ^ pr_goal end); |
127 in pr_header ^ pr_facts ^ pr_goal end); |
126 |
128 |
127 |
129 |
128 (* results *) |
130 (* results *) |
129 |
131 |
|
132 fun position_markup pos = Pretty.mark (Position.markup pos Markup.position); |
|
133 |
130 local |
134 local |
131 |
135 |
132 fun pretty_fact_name (kind, "") = Pretty.keyword1 kind |
136 fun pretty_fact_name pos (kind, "") = position_markup pos (Pretty.keyword1 kind) |
133 | pretty_fact_name (kind, name) = |
137 | pretty_fact_name pos (kind, name) = |
134 Pretty.block [Pretty.keyword1 kind, Pretty.brk 1, |
138 Pretty.block [position_markup pos (Pretty.keyword1 kind), Pretty.brk 1, |
135 Pretty.str (Long_Name.base_name name), Pretty.str ":"]; |
139 Pretty.str (Long_Name.base_name name), Pretty.str ":"]; |
136 |
140 |
137 fun pretty_facts ctxt = |
141 fun pretty_facts ctxt = |
138 flat o (separate [Pretty.fbrk, Pretty.keyword2 "and", Pretty.str " "]) o |
142 flat o (separate [Pretty.fbrk, Pretty.keyword2 "and", Pretty.str " "]) o |
139 map (single o Proof_Context.pretty_fact ctxt); |
143 map (single o Proof_Context.pretty_fact ctxt); |
140 |
144 |
141 in |
145 in |
142 |
146 |
143 fun print_results do_print ctxt ((kind, name), facts) = |
147 fun print_results do_print pos ctxt ((kind, name), facts) = |
144 if not do_print orelse kind = "" then () |
148 if not do_print orelse kind = "" then () |
145 else if name = "" then |
149 else if name = "" then |
146 (Pretty.writeln o Pretty.mark Markup.state) |
150 (Pretty.writeln o Pretty.mark Markup.state) |
147 (Pretty.block (Pretty.keyword1 kind :: Pretty.brk 1 :: pretty_facts ctxt facts)) |
151 (Pretty.block (position_markup pos (Pretty.keyword1 kind) :: Pretty.brk 1 :: |
|
152 pretty_facts ctxt facts)) |
148 else |
153 else |
149 (Pretty.writeln o Pretty.mark Markup.state) |
154 (Pretty.writeln o Pretty.mark Markup.state) |
150 (case facts of |
155 (case facts of |
151 [fact] => Pretty.blk (1, [pretty_fact_name (kind, name), Pretty.fbrk, |
156 [fact] => Pretty.blk (1, [pretty_fact_name pos (kind, name), Pretty.fbrk, |
152 Proof_Context.pretty_fact ctxt fact]) |
157 Proof_Context.pretty_fact ctxt fact]) |
153 | _ => Pretty.blk (1, [pretty_fact_name (kind, name), Pretty.fbrk, |
158 | _ => Pretty.blk (1, [pretty_fact_name pos (kind, name), Pretty.fbrk, |
154 Pretty.blk (1, Pretty.str "(" :: pretty_facts ctxt facts @ [Pretty.str ")"])])); |
159 Pretty.blk (1, Pretty.str "(" :: pretty_facts ctxt facts @ [Pretty.str ")"])])); |
155 |
160 |
156 end; |
161 end; |
157 |
162 |
158 |
163 |
162 |
167 |
163 fun pretty_var ctxt (x, T) = |
168 fun pretty_var ctxt (x, T) = |
164 Pretty.block [Pretty.str x, Pretty.str " ::", Pretty.brk 1, |
169 Pretty.block [Pretty.str x, Pretty.str " ::", Pretty.brk 1, |
165 Pretty.quote (Syntax.pretty_typ ctxt T)]; |
170 Pretty.quote (Syntax.pretty_typ ctxt T)]; |
166 |
171 |
167 fun pretty_vars ctxt kind vs = Pretty.big_list kind (map (pretty_var ctxt) vs); |
172 fun pretty_vars pos ctxt kind vs = |
|
173 Pretty.block (Pretty.fbreaks (position_markup pos (Pretty.str kind) :: map (pretty_var ctxt) vs)); |
168 |
174 |
169 fun pretty_consts ctxt pred cs = |
175 fun pretty_consts pos ctxt pred cs = |
170 (case filter pred (#1 (Proof_Context.inferred_fixes ctxt)) of |
176 (case filter pred (#1 (Proof_Context.inferred_fixes ctxt)) of |
171 [] => pretty_vars ctxt "constants" cs |
177 [] => pretty_vars pos ctxt "constants" cs |
172 | ps => Pretty.chunks [pretty_vars ctxt "parameters" ps, pretty_vars ctxt "constants" cs]); |
178 | ps => Pretty.chunks [pretty_vars pos ctxt "parameters" ps, pretty_vars pos ctxt "constants" cs]); |
173 |
179 |
174 in |
180 in |
175 |
181 |
176 fun print_consts do_print ctxt pred cs = |
182 fun print_consts do_print pos ctxt pred cs = |
177 if not do_print orelse null cs then () |
183 if not do_print orelse null cs then () |
178 else Pretty.writeln (Pretty.mark Markup.state (pretty_consts ctxt pred cs)); |
184 else Pretty.writeln (Pretty.mark Markup.state (pretty_consts pos ctxt pred cs)); |
179 |
185 |
180 end; |
186 end; |
181 |
187 |
182 end; |
188 end; |