1 (* Title: HOL/Tools/Sledgehammer/sledgehammer_reconstruct.ML |
|
2 Author: Lawrence C. Paulson, Cambridge University Computer Laboratory |
|
3 Author: Claire Quigley, Cambridge University Computer Laboratory |
|
4 Author: Jasmin Blanchette, TU Muenchen |
|
5 |
|
6 Proof reconstruction for Sledgehammer. |
|
7 *) |
|
8 |
|
9 signature SLEDGEHAMMER_RECONSTRUCT = |
|
10 sig |
|
11 type locality = Sledgehammer_Filter.locality |
|
12 type minimize_command = string list -> string |
|
13 type metis_params = |
|
14 string * bool * minimize_command * string * (string * locality) list vector |
|
15 * thm * int |
|
16 type isar_params = |
|
17 string Symtab.table * bool * int * Proof.context * int list list |
|
18 type text_result = string * (string * locality) list |
|
19 |
|
20 val repair_conjecture_shape_and_axiom_names : |
|
21 string -> int list list -> (string * locality) list vector |
|
22 -> int list list * (string * locality) list vector |
|
23 val metis_proof_text : metis_params -> text_result |
|
24 val isar_proof_text : isar_params -> metis_params -> text_result |
|
25 val proof_text : bool -> isar_params -> metis_params -> text_result |
|
26 end; |
|
27 |
|
28 structure Sledgehammer_Reconstruct : SLEDGEHAMMER_RECONSTRUCT = |
|
29 struct |
|
30 |
|
31 open ATP_Problem |
|
32 open ATP_Proof |
|
33 open Metis_Translate |
|
34 open Sledgehammer_Util |
|
35 open Sledgehammer_Filter |
|
36 open Sledgehammer_Translate |
|
37 |
|
38 type minimize_command = string list -> string |
|
39 type metis_params = |
|
40 string * bool * minimize_command * string * (string * locality) list vector |
|
41 * thm * int |
|
42 type isar_params = |
|
43 string Symtab.table * bool * int * Proof.context * int list list |
|
44 type text_result = string * (string * locality) list |
|
45 |
|
46 fun is_head_digit s = Char.isDigit (String.sub (s, 0)) |
|
47 val scan_integer = Scan.many1 is_head_digit >> (the o Int.fromString o implode) |
|
48 |
|
49 fun find_first_in_list_vector vec key = |
|
50 Vector.foldl (fn (ps, NONE) => AList.lookup (op =) ps key |
|
51 | (_, value) => value) NONE vec |
|
52 |
|
53 |
|
54 (** SPASS's Flotter hack **) |
|
55 |
|
56 (* This is a hack required for keeping track of axioms after they have been |
|
57 clausified by SPASS's Flotter tool. The "ATP/scripts/spass" script is also |
|
58 part of this hack. *) |
|
59 |
|
60 val set_ClauseFormulaRelationN = "set_ClauseFormulaRelation" |
|
61 |
|
62 fun extract_clause_sequence output = |
|
63 let |
|
64 val tokens_of = String.tokens (not o Char.isAlphaNum) |
|
65 fun extract_num ("clause" :: (ss as _ :: _)) = |
|
66 Int.fromString (List.last ss) |
|
67 | extract_num _ = NONE |
|
68 in output |> split_lines |> map_filter (extract_num o tokens_of) end |
|
69 |
|
70 val parse_clause_formula_pair = |
|
71 $$ "(" |-- scan_integer --| $$ "," |
|
72 -- (Symbol.scan_id ::: Scan.repeat ($$ "," |-- Symbol.scan_id)) --| $$ ")" |
|
73 --| Scan.option ($$ ",") |
|
74 val parse_clause_formula_relation = |
|
75 Scan.this_string set_ClauseFormulaRelationN |-- $$ "(" |
|
76 |-- Scan.repeat parse_clause_formula_pair |
|
77 val extract_clause_formula_relation = |
|
78 Substring.full #> Substring.position set_ClauseFormulaRelationN |
|
79 #> snd #> Substring.position "." #> fst #> Substring.string |
|
80 #> explode #> filter_out Symbol.is_blank #> parse_clause_formula_relation |
|
81 #> fst |
|
82 |
|
83 fun repair_conjecture_shape_and_axiom_names output conjecture_shape |
|
84 axiom_names = |
|
85 if String.isSubstring set_ClauseFormulaRelationN output then |
|
86 let |
|
87 val j0 = hd (hd conjecture_shape) |
|
88 val seq = extract_clause_sequence output |
|
89 val name_map = extract_clause_formula_relation output |
|
90 fun renumber_conjecture j = |
|
91 conjecture_prefix ^ string_of_int (j - j0) |
|
92 |> AList.find (fn (s, ss) => member (op =) ss s) name_map |
|
93 |> map (fn s => find_index (curry (op =) s) seq + 1) |
|
94 fun names_for_number j = |
|
95 j |> AList.lookup (op =) name_map |> these |
|
96 |> map_filter (try (unprefix axiom_prefix)) |> map unascii_of |
|
97 |> map (fn name => |
|
98 (name, name |> find_first_in_list_vector axiom_names |
|
99 |> the) |
|
100 handle Option.Option => |
|
101 error ("No such fact: " ^ quote name ^ ".")) |
|
102 in |
|
103 (conjecture_shape |> map (maps renumber_conjecture), |
|
104 seq |> map names_for_number |> Vector.fromList) |
|
105 end |
|
106 else |
|
107 (conjecture_shape, axiom_names) |
|
108 |
|
109 |
|
110 (** Soft-core proof reconstruction: Metis one-liner **) |
|
111 |
|
112 fun string_for_label (s, num) = s ^ string_of_int num |
|
113 |
|
114 fun metis_using [] = "" |
|
115 | metis_using ls = |
|
116 "using " ^ space_implode " " (map string_for_label ls) ^ " " |
|
117 fun metis_apply _ 1 = "by " |
|
118 | metis_apply 1 _ = "apply " |
|
119 | metis_apply i _ = "prefer " ^ string_of_int i ^ " apply " |
|
120 fun metis_name full_types = if full_types then "metisFT" else "metis" |
|
121 fun metis_call full_types [] = metis_name full_types |
|
122 | metis_call full_types ss = |
|
123 "(" ^ metis_name full_types ^ " " ^ space_implode " " ss ^ ")" |
|
124 fun metis_command full_types i n (ls, ss) = |
|
125 metis_using ls ^ metis_apply i n ^ metis_call full_types ss |
|
126 fun metis_line banner full_types i n ss = |
|
127 banner ^ ": " ^ |
|
128 Markup.markup Markup.sendback (metis_command full_types i n ([], ss)) ^ "." |
|
129 fun minimize_line _ [] = "" |
|
130 | minimize_line minimize_command ss = |
|
131 case minimize_command ss of |
|
132 "" => "" |
|
133 | command => |
|
134 "\nTo minimize the number of lemmas, try this: " ^ |
|
135 Markup.markup Markup.sendback command ^ "." |
|
136 |
|
137 fun resolve_axiom axiom_names ((_, SOME s)) = |
|
138 (case strip_prefix_and_unascii axiom_prefix s of |
|
139 SOME s' => (case find_first_in_list_vector axiom_names s' of |
|
140 SOME x => [(s', x)] |
|
141 | NONE => []) |
|
142 | NONE => []) |
|
143 | resolve_axiom axiom_names (num, NONE) = |
|
144 case Int.fromString num of |
|
145 SOME j => |
|
146 if j > 0 andalso j <= Vector.length axiom_names then |
|
147 Vector.sub (axiom_names, j - 1) |
|
148 else |
|
149 [] |
|
150 | NONE => [] |
|
151 |
|
152 fun add_fact axiom_names (Inference (name, _, [])) = |
|
153 append (resolve_axiom axiom_names name) |
|
154 | add_fact _ _ = I |
|
155 |
|
156 fun used_facts_in_tstplike_proof axiom_names = |
|
157 atp_proof_from_tstplike_string #> rpair [] #-> fold (add_fact axiom_names) |
|
158 |
|
159 fun used_facts axiom_names = |
|
160 used_facts_in_tstplike_proof axiom_names |
|
161 #> List.partition (curry (op =) Chained o snd) |
|
162 #> pairself (sort_distinct (string_ord o pairself fst)) |
|
163 |
|
164 fun metis_proof_text (banner, full_types, minimize_command, |
|
165 tstplike_proof, axiom_names, goal, i) = |
|
166 let |
|
167 val (chained_lemmas, other_lemmas) = |
|
168 used_facts axiom_names tstplike_proof |
|
169 val n = Logic.count_prems (prop_of goal) |
|
170 in |
|
171 (metis_line banner full_types i n (map fst other_lemmas) ^ |
|
172 minimize_line minimize_command (map fst (other_lemmas @ chained_lemmas)), |
|
173 other_lemmas @ chained_lemmas) |
|
174 end |
|
175 |
|
176 |
|
177 (** Hard-core proof reconstruction: structured Isar proofs **) |
|
178 |
|
179 (* Simple simplifications to ensure that sort annotations don't leave a trail of |
|
180 spurious "True"s. *) |
|
181 fun s_not @{const False} = @{const True} |
|
182 | s_not @{const True} = @{const False} |
|
183 | s_not (@{const Not} $ t) = t |
|
184 | s_not t = @{const Not} $ t |
|
185 fun s_conj (@{const True}, t2) = t2 |
|
186 | s_conj (t1, @{const True}) = t1 |
|
187 | s_conj p = HOLogic.mk_conj p |
|
188 fun s_disj (@{const False}, t2) = t2 |
|
189 | s_disj (t1, @{const False}) = t1 |
|
190 | s_disj p = HOLogic.mk_disj p |
|
191 fun s_imp (@{const True}, t2) = t2 |
|
192 | s_imp (t1, @{const False}) = s_not t1 |
|
193 | s_imp p = HOLogic.mk_imp p |
|
194 fun s_iff (@{const True}, t2) = t2 |
|
195 | s_iff (t1, @{const True}) = t1 |
|
196 | s_iff (t1, t2) = HOLogic.eq_const HOLogic.boolT $ t1 $ t2 |
|
197 |
|
198 fun forall_of v t = HOLogic.all_const (fastype_of v) $ lambda v t |
|
199 fun exists_of v t = HOLogic.exists_const (fastype_of v) $ lambda v t |
|
200 |
|
201 fun negate_term (Const (@{const_name All}, T) $ Abs (s, T', t')) = |
|
202 Const (@{const_name Ex}, T) $ Abs (s, T', negate_term t') |
|
203 | negate_term (Const (@{const_name Ex}, T) $ Abs (s, T', t')) = |
|
204 Const (@{const_name All}, T) $ Abs (s, T', negate_term t') |
|
205 | negate_term (@{const HOL.implies} $ t1 $ t2) = |
|
206 @{const HOL.conj} $ t1 $ negate_term t2 |
|
207 | negate_term (@{const HOL.conj} $ t1 $ t2) = |
|
208 @{const HOL.disj} $ negate_term t1 $ negate_term t2 |
|
209 | negate_term (@{const HOL.disj} $ t1 $ t2) = |
|
210 @{const HOL.conj} $ negate_term t1 $ negate_term t2 |
|
211 | negate_term (@{const Not} $ t) = t |
|
212 | negate_term t = @{const Not} $ t |
|
213 |
|
214 val indent_size = 2 |
|
215 val no_label = ("", ~1) |
|
216 |
|
217 val raw_prefix = "X" |
|
218 val assum_prefix = "A" |
|
219 val fact_prefix = "F" |
|
220 |
|
221 fun resolve_conjecture conjecture_shape (num, s_opt) = |
|
222 let |
|
223 val k = case try (unprefix conjecture_prefix) (the_default "" s_opt) of |
|
224 SOME s => Int.fromString s |> the_default ~1 |
|
225 | NONE => case Int.fromString num of |
|
226 SOME j => find_index (exists (curry (op =) j)) |
|
227 conjecture_shape |
|
228 | NONE => ~1 |
|
229 in if k >= 0 then [k] else [] end |
|
230 |
|
231 fun is_axiom conjecture_shape = not o null o resolve_axiom conjecture_shape |
|
232 fun is_conjecture conjecture_shape = not o null o resolve_conjecture conjecture_shape |
|
233 |
|
234 fun raw_label_for_name conjecture_shape name = |
|
235 case resolve_conjecture conjecture_shape name of |
|
236 [j] => (conjecture_prefix, j) |
|
237 | _ => case Int.fromString (fst name) of |
|
238 SOME j => (raw_prefix, j) |
|
239 | NONE => (raw_prefix ^ fst name, 0) |
|
240 |
|
241 (**** INTERPRETATION OF TSTP SYNTAX TREES ****) |
|
242 |
|
243 exception FO_TERM of string fo_term list |
|
244 exception FORMULA of (string, string fo_term) formula list |
|
245 exception SAME of unit |
|
246 |
|
247 (* Type variables are given the basic sort "HOL.type". Some will later be |
|
248 constrained by information from type literals, or by type inference. *) |
|
249 fun type_from_fo_term tfrees (u as ATerm (a, us)) = |
|
250 let val Ts = map (type_from_fo_term tfrees) us in |
|
251 case strip_prefix_and_unascii type_const_prefix a of |
|
252 SOME b => Type (invert_const b, Ts) |
|
253 | NONE => |
|
254 if not (null us) then |
|
255 raise FO_TERM [u] (* only "tconst"s have type arguments *) |
|
256 else case strip_prefix_and_unascii tfree_prefix a of |
|
257 SOME b => |
|
258 let val s = "'" ^ b in |
|
259 TFree (s, AList.lookup (op =) tfrees s |> the_default HOLogic.typeS) |
|
260 end |
|
261 | NONE => |
|
262 case strip_prefix_and_unascii tvar_prefix a of |
|
263 SOME b => TVar (("'" ^ b, 0), HOLogic.typeS) |
|
264 | NONE => |
|
265 (* Variable from the ATP, say "X1" *) |
|
266 Type_Infer.param 0 (a, HOLogic.typeS) |
|
267 end |
|
268 |
|
269 (* Type class literal applied to a type. Returns triple of polarity, class, |
|
270 type. *) |
|
271 fun type_constraint_from_term pos tfrees (u as ATerm (a, us)) = |
|
272 case (strip_prefix_and_unascii class_prefix a, |
|
273 map (type_from_fo_term tfrees) us) of |
|
274 (SOME b, [T]) => (pos, b, T) |
|
275 | _ => raise FO_TERM [u] |
|
276 |
|
277 (** Accumulate type constraints in a formula: negative type literals **) |
|
278 fun add_var (key, z) = Vartab.map_default (key, []) (cons z) |
|
279 fun add_type_constraint (false, cl, TFree (a ,_)) = add_var ((a, ~1), cl) |
|
280 | add_type_constraint (false, cl, TVar (ix, _)) = add_var (ix, cl) |
|
281 | add_type_constraint _ = I |
|
282 |
|
283 fun repair_atp_variable_name f s = |
|
284 let |
|
285 fun subscript_name s n = s ^ nat_subscript n |
|
286 val s = String.map f s |
|
287 in |
|
288 case space_explode "_" s of |
|
289 [_] => (case take_suffix Char.isDigit (String.explode s) of |
|
290 (cs1 as _ :: _, cs2 as _ :: _) => |
|
291 subscript_name (String.implode cs1) |
|
292 (the (Int.fromString (String.implode cs2))) |
|
293 | (_, _) => s) |
|
294 | [s1, s2] => (case Int.fromString s2 of |
|
295 SOME n => subscript_name s1 n |
|
296 | NONE => s) |
|
297 | _ => s |
|
298 end |
|
299 |
|
300 (* First-order translation. No types are known for variables. "HOLogic.typeT" |
|
301 should allow them to be inferred. *) |
|
302 fun raw_term_from_pred thy full_types tfrees = |
|
303 let |
|
304 fun aux opt_T extra_us u = |
|
305 case u of |
|
306 ATerm ("hBOOL", [u1]) => aux (SOME @{typ bool}) [] u1 |
|
307 | ATerm ("hAPP", [u1, u2]) => aux opt_T (u2 :: extra_us) u1 |
|
308 | ATerm (a, us) => |
|
309 if a = type_wrapper_name then |
|
310 case us of |
|
311 [typ_u, term_u] => |
|
312 aux (SOME (type_from_fo_term tfrees typ_u)) extra_us term_u |
|
313 | _ => raise FO_TERM us |
|
314 else case strip_prefix_and_unascii const_prefix a of |
|
315 SOME "equal" => |
|
316 let val ts = map (aux NONE []) us in |
|
317 if length ts = 2 andalso hd ts aconv List.last ts then |
|
318 (* Vampire is keen on producing these. *) |
|
319 @{const True} |
|
320 else |
|
321 list_comb (Const (@{const_name HOL.eq}, HOLogic.typeT), ts) |
|
322 end |
|
323 | SOME b => |
|
324 let |
|
325 val c = invert_const b |
|
326 val num_type_args = num_type_args thy c |
|
327 val (type_us, term_us) = |
|
328 chop (if full_types then 0 else num_type_args) us |
|
329 (* Extra args from "hAPP" come after any arguments given directly to |
|
330 the constant. *) |
|
331 val term_ts = map (aux NONE []) term_us |
|
332 val extra_ts = map (aux NONE []) extra_us |
|
333 val t = |
|
334 Const (c, if full_types then |
|
335 case opt_T of |
|
336 SOME T => map fastype_of term_ts ---> T |
|
337 | NONE => |
|
338 if num_type_args = 0 then |
|
339 Sign.const_instance thy (c, []) |
|
340 else |
|
341 raise Fail ("no type information for " ^ quote c) |
|
342 else |
|
343 Sign.const_instance thy (c, |
|
344 map (type_from_fo_term tfrees) type_us)) |
|
345 in list_comb (t, term_ts @ extra_ts) end |
|
346 | NONE => (* a free or schematic variable *) |
|
347 let |
|
348 val ts = map (aux NONE []) (us @ extra_us) |
|
349 val T = map fastype_of ts ---> HOLogic.typeT |
|
350 val t = |
|
351 case strip_prefix_and_unascii fixed_var_prefix a of |
|
352 SOME b => Free (b, T) |
|
353 | NONE => |
|
354 case strip_prefix_and_unascii schematic_var_prefix a of |
|
355 SOME b => Var ((b, 0), T) |
|
356 | NONE => |
|
357 if is_atp_variable a then |
|
358 Var ((repair_atp_variable_name Char.toLower a, 0), T) |
|
359 else |
|
360 (* Skolem constants? *) |
|
361 Var ((repair_atp_variable_name Char.toUpper a, 0), T) |
|
362 in list_comb (t, ts) end |
|
363 in aux (SOME HOLogic.boolT) [] end |
|
364 |
|
365 fun term_from_pred thy full_types tfrees pos (u as ATerm (s, _)) = |
|
366 if String.isPrefix class_prefix s then |
|
367 add_type_constraint (type_constraint_from_term pos tfrees u) |
|
368 #> pair @{const True} |
|
369 else |
|
370 pair (raw_term_from_pred thy full_types tfrees u) |
|
371 |
|
372 val combinator_table = |
|
373 [(@{const_name Meson.COMBI}, @{thm Meson.COMBI_def_raw}), |
|
374 (@{const_name Meson.COMBK}, @{thm Meson.COMBK_def_raw}), |
|
375 (@{const_name Meson.COMBB}, @{thm Meson.COMBB_def_raw}), |
|
376 (@{const_name Meson.COMBC}, @{thm Meson.COMBC_def_raw}), |
|
377 (@{const_name Meson.COMBS}, @{thm Meson.COMBS_def_raw})] |
|
378 |
|
379 fun uncombine_term (t1 $ t2) = betapply (pairself uncombine_term (t1, t2)) |
|
380 | uncombine_term (Abs (s, T, t')) = Abs (s, T, uncombine_term t') |
|
381 | uncombine_term (t as Const (x as (s, _))) = |
|
382 (case AList.lookup (op =) combinator_table s of |
|
383 SOME thm => thm |> prop_of |> specialize_type @{theory} x |> Logic.dest_equals |> snd |
|
384 | NONE => t) |
|
385 | uncombine_term t = t |
|
386 |
|
387 (* Update schematic type variables with detected sort constraints. It's not |
|
388 totally clear when this code is necessary. *) |
|
389 fun repair_tvar_sorts (t, tvar_tab) = |
|
390 let |
|
391 fun do_type (Type (a, Ts)) = Type (a, map do_type Ts) |
|
392 | do_type (TVar (xi, s)) = |
|
393 TVar (xi, the_default s (Vartab.lookup tvar_tab xi)) |
|
394 | do_type (TFree z) = TFree z |
|
395 fun do_term (Const (a, T)) = Const (a, do_type T) |
|
396 | do_term (Free (a, T)) = Free (a, do_type T) |
|
397 | do_term (Var (xi, T)) = Var (xi, do_type T) |
|
398 | do_term (t as Bound _) = t |
|
399 | do_term (Abs (a, T, t)) = Abs (a, do_type T, do_term t) |
|
400 | do_term (t1 $ t2) = do_term t1 $ do_term t2 |
|
401 in t |> not (Vartab.is_empty tvar_tab) ? do_term end |
|
402 |
|
403 fun quantify_over_var quant_of var_s t = |
|
404 let |
|
405 val vars = [] |> Term.add_vars t |> filter (fn ((s, _), _) => s = var_s) |
|
406 |> map Var |
|
407 in fold_rev quant_of vars t end |
|
408 |
|
409 (* Interpret an ATP formula as a HOL term, extracting sort constraints as they |
|
410 appear in the formula. *) |
|
411 fun prop_from_formula thy full_types tfrees phi = |
|
412 let |
|
413 fun do_formula pos phi = |
|
414 case phi of |
|
415 AQuant (_, [], phi) => do_formula pos phi |
|
416 | AQuant (q, x :: xs, phi') => |
|
417 do_formula pos (AQuant (q, xs, phi')) |
|
418 #>> quantify_over_var (case q of |
|
419 AForall => forall_of |
|
420 | AExists => exists_of) |
|
421 (repair_atp_variable_name Char.toLower x) |
|
422 | AConn (ANot, [phi']) => do_formula (not pos) phi' #>> s_not |
|
423 | AConn (c, [phi1, phi2]) => |
|
424 do_formula (pos |> c = AImplies ? not) phi1 |
|
425 ##>> do_formula pos phi2 |
|
426 #>> (case c of |
|
427 AAnd => s_conj |
|
428 | AOr => s_disj |
|
429 | AImplies => s_imp |
|
430 | AIf => s_imp o swap |
|
431 | AIff => s_iff |
|
432 | ANotIff => s_not o s_iff) |
|
433 | AAtom tm => term_from_pred thy full_types tfrees pos tm |
|
434 | _ => raise FORMULA [phi] |
|
435 in repair_tvar_sorts (do_formula true phi Vartab.empty) end |
|
436 |
|
437 fun check_formula ctxt = |
|
438 Type.constraint HOLogic.boolT |
|
439 #> Syntax.check_term (ProofContext.set_mode ProofContext.mode_schematic ctxt) |
|
440 |
|
441 |
|
442 (**** Translation of TSTP files to Isar Proofs ****) |
|
443 |
|
444 fun unvarify_term (Var ((s, 0), T)) = Free (s, T) |
|
445 | unvarify_term t = raise TERM ("unvarify_term: non-Var", [t]) |
|
446 |
|
447 fun decode_line full_types tfrees (Definition (name, phi1, phi2)) ctxt = |
|
448 let |
|
449 val thy = ProofContext.theory_of ctxt |
|
450 val t1 = prop_from_formula thy full_types tfrees phi1 |
|
451 val vars = snd (strip_comb t1) |
|
452 val frees = map unvarify_term vars |
|
453 val unvarify_args = subst_atomic (vars ~~ frees) |
|
454 val t2 = prop_from_formula thy full_types tfrees phi2 |
|
455 val (t1, t2) = |
|
456 HOLogic.eq_const HOLogic.typeT $ t1 $ t2 |
|
457 |> unvarify_args |> uncombine_term |> check_formula ctxt |
|
458 |> HOLogic.dest_eq |
|
459 in |
|
460 (Definition (name, t1, t2), |
|
461 fold Variable.declare_term (maps OldTerm.term_frees [t1, t2]) ctxt) |
|
462 end |
|
463 | decode_line full_types tfrees (Inference (name, u, deps)) ctxt = |
|
464 let |
|
465 val thy = ProofContext.theory_of ctxt |
|
466 val t = u |> prop_from_formula thy full_types tfrees |
|
467 |> uncombine_term |> check_formula ctxt |
|
468 in |
|
469 (Inference (name, t, deps), |
|
470 fold Variable.declare_term (OldTerm.term_frees t) ctxt) |
|
471 end |
|
472 fun decode_lines ctxt full_types tfrees lines = |
|
473 fst (fold_map (decode_line full_types tfrees) lines ctxt) |
|
474 |
|
475 fun is_same_inference _ (Definition _) = false |
|
476 | is_same_inference t (Inference (_, t', _)) = t aconv t' |
|
477 |
|
478 (* No "real" literals means only type information (tfree_tcs, clsrel, or |
|
479 clsarity). *) |
|
480 val is_only_type_information = curry (op aconv) HOLogic.true_const |
|
481 |
|
482 fun replace_one_dependency (old, new) dep = |
|
483 if is_same_step (dep, old) then new else [dep] |
|
484 fun replace_dependencies_in_line _ (line as Definition _) = line |
|
485 | replace_dependencies_in_line p (Inference (name, t, deps)) = |
|
486 Inference (name, t, fold (union (op =) o replace_one_dependency p) deps []) |
|
487 |
|
488 (* Discard axioms; consolidate adjacent lines that prove the same formula, since |
|
489 they differ only in type information.*) |
|
490 fun add_line _ _ (line as Definition _) lines = line :: lines |
|
491 | add_line conjecture_shape axiom_names (Inference (name, t, [])) lines = |
|
492 (* No dependencies: axiom, conjecture, or (for Vampire) internal axioms or |
|
493 definitions. *) |
|
494 if is_axiom axiom_names name then |
|
495 (* Axioms are not proof lines. *) |
|
496 if is_only_type_information t then |
|
497 map (replace_dependencies_in_line (name, [])) lines |
|
498 (* Is there a repetition? If so, replace later line by earlier one. *) |
|
499 else case take_prefix (not o is_same_inference t) lines of |
|
500 (_, []) => lines (* no repetition of proof line *) |
|
501 | (pre, Inference (name', _, _) :: post) => |
|
502 pre @ map (replace_dependencies_in_line (name', [name])) post |
|
503 else if is_conjecture conjecture_shape name then |
|
504 Inference (name, negate_term t, []) :: lines |
|
505 else |
|
506 map (replace_dependencies_in_line (name, [])) lines |
|
507 | add_line _ _ (Inference (name, t, deps)) lines = |
|
508 (* Type information will be deleted later; skip repetition test. *) |
|
509 if is_only_type_information t then |
|
510 Inference (name, t, deps) :: lines |
|
511 (* Is there a repetition? If so, replace later line by earlier one. *) |
|
512 else case take_prefix (not o is_same_inference t) lines of |
|
513 (* FIXME: Doesn't this code risk conflating proofs involving different |
|
514 types? *) |
|
515 (_, []) => Inference (name, t, deps) :: lines |
|
516 | (pre, Inference (name', t', _) :: post) => |
|
517 Inference (name, t', deps) :: |
|
518 pre @ map (replace_dependencies_in_line (name', [name])) post |
|
519 |
|
520 (* Recursively delete empty lines (type information) from the proof. *) |
|
521 fun add_nontrivial_line (Inference (name, t, [])) lines = |
|
522 if is_only_type_information t then delete_dependency name lines |
|
523 else Inference (name, t, []) :: lines |
|
524 | add_nontrivial_line line lines = line :: lines |
|
525 and delete_dependency name lines = |
|
526 fold_rev add_nontrivial_line |
|
527 (map (replace_dependencies_in_line (name, [])) lines) [] |
|
528 |
|
529 (* ATPs sometimes reuse free variable names in the strangest ways. Removing |
|
530 offending lines often does the trick. *) |
|
531 fun is_bad_free frees (Free x) = not (member (op =) frees x) |
|
532 | is_bad_free _ _ = false |
|
533 |
|
534 fun add_desired_line _ _ _ _ (line as Definition (name, _, _)) (j, lines) = |
|
535 (j, line :: map (replace_dependencies_in_line (name, [])) lines) |
|
536 | add_desired_line isar_shrink_factor conjecture_shape axiom_names frees |
|
537 (Inference (name, t, deps)) (j, lines) = |
|
538 (j + 1, |
|
539 if is_axiom axiom_names name orelse |
|
540 is_conjecture conjecture_shape name orelse |
|
541 (* the last line must be kept *) |
|
542 j = 0 orelse |
|
543 (not (is_only_type_information t) andalso |
|
544 null (Term.add_tvars t []) andalso |
|
545 not (exists_subterm (is_bad_free frees) t) andalso |
|
546 length deps >= 2 andalso j mod isar_shrink_factor = 0 andalso |
|
547 (* kill next to last line, which usually results in a trivial step *) |
|
548 j <> 1) then |
|
549 Inference (name, t, deps) :: lines (* keep line *) |
|
550 else |
|
551 map (replace_dependencies_in_line (name, deps)) lines) (* drop line *) |
|
552 |
|
553 (** Isar proof construction and manipulation **) |
|
554 |
|
555 fun merge_fact_sets (ls1, ss1) (ls2, ss2) = |
|
556 (union (op =) ls1 ls2, union (op =) ss1 ss2) |
|
557 |
|
558 type label = string * int |
|
559 type facts = label list * string list |
|
560 |
|
561 datatype isar_qualifier = Show | Then | Moreover | Ultimately |
|
562 |
|
563 datatype isar_step = |
|
564 Fix of (string * typ) list | |
|
565 Let of term * term | |
|
566 Assume of label * term | |
|
567 Have of isar_qualifier list * label * term * byline |
|
568 and byline = |
|
569 ByMetis of facts | |
|
570 CaseSplit of isar_step list list * facts |
|
571 |
|
572 fun smart_case_split [] facts = ByMetis facts |
|
573 | smart_case_split proofs facts = CaseSplit (proofs, facts) |
|
574 |
|
575 fun add_fact_from_dependency conjecture_shape axiom_names name = |
|
576 if is_axiom axiom_names name then |
|
577 apsnd (union (op =) (map fst (resolve_axiom axiom_names name))) |
|
578 else |
|
579 apfst (insert (op =) (raw_label_for_name conjecture_shape name)) |
|
580 |
|
581 fun step_for_line _ _ _ (Definition (_, t1, t2)) = Let (t1, t2) |
|
582 | step_for_line conjecture_shape _ _ (Inference (name, t, [])) = |
|
583 Assume (raw_label_for_name conjecture_shape name, t) |
|
584 | step_for_line conjecture_shape axiom_names j (Inference (name, t, deps)) = |
|
585 Have (if j = 1 then [Show] else [], |
|
586 raw_label_for_name conjecture_shape name, |
|
587 fold_rev forall_of (map Var (Term.add_vars t [])) t, |
|
588 ByMetis (fold (add_fact_from_dependency conjecture_shape axiom_names) |
|
589 deps ([], []))) |
|
590 |
|
591 fun repair_name "$true" = "c_True" |
|
592 | repair_name "$false" = "c_False" |
|
593 | repair_name "$$e" = "c_equal" (* seen in Vampire proofs *) |
|
594 | repair_name "equal" = "c_equal" (* needed by SPASS? *) |
|
595 | repair_name s = |
|
596 if String.isPrefix "sQ" s andalso String.isSuffix "_eqProxy" s then |
|
597 "c_equal" (* seen in Vampire proofs *) |
|
598 else |
|
599 s |
|
600 |
|
601 fun isar_proof_from_tstplike_proof pool ctxt full_types tfrees isar_shrink_factor |
|
602 tstplike_proof conjecture_shape axiom_names params frees = |
|
603 let |
|
604 val lines = |
|
605 tstplike_proof |
|
606 |> atp_proof_from_tstplike_string |
|
607 |> nasty_atp_proof pool |
|
608 |> map_term_names_in_atp_proof repair_name |
|
609 |> decode_lines ctxt full_types tfrees |
|
610 |> rpair [] |-> fold_rev (add_line conjecture_shape axiom_names) |
|
611 |> rpair [] |-> fold_rev add_nontrivial_line |
|
612 |> rpair (0, []) |-> fold_rev (add_desired_line isar_shrink_factor |
|
613 conjecture_shape axiom_names frees) |
|
614 |> snd |
|
615 in |
|
616 (if null params then [] else [Fix params]) @ |
|
617 map2 (step_for_line conjecture_shape axiom_names) (length lines downto 1) |
|
618 lines |
|
619 end |
|
620 |
|
621 (* When redirecting proofs, we keep information about the labels seen so far in |
|
622 the "backpatches" data structure. The first component indicates which facts |
|
623 should be associated with forthcoming proof steps. The second component is a |
|
624 pair ("assum_ls", "drop_ls"), where "assum_ls" are the labels that should |
|
625 become assumptions and "drop_ls" are the labels that should be dropped in a |
|
626 case split. *) |
|
627 type backpatches = (label * facts) list * (label list * label list) |
|
628 |
|
629 fun used_labels_of_step (Have (_, _, _, by)) = |
|
630 (case by of |
|
631 ByMetis (ls, _) => ls |
|
632 | CaseSplit (proofs, (ls, _)) => |
|
633 fold (union (op =) o used_labels_of) proofs ls) |
|
634 | used_labels_of_step _ = [] |
|
635 and used_labels_of proof = fold (union (op =) o used_labels_of_step) proof [] |
|
636 |
|
637 fun new_labels_of_step (Fix _) = [] |
|
638 | new_labels_of_step (Let _) = [] |
|
639 | new_labels_of_step (Assume (l, _)) = [l] |
|
640 | new_labels_of_step (Have (_, l, _, _)) = [l] |
|
641 val new_labels_of = maps new_labels_of_step |
|
642 |
|
643 val join_proofs = |
|
644 let |
|
645 fun aux _ [] = NONE |
|
646 | aux proof_tail (proofs as (proof1 :: _)) = |
|
647 if exists null proofs then |
|
648 NONE |
|
649 else if forall (curry (op =) (hd proof1) o hd) (tl proofs) then |
|
650 aux (hd proof1 :: proof_tail) (map tl proofs) |
|
651 else case hd proof1 of |
|
652 Have ([], l, t, _) => (* FIXME: should we really ignore the "by"? *) |
|
653 if forall (fn Have ([], l', t', _) :: _ => (l, t) = (l', t') |
|
654 | _ => false) (tl proofs) andalso |
|
655 not (exists (member (op =) (maps new_labels_of proofs)) |
|
656 (used_labels_of proof_tail)) then |
|
657 SOME (l, t, map rev proofs, proof_tail) |
|
658 else |
|
659 NONE |
|
660 | _ => NONE |
|
661 in aux [] o map rev end |
|
662 |
|
663 fun case_split_qualifiers proofs = |
|
664 case length proofs of |
|
665 0 => [] |
|
666 | 1 => [Then] |
|
667 | _ => [Ultimately] |
|
668 |
|
669 fun redirect_proof hyp_ts concl_t proof = |
|
670 let |
|
671 (* The first pass outputs those steps that are independent of the negated |
|
672 conjecture. The second pass flips the proof by contradiction to obtain a |
|
673 direct proof, introducing case splits when an inference depends on |
|
674 several facts that depend on the negated conjecture. *) |
|
675 val concl_l = (conjecture_prefix, length hyp_ts) |
|
676 fun first_pass ([], contra) = ([], contra) |
|
677 | first_pass ((step as Fix _) :: proof, contra) = |
|
678 first_pass (proof, contra) |>> cons step |
|
679 | first_pass ((step as Let _) :: proof, contra) = |
|
680 first_pass (proof, contra) |>> cons step |
|
681 | first_pass ((step as Assume (l as (_, j), _)) :: proof, contra) = |
|
682 if l = concl_l then first_pass (proof, contra ||> cons step) |
|
683 else first_pass (proof, contra) |>> cons (Assume (l, nth hyp_ts j)) |
|
684 | first_pass (Have (qs, l, t, ByMetis (ls, ss)) :: proof, contra) = |
|
685 let val step = Have (qs, l, t, ByMetis (ls, ss)) in |
|
686 if exists (member (op =) (fst contra)) ls then |
|
687 first_pass (proof, contra |>> cons l ||> cons step) |
|
688 else |
|
689 first_pass (proof, contra) |>> cons step |
|
690 end |
|
691 | first_pass _ = raise Fail "malformed proof" |
|
692 val (proof_top, (contra_ls, contra_proof)) = |
|
693 first_pass (proof, ([concl_l], [])) |
|
694 val backpatch_label = the_default ([], []) oo AList.lookup (op =) o fst |
|
695 fun backpatch_labels patches ls = |
|
696 fold merge_fact_sets (map (backpatch_label patches) ls) ([], []) |
|
697 fun second_pass end_qs ([], assums, patches) = |
|
698 ([Have (end_qs, no_label, concl_t, |
|
699 ByMetis (backpatch_labels patches (map snd assums)))], patches) |
|
700 | second_pass end_qs (Assume (l, t) :: proof, assums, patches) = |
|
701 second_pass end_qs (proof, (t, l) :: assums, patches) |
|
702 | second_pass end_qs (Have (qs, l, t, ByMetis (ls, ss)) :: proof, assums, |
|
703 patches) = |
|
704 (if member (op =) (snd (snd patches)) l andalso |
|
705 not (member (op =) (fst (snd patches)) l) andalso |
|
706 not (AList.defined (op =) (fst patches) l) then |
|
707 second_pass end_qs (proof, assums, patches ||> apsnd (append ls)) |
|
708 else case List.partition (member (op =) contra_ls) ls of |
|
709 ([contra_l], co_ls) => |
|
710 if member (op =) qs Show then |
|
711 second_pass end_qs (proof, assums, |
|
712 patches |>> cons (contra_l, (co_ls, ss))) |
|
713 else |
|
714 second_pass end_qs |
|
715 (proof, assums, |
|
716 patches |>> cons (contra_l, (l :: co_ls, ss))) |
|
717 |>> cons (if member (op =) (fst (snd patches)) l then |
|
718 Assume (l, negate_term t) |
|
719 else |
|
720 Have (qs, l, negate_term t, |
|
721 ByMetis (backpatch_label patches l))) |
|
722 | (contra_ls as _ :: _, co_ls) => |
|
723 let |
|
724 val proofs = |
|
725 map_filter |
|
726 (fn l => |
|
727 if l = concl_l then |
|
728 NONE |
|
729 else |
|
730 let |
|
731 val drop_ls = filter (curry (op <>) l) contra_ls |
|
732 in |
|
733 second_pass [] |
|
734 (proof, assums, |
|
735 patches ||> apfst (insert (op =) l) |
|
736 ||> apsnd (union (op =) drop_ls)) |
|
737 |> fst |> SOME |
|
738 end) contra_ls |
|
739 val (assumes, facts) = |
|
740 if member (op =) (fst (snd patches)) l then |
|
741 ([Assume (l, negate_term t)], (l :: co_ls, ss)) |
|
742 else |
|
743 ([], (co_ls, ss)) |
|
744 in |
|
745 (case join_proofs proofs of |
|
746 SOME (l, t, proofs, proof_tail) => |
|
747 Have (case_split_qualifiers proofs @ |
|
748 (if null proof_tail then end_qs else []), l, t, |
|
749 smart_case_split proofs facts) :: proof_tail |
|
750 | NONE => |
|
751 [Have (case_split_qualifiers proofs @ end_qs, no_label, |
|
752 concl_t, smart_case_split proofs facts)], |
|
753 patches) |
|
754 |>> append assumes |
|
755 end |
|
756 | _ => raise Fail "malformed proof") |
|
757 | second_pass _ _ = raise Fail "malformed proof" |
|
758 val proof_bottom = |
|
759 second_pass [Show] (contra_proof, [], ([], ([], []))) |> fst |
|
760 in proof_top @ proof_bottom end |
|
761 |
|
762 (* FIXME: Still needed? Probably not. *) |
|
763 val kill_duplicate_assumptions_in_proof = |
|
764 let |
|
765 fun relabel_facts subst = |
|
766 apfst (map (fn l => AList.lookup (op =) subst l |> the_default l)) |
|
767 fun do_step (step as Assume (l, t)) (proof, subst, assums) = |
|
768 (case AList.lookup (op aconv) assums t of |
|
769 SOME l' => (proof, (l, l') :: subst, assums) |
|
770 | NONE => (step :: proof, subst, (t, l) :: assums)) |
|
771 | do_step (Have (qs, l, t, by)) (proof, subst, assums) = |
|
772 (Have (qs, l, t, |
|
773 case by of |
|
774 ByMetis facts => ByMetis (relabel_facts subst facts) |
|
775 | CaseSplit (proofs, facts) => |
|
776 CaseSplit (map do_proof proofs, relabel_facts subst facts)) :: |
|
777 proof, subst, assums) |
|
778 | do_step step (proof, subst, assums) = (step :: proof, subst, assums) |
|
779 and do_proof proof = fold do_step proof ([], [], []) |> #1 |> rev |
|
780 in do_proof end |
|
781 |
|
782 val then_chain_proof = |
|
783 let |
|
784 fun aux _ [] = [] |
|
785 | aux _ ((step as Assume (l, _)) :: proof) = step :: aux l proof |
|
786 | aux l' (Have (qs, l, t, by) :: proof) = |
|
787 (case by of |
|
788 ByMetis (ls, ss) => |
|
789 Have (if member (op =) ls l' then |
|
790 (Then :: qs, l, t, |
|
791 ByMetis (filter_out (curry (op =) l') ls, ss)) |
|
792 else |
|
793 (qs, l, t, ByMetis (ls, ss))) |
|
794 | CaseSplit (proofs, facts) => |
|
795 Have (qs, l, t, CaseSplit (map (aux no_label) proofs, facts))) :: |
|
796 aux l proof |
|
797 | aux _ (step :: proof) = step :: aux no_label proof |
|
798 in aux no_label end |
|
799 |
|
800 fun kill_useless_labels_in_proof proof = |
|
801 let |
|
802 val used_ls = used_labels_of proof |
|
803 fun do_label l = if member (op =) used_ls l then l else no_label |
|
804 fun do_step (Assume (l, t)) = Assume (do_label l, t) |
|
805 | do_step (Have (qs, l, t, by)) = |
|
806 Have (qs, do_label l, t, |
|
807 case by of |
|
808 CaseSplit (proofs, facts) => |
|
809 CaseSplit (map (map do_step) proofs, facts) |
|
810 | _ => by) |
|
811 | do_step step = step |
|
812 in map do_step proof end |
|
813 |
|
814 fun prefix_for_depth n = replicate_string (n + 1) |
|
815 |
|
816 val relabel_proof = |
|
817 let |
|
818 fun aux _ _ _ [] = [] |
|
819 | aux subst depth (next_assum, next_fact) (Assume (l, t) :: proof) = |
|
820 if l = no_label then |
|
821 Assume (l, t) :: aux subst depth (next_assum, next_fact) proof |
|
822 else |
|
823 let val l' = (prefix_for_depth depth assum_prefix, next_assum) in |
|
824 Assume (l', t) :: |
|
825 aux ((l, l') :: subst) depth (next_assum + 1, next_fact) proof |
|
826 end |
|
827 | aux subst depth (next_assum, next_fact) (Have (qs, l, t, by) :: proof) = |
|
828 let |
|
829 val (l', subst, next_fact) = |
|
830 if l = no_label then |
|
831 (l, subst, next_fact) |
|
832 else |
|
833 let |
|
834 val l' = (prefix_for_depth depth fact_prefix, next_fact) |
|
835 in (l', (l, l') :: subst, next_fact + 1) end |
|
836 val relabel_facts = |
|
837 apfst (maps (the_list o AList.lookup (op =) subst)) |
|
838 val by = |
|
839 case by of |
|
840 ByMetis facts => ByMetis (relabel_facts facts) |
|
841 | CaseSplit (proofs, facts) => |
|
842 CaseSplit (map (aux subst (depth + 1) (1, 1)) proofs, |
|
843 relabel_facts facts) |
|
844 in |
|
845 Have (qs, l', t, by) :: |
|
846 aux subst depth (next_assum, next_fact) proof |
|
847 end |
|
848 | aux subst depth nextp (step :: proof) = |
|
849 step :: aux subst depth nextp proof |
|
850 in aux [] 0 (1, 1) end |
|
851 |
|
852 fun string_for_proof ctxt0 full_types i n = |
|
853 let |
|
854 val ctxt = ctxt0 |
|
855 |> Config.put show_free_types false |
|
856 |> Config.put show_types true |
|
857 fun fix_print_mode f x = |
|
858 Print_Mode.setmp (filter (curry (op =) Symbol.xsymbolsN) |
|
859 (print_mode_value ())) f x |
|
860 fun do_indent ind = replicate_string (ind * indent_size) " " |
|
861 fun do_free (s, T) = |
|
862 maybe_quote s ^ " :: " ^ |
|
863 maybe_quote (fix_print_mode (Syntax.string_of_typ ctxt) T) |
|
864 fun do_label l = if l = no_label then "" else string_for_label l ^ ": " |
|
865 fun do_have qs = |
|
866 (if member (op =) qs Moreover then "moreover " else "") ^ |
|
867 (if member (op =) qs Ultimately then "ultimately " else "") ^ |
|
868 (if member (op =) qs Then then |
|
869 if member (op =) qs Show then "thus" else "hence" |
|
870 else |
|
871 if member (op =) qs Show then "show" else "have") |
|
872 val do_term = maybe_quote o fix_print_mode (Syntax.string_of_term ctxt) |
|
873 fun do_facts (ls, ss) = |
|
874 metis_command full_types 1 1 |
|
875 (ls |> sort_distinct (prod_ord string_ord int_ord), |
|
876 ss |> sort_distinct string_ord) |
|
877 and do_step ind (Fix xs) = |
|
878 do_indent ind ^ "fix " ^ space_implode " and " (map do_free xs) ^ "\n" |
|
879 | do_step ind (Let (t1, t2)) = |
|
880 do_indent ind ^ "let " ^ do_term t1 ^ " = " ^ do_term t2 ^ "\n" |
|
881 | do_step ind (Assume (l, t)) = |
|
882 do_indent ind ^ "assume " ^ do_label l ^ do_term t ^ "\n" |
|
883 | do_step ind (Have (qs, l, t, ByMetis facts)) = |
|
884 do_indent ind ^ do_have qs ^ " " ^ |
|
885 do_label l ^ do_term t ^ " " ^ do_facts facts ^ "\n" |
|
886 | do_step ind (Have (qs, l, t, CaseSplit (proofs, facts))) = |
|
887 space_implode (do_indent ind ^ "moreover\n") |
|
888 (map (do_block ind) proofs) ^ |
|
889 do_indent ind ^ do_have qs ^ " " ^ do_label l ^ do_term t ^ " " ^ |
|
890 do_facts facts ^ "\n" |
|
891 and do_steps prefix suffix ind steps = |
|
892 let val s = implode (map (do_step ind) steps) in |
|
893 replicate_string (ind * indent_size - size prefix) " " ^ prefix ^ |
|
894 String.extract (s, ind * indent_size, |
|
895 SOME (size s - ind * indent_size - 1)) ^ |
|
896 suffix ^ "\n" |
|
897 end |
|
898 and do_block ind proof = do_steps "{ " " }" (ind + 1) proof |
|
899 (* One-step proofs are pointless; better use the Metis one-liner |
|
900 directly. *) |
|
901 and do_proof [Have (_, _, _, ByMetis _)] = "" |
|
902 | do_proof proof = |
|
903 (if i <> 1 then "prefer " ^ string_of_int i ^ "\n" else "") ^ |
|
904 do_indent 0 ^ "proof -\n" ^ do_steps "" "" 1 proof ^ do_indent 0 ^ |
|
905 (if n <> 1 then "next" else "qed") |
|
906 in do_proof end |
|
907 |
|
908 fun isar_proof_text (pool, debug, isar_shrink_factor, ctxt, conjecture_shape) |
|
909 (other_params as (_, full_types, _, tstplike_proof, |
|
910 axiom_names, goal, i)) = |
|
911 let |
|
912 val (params, hyp_ts, concl_t) = strip_subgoal goal i |
|
913 val frees = fold Term.add_frees (concl_t :: hyp_ts) [] |
|
914 val tfrees = fold Term.add_tfrees (concl_t :: hyp_ts) [] |
|
915 val n = Logic.count_prems (prop_of goal) |
|
916 val (one_line_proof, lemma_names) = metis_proof_text other_params |
|
917 fun isar_proof_for () = |
|
918 case isar_proof_from_tstplike_proof pool ctxt full_types tfrees |
|
919 isar_shrink_factor tstplike_proof conjecture_shape axiom_names |
|
920 params frees |
|
921 |> redirect_proof hyp_ts concl_t |
|
922 |> kill_duplicate_assumptions_in_proof |
|
923 |> then_chain_proof |
|
924 |> kill_useless_labels_in_proof |
|
925 |> relabel_proof |
|
926 |> string_for_proof ctxt full_types i n of |
|
927 "" => "\nNo structured proof available." |
|
928 | proof => "\n\nStructured proof:\n" ^ Markup.markup Markup.sendback proof |
|
929 val isar_proof = |
|
930 if debug then |
|
931 isar_proof_for () |
|
932 else |
|
933 try isar_proof_for () |
|
934 |> the_default "\nWarning: The Isar proof construction failed." |
|
935 in (one_line_proof ^ isar_proof, lemma_names) end |
|
936 |
|
937 fun proof_text isar_proof isar_params other_params = |
|
938 (if isar_proof then isar_proof_text isar_params else metis_proof_text) |
|
939 other_params |
|
940 |
|
941 end; |
|