author | blanchet |
Wed, 20 Feb 2013 08:44:24 +0100 | |
changeset 51192 | 4dc6bb65c3c3 |
parent 51190 | 2654b3965c8d |
child 51193 | 5aef949c24b7 |
permissions | -rw-r--r-- |
49883 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_reconstruct.ML |
2 |
Author: Jasmin Blanchette, TU Muenchen |
|
3 |
Author: Steffen Juilf Smolka, TU Muenchen |
|
4 |
||
49914 | 5 |
Isar proof reconstruction from ATP proofs. |
49883 | 6 |
*) |
7 |
||
8 |
signature SLEDGEHAMMER_PROOF_RECONSTRUCT = |
|
9 |
sig |
|
49914 | 10 |
type 'a proof = 'a ATP_Proof.proof |
11 |
type stature = ATP_Problem_Generate.stature |
|
12 |
||
13 |
datatype reconstructor = |
|
14 |
Metis of string * string | |
|
15 |
SMT |
|
16 |
||
17 |
datatype play = |
|
18 |
Played of reconstructor * Time.time | |
|
19 |
Trust_Playable of reconstructor * Time.time option | |
|
20 |
Failed_to_Play of reconstructor |
|
21 |
||
22 |
type minimize_command = string list -> string |
|
23 |
type one_line_params = |
|
24 |
play * string * (string * stature) list * minimize_command * int * int |
|
25 |
type isar_params = |
|
50557 | 26 |
bool * bool * Time.time option * real * string Symtab.table |
50004
c96e8e40d789
several improvements to Isar proof reconstruction, by Steffen Smolka (step merging in case splits, time measurements, etc.)
blanchet
parents:
49994
diff
changeset
|
27 |
* (string * stature) list vector * int Symtab.table * string proof * thm |
49914 | 28 |
|
29 |
val smtN : string |
|
30 |
val string_for_reconstructor : reconstructor -> string |
|
31 |
val lam_trans_from_atp_proof : string proof -> string -> string |
|
32 |
val is_typed_helper_used_in_atp_proof : string proof -> bool |
|
33 |
val used_facts_in_atp_proof : |
|
34 |
Proof.context -> (string * stature) list vector -> string proof -> |
|
35 |
(string * stature) list |
|
36 |
val used_facts_in_unsound_atp_proof : |
|
37 |
Proof.context -> (string * stature) list vector -> 'a proof -> |
|
38 |
string list option |
|
39 |
val one_line_proof_text : int -> one_line_params -> string |
|
49883 | 40 |
val isar_proof_text : |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
41 |
Proof.context -> bool option -> isar_params -> one_line_params -> string |
49883 | 42 |
val proof_text : |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
43 |
Proof.context -> bool option -> isar_params -> int -> one_line_params |
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
44 |
-> string |
49883 | 45 |
end; |
46 |
||
47 |
structure Sledgehammer_Reconstruct : SLEDGEHAMMER_PROOF_RECONSTRUCT = |
|
48 |
struct |
|
49 |
||
50 |
open ATP_Util |
|
49914 | 51 |
open ATP_Problem |
49883 | 52 |
open ATP_Proof |
53 |
open ATP_Problem_Generate |
|
54 |
open ATP_Proof_Reconstruct |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
55 |
open Sledgehammer_Util |
50264
a9ec48b98734
renamed sledgehammer_isar_reconstruct to sledgehammer_proof
smolkas
parents:
50262
diff
changeset
|
56 |
open Sledgehammer_Proof |
50258 | 57 |
open Sledgehammer_Annotate |
51130
76d68444cd59
renamed sledgehammer_shrink to sledgehammer_compress
smolkas
parents:
51129
diff
changeset
|
58 |
open Sledgehammer_Compress |
49914 | 59 |
|
60 |
structure String_Redirect = ATP_Proof_Redirect( |
|
61 |
type key = step_name |
|
62 |
val ord = fn ((s, _ : string list), (s', _)) => fast_string_ord (s, s') |
|
63 |
val string_of = fst) |
|
64 |
||
49883 | 65 |
open String_Redirect |
66 |
||
49916
412346127bfa
fixed theorem lookup code in Isar proof reconstruction
blanchet
parents:
49915
diff
changeset
|
67 |
|
49914 | 68 |
(** reconstructors **) |
69 |
||
70 |
datatype reconstructor = |
|
71 |
Metis of string * string | |
|
72 |
SMT |
|
73 |
||
74 |
datatype play = |
|
75 |
Played of reconstructor * Time.time | |
|
76 |
Trust_Playable of reconstructor * Time.time option | |
|
77 |
Failed_to_Play of reconstructor |
|
78 |
||
79 |
val smtN = "smt" |
|
80 |
||
81 |
fun string_for_reconstructor (Metis (type_enc, lam_trans)) = |
|
82 |
metis_call type_enc lam_trans |
|
83 |
| string_for_reconstructor SMT = smtN |
|
84 |
||
85 |
||
86 |
(** fact extraction from ATP proofs **) |
|
87 |
||
88 |
fun find_first_in_list_vector vec key = |
|
89 |
Vector.foldl (fn (ps, NONE) => AList.lookup (op =) ps key |
|
90 |
| (_, value) => value) NONE vec |
|
91 |
||
92 |
val unprefix_fact_number = space_implode "_" o tl o space_explode "_" |
|
93 |
||
94 |
fun resolve_one_named_fact fact_names s = |
|
95 |
case try (unprefix fact_prefix) s of |
|
96 |
SOME s' => |
|
97 |
let val s' = s' |> unprefix_fact_number |> unascii_of in |
|
98 |
s' |> find_first_in_list_vector fact_names |> Option.map (pair s') |
|
99 |
end |
|
100 |
| NONE => NONE |
|
101 |
fun resolve_fact fact_names = map_filter (resolve_one_named_fact fact_names) |
|
102 |
fun is_fact fact_names = not o null o resolve_fact fact_names |
|
103 |
||
104 |
fun resolve_one_named_conjecture s = |
|
105 |
case try (unprefix conjecture_prefix) s of |
|
106 |
SOME s' => Int.fromString s' |
|
107 |
| NONE => NONE |
|
108 |
||
109 |
val resolve_conjecture = map_filter resolve_one_named_conjecture |
|
110 |
val is_conjecture = not o null o resolve_conjecture |
|
111 |
||
112 |
val ascii_of_lam_fact_prefix = ascii_of lam_fact_prefix |
|
113 |
||
114 |
(* overapproximation (good enough) *) |
|
115 |
fun is_lam_lifted s = |
|
116 |
String.isPrefix fact_prefix s andalso |
|
117 |
String.isSubstring ascii_of_lam_fact_prefix s |
|
118 |
||
119 |
val is_combinator_def = String.isPrefix (helper_prefix ^ combinator_prefix) |
|
120 |
||
121 |
fun is_axiom_used_in_proof pred = |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
122 |
exists (fn Inference_Step ((_, ss), _, _, _, []) => exists pred ss |
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
123 |
| _ => false) |
49914 | 124 |
|
125 |
fun lam_trans_from_atp_proof atp_proof default = |
|
126 |
case (is_axiom_used_in_proof is_combinator_def atp_proof, |
|
127 |
is_axiom_used_in_proof is_lam_lifted atp_proof) of |
|
128 |
(false, false) => default |
|
129 |
| (false, true) => liftingN |
|
130 |
(* | (true, true) => combs_and_liftingN -- not supported by "metis" *) |
|
131 |
| (true, _) => combsN |
|
132 |
||
133 |
val is_typed_helper_name = |
|
134 |
String.isPrefix helper_prefix andf String.isSuffix typed_helper_suffix |
|
51031
63d71b247323
more robustness in Isar proof reconstruction (cf. bug report by Ondrej)
blanchet
parents:
51026
diff
changeset
|
135 |
|
49914 | 136 |
fun is_typed_helper_used_in_atp_proof atp_proof = |
137 |
is_axiom_used_in_proof is_typed_helper_name atp_proof |
|
138 |
||
139 |
fun add_non_rec_defs fact_names accum = |
|
140 |
Vector.foldl (fn (facts, facts') => |
|
141 |
union (op =) (filter (fn (_, (_, status)) => status = Non_Rec_Def) facts) |
|
142 |
facts') |
|
143 |
accum fact_names |
|
144 |
||
145 |
val isa_ext = Thm.get_name_hint @{thm ext} |
|
146 |
val isa_short_ext = Long_Name.base_name isa_ext |
|
147 |
||
148 |
fun ext_name ctxt = |
|
149 |
if Thm.eq_thm_prop (@{thm ext}, |
|
51026 | 150 |
singleton (Attrib.eval_thms ctxt) (Facts.named isa_short_ext, [])) then |
49914 | 151 |
isa_short_ext |
152 |
else |
|
153 |
isa_ext |
|
154 |
||
50675 | 155 |
val leo2_extcnf_equal_neg_rule = "extcnf_equal_neg" |
156 |
val leo2_unfold_def_rule = "unfold_def" |
|
49914 | 157 |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
158 |
fun add_fact ctxt fact_names (Inference_Step ((_, ss), _, _, rule, deps)) = |
50675 | 159 |
(if rule = leo2_extcnf_equal_neg_rule then |
49914 | 160 |
insert (op =) (ext_name ctxt, (Global, General)) |
50675 | 161 |
else if rule = leo2_unfold_def_rule then |
49914 | 162 |
(* LEO 1.3.3 does not record definitions properly, leading to missing |
51026 | 163 |
dependencies in the TSTP proof. Remove the next line once this is |
164 |
fixed. *) |
|
49914 | 165 |
add_non_rec_defs fact_names |
166 |
else if rule = satallax_coreN then |
|
167 |
(fn [] => |
|
168 |
(* Satallax doesn't include definitions in its unsatisfiable cores, |
|
169 |
so we assume the worst and include them all here. *) |
|
170 |
[(ext_name ctxt, (Global, General))] |> add_non_rec_defs fact_names |
|
171 |
| facts => facts) |
|
172 |
else |
|
173 |
I) |
|
51026 | 174 |
#> (if null deps then union (op =) (resolve_fact fact_names ss) else I) |
49914 | 175 |
| add_fact _ _ _ = I |
176 |
||
177 |
fun used_facts_in_atp_proof ctxt fact_names atp_proof = |
|
178 |
if null atp_proof then Vector.foldl (uncurry (union (op =))) [] fact_names |
|
179 |
else fold (add_fact ctxt fact_names) atp_proof [] |
|
180 |
||
181 |
fun used_facts_in_unsound_atp_proof _ _ [] = NONE |
|
182 |
| used_facts_in_unsound_atp_proof ctxt fact_names atp_proof = |
|
183 |
let val used_facts = used_facts_in_atp_proof ctxt fact_names atp_proof in |
|
184 |
if forall (fn (_, (sc, _)) => sc = Global) used_facts andalso |
|
185 |
not (is_axiom_used_in_proof (is_conjecture o single) atp_proof) then |
|
186 |
SOME (map fst used_facts) |
|
187 |
else |
|
188 |
NONE |
|
189 |
end |
|
190 |
||
191 |
||
192 |
(** one-liner reconstructor proofs **) |
|
193 |
||
194 |
fun show_time NONE = "" |
|
195 |
| show_time (SOME ext_time) = " (" ^ string_from_ext_time ext_time ^ ")" |
|
196 |
||
49986
90e7be285b49
took out "using only ..." comments in Sledgehammer generated metis/smt calls, until these can be generated soundly
blanchet
parents:
49983
diff
changeset
|
197 |
(* FIXME: Various bugs, esp. with "unfolding" |
49914 | 198 |
fun unusing_chained_facts _ 0 = "" |
199 |
| unusing_chained_facts used_chaineds num_chained = |
|
200 |
if length used_chaineds = num_chained then "" |
|
201 |
else if null used_chaineds then "(* using no facts *) " |
|
202 |
else "(* using only " ^ space_implode " " used_chaineds ^ " *) " |
|
49986
90e7be285b49
took out "using only ..." comments in Sledgehammer generated metis/smt calls, until these can be generated soundly
blanchet
parents:
49983
diff
changeset
|
203 |
*) |
49914 | 204 |
|
205 |
fun apply_on_subgoal _ 1 = "by " |
|
206 |
| apply_on_subgoal 1 _ = "apply " |
|
207 |
| apply_on_subgoal i n = |
|
208 |
"prefer " ^ string_of_int i ^ " " ^ apply_on_subgoal 1 n |
|
209 |
||
210 |
fun using_labels [] = "" |
|
211 |
| using_labels ls = |
|
212 |
"using " ^ space_implode " " (map string_for_label ls) ^ " " |
|
213 |
||
214 |
fun command_call name [] = |
|
50239 | 215 |
name |> not (Symbol_Pos.is_identifier name) ? enclose "(" ")" |
49914 | 216 |
| command_call name args = "(" ^ name ^ " " ^ space_implode " " args ^ ")" |
217 |
||
218 |
fun reconstructor_command reconstr i n used_chaineds num_chained (ls, ss) = |
|
49986
90e7be285b49
took out "using only ..." comments in Sledgehammer generated metis/smt calls, until these can be generated soundly
blanchet
parents:
49983
diff
changeset
|
219 |
(* unusing_chained_facts used_chaineds num_chained ^ *) |
49914 | 220 |
using_labels ls ^ apply_on_subgoal i n ^ |
221 |
command_call (string_for_reconstructor reconstr) ss |
|
222 |
||
223 |
fun try_command_line banner time command = |
|
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50410
diff
changeset
|
224 |
banner ^ ": " ^ Active.sendback_markup command ^ show_time time ^ "." |
49914 | 225 |
|
226 |
fun minimize_line _ [] = "" |
|
227 |
| minimize_line minimize_command ss = |
|
228 |
case minimize_command ss of |
|
229 |
"" => "" |
|
230 |
| command => |
|
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50410
diff
changeset
|
231 |
"\nTo minimize: " ^ Active.sendback_markup command ^ "." |
49914 | 232 |
|
233 |
fun split_used_facts facts = |
|
234 |
facts |> List.partition (fn (_, (sc, _)) => sc = Chained) |
|
235 |
|> pairself (sort_distinct (string_ord o pairself fst)) |
|
236 |
||
237 |
type minimize_command = string list -> string |
|
238 |
type one_line_params = |
|
239 |
play * string * (string * stature) list * minimize_command * int * int |
|
240 |
||
241 |
fun one_line_proof_text num_chained |
|
242 |
(preplay, banner, used_facts, minimize_command, subgoal, |
|
243 |
subgoal_count) = |
|
244 |
let |
|
245 |
val (chained, extra) = split_used_facts used_facts |
|
246 |
val (failed, reconstr, ext_time) = |
|
247 |
case preplay of |
|
248 |
Played (reconstr, time) => (false, reconstr, (SOME (false, time))) |
|
249 |
| Trust_Playable (reconstr, time) => |
|
250 |
(false, reconstr, |
|
251 |
case time of |
|
252 |
NONE => NONE |
|
253 |
| SOME time => |
|
254 |
if time = Time.zeroTime then NONE else SOME (true, time)) |
|
255 |
| Failed_to_Play reconstr => (true, reconstr, NONE) |
|
256 |
val try_line = |
|
257 |
([], map fst extra) |
|
258 |
|> reconstructor_command reconstr subgoal subgoal_count (map fst chained) |
|
259 |
num_chained |
|
260 |
|> (if failed then |
|
261 |
enclose "One-line proof reconstruction failed: " |
|
262 |
".\n(Invoking \"sledgehammer\" with \"[strict]\" might \ |
|
263 |
\solve this.)" |
|
264 |
else |
|
265 |
try_command_line banner ext_time) |
|
266 |
in try_line ^ minimize_line minimize_command (map fst (extra @ chained)) end |
|
267 |
||
268 |
||
269 |
(** Isar proof construction and manipulation **) |
|
270 |
||
50017 | 271 |
val assume_prefix = "a" |
49914 | 272 |
val have_prefix = "f" |
273 |
val raw_prefix = "x" |
|
274 |
||
275 |
fun raw_label_for_name (num, ss) = |
|
276 |
case resolve_conjecture ss of |
|
277 |
[j] => (conjecture_prefix, j) |
|
278 |
| _ => (raw_prefix ^ ascii_of num, 0) |
|
279 |
||
50005 | 280 |
fun label_of_clause [name] = raw_label_for_name name |
50262 | 281 |
| label_of_clause c = (space_implode "___" (map (fst o raw_label_for_name) c), 0) |
50005 | 282 |
|
283 |
fun add_fact_from_dependencies fact_names (names as [(_, ss)]) = |
|
284 |
if is_fact fact_names ss then |
|
285 |
apsnd (union (op =) (map fst (resolve_fact fact_names ss))) |
|
286 |
else |
|
287 |
apfst (insert (op =) (label_of_clause names)) |
|
288 |
| add_fact_from_dependencies fact_names names = |
|
289 |
apfst (insert (op =) (label_of_clause names)) |
|
49914 | 290 |
|
291 |
fun repair_name "$true" = "c_True" |
|
292 |
| repair_name "$false" = "c_False" |
|
293 |
| repair_name "$$e" = tptp_equal (* seen in Vampire proofs *) |
|
294 |
| repair_name s = |
|
295 |
if is_tptp_equal s orelse |
|
296 |
(* seen in Vampire proofs *) |
|
297 |
(String.isPrefix "sQ" s andalso String.isSuffix "_eqProxy" s) then |
|
298 |
tptp_equal |
|
299 |
else |
|
300 |
s |
|
301 |
||
302 |
fun unvarify_term (Var ((s, 0), T)) = Free (s, T) |
|
303 |
| unvarify_term t = raise TERM ("unvarify_term: non-Var", [t]) |
|
304 |
||
305 |
fun infer_formula_types ctxt = |
|
306 |
Type.constraint HOLogic.boolT |
|
307 |
#> Syntax.check_term |
|
308 |
(Proof_Context.set_mode Proof_Context.mode_schematic ctxt) |
|
309 |
||
310 |
val combinator_table = |
|
311 |
[(@{const_name Meson.COMBI}, @{thm Meson.COMBI_def [abs_def]}), |
|
312 |
(@{const_name Meson.COMBK}, @{thm Meson.COMBK_def [abs_def]}), |
|
313 |
(@{const_name Meson.COMBB}, @{thm Meson.COMBB_def [abs_def]}), |
|
314 |
(@{const_name Meson.COMBC}, @{thm Meson.COMBC_def [abs_def]}), |
|
315 |
(@{const_name Meson.COMBS}, @{thm Meson.COMBS_def [abs_def]})] |
|
316 |
||
317 |
fun uncombine_term thy = |
|
318 |
let |
|
319 |
fun aux (t1 $ t2) = betapply (pairself aux (t1, t2)) |
|
320 |
| aux (Abs (s, T, t')) = Abs (s, T, aux t') |
|
321 |
| aux (t as Const (x as (s, _))) = |
|
322 |
(case AList.lookup (op =) combinator_table s of |
|
323 |
SOME thm => thm |> prop_of |> specialize_type thy x |
|
324 |
|> Logic.dest_equals |> snd |
|
325 |
| NONE => t) |
|
326 |
| aux t = t |
|
327 |
in aux end |
|
328 |
||
329 |
fun decode_line sym_tab (Definition_Step (name, phi1, phi2)) ctxt = |
|
330 |
let |
|
331 |
val thy = Proof_Context.theory_of ctxt |
|
332 |
val t1 = prop_from_atp ctxt true sym_tab phi1 |
|
333 |
val vars = snd (strip_comb t1) |
|
334 |
val frees = map unvarify_term vars |
|
335 |
val unvarify_args = subst_atomic (vars ~~ frees) |
|
336 |
val t2 = prop_from_atp ctxt true sym_tab phi2 |
|
337 |
val (t1, t2) = |
|
338 |
HOLogic.eq_const HOLogic.typeT $ t1 $ t2 |
|
339 |
|> unvarify_args |> uncombine_term thy |> infer_formula_types ctxt |
|
340 |
|> HOLogic.dest_eq |
|
341 |
in |
|
342 |
(Definition_Step (name, t1, t2), |
|
343 |
fold Variable.declare_term (maps Misc_Legacy.term_frees [t1, t2]) ctxt) |
|
344 |
end |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
345 |
| decode_line sym_tab (Inference_Step (name, role, u, rule, deps)) ctxt = |
49914 | 346 |
let |
347 |
val thy = Proof_Context.theory_of ctxt |
|
348 |
val t = u |> prop_from_atp ctxt true sym_tab |
|
349 |
|> uncombine_term thy |> infer_formula_types ctxt |
|
350 |
in |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
351 |
(Inference_Step (name, role, t, rule, deps), |
49914 | 352 |
fold Variable.declare_term (Misc_Legacy.term_frees t) ctxt) |
353 |
end |
|
354 |
fun decode_lines ctxt sym_tab lines = |
|
355 |
fst (fold_map (decode_line sym_tab) lines ctxt) |
|
356 |
||
357 |
fun replace_one_dependency (old, new) dep = |
|
358 |
if is_same_atp_step dep old then new else [dep] |
|
359 |
fun replace_dependencies_in_line _ (line as Definition_Step _) = line |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
360 |
| replace_dependencies_in_line p |
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
361 |
(Inference_Step (name, role, t, rule, deps)) = |
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
362 |
Inference_Step (name, role, t, rule, |
49914 | 363 |
fold (union (op =) o replace_one_dependency p) deps []) |
364 |
||
365 |
(* No "real" literals means only type information (tfree_tcs, clsrel, or |
|
366 |
clsarity). *) |
|
367 |
fun is_only_type_information t = t aconv @{term True} |
|
368 |
||
50905 | 369 |
fun s_maybe_not role = role <> Conjecture ? s_not |
370 |
||
49914 | 371 |
fun is_same_inference _ (Definition_Step _) = false |
50905 | 372 |
| is_same_inference (role, t) (Inference_Step (_, role', t', _, _)) = |
373 |
s_maybe_not role t aconv s_maybe_not role' t' |
|
49914 | 374 |
|
375 |
(* Discard facts; consolidate adjacent lines that prove the same formula, since |
|
376 |
they differ only in type information.*) |
|
377 |
fun add_line _ (line as Definition_Step _) lines = line :: lines |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
378 |
| add_line fact_names (Inference_Step (name as (_, ss), role, t, rule, [])) |
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
379 |
lines = |
49914 | 380 |
(* No dependencies: fact, conjecture, or (for Vampire) internal facts or |
381 |
definitions. *) |
|
50905 | 382 |
if is_conjecture ss then |
383 |
Inference_Step (name, role, t, rule, []) :: lines |
|
384 |
else if is_fact fact_names ss then |
|
49914 | 385 |
(* Facts are not proof lines. *) |
386 |
if is_only_type_information t then |
|
387 |
map (replace_dependencies_in_line (name, [])) lines |
|
50905 | 388 |
else |
389 |
lines |
|
49914 | 390 |
else |
391 |
map (replace_dependencies_in_line (name, [])) lines |
|
50675 | 392 |
| add_line _ (line as Inference_Step (name, role, t, rule, deps)) lines = |
49914 | 393 |
(* Type information will be deleted later; skip repetition test. *) |
394 |
if is_only_type_information t then |
|
50675 | 395 |
line :: lines |
49914 | 396 |
(* Is there a repetition? If so, replace later line by earlier one. *) |
50905 | 397 |
else case take_prefix (not o is_same_inference (role, t)) lines of |
50675 | 398 |
(_, []) => line :: lines |
399 |
| (pre, Inference_Step (name', _, _, _, _) :: post) => |
|
400 |
line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
|
401 |
| _ => raise Fail "unexpected inference" |
|
49914 | 402 |
|
403 |
val waldmeister_conjecture_num = "1.0.0.0" |
|
404 |
||
405 |
val repair_waldmeister_endgame = |
|
406 |
let |
|
50905 | 407 |
fun do_tail (Inference_Step (name, _, t, rule, deps)) = |
408 |
Inference_Step (name, Negated_Conjecture, s_not t, rule, deps) |
|
49914 | 409 |
| do_tail line = line |
410 |
fun do_body [] = [] |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
411 |
| do_body ((line as Inference_Step ((num, _), _, _, _, _)) :: lines) = |
49914 | 412 |
if num = waldmeister_conjecture_num then map do_tail (line :: lines) |
413 |
else line :: do_body lines |
|
414 |
| do_body (line :: lines) = line :: do_body lines |
|
415 |
in do_body end |
|
416 |
||
417 |
(* Recursively delete empty lines (type information) from the proof. *) |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
418 |
fun add_nontrivial_line (line as Inference_Step (name, _, t, _, [])) lines = |
49914 | 419 |
if is_only_type_information t then delete_dependency name lines |
420 |
else line :: lines |
|
421 |
| add_nontrivial_line line lines = line :: lines |
|
422 |
and delete_dependency name lines = |
|
423 |
fold_rev add_nontrivial_line |
|
424 |
(map (replace_dependencies_in_line (name, [])) lines) [] |
|
425 |
||
426 |
(* ATPs sometimes reuse free variable names in the strangest ways. Removing |
|
427 |
offending lines often does the trick. *) |
|
428 |
fun is_bad_free frees (Free x) = not (member (op =) frees x) |
|
429 |
| is_bad_free _ _ = false |
|
430 |
||
50675 | 431 |
val e_skolemize_rule = "skolemize" |
432 |
val vampire_skolemisation_rule = "skolemisation" |
|
433 |
||
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
434 |
val is_skolemize_rule = |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
435 |
member (op =) [e_skolemize_rule, vampire_skolemisation_rule] |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
436 |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
437 |
fun add_desired_line _ _ (line as Definition_Step (name, _, _)) (j, lines) = |
49914 | 438 |
(j, line :: map (replace_dependencies_in_line (name, [])) lines) |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
439 |
| add_desired_line fact_names frees |
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
440 |
(Inference_Step (name as (_, ss), role, t, rule, deps)) (j, lines) = |
49914 | 441 |
(j + 1, |
442 |
if is_fact fact_names ss orelse |
|
443 |
is_conjecture ss orelse |
|
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
444 |
is_skolemize_rule rule orelse |
49914 | 445 |
(* the last line must be kept *) |
446 |
j = 0 orelse |
|
447 |
(not (is_only_type_information t) andalso |
|
448 |
null (Term.add_tvars t []) andalso |
|
449 |
not (exists_subterm (is_bad_free frees) t) andalso |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
450 |
length deps >= 2 andalso |
49914 | 451 |
(* kill next to last line, which usually results in a trivial step *) |
452 |
j <> 1) then |
|
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
453 |
Inference_Step (name, role, t, rule, deps) :: lines (* keep line *) |
49914 | 454 |
else |
455 |
map (replace_dependencies_in_line (name, deps)) lines) (* drop line *) |
|
456 |
||
457 |
val indent_size = 2 |
|
458 |
||
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
459 |
fun string_for_proof ctxt type_enc lam_trans i n proof = |
49883 | 460 |
let |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
461 |
val register_fixes = map Free #> fold Variable.auto_fixes |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
462 |
fun add_suffix suffix (s, ctxt) = (s ^ suffix, ctxt) |
51158 | 463 |
fun of_indent ind = replicate_string (ind * indent_size) " " |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
464 |
fun of_moreover ind = of_indent ind ^ "moreover\n" |
51158 | 465 |
fun of_label l = if l = no_label then "" else string_for_label l ^ ": " |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
466 |
fun of_obtain qs nr = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
467 |
(if nr>1 orelse (nr=1 andalso member (op=) qs Then) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
468 |
then "ultimately " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
469 |
else if nr=1 orelse member (op=) qs Then |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
470 |
then "then " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
471 |
else "") ^ "obtain" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
472 |
fun of_show_have qs = if member (op=) qs Show then "show" else "have" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
473 |
fun of_thus_hence qs = if member (op=) qs Show then "thus" else "hence" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
474 |
fun of_prove qs nr = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
475 |
if nr>1 orelse (nr=1 andalso member (op=) qs Then) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
476 |
then "ultimately " ^ of_show_have qs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
477 |
else if nr=1 orelse member (op=) qs Then |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
478 |
then of_thus_hence qs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
479 |
else of_show_have qs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
480 |
fun add_term term (s, ctxt)= |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
481 |
(s ^ (annotate_types ctxt term |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
482 |
|> with_vanilla_print_mode (Syntax.string_of_term ctxt) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
483 |
|> simplify_spaces |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
484 |
|> maybe_quote), |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
485 |
ctxt |> Variable.auto_fixes term) |
49883 | 486 |
val reconstr = Metis (type_enc, lam_trans) |
51158 | 487 |
fun of_metis ind options (ls, ss) = |
488 |
"\n" ^ of_indent (ind + 1) ^ options ^ |
|
49883 | 489 |
reconstructor_command reconstr 1 1 [] 0 |
490 |
(ls |> sort_distinct (prod_ord string_ord int_ord), |
|
491 |
ss |> sort_distinct string_ord) |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
492 |
fun of_free (s, T) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
493 |
maybe_quote s ^ " :: " ^ |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
494 |
maybe_quote (simplify_spaces (with_vanilla_print_mode |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
495 |
(Syntax.string_of_typ ctxt) T)) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
496 |
fun add_frees xs (s, ctxt) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
497 |
(s ^ space_implode " and " (map of_free xs), ctxt |> register_fixes xs) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
498 |
fun add_fix _ [] = I |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
499 |
| add_fix ind xs = add_suffix (of_indent ind ^ "fix ") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
500 |
#> add_frees xs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
501 |
#> add_suffix "\n" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
502 |
fun add_assm ind (l, t) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
503 |
add_suffix (of_indent ind ^ "assume " ^ of_label l) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
504 |
#> add_term t |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
505 |
#> add_suffix "\n" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
506 |
fun add_assms ind assms = fold (add_assm ind) assms |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
507 |
fun add_step_post ind l t facts options = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
508 |
add_suffix (of_label l) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
509 |
#> add_term t |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
510 |
#> add_suffix (of_metis ind options facts ^ "\n") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
511 |
fun of_subproof ind ctxt proof = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
512 |
let |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
513 |
val ind = ind + 1 |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
514 |
val s = of_proof ind ctxt proof |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
515 |
val prefix = "{ " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
516 |
val suffix = " }" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
517 |
in |
49883 | 518 |
replicate_string (ind * indent_size - size prefix) " " ^ prefix ^ |
519 |
String.extract (s, ind * indent_size, |
|
520 |
SOME (size s - ind * indent_size - 1)) ^ |
|
521 |
suffix ^ "\n" |
|
522 |
end |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
523 |
and of_subproofs _ _ _ [] = "" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
524 |
| of_subproofs ind ctxt qs subproofs = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
525 |
(if member (op=) qs Then then of_moreover ind else "") ^ |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
526 |
space_implode (of_moreover ind) (map (of_subproof ind ctxt) subproofs) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
527 |
and add_step_pre ind qs subproofs (s, ctxt) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
528 |
(s ^ of_subproofs ind ctxt qs subproofs ^ of_indent ind, ctxt) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
529 |
and add_step ind (Let (t1, t2)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
530 |
add_suffix (of_indent ind ^ "let ") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
531 |
#> add_term t1 |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
532 |
#> add_suffix " = " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
533 |
#> add_term t2 |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
534 |
#> add_suffix "\n" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
535 |
| add_step ind (Prove (qs, l, t, By_Metis (subproofs, facts))) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
536 |
add_step_pre ind qs subproofs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
537 |
#> add_suffix (of_prove qs (length subproofs) ^ " ") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
538 |
#> add_step_post ind l t facts "" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
539 |
| add_step ind (Obtain (qs, Fix xs, l, t, |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
540 |
By_Metis (subproofs, facts))) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
541 |
add_step_pre ind qs subproofs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
542 |
#> add_suffix (of_obtain qs (length subproofs) ^ " ") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
543 |
#> add_frees xs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
544 |
#> add_suffix " where " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
545 |
(* The new skolemizer puts the arguments in the same order as the ATPs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
546 |
(E and Vampire -- but see also "atp_proof_reconstruct.ML" regarding |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
547 |
Vampire). *) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
548 |
#> add_step_post ind l t facts "using [[metis_new_skolem]] " |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
549 |
and add_steps ind steps = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
550 |
fold (add_step ind) steps |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
551 |
and of_proof ind ctxt (Proof (Fix xs, Assume assms, steps)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
552 |
("", ctxt) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
553 |
|> add_fix ind xs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
554 |
|> add_assms ind assms |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
555 |
|> add_steps ind steps |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
556 |
|> fst |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
557 |
in |
49883 | 558 |
(* One-step proofs are pointless; better use the Metis one-liner |
559 |
directly. *) |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
560 |
case proof of |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
561 |
Proof (Fix [], Assume [], [Prove (_, _, _, By_Metis ([], _))]) => "" |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
562 |
| _ => (if i <> 1 then "prefer " ^ string_of_int i ^ "\n" else "") ^ |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
563 |
of_indent 0 ^ "proof -\n" ^ of_proof 1 ctxt proof ^ |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
564 |
of_indent 0 ^ (if n <> 1 then "next" else "qed") |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
565 |
end |
49883 | 566 |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
567 |
fun add_labels_of_step step = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
568 |
(case byline_of_step step of |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
569 |
NONE => I |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
570 |
| SOME (By_Metis (subproofs, (ls, _))) => |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
571 |
union (op =) (add_labels_of_proofs subproofs ls)) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
572 |
and add_labels_of_proof proof = fold add_labels_of_step (steps_of_proof proof) |
51178 | 573 |
and add_labels_of_proofs proofs = fold add_labels_of_proof proofs |
49914 | 574 |
|
575 |
fun kill_useless_labels_in_proof proof = |
|
576 |
let |
|
51178 | 577 |
val used_ls = add_labels_of_proof proof [] |
49914 | 578 |
fun do_label l = if member (op =) used_ls l then l else no_label |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
579 |
fun do_assms (Assume assms) = Assume (map (apfst do_label) assms) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
580 |
fun do_step (Obtain (qs, xs, l, t, By_Metis (subproofs, facts))) = |
51178 | 581 |
Obtain (qs, xs, do_label l, t, By_Metis (map do_proof subproofs, facts)) |
582 |
| do_step (Prove (qs, l, t, By_Metis (subproofs, facts))) = |
|
583 |
Prove (qs, do_label l, t, By_Metis (map do_proof subproofs, facts)) |
|
49914 | 584 |
| do_step step = step |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
585 |
and do_proof (Proof (fix, assms, steps)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
586 |
Proof (fix, do_assms assms, map do_step steps) |
51128
0021ea861129
introduced subblock in isar_step datatype for conjecture herbrandization
smolkas
parents:
51031
diff
changeset
|
587 |
in do_proof proof end |
49914 | 588 |
|
589 |
fun prefix_for_depth n = replicate_string (n + 1) |
|
590 |
||
591 |
val relabel_proof = |
|
592 |
let |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
593 |
fun fresh_label depth prefix (old as (l, subst, next)) = |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
594 |
if l = no_label then |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
595 |
old |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
596 |
else |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
597 |
let val l' = (prefix_for_depth depth prefix, next) in |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
598 |
(l', (l, l') :: subst, next + 1) |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
599 |
end |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
600 |
fun do_facts subst = |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
601 |
apfst (maps (the_list o AList.lookup (op =) subst)) |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
602 |
fun do_assm depth (l, t) (subst, next) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
603 |
let |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
604 |
val (l, subst, next) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
605 |
(l, subst, next) |> fresh_label depth assume_prefix |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
606 |
in |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
607 |
((l, t), (subst, next)) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
608 |
end |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
609 |
fun do_assms subst depth (Assume assms) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
610 |
fold_map (do_assm depth) assms (subst, 1) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
611 |
|> apfst Assume |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
612 |
|> apsnd fst |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
613 |
fun do_steps _ _ _ [] = [] |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
614 |
| do_steps subst depth next (Obtain (qs, xs, l, t, by) :: steps) = |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
615 |
let |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
616 |
val (l, subst, next) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
617 |
(l, subst, next) |> fresh_label depth have_prefix |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
618 |
val by = by |> do_byline subst depth |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
619 |
in |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
620 |
Obtain (qs, xs, l, t, by) :: do_steps subst depth next steps |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
621 |
end |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
622 |
| do_steps subst depth next (Prove (qs, l, t, by) :: steps) = |
49914 | 623 |
let |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
624 |
val (l, subst, next) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
625 |
(l, subst, next) |> fresh_label depth have_prefix |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
626 |
val by = by |> do_byline subst depth |
49914 | 627 |
in |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
628 |
Prove (qs, l, t, by) :: do_steps subst depth next steps |
49914 | 629 |
end |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
630 |
| do_steps subst depth next (step :: steps) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
631 |
step :: do_steps subst depth next steps |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
632 |
and do_proof subst depth (Proof (fix, assms, steps)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
633 |
let val (assms, subst) = do_assms subst depth assms in |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
634 |
Proof (fix, assms, do_steps subst depth 1 steps) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
635 |
end |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
636 |
and do_byline subst depth (By_Metis (subproofs, facts)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
637 |
By_Metis (do_proofs subst depth subproofs, do_facts subst facts) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
638 |
and do_proofs subst depth = map (do_proof subst (depth + 1)) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
639 |
in do_proof [] 0 end |
49914 | 640 |
|
50004
c96e8e40d789
several improvements to Isar proof reconstruction, by Steffen Smolka (step merging in case splits, time measurements, etc.)
blanchet
parents:
49994
diff
changeset
|
641 |
val chain_direct_proof = |
c96e8e40d789
several improvements to Isar proof reconstruction, by Steffen Smolka (step merging in case splits, time measurements, etc.)
blanchet
parents:
49994
diff
changeset
|
642 |
let |
51178 | 643 |
fun do_qs_lfs NONE lfs = ([], lfs) |
644 |
| do_qs_lfs (SOME l0) lfs = |
|
645 |
if member (op =) lfs l0 then ([Then], lfs |> remove (op =) l0) |
|
646 |
else ([], lfs) |
|
647 |
fun chain_step lbl (Obtain (qs, xs, l, t, |
|
648 |
By_Metis (subproofs, (lfs, gfs)))) = |
|
649 |
let val (qs', lfs) = do_qs_lfs lbl lfs in |
|
650 |
Obtain (qs' @ qs, xs, l, t, |
|
651 |
By_Metis (chain_proofs subproofs, (lfs, gfs))) |
|
652 |
end |
|
653 |
| chain_step lbl (Prove (qs, l, t, By_Metis (subproofs, (lfs, gfs)))) = |
|
654 |
let val (qs', lfs) = do_qs_lfs lbl lfs in |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
655 |
Prove (qs' @ qs, l, t, By_Metis (chain_proofs subproofs, (lfs, gfs))) |
51178 | 656 |
end |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
657 |
| chain_step _ step = step |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
658 |
and chain_steps _ [] = [] |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
659 |
| chain_steps (prev as SOME _) (i :: is) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
660 |
chain_step prev i :: chain_steps (label_of_step i) is |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
661 |
| chain_steps _ (i :: is) = i :: chain_steps (label_of_step i) is |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
662 |
and chain_proof (Proof (fix, Assume assms, steps)) = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
663 |
Proof (fix, Assume assms, |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
664 |
chain_steps (try (List.last #> fst) assms) steps) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
665 |
and chain_proofs proofs = map (chain_proof) proofs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
666 |
in chain_proof end |
49883 | 667 |
|
49914 | 668 |
type isar_params = |
50557 | 669 |
bool * bool * Time.time option * real * string Symtab.table |
50004
c96e8e40d789
several improvements to Isar proof reconstruction, by Steffen Smolka (step merging in case splits, time measurements, etc.)
blanchet
parents:
49994
diff
changeset
|
670 |
* (string * stature) list vector * int Symtab.table * string proof * thm |
49914 | 671 |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
672 |
fun isar_proof_text ctxt isar_proofs |
51130
76d68444cd59
renamed sledgehammer_shrink to sledgehammer_compress
smolkas
parents:
51129
diff
changeset
|
673 |
(debug, verbose, preplay_timeout, isar_compress, pool, fact_names, sym_tab, |
50020 | 674 |
atp_proof, goal) |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
675 |
(one_line_params as (_, _, _, _, subgoal, subgoal_count)) = |
49883 | 676 |
let |
677 |
val (params, hyp_ts, concl_t) = strip_subgoal ctxt goal subgoal |
|
678 |
val frees = fold Term.add_frees (concl_t :: hyp_ts) [] |
|
679 |
val one_line_proof = one_line_proof_text 0 one_line_params |
|
680 |
val type_enc = |
|
681 |
if is_typed_helper_used_in_atp_proof atp_proof then full_typesN |
|
682 |
else partial_typesN |
|
683 |
val lam_trans = lam_trans_from_atp_proof atp_proof metis_default_lam_trans |
|
50557 | 684 |
val preplay = preplay_timeout <> SOME Time.zeroTime |
49883 | 685 |
|
686 |
fun isar_proof_of () = |
|
687 |
let |
|
688 |
val atp_proof = |
|
689 |
atp_proof |
|
690 |
|> clean_up_atp_proof_dependencies |
|
691 |
|> nasty_atp_proof pool |
|
692 |
|> map_term_names_in_atp_proof repair_name |
|
693 |
|> decode_lines ctxt sym_tab |
|
50905 | 694 |
|> repair_waldmeister_endgame |
49883 | 695 |
|> rpair [] |-> fold_rev (add_line fact_names) |
696 |
|> rpair [] |-> fold_rev add_nontrivial_line |
|
697 |
|> rpair (0, []) |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
698 |
|-> fold_rev (add_desired_line fact_names frees) |
49883 | 699 |
|> snd |
700 |
val conj_name = conjecture_prefix ^ string_of_int (length hyp_ts) |
|
701 |
val conjs = |
|
50010
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
702 |
atp_proof |> map_filter |
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
703 |
(fn Inference_Step (name as (_, ss), _, _, _, []) => |
50010
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
704 |
if member (op =) ss conj_name then SOME name else NONE |
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
705 |
| _ => NONE) |
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
706 |
val assms = |
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
707 |
atp_proof |> map_filter |
50013
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
708 |
(fn Inference_Step (name as (_, ss), _, _, _, []) => |
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
709 |
(case resolve_conjecture ss of |
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
710 |
[j] => |
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
711 |
if j = length hyp_ts then NONE |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
712 |
else SOME (raw_label_for_name name, nth hyp_ts j) |
50013
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
713 |
| _ => NONE) |
50010
17488e45eb5a
proper handling of assumptions arising from the goal's being expressed in rule format, for Isar proof construction
blanchet
parents:
50005
diff
changeset
|
714 |
| _ => NONE) |
49883 | 715 |
fun dep_of_step (Definition_Step _) = NONE |
50012
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
716 |
| dep_of_step (Inference_Step (name, _, _, _, from)) = |
01cb92151a53
track formula roles in proofs and use that to determine whether the conjecture should be negated or not
blanchet
parents:
50010
diff
changeset
|
717 |
SOME (from, name) |
51145 | 718 |
val refute_graph = |
719 |
atp_proof |> map_filter dep_of_step |> make_refute_graph |
|
720 |
val axioms = axioms_of_refute_graph refute_graph conjs |
|
721 |
val tainted = tainted_atoms_of_refute_graph refute_graph conjs |
|
51156 | 722 |
val is_clause_tainted = exists (member (op =) tainted) |
51031
63d71b247323
more robustness in Isar proof reconstruction (cf. bug report by Ondrej)
blanchet
parents:
51026
diff
changeset
|
723 |
val bot = atp_proof |> List.last |> dep_of_step |> the |> snd |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
724 |
val steps = |
49883 | 725 |
Symtab.empty |
726 |
|> fold (fn Definition_Step _ => I (* FIXME *) |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
727 |
| Inference_Step (name as (s, _), role, t, rule, _) => |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
728 |
Symtab.update_new (s, (rule, |
51156 | 729 |
t |> (if is_clause_tainted [name] then |
50905 | 730 |
s_maybe_not role |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
731 |
#> fold exists_of (map Var (Term.add_vars t [])) |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
732 |
else |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
733 |
I)))) |
49883 | 734 |
atp_proof |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
735 |
fun is_clause_skolemize_rule [(s, _)] = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
736 |
Option.map (is_skolemize_rule o fst) (Symtab.lookup steps s) = |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
737 |
SOME true |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
738 |
| is_clause_skolemize_rule _ = false |
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
739 |
(* The assumptions and conjecture are "prop"s; the other formulas are |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
740 |
"bool"s. *) |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
741 |
fun prop_of_clause [(s, ss)] = |
50016 | 742 |
(case resolve_conjecture ss of |
743 |
[j] => if j = length hyp_ts then concl_t else nth hyp_ts j |
|
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
744 |
| _ => the_default ("", @{term False}) (Symtab.lookup steps s) |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
745 |
|> snd |> HOLogic.mk_Trueprop |> close_form) |
50016 | 746 |
| prop_of_clause names = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
747 |
let |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
748 |
val lits = map snd (map_filter (Symtab.lookup steps o fst) names) |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
749 |
in |
50018
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
750 |
case List.partition (can HOLogic.dest_not) lits of |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
751 |
(negs as _ :: _, pos as _ :: _) => |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
752 |
HOLogic.mk_imp |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
753 |
(Library.foldr1 s_conj (map HOLogic.dest_not negs), |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
754 |
Library.foldr1 s_disj pos) |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
755 |
| _ => fold (curry s_disj) lits @{term False} |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
756 |
end |
50016 | 757 |
|> HOLogic.mk_Trueprop |> close_form |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
758 |
fun isar_proof_of_direct_proof infs = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
759 |
let |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
760 |
fun maybe_show outer c = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
761 |
(outer andalso length c = 1 andalso subset (op =) (c, conjs)) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
762 |
? cons Show |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
763 |
val is_fixed = Variable.is_declared ctxt orf can Name.dest_skolem |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
764 |
fun skolems_of t = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
765 |
Term.add_frees t [] |> filter_out (is_fixed o fst) |> rev |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
766 |
fun do_steps _ _ accum [] = rev accum |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
767 |
| do_steps outer _ accum (Have (gamma, c) :: infs) = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
768 |
let |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
769 |
val l = label_of_clause c |
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
770 |
val t = prop_of_clause c |
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
771 |
val by = |
51178 | 772 |
By_Metis ([], |
773 |
(fold (add_fact_from_dependencies fact_names) |
|
774 |
gamma no_facts)) |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
775 |
fun prove by = Prove (maybe_show outer c [], l, t, by) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
776 |
fun do_rest lbl step = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
777 |
do_steps outer (SOME lbl) (step :: accum) infs |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
778 |
in |
51156 | 779 |
if is_clause_tainted c then |
51149 | 780 |
case gamma of |
781 |
[g] => |
|
51156 | 782 |
if is_clause_skolemize_rule g andalso |
783 |
is_clause_tainted g then |
|
51149 | 784 |
let |
51178 | 785 |
val subproof = |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
786 |
Proof (Fix (skolems_of (prop_of_clause g)), |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
787 |
Assume [], rev accum) |
51149 | 788 |
in |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
789 |
do_steps outer (SOME l) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
790 |
[prove (By_Metis ([subproof], no_facts))] [] |
51149 | 791 |
end |
792 |
else |
|
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
793 |
do_rest l (prove by) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
794 |
| _ => do_rest l (prove by) |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
795 |
else |
51149 | 796 |
if is_clause_skolemize_rule c then |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
797 |
do_rest l (Obtain ([], Fix (skolems_of t), l, t, by)) |
51149 | 798 |
else |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
799 |
do_rest l (prove by) |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
800 |
end |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
801 |
| do_steps outer predecessor accum (Cases cases :: infs) = |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
802 |
let |
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
803 |
fun do_case (c, infs) = |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
804 |
do_proof false [] [(label_of_clause c, prop_of_clause c)] infs |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
805 |
val c = succedent_of_cases cases |
51178 | 806 |
val l = label_of_clause c |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
807 |
val t = prop_of_clause c |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
808 |
val step = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
809 |
(Prove (maybe_show outer c [], l, t, By_Metis |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
810 |
(map do_case cases, (the_list predecessor, [])))) |
51149 | 811 |
in |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
812 |
do_steps outer (SOME l) (step :: accum) infs |
51149 | 813 |
end |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
814 |
and do_proof outer fix assms infs = |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
815 |
Proof (Fix fix, Assume assms, do_steps outer NONE [] infs) |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
816 |
in |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
817 |
do_proof true params assms infs |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
818 |
end |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
819 |
|
51165 | 820 |
val cleanup_labels_in_proof = |
821 |
chain_direct_proof |
|
822 |
#> kill_useless_labels_in_proof |
|
823 |
#> relabel_proof |
|
50924 | 824 |
val (isar_proof, (preplay_fail, preplay_time)) = |
51145 | 825 |
refute_graph |
51031
63d71b247323
more robustness in Isar proof reconstruction (cf. bug report by Ondrej)
blanchet
parents:
51026
diff
changeset
|
826 |
|> redirect_graph axioms tainted bot |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
827 |
|> isar_proof_of_direct_proof |
51130
76d68444cd59
renamed sledgehammer_shrink to sledgehammer_compress
smolkas
parents:
51129
diff
changeset
|
828 |
|> (if not preplay andalso isar_compress <= 1.0 then |
50677 | 829 |
rpair (false, (true, seconds 0.0)) |
50557 | 830 |
else |
51130
76d68444cd59
renamed sledgehammer_shrink to sledgehammer_compress
smolkas
parents:
51129
diff
changeset
|
831 |
compress_proof debug ctxt type_enc lam_trans preplay |
50679 | 832 |
preplay_timeout |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
833 |
(if isar_proofs = SOME true then isar_compress else 1000.0)) |
51165 | 834 |
|>> cleanup_labels_in_proof |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
835 |
val isar_text = |
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
836 |
string_for_proof ctxt type_enc lam_trans subgoal subgoal_count |
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
837 |
isar_proof |
49883 | 838 |
in |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
839 |
case isar_text of |
49883 | 840 |
"" => |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
841 |
if isar_proofs = SOME true then |
50671 | 842 |
"\nNo structured proof available (proof too simple)." |
49883 | 843 |
else |
844 |
"" |
|
845 |
| _ => |
|
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
846 |
let |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
847 |
val msg = |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
848 |
(if preplay then |
50924 | 849 |
[(if preplay_fail then "may fail, " else "") ^ |
850 |
Sledgehammer_Preplay.string_of_preplay_time preplay_time] |
|
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
851 |
else |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
852 |
[]) @ |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
853 |
(if verbose then |
51179
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
854 |
let |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
855 |
val num_steps = add_metis_steps (steps_of_proof isar_proof) 0 |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
856 |
in |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
857 |
[string_of_int num_steps ^ " step" ^ plural_s num_steps] |
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
smolkas
parents:
51178
diff
changeset
|
858 |
end |
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
859 |
else |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
860 |
[]) |
50277 | 861 |
in |
862 |
"\n\nStructured proof " |
|
863 |
^ (commas msg |> not (null msg) ? enclose "(" ")") |
|
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50410
diff
changeset
|
864 |
^ ":\n" ^ Active.sendback_markup isar_text |
50277 | 865 |
end |
49883 | 866 |
end |
867 |
val isar_proof = |
|
868 |
if debug then |
|
869 |
isar_proof_of () |
|
870 |
else case try isar_proof_of () of |
|
871 |
SOME s => s |
|
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
872 |
| NONE => if isar_proofs = SOME true then |
49883 | 873 |
"\nWarning: The Isar proof construction failed." |
874 |
else |
|
875 |
"" |
|
876 |
in one_line_proof ^ isar_proof end |
|
877 |
||
51187
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
878 |
fun isar_proof_would_be_a_good_idea preplay = |
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
879 |
case preplay of |
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
880 |
Played (reconstr, _) => reconstr = SMT |
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
881 |
| Trust_Playable _ => false |
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
882 |
| Failed_to_Play _ => true |
c344cf148e8f
avoid using "smt" for minimization -- better use the prover itself, since then Sledgehammer gets to try metis again and gives the opportunity to output an Isar proof -- and show Isar proof as fallback for SMT proofs
blanchet
parents:
51179
diff
changeset
|
883 |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
884 |
fun proof_text ctxt isar_proofs isar_params num_chained |
49883 | 885 |
(one_line_params as (preplay, _, _, _, _, _)) = |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
886 |
(if isar_proofs = SOME true orelse |
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51187
diff
changeset
|
887 |
(isar_proofs = NONE andalso isar_proof_would_be_a_good_idea preplay) then |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
888 |
isar_proof_text ctxt isar_proofs isar_params |
49883 | 889 |
else |
890 |
one_line_proof_text num_chained) one_line_params |
|
891 |
||
892 |
end; |