author | blanchet |
Tue, 19 Nov 2013 18:34:04 +0100 | |
changeset 54503 | b490e15a5e19 |
parent 54501 | 77c9460e01b0 |
child 54505 | d023838eb252 |
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 |
||
52374 | 8 |
signature SLEDGEHAMMER_RECONSTRUCT = |
49883 | 9 |
sig |
54495 | 10 |
type ('a, 'b) atp_step = ('a, 'b) ATP_Proof.atp_step |
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53052
diff
changeset
|
11 |
type 'a atp_proof = 'a ATP_Proof.atp_proof |
49914 | 12 |
type stature = ATP_Problem_Generate.stature |
54495 | 13 |
type one_line_params = Sledgehammer_Reconstructor.one_line_params |
49914 | 14 |
|
15 |
type isar_params = |
|
54500 | 16 |
bool * bool * string * string * Time.time option * real * bool * (string * stature) list vector |
17 |
* (term, string) atp_step list * thm |
|
49914 | 18 |
|
49883 | 19 |
val isar_proof_text : |
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
20 |
Proof.context -> bool option -> isar_params -> one_line_params -> string |
49883 | 21 |
val proof_text : |
54500 | 22 |
Proof.context -> bool option -> (unit -> isar_params) -> int -> one_line_params -> string |
49883 | 23 |
end; |
24 |
||
52374 | 25 |
structure Sledgehammer_Reconstruct : SLEDGEHAMMER_RECONSTRUCT = |
49883 | 26 |
struct |
27 |
||
28 |
open ATP_Util |
|
49914 | 29 |
open ATP_Problem |
49883 | 30 |
open ATP_Proof |
31 |
open ATP_Problem_Generate |
|
32 |
open ATP_Proof_Reconstruct |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
33 |
open Sledgehammer_Util |
52555 | 34 |
open Sledgehammer_Reconstructor |
50264
a9ec48b98734
renamed sledgehammer_isar_reconstruct to sledgehammer_proof
smolkas
parents:
50262
diff
changeset
|
35 |
open Sledgehammer_Proof |
50258 | 36 |
open Sledgehammer_Annotate |
52555 | 37 |
open Sledgehammer_Print |
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
38 |
open Sledgehammer_Preplay |
51130
76d68444cd59
renamed sledgehammer_shrink to sledgehammer_compress
smolkas
parents:
51129
diff
changeset
|
39 |
open Sledgehammer_Compress |
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
40 |
open Sledgehammer_Try0 |
52611
831f7479c74f
minimize dependencies (used facts) of Isar proof steps; remove unreferenced steps
smolkas
parents:
52592
diff
changeset
|
41 |
open Sledgehammer_Minimize_Isar |
49914 | 42 |
|
43 |
structure String_Redirect = ATP_Proof_Redirect( |
|
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53052
diff
changeset
|
44 |
type key = atp_step_name |
49914 | 45 |
val ord = fn ((s, _ : string list), (s', _)) => fast_string_ord (s, s') |
46 |
val string_of = fst) |
|
47 |
||
49883 | 48 |
open String_Redirect |
49 |
||
54501 | 50 |
fun raw_label_of_num num = (num, 0) |
49914 | 51 |
|
54501 | 52 |
fun label_of_clause [(num, _)] = raw_label_of_num num |
53 |
| label_of_clause c = (space_implode "___" (map (fst o raw_label_of_num o fst) c), 0) |
|
50005 | 54 |
|
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51998
diff
changeset
|
55 |
fun add_fact_of_dependencies fact_names (names as [(_, ss)]) = |
50005 | 56 |
if is_fact fact_names ss then |
57 |
apsnd (union (op =) (map fst (resolve_fact fact_names ss))) |
|
58 |
else |
|
59 |
apfst (insert (op =) (label_of_clause names)) |
|
52034
11b48e7a4e7e
correctly 'repair' the monomorphization context for SMT solvers from Sledgehammer
blanchet
parents:
52031
diff
changeset
|
60 |
| add_fact_of_dependencies _ names = |
50005 | 61 |
apfst (insert (op =) (label_of_clause names)) |
49914 | 62 |
|
63 |
fun replace_one_dependency (old, new) dep = |
|
64 |
if is_same_atp_step dep old then new else [dep] |
|
51201 | 65 |
fun replace_dependencies_in_line p (name, role, t, rule, deps) = |
66 |
(name, role, t, rule, fold (union (op =) o replace_one_dependency p) deps []) |
|
49914 | 67 |
|
68 |
(* No "real" literals means only type information (tfree_tcs, clsrel, or |
|
69 |
clsarity). *) |
|
70 |
fun is_only_type_information t = t aconv @{term True} |
|
71 |
||
50905 | 72 |
fun s_maybe_not role = role <> Conjecture ? s_not |
73 |
||
51201 | 74 |
fun is_same_inference (role, t) (_, role', t', _, _) = |
75 |
s_maybe_not role t aconv s_maybe_not role' t' |
|
49914 | 76 |
|
77 |
(* Discard facts; consolidate adjacent lines that prove the same formula, since |
|
78 |
they differ only in type information.*) |
|
51201 | 79 |
fun add_line fact_names (name as (_, ss), role, t, rule, []) lines = |
49914 | 80 |
(* No dependencies: fact, conjecture, or (for Vampire) internal facts or |
81 |
definitions. *) |
|
50905 | 82 |
if is_conjecture ss then |
51201 | 83 |
(name, role, t, rule, []) :: lines |
50905 | 84 |
else if is_fact fact_names ss then |
49914 | 85 |
(* Facts are not proof lines. *) |
86 |
if is_only_type_information t then |
|
87 |
map (replace_dependencies_in_line (name, [])) lines |
|
50905 | 88 |
else |
89 |
lines |
|
49914 | 90 |
else |
91 |
map (replace_dependencies_in_line (name, [])) lines |
|
51201 | 92 |
| add_line _ (line as (name, role, t, _, _)) lines = |
49914 | 93 |
(* Type information will be deleted later; skip repetition test. *) |
94 |
if is_only_type_information t then |
|
50675 | 95 |
line :: lines |
49914 | 96 |
(* Is there a repetition? If so, replace later line by earlier one. *) |
50905 | 97 |
else case take_prefix (not o is_same_inference (role, t)) lines of |
50675 | 98 |
(_, []) => line :: lines |
51201 | 99 |
| (pre, (name', _, _, _, _) :: post) => |
50675 | 100 |
line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
49914 | 101 |
|
102 |
(* Recursively delete empty lines (type information) from the proof. *) |
|
51201 | 103 |
fun add_nontrivial_line (line as (name, _, t, _, [])) lines = |
49914 | 104 |
if is_only_type_information t then delete_dependency name lines |
105 |
else line :: lines |
|
106 |
| add_nontrivial_line line lines = line :: lines |
|
107 |
and delete_dependency name lines = |
|
108 |
fold_rev add_nontrivial_line |
|
109 |
(map (replace_dependencies_in_line (name, [])) lines) [] |
|
110 |
||
50675 | 111 |
val e_skolemize_rule = "skolemize" |
112 |
val vampire_skolemisation_rule = "skolemisation" |
|
113 |
||
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
114 |
val is_skolemize_rule = |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
115 |
member (op =) [e_skolemize_rule, vampire_skolemisation_rule] |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
116 |
|
52125
ac7830871177
improved handling of free variables' types in Isar proofs
blanchet
parents:
52077
diff
changeset
|
117 |
fun add_desired_line fact_names (name as (_, ss), role, t, rule, deps) |
51201 | 118 |
(j, lines) = |
51198 | 119 |
(j + 1, |
120 |
if is_fact fact_names ss orelse |
|
121 |
is_conjecture ss orelse |
|
122 |
is_skolemize_rule rule orelse |
|
123 |
(* the last line must be kept *) |
|
124 |
j = 0 orelse |
|
125 |
(not (is_only_type_information t) andalso |
|
126 |
null (Term.add_tvars t []) andalso |
|
127 |
length deps >= 2 andalso |
|
128 |
(* kill next to last line, which usually results in a trivial step *) |
|
129 |
j <> 1) then |
|
51201 | 130 |
(name, role, t, rule, deps) :: lines (* keep line *) |
51198 | 131 |
else |
132 |
map (replace_dependencies_in_line (name, deps)) lines) (* drop line *) |
|
49914 | 133 |
|
49883 | 134 |
|
52454 | 135 |
val add_labels_of_proof = |
136 |
steps_of_proof #> fold_isar_steps |
|
52756
1ac8a0d0ddb1
parse nonnumeric identifiers in E proofs correctly
blanchet
parents:
52697
diff
changeset
|
137 |
(byline_of_step #> (fn SOME (By ((ls, _), _)) => union (op =) ls | _ => I)) |
49914 | 138 |
|
139 |
fun kill_useless_labels_in_proof proof = |
|
140 |
let |
|
51178 | 141 |
val used_ls = add_labels_of_proof proof [] |
49914 | 142 |
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
|
143 |
fun do_assms (Assume assms) = Assume (map (apfst do_label) assms) |
52454 | 144 |
fun do_step (Prove (qs, xs, l, t, subproofs, by)) = |
54501 | 145 |
Prove (qs, xs, do_label l, t, map do_proof subproofs, by) |
49914 | 146 |
| 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
|
147 |
and do_proof (Proof (fix, assms, steps)) = |
54501 | 148 |
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
|
149 |
in do_proof proof end |
49914 | 150 |
|
51998
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
blanchet
parents:
51976
diff
changeset
|
151 |
fun prefix_of_depth n = replicate_string (n + 1) |
49914 | 152 |
|
54501 | 153 |
val assume_prefix = "a" |
154 |
val have_prefix = "f" |
|
155 |
||
49914 | 156 |
val relabel_proof = |
157 |
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
|
158 |
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
|
159 |
if l = no_label then |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
160 |
old |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
161 |
else |
51998
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
blanchet
parents:
51976
diff
changeset
|
162 |
let val l' = (prefix_of_depth depth prefix, next) 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
|
163 |
(l', (l, l') :: subst, next + 1) |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
164 |
end |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
165 |
fun do_facts subst = |
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
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
|
170 |
(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
|
171 |
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
|
172 |
((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
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
|> 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
|
177 |
|> 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
|
178 |
fun do_steps _ _ _ [] = [] |
52454 | 179 |
| do_steps subst depth next (Prove (qs, xs, l, t, sub, by) :: steps) = |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
(l, subst, next) |> fresh_label depth have_prefix |
52454 | 183 |
val sub = do_proofs subst depth sub |
52626 | 184 |
val by = by |> do_byline subst |
52454 | 185 |
in Prove (qs, xs, l, t, sub, by) :: do_steps subst depth next steps 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
|
186 |
| 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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
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
|
191 |
end |
52626 | 192 |
and do_byline subst byline = |
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
193 |
map_facts_of_byline (do_facts subst) byline |
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
|
194 |
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
|
195 |
in do_proof [] 0 end |
49914 | 196 |
|
50004
c96e8e40d789
several improvements to Isar proof reconstruction, by Steffen Smolka (step merging in case splits, time measurements, etc.)
blanchet
parents:
49994
diff
changeset
|
197 |
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
|
198 |
let |
51178 | 199 |
fun do_qs_lfs NONE lfs = ([], lfs) |
200 |
| do_qs_lfs (SOME l0) lfs = |
|
201 |
if member (op =) lfs l0 then ([Then], lfs |> remove (op =) l0) |
|
202 |
else ([], lfs) |
|
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
203 |
fun chain_step lbl |
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
204 |
(Prove (qs, xs, l, t, subproofs, By ((lfs, gfs), method))) = |
52453 | 205 |
let val (qs', lfs) = do_qs_lfs lbl lfs in |
52454 | 206 |
Prove (qs' @ qs, xs, l, t, chain_proofs subproofs, |
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
207 |
By ((lfs, gfs), method)) |
52453 | 208 |
end |
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50671
diff
changeset
|
209 |
| 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
|
210 |
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
|
211 |
| 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
|
212 |
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
|
213 |
| 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
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
in chain_proof end |
49883 | 219 |
|
49914 | 220 |
type isar_params = |
54500 | 221 |
bool * bool * string * string * Time.time option * real * bool * (string * stature) list vector |
222 |
* (term, string) atp_step list * thm |
|
49914 | 223 |
|
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
224 |
fun isar_proof_text ctxt isar_proofs |
54500 | 225 |
(debug, verbose, metis_type_enc, metis_lam_trans, preplay_timeout, isar_compress, |
226 |
isar_try0, fact_names, atp_proof, goal) |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
227 |
(one_line_params as (_, _, _, _, subgoal, subgoal_count)) = |
49883 | 228 |
let |
52196
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
229 |
val (params, hyp_ts, concl_t) = strip_subgoal goal subgoal ctxt |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
230 |
val (_, ctxt) = |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
231 |
params |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
232 |
|> map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
233 |
|> (fn fixes => |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
234 |
ctxt |> Variable.set_body false |
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52150
diff
changeset
|
235 |
|> Proof_Context.add_fixes fixes) |
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
236 |
val one_line_proof = one_line_proof_text 0 one_line_params |
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
237 |
val do_preplay = preplay_timeout <> SOME Time.zeroTime |
49883 | 238 |
|
239 |
fun isar_proof_of () = |
|
240 |
let |
|
241 |
val atp_proof = |
|
242 |
atp_proof |
|
243 |
|> rpair [] |-> fold_rev (add_line fact_names) |
|
244 |
|> rpair [] |-> fold_rev add_nontrivial_line |
|
245 |
|> rpair (0, []) |
|
52125
ac7830871177
improved handling of free variables' types in Isar proofs
blanchet
parents:
52077
diff
changeset
|
246 |
|-> fold_rev (add_desired_line fact_names) |
49883 | 247 |
|> snd |
248 |
val conj_name = conjecture_prefix ^ string_of_int (length hyp_ts) |
|
249 |
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
|
250 |
atp_proof |> map_filter |
51201 | 251 |
(fn (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
|
252 |
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
|
253 |
| _ => 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
|
254 |
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
|
255 |
atp_proof |> map_filter |
54501 | 256 |
(fn ((num, ss), _, _, _, []) => |
50013
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
257 |
(case resolve_conjecture ss of |
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
258 |
[j] => |
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
259 |
if j = length hyp_ts then NONE |
54501 | 260 |
else SOME (raw_label_of_num num, nth hyp_ts j) |
50013
cceec179bdca
use original formulas for hypotheses and conclusion to avoid mismatches
blanchet
parents:
50012
diff
changeset
|
261 |
| _ => 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
|
262 |
| _ => NONE) |
51212
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
263 |
val bot = atp_proof |> List.last |> #1 |
51145 | 264 |
val refute_graph = |
51212
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
265 |
atp_proof |
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
266 |
|> map (fn (name, _, _, _, from) => (from, name)) |
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
267 |
|> make_refute_graph bot |
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
268 |
|> fold (Atom_Graph.default_node o rpair ()) conjs |
51145 | 269 |
val axioms = axioms_of_refute_graph refute_graph conjs |
270 |
val tainted = tainted_atoms_of_refute_graph refute_graph conjs |
|
51156 | 271 |
val is_clause_tainted = exists (member (op =) tainted) |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
272 |
val steps = |
49883 | 273 |
Symtab.empty |
51201 | 274 |
|> fold (fn (name as (s, _), role, t, rule, _) => |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
275 |
Symtab.update_new (s, (rule, |
51156 | 276 |
t |> (if is_clause_tainted [name] then |
50905 | 277 |
s_maybe_not role |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
278 |
#> fold exists_of (map Var (Term.add_vars t [])) |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
279 |
else |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
280 |
I)))) |
49883 | 281 |
atp_proof |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
282 |
fun is_clause_skolemize_rule [(s, _)] = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
283 |
Option.map (is_skolemize_rule o fst) (Symtab.lookup steps s) = |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
284 |
SOME true |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
285 |
| is_clause_skolemize_rule _ = false |
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
286 |
(* The assumptions and conjecture are "prop"s; the other formulas are |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
287 |
"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
|
288 |
fun prop_of_clause [(s, ss)] = |
50016 | 289 |
(case resolve_conjecture ss of |
290 |
[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
|
291 |
| _ => the_default ("", @{term False}) (Symtab.lookup steps s) |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
292 |
|> snd |> HOLogic.mk_Trueprop |> close_form) |
50016 | 293 |
| prop_of_clause names = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
294 |
let |
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
295 |
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
|
296 |
in |
50018
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
297 |
case List.partition (can HOLogic.dest_not) lits of |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
298 |
(negs as _ :: _, pos as _ :: _) => |
51212
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
299 |
s_imp (Library.foldr1 s_conj (map HOLogic.dest_not negs), |
2bbcc9cc12b4
ensure all conjecture clauses are in the graph -- to prevent exceptions later
blanchet
parents:
51208
diff
changeset
|
300 |
Library.foldr1 s_disj pos) |
50018
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
301 |
| _ => fold (curry s_disj) lits @{term False} |
4ea26c74d7ea
use implications rather than disjunctions to improve readability
blanchet
parents:
50017
diff
changeset
|
302 |
end |
50016 | 303 |
|> 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
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
(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
|
308 |
? 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
|
309 |
val is_fixed = Variable.is_declared ctxt orf can Name.dest_skolem |
54501 | 310 |
fun skolems_of t = Term.add_frees t [] |> filter_out (is_fixed o fst) |> rev |
51976
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
311 |
fun do_steps outer predecessor accum [] = |
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
312 |
accum |
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
313 |
|> (if tainted = [] then |
54501 | 314 |
cons (Prove (if outer then [Show] else [], Fix [], no_label, concl_t, [], |
54503 | 315 |
By (([the predecessor], []), MetisM))) |
51976
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
316 |
else |
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
317 |
I) |
e5303bd748f2
generate valid direct Isar proof also if the facts are contradictory
blanchet
parents:
51879
diff
changeset
|
318 |
|> rev |
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
|
319 |
| do_steps outer _ accum (Have (gamma, c) :: infs) = |
50676
83b8a5a39709
generate "obtain" steps corresponding to skolemization inferences
blanchet
parents:
50675
diff
changeset
|
320 |
let |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
321 |
val l = label_of_clause c |
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
322 |
val t = prop_of_clause c |
54503 | 323 |
val by = By ((fold (add_fact_of_dependencies fact_names) gamma no_facts), MetisM) |
54501 | 324 |
fun prove sub by = Prove (maybe_show outer c [], Fix [], l, t, sub, by) |
325 |
fun do_rest l step = do_steps outer (SOME l) (step :: accum) infs |
|
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
326 |
in |
51156 | 327 |
if is_clause_tainted c then |
51149 | 328 |
case gamma of |
329 |
[g] => |
|
54501 | 330 |
if is_clause_skolemize_rule g andalso is_clause_tainted g then |
51149 | 331 |
let |
51178 | 332 |
val subproof = |
54501 | 333 |
Proof (Fix (skolems_of (prop_of_clause g)), Assume [], rev accum) |
51149 | 334 |
in |
54503 | 335 |
do_steps outer (SOME l) [prove [subproof] (By (no_facts, MetisM))] [] |
51149 | 336 |
end |
337 |
else |
|
52454 | 338 |
do_rest l (prove [] by) |
339 |
| _ => do_rest l (prove [] by) |
|
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
340 |
else |
51149 | 341 |
if is_clause_skolemize_rule c then |
52454 | 342 |
do_rest l (Prove ([], Fix (skolems_of t), l, t, [], by)) |
51149 | 343 |
else |
52454 | 344 |
do_rest l (prove [] by) |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
345 |
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
|
346 |
| do_steps outer predecessor accum (Cases cases :: infs) = |
51148
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
347 |
let |
2246a2e17f92
tuning -- refactoring in preparation for handling skolemization of conjecture
blanchet
parents:
51147
diff
changeset
|
348 |
fun do_case (c, infs) = |
54501 | 349 |
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
|
350 |
val c = succedent_of_cases cases |
51178 | 351 |
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
|
352 |
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
|
353 |
val step = |
54501 | 354 |
Prove (maybe_show outer c [], Fix [], l, t, map do_case cases, |
54503 | 355 |
By ((the_list predecessor, []), MetisM)) |
51149 | 356 |
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
|
357 |
do_steps outer (SOME l) (step :: accum) infs |
51149 | 358 |
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
|
359 |
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
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
|
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
365 |
(* 60 seconds seems like a good interpreation of "no timeout" *) |
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
366 |
val preplay_timeout = preplay_timeout |> the_default (seconds 60.0) |
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
367 |
|
51741 | 368 |
val clean_up_labels_in_proof = |
51165 | 369 |
chain_direct_proof |
370 |
#> kill_useless_labels_in_proof |
|
371 |
#> relabel_proof |
|
53761
4d34e267fba9
use configuration mechanism for low-level tracing
blanchet
parents:
53586
diff
changeset
|
372 |
val (preplay_interface as {overall_preplay_stats, ...}, isar_proof) = |
51145 | 373 |
refute_graph |
51031
63d71b247323
more robustness in Isar proof reconstruction (cf. bug report by Ondrej)
blanchet
parents:
51026
diff
changeset
|
374 |
|> 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
|
375 |
|> isar_proof_of_direct_proof |
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
376 |
|> relabel_proof_canonically |
54500 | 377 |
|> `(proof_preplay_interface debug ctxt metis_type_enc metis_lam_trans do_preplay |
53761
4d34e267fba9
use configuration mechanism for low-level tracing
blanchet
parents:
53586
diff
changeset
|
378 |
preplay_timeout) |
52626 | 379 |
val ((preplay_time, preplay_fail), isar_proof) = |
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
380 |
isar_proof |
54501 | 381 |
|> compress_proof (if isar_proofs = SOME true then isar_compress else 1000.0) |
53762 | 382 |
preplay_interface |
52632
23393c31c7fe
added sledgehammer parameters isar_try0 and isar_minimize and their negative aliases
smolkas
parents:
52626
diff
changeset
|
383 |
|> isar_try0 ? try0 preplay_timeout preplay_interface |
54501 | 384 |
|> minimize_dependencies_and_remove_unrefed_steps isar_try0 preplay_interface |
52626 | 385 |
|> `overall_preplay_stats |
386 |
||> clean_up_labels_in_proof |
|
54500 | 387 |
val isar_text = |
388 |
string_of_proof ctxt metis_type_enc metis_lam_trans subgoal subgoal_count isar_proof |
|
49883 | 389 |
in |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
390 |
case isar_text of |
49883 | 391 |
"" => |
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
|
392 |
if isar_proofs = SOME true then |
50671 | 393 |
"\nNo structured proof available (proof too simple)." |
49883 | 394 |
else |
395 |
"" |
|
396 |
| _ => |
|
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
397 |
let |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
398 |
val msg = |
51203 | 399 |
(if verbose then |
400 |
let |
|
52592
8a25b17e3d79
optimize isar-proofs by trying different proof methods
smolkas
parents:
52556
diff
changeset
|
401 |
val num_steps = add_proof_steps (steps_of_proof isar_proof) 0 |
51203 | 402 |
in [string_of_int num_steps ^ " step" ^ plural_s num_steps] end |
403 |
else |
|
404 |
[]) @ |
|
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
405 |
(if do_preplay then |
50924 | 406 |
[(if preplay_fail then "may fail, " else "") ^ |
52556
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
smolkas
parents:
52555
diff
changeset
|
407 |
string_of_preplay_time preplay_time] |
50670
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
408 |
else |
eaa540986291
properly take the existential closure of skolems
blanchet
parents:
50557
diff
changeset
|
409 |
[]) |
50277 | 410 |
in |
51741 | 411 |
"\n\nStructured proof" |
412 |
^ (commas msg |> not (null msg) ? enclose " (" ")") |
|
52697
6fb98a20c349
explicit padding on command boundary for "auto" generated sendback -- do not replace the corresponding goal command, but append to it;
wenzelm
parents:
52632
diff
changeset
|
413 |
^ ":\n" ^ |
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
414 |
Active.sendback_markup [Markup.padding_command] isar_text |
50277 | 415 |
end |
49883 | 416 |
end |
417 |
val isar_proof = |
|
418 |
if debug then |
|
419 |
isar_proof_of () |
|
420 |
else case try isar_proof_of () of |
|
421 |
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
|
422 |
| NONE => if isar_proofs = SOME true then |
49883 | 423 |
"\nWarning: The Isar proof construction failed." |
424 |
else |
|
425 |
"" |
|
426 |
in one_line_proof ^ isar_proof end |
|
427 |
||
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
|
428 |
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
|
429 |
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
|
430 |
Played (reconstr, _) => reconstr = SMT |
54093 | 431 |
| Trust_Playable _ => false |
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
|
432 |
| 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
|
433 |
|
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
434 |
fun proof_text ctxt isar_proofs isar_params num_chained |
49883 | 435 |
(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
|
436 |
(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
|
437 |
(isar_proofs = NONE andalso isar_proof_would_be_a_good_idea preplay) then |
54500 | 438 |
isar_proof_text ctxt isar_proofs (isar_params ()) |
49883 | 439 |
else |
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
440 |
one_line_proof_text num_chained) one_line_params |
49883 | 441 |
|
442 |
end; |