author | wenzelm |
Sun, 06 Jul 2025 15:26:59 +0200 | |
changeset 82820 | ae85cd17ffbe |
parent 82202 | a1f85f579a07 |
permissions | -rw-r--r-- |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_isar.ML |
49883 | 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 |
||
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
8 |
signature SLEDGEHAMMER_ISAR = |
49883 | 9 |
sig |
54771
85879aa61334
move some Z3 specifics out (and into private repository with the rest of the Z3-specific code)
blanchet
parents:
54770
diff
changeset
|
10 |
type atp_step_name = ATP_Proof.atp_step_name |
54495 | 11 |
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
|
12 |
type 'a atp_proof = 'a ATP_Proof.atp_proof |
49914 | 13 |
type stature = ATP_Problem_Generate.stature |
55287 | 14 |
type one_line_params = Sledgehammer_Proof_Methods.one_line_params |
49914 | 15 |
|
55222 | 16 |
val trace : bool Config.T |
17 |
||
49914 | 18 |
type isar_params = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
19 |
bool * (string option * string option * string list) * Time.time * real option * bool * bool |
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
20 |
* (term, string) atp_step list * thm |
49914 | 21 |
|
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70931
diff
changeset
|
22 |
val proof_text : Proof.context -> bool -> bool option -> bool -> (unit -> isar_params) -> int -> |
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70931
diff
changeset
|
23 |
one_line_params -> string |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
75956
diff
changeset
|
24 |
val abduce_text : Proof.context -> term list -> string |
49883 | 25 |
end; |
26 |
||
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
27 |
structure Sledgehammer_Isar : SLEDGEHAMMER_ISAR = |
49883 | 28 |
struct |
29 |
||
30 |
open ATP_Util |
|
49914 | 31 |
open ATP_Problem |
70931 | 32 |
open ATP_Problem_Generate |
49883 | 33 |
open ATP_Proof |
34 |
open ATP_Proof_Reconstruct |
|
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49917
diff
changeset
|
35 |
open Sledgehammer_Util |
55287 | 36 |
open Sledgehammer_Proof_Methods |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
37 |
open Sledgehammer_Isar_Proof |
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
38 |
open Sledgehammer_Isar_Preplay |
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
39 |
open Sledgehammer_Isar_Compress |
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55194
diff
changeset
|
40 |
open Sledgehammer_Isar_Minimize |
49914 | 41 |
|
42 |
structure String_Redirect = ATP_Proof_Redirect( |
|
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53052
diff
changeset
|
43 |
type key = atp_step_name |
49914 | 44 |
val ord = fn ((s, _ : string list), (s', _)) => fast_string_ord (s, s') |
45 |
val string_of = fst) |
|
46 |
||
49883 | 47 |
open String_Redirect |
48 |
||
69593 | 49 |
val trace = Attrib.setup_config_bool \<^binding>\<open>sledgehammer_isar_trace\<close> (K false) |
55222 | 50 |
|
57785 | 51 |
val e_definition_rule = "definition" |
57654
f89c0749533d
'shift_quantors' is not an E skolemization rule (cf. 3ab503b04bdb)
blanchet
parents:
57288
diff
changeset
|
52 |
val e_skolemize_rule = "skolemize" |
57759 | 53 |
val leo2_extcnf_forall_neg_rule = "extcnf_forall_neg" |
57709 | 54 |
val satallax_skolemize_rule = "tab_ex" |
79730
4031aafc2dda
deal with new-style Vampire skolemization in reconstructed Isar proofs
blanchet
parents:
79143
diff
changeset
|
55 |
val vampire_choice_axiom_rule = "choice_axiom" |
54746 | 56 |
val vampire_skolemisation_rule = "skolemisation" |
57761 | 57 |
val veriT_la_generic_rule = "la_generic" |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
58 |
val veriT_simp_arith_rule = "simp_arith" |
75956
1e2a9d2251b0
remove duplicate parsing for alethe; fix skolemization;
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75873
diff
changeset
|
59 |
val veriT_skolemize_rules = Lethe_Proof.skolemization_steps |
58061 | 60 |
val z3_skolemize_rule = Z3_Proof.string_of_rule Z3_Proof.Skolemize |
61 |
val z3_th_lemma_rule_prefix = Z3_Proof.string_of_rule (Z3_Proof.Th_Lemma "") |
|
57702
dfc834e39c1f
Skolemization support for leo-II and Zipperposition.
fleury
parents:
57699
diff
changeset
|
62 |
val zipperposition_cnf_rule = "cnf" |
54746 | 63 |
|
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
64 |
val symbol_introduction_rules = |
57785 | 65 |
[e_definition_rule, e_skolemize_rule, leo2_extcnf_forall_neg_rule, satallax_skolemize_rule, |
79730
4031aafc2dda
deal with new-style Vampire skolemization in reconstructed Isar proofs
blanchet
parents:
79143
diff
changeset
|
66 |
spass_skolemize_rule, vampire_choice_axiom_rule, vampire_skolemisation_rule, z3_skolemize_rule, |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
67 |
zipperposition_cnf_rule, zipperposition_define_rule] @ veriT_skolemize_rules |
54746 | 68 |
|
58653
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
69 |
fun is_ext_rule rule = (rule = leo2_extcnf_equal_neg_rule) |
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
70 |
val is_maybe_ext_rule = is_ext_rule orf String.isPrefix satallax_tab_rule_prefix |
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
71 |
|
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
72 |
val is_symbol_introduction_rule = member (op =) symbol_introduction_rules |
57761 | 73 |
fun is_arith_rule rule = |
57762 | 74 |
String.isPrefix z3_th_lemma_rule_prefix rule orelse rule = veriT_simp_arith_rule orelse |
57761 | 75 |
rule = veriT_la_generic_rule |
54755 | 76 |
|
54501 | 77 |
fun raw_label_of_num num = (num, 0) |
49914 | 78 |
|
54501 | 79 |
fun label_of_clause [(num, _)] = raw_label_of_num num |
80 |
| label_of_clause c = (space_implode "___" (map (fst o raw_label_of_num o fst) c), 0) |
|
50005 | 81 |
|
58653
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
82 |
fun add_global_fact ss = apsnd (union (op =) ss) |
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
83 |
|
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
84 |
fun add_fact_of_dependency [(_, ss as _ :: _)] = add_global_fact ss |
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
85 |
| add_fact_of_dependency names = apfst (insert (op =) (label_of_clause names)) |
49914 | 86 |
|
54799 | 87 |
fun add_line_pass1 (line as (name, role, t, rule, [])) lines = |
54770 | 88 |
(* No dependencies: lemma (for Z3), fact, conjecture, or (for Vampire) internal facts or |
89 |
definitions. *) |
|
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
90 |
if role = Conjecture orelse role = Negated_Conjecture then |
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
91 |
line :: lines |
69593 | 92 |
else if t aconv \<^prop>\<open>True\<close> then |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
93 |
map (replace_dependencies_in_line (name, [])) lines |
75123
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
94 |
else if role = Definition orelse role = Lemma orelse role = Hypothesis |
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
95 |
orelse is_arith_rule rule then |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
96 |
line :: lines |
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
97 |
else if role = Axiom then |
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
98 |
lines (* axioms (facts) need no proof lines *) |
57768
a63f14f1214c
fine-tuned Isar reconstruction, esp. boolean simplifications
blanchet
parents:
57767
diff
changeset
|
99 |
else |
a63f14f1214c
fine-tuned Isar reconstruction, esp. boolean simplifications
blanchet
parents:
57767
diff
changeset
|
100 |
map (replace_dependencies_in_line (name, [])) lines |
54755 | 101 |
| add_line_pass1 line lines = line :: lines |
49914 | 102 |
|
57771 | 103 |
fun add_lines_pass2 res [] = rev res |
104 |
| add_lines_pass2 res ((line as (name, role, t, rule, deps)) :: lines) = |
|
55184
6e2295db4cf8
keep formula right before skolemization, because the universal variables might be different (or differently ordered) as in the original axiom or negated conjecture from which it was skolemized
blanchet
parents:
55183
diff
changeset
|
105 |
let |
57791 | 106 |
fun normalize role = |
107 |
role = Conjecture ? (HOLogic.dest_Trueprop #> s_not #> HOLogic.mk_Trueprop) |
|
108 |
||
57771 | 109 |
val norm_t = normalize role t |
110 |
val is_duplicate = |
|
111 |
exists (fn (prev_name, prev_role, prev_t, _, _) => |
|
58514
1fc93ea5136b
eliminate duplicate hypotheses (which can arise due to (un)clausification)
blanchet
parents:
58506
diff
changeset
|
112 |
(prev_role = Hypothesis andalso prev_t aconv t) orelse |
1fc93ea5136b
eliminate duplicate hypotheses (which can arise due to (un)clausification)
blanchet
parents:
58506
diff
changeset
|
113 |
(member (op =) deps prev_name andalso |
1fc93ea5136b
eliminate duplicate hypotheses (which can arise due to (un)clausification)
blanchet
parents:
58506
diff
changeset
|
114 |
Term.aconv_untyped (normalize prev_role prev_t, norm_t))) |
57771 | 115 |
res |
57770
6c4ab6f0a6fc
normalize conjectures vs. negated conjectures when comparing terms
blanchet
parents:
57769
diff
changeset
|
116 |
|
69593 | 117 |
fun looks_boring () = t aconv \<^prop>\<open>False\<close> orelse length deps < 2 |
55184
6e2295db4cf8
keep formula right before skolemization, because the universal variables might be different (or differently ordered) as in the original axiom or negated conjecture from which it was skolemized
blanchet
parents:
55183
diff
changeset
|
118 |
|
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
119 |
fun is_symbol_introduction_line (_, _, _, rule', deps') = |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
120 |
is_symbol_introduction_rule rule' andalso member (op =) deps' name |
57770
6c4ab6f0a6fc
normalize conjectures vs. negated conjectures when comparing terms
blanchet
parents:
57769
diff
changeset
|
121 |
|
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
122 |
fun is_before_symbol_introduction_rule () = exists is_symbol_introduction_line lines |
55184
6e2295db4cf8
keep formula right before skolemization, because the universal variables might be different (or differently ordered) as in the original axiom or negated conjecture from which it was skolemized
blanchet
parents:
55183
diff
changeset
|
123 |
in |
57771 | 124 |
if is_duplicate orelse |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
125 |
(role = Plain andalso not (is_symbol_introduction_rule rule) andalso |
58653
4b44c227c0e0
improved handling of extensionality in Isar proofs generated from LEO-II and Satallax
blanchet
parents:
58517
diff
changeset
|
126 |
not (is_ext_rule rule) andalso not (is_arith_rule rule) andalso |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
127 |
not (null lines) andalso looks_boring () andalso |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
128 |
not (is_before_symbol_introduction_rule ())) then |
57771 | 129 |
add_lines_pass2 res (map (replace_dependencies_in_line (name, deps)) lines) |
55184
6e2295db4cf8
keep formula right before skolemization, because the universal variables might be different (or differently ordered) as in the original axiom or negated conjecture from which it was skolemized
blanchet
parents:
55183
diff
changeset
|
130 |
else |
57771 | 131 |
add_lines_pass2 (line :: res) lines |
55184
6e2295db4cf8
keep formula right before skolemization, because the universal variables might be different (or differently ordered) as in the original axiom or negated conjecture from which it was skolemized
blanchet
parents:
55183
diff
changeset
|
132 |
end |
49914 | 133 |
|
134 |
type isar_params = |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
135 |
bool * (string option * string option * string list) * Time.time * real option * bool * bool |
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
136 |
* (term, string) atp_step list * thm |
49914 | 137 |
|
78695 | 138 |
val basic_systematic_methods = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
139 |
[Metis_Method (NONE, NONE, []), Meson_Method, Blast_Method, SATx_Method, Argo_Method] |
78695 | 140 |
val basic_simp_based_methods = |
141 |
[Auto_Method, Simp_Method, Fastforce_Method, Force_Method] |
|
142 |
val basic_arith_methods = |
|
143 |
[Linarith_Method, Presburger_Method, Algebra_Method] |
|
55311 | 144 |
|
57744
a68b8db8691d
added appropriate method for skolemization of Z3 steps to the mix
blanchet
parents:
57741
diff
changeset
|
145 |
val arith_methods = basic_arith_methods @ basic_simp_based_methods @ basic_systematic_methods |
a68b8db8691d
added appropriate method for skolemization of Z3 steps to the mix
blanchet
parents:
57741
diff
changeset
|
146 |
val systematic_methods = |
a68b8db8691d
added appropriate method for skolemization of Z3 steps to the mix
blanchet
parents:
57741
diff
changeset
|
147 |
basic_systematic_methods @ basic_arith_methods @ basic_simp_based_methods @ |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
148 |
[Metis_Method (SOME full_typesN, NONE, []), Metis_Method (SOME no_typesN, NONE, [])] |
57744
a68b8db8691d
added appropriate method for skolemization of Z3 steps to the mix
blanchet
parents:
57741
diff
changeset
|
149 |
val rewrite_methods = basic_simp_based_methods @ basic_systematic_methods @ basic_arith_methods |
58517 | 150 |
val skolem_methods = Moura_Method :: systematic_methods |
54766
6ac273f176cd
store alternative proof methods in Isar data structure
blanchet
parents:
54765
diff
changeset
|
151 |
|
60612
79d71bfea310
removed chained facts from preplaying -- and careful about extra chained facts when removing 'proof -' and 'qed' from one-line Isar proofs
blanchet
parents:
59577
diff
changeset
|
152 |
fun isar_proof_text ctxt debug num_chained isar_proofs smt_proofs isar_params |
57739 | 153 |
(one_line_params as ((used_facts, (_, one_line_play)), banner, subgoal, subgoal_count)) = |
49883 | 154 |
let |
58843 | 155 |
val _ = if debug then writeln "Constructing Isar proof..." else () |
56097 | 156 |
|
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
157 |
fun generate_proof_text () = |
49883 | 158 |
let |
57791 | 159 |
val (verbose, alt_metis_args, preplay_timeout, compress, try0, minimize, atp_proof0, goal) = |
57245 | 160 |
isar_params () |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
161 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
162 |
if null atp_proof0 then |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
163 |
one_line_proof_text one_line_params |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
164 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
165 |
let |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
166 |
val systematic_methods' = insert (op =) (Metis_Method alt_metis_args) systematic_methods |
55168
948e8b7ea82f
correctly handle exceptions arising from (experimental) Isar proof code
blanchet
parents:
54838
diff
changeset
|
167 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
168 |
fun massage_methods (meths as meth :: _) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
169 |
if not try0 then [meth] |
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75124
diff
changeset
|
170 |
else if smt_proofs then insert (op =) (SMT_Method SMT_Z3) meths |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
171 |
else meths |
55168
948e8b7ea82f
correctly handle exceptions arising from (experimental) Isar proof code
blanchet
parents:
54838
diff
changeset
|
172 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
173 |
val (params, _, concl_t) = strip_subgoal goal subgoal ctxt |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
174 |
val fixes = map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
175 |
val ctxt = ctxt |> Variable.set_body false |> Proof_Context.add_fixes fixes |> snd |
55168
948e8b7ea82f
correctly handle exceptions arising from (experimental) Isar proof code
blanchet
parents:
54838
diff
changeset
|
176 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
177 |
val do_preplay = preplay_timeout <> Time.zeroTime |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
178 |
val compress = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
179 |
(case compress of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
180 |
NONE => if isar_proofs = NONE andalso do_preplay then 1000.0 else 10.0 |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
181 |
| SOME n => n) |
55168
948e8b7ea82f
correctly handle exceptions arising from (experimental) Isar proof code
blanchet
parents:
54838
diff
changeset
|
182 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
183 |
fun is_fixed ctxt = Variable.is_declared ctxt orf Name.is_skolem |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
184 |
fun introduced_symbols_of ctxt t = |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
185 |
Term.add_frees t [] |> filter_out (is_fixed ctxt o fst) |> rev |
54700 | 186 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
187 |
fun get_role keep_role ((num, _), role, t, rule, _) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
188 |
if keep_role role then SOME ((raw_label_of_num num, t), rule) else NONE |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
189 |
|
72355 | 190 |
val trace = Config.get ctxt trace |
191 |
||
192 |
val string_of_atp_steps = |
|
193 |
let val to_string = ATP_Proof.string_of_atp_step (Syntax.string_of_term ctxt) I in |
|
194 |
enclose "[\n" "\n]" o cat_lines o map (enclose " " "," o to_string) |
|
195 |
end |
|
196 |
||
197 |
val atp_proof = atp_proof0 |
|
198 |
|> trace ? tap (tracing o prefix "atp_proof0 = " o string_of_atp_steps) |
|
75047
7d2a5d1f09af
guard against duplicate lines in Zipperposition proofs
blanchet
parents:
72798
diff
changeset
|
199 |
|> distinct (op =) (* Zipperposition generates duplicate lines *) |
7d2a5d1f09af
guard against duplicate lines in Zipperposition proofs
blanchet
parents:
72798
diff
changeset
|
200 |
|> (fn lines => fold_rev add_line_pass1 lines []) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
201 |
|> add_lines_pass2 [] |
72355 | 202 |
|> trace ? tap (tracing o prefix "atp_proof = " o string_of_atp_steps) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
203 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
204 |
val conjs = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
205 |
map_filter (fn (name, role, _, _, _) => |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
206 |
if member (op =) [Conjecture, Negated_Conjecture] role then SOME name else NONE) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
207 |
atp_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
208 |
val assms = map_filter (Option.map fst o get_role (curry (op =) Hypothesis)) atp_proof |
57288
ffd928316c75
supports gradual skolemization (cf. Z3) by threading context through correctly
blanchet
parents:
57287
diff
changeset
|
209 |
|
72584 | 210 |
fun add_lemma ((label, goal), rule) ctxt = |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
211 |
let |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
212 |
val (obtains, proof_methods) = |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
213 |
(if is_symbol_introduction_rule rule then (introduced_symbols_of ctxt goal, skolem_methods) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
214 |
else if is_arith_rule rule then ([], arith_methods) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
215 |
else ([], rewrite_methods)) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
216 |
||> massage_methods |
72584 | 217 |
val prove = Prove { |
218 |
qualifiers = [], |
|
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
219 |
obtains = obtains, |
72584 | 220 |
label = label, |
221 |
goal = goal, |
|
222 |
subproofs = [], |
|
223 |
facts = ([], []), |
|
224 |
proof_methods = proof_methods, |
|
225 |
comment = ""} |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
226 |
in |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
227 |
(prove, ctxt |> not (null obtains) ? (Variable.add_fixes (map fst obtains) #> snd)) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
228 |
end |
57288
ffd928316c75
supports gradual skolemization (cf. Z3) by threading context through correctly
blanchet
parents:
57287
diff
changeset
|
229 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
230 |
val (lems, _) = |
75123
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
231 |
fold_map add_lemma (map_filter (get_role (member (op =) [Definition, Lemma])) |
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
232 |
atp_proof) ctxt |
54700 | 233 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
234 |
val bot = #1 (List.last atp_proof) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
235 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
236 |
val refute_graph = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
237 |
atp_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
238 |
|> map (fn (name, _, _, _, from) => (from, name)) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
239 |
|> make_refute_graph bot |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
240 |
|> fold (Atom_Graph.default_node o rpair ()) conjs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
241 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
242 |
val axioms = axioms_of_refute_graph refute_graph conjs |
54700 | 243 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
244 |
val tainted = tainted_atoms_of_refute_graph refute_graph conjs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
245 |
val is_clause_tainted = exists (member (op =) tainted) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
246 |
val steps = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
247 |
Symtab.empty |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
248 |
|> fold (fn (name as (s, _), role, t, rule, _) => |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
249 |
Symtab.update_new (s, (rule, t |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
250 |
|> (if is_clause_tainted [name] then |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
251 |
HOLogic.dest_Trueprop |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
252 |
#> role <> Conjecture ? s_not |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
253 |
#> fold exists_of (map Var (Term.add_vars t [])) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
254 |
#> HOLogic.mk_Trueprop |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
255 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
256 |
I)))) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
257 |
atp_proof |
58516
1edba0152491
insert lemmas closer to where they are needed, both for esthetics and (primarily) for correctness in case the lemma refers to a skolem
blanchet
parents:
58514
diff
changeset
|
258 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
259 |
fun is_referenced_in_step _ (Let _) = false |
72584 | 260 |
| is_referenced_in_step l (Prove {subproofs, facts = (ls, _), ...}) = |
261 |
member (op =) ls l orelse exists (is_referenced_in_proof l) subproofs |
|
72582 | 262 |
and is_referenced_in_proof l (Proof {steps, ...}) = |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
263 |
exists (is_referenced_in_step l) steps |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
264 |
|
78696
ef89f1beee95
parse applie lambdas correctly plus deal gracefully with lambda-lifting in Zipperposition
blanchet
parents:
78695
diff
changeset
|
265 |
(* We try to introduce pure lemmas (not "obtains") close to where |
ef89f1beee95
parse applie lambdas correctly plus deal gracefully with lambda-lifting in Zipperposition
blanchet
parents:
78695
diff
changeset
|
266 |
they are used. *) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
267 |
fun insert_lemma_in_step lem |
75057
79b4e711d6a2
robustly handle empty proof blocks in Isar proof output
blanchet
parents:
75051
diff
changeset
|
268 |
(step as Prove {qualifiers, obtains, label, goal, subproofs, facts = (ls, gs), |
79b4e711d6a2
robustly handle empty proof blocks in Isar proof output
blanchet
parents:
75051
diff
changeset
|
269 |
proof_methods, comment}) = |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
270 |
let val l' = the (label_of_isar_step lem) in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
271 |
if member (op =) ls l' then |
58517 | 272 |
[lem, step] |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
273 |
else |
72584 | 274 |
let val refs = map (is_referenced_in_proof l') subproofs in |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
275 |
if length (filter I refs) = 1 then |
72584 | 276 |
[Prove { |
277 |
qualifiers = qualifiers, |
|
278 |
obtains = obtains, |
|
279 |
label = label, |
|
280 |
goal = goal, |
|
281 |
subproofs = |
|
282 |
map2 (fn false => I | true => insert_lemma_in_proof lem) refs subproofs, |
|
283 |
facts = (ls, gs), |
|
284 |
proof_methods = proof_methods, |
|
285 |
comment = comment}] |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
286 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
287 |
[lem, step] |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
288 |
end |
58517 | 289 |
end |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
290 |
and insert_lemma_in_steps lem [] = [lem] |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
291 |
| insert_lemma_in_steps lem (step :: steps) = |
78696
ef89f1beee95
parse applie lambdas correctly plus deal gracefully with lambda-lifting in Zipperposition
blanchet
parents:
78695
diff
changeset
|
292 |
if not (null (obtains_of_isar_step lem)) |
ef89f1beee95
parse applie lambdas correctly plus deal gracefully with lambda-lifting in Zipperposition
blanchet
parents:
78695
diff
changeset
|
293 |
orelse is_referenced_in_step (the (label_of_isar_step lem)) step then |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
294 |
insert_lemma_in_step lem step @ steps |
54700 | 295 |
else |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
296 |
step :: insert_lemma_in_steps lem steps |
72583 | 297 |
and insert_lemma_in_proof lem (proof as Proof {steps, ...}) = |
72585 | 298 |
isar_proof_with_steps proof (insert_lemma_in_steps lem steps) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
299 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
300 |
val rule_of_clause_id = fst o the o Symtab.lookup steps o fst |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
301 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
302 |
val finish_off = close_form #> rename_bound_vars |
54755 | 303 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
304 |
fun prop_of_clause [(num, _)] = Symtab.lookup steps num |> the |> snd |> finish_off |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
305 |
| prop_of_clause names = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
306 |
let |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
307 |
val lits = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
308 |
map (HOLogic.dest_Trueprop o snd) (map_filter (Symtab.lookup steps o fst) names) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
309 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
310 |
(case List.partition (can HOLogic.dest_not) lits of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
311 |
(negs as _ :: _, pos as _ :: _) => |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
312 |
s_imp (Library.foldr1 s_conj (map HOLogic.dest_not negs), |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
313 |
Library.foldr1 s_disj pos) |
69593 | 314 |
| _ => fold (curry s_disj) lits \<^term>\<open>False\<close>) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
315 |
end |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
316 |
|> HOLogic.mk_Trueprop |> finish_off |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
317 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
318 |
fun maybe_show outer c = if outer andalso eq_set (op =) (c, conjs) then [Show] else [] |
55280 | 319 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
320 |
fun isar_steps outer predecessor accum [] = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
321 |
accum |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
322 |
|> (if tainted = [] then |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
323 |
(* e.g., trivial, empty proof by Z3 *) |
72584 | 324 |
cons (Prove { |
325 |
qualifiers = if outer then [Show] else [], |
|
326 |
obtains = [], |
|
327 |
label = no_label, |
|
328 |
goal = concl_t, |
|
329 |
subproofs = [], |
|
330 |
facts = sort_facts (the_list predecessor, []), |
|
331 |
proof_methods = massage_methods systematic_methods', |
|
332 |
comment = ""}) |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
333 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
334 |
I) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
335 |
|> rev |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
336 |
| isar_steps outer _ accum (Have (id, (gamma, c)) :: infs) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
337 |
let |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
338 |
val l = label_of_clause c |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
339 |
val t = prop_of_clause c |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
340 |
val rule = rule_of_clause_id id |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
341 |
val introduces_symbols = is_symbol_introduction_rule rule |
54700 | 342 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
343 |
val deps = ([], []) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
344 |
|> fold add_fact_of_dependency gamma |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
345 |
|> is_maybe_ext_rule rule ? add_global_fact [short_thm_name ctxt ext] |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
346 |
|> sort_facts |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
347 |
val meths = |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
348 |
(if introduces_symbols then skolem_methods |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
349 |
else if is_arith_rule rule then arith_methods |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
350 |
else systematic_methods') |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
351 |
|> massage_methods |
55214
48a347b40629
better tracing + syntactically correct 'metis' calls
blanchet
parents:
55213
diff
changeset
|
352 |
|
72584 | 353 |
fun prove subproofs facts = Prove { |
354 |
qualifiers = maybe_show outer c, |
|
355 |
obtains = [], |
|
356 |
label = l, |
|
357 |
goal = t, |
|
358 |
subproofs = subproofs, |
|
359 |
facts = facts, |
|
360 |
proof_methods = meths, |
|
361 |
comment = ""} |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
362 |
fun steps_of_rest step = isar_steps outer (SOME l) (step :: accum) infs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
363 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
364 |
if is_clause_tainted c then |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
365 |
(case gamma of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
366 |
[g] => |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
367 |
if introduces_symbols andalso is_clause_tainted g andalso not (null accum) then |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
368 |
let |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
369 |
val fixes = introduced_symbols_of ctxt (prop_of_clause g) |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
370 |
val subproof = Proof {fixes = fixes, assumptions = [], steps = rev accum} |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
371 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
372 |
isar_steps outer (SOME l) [prove [subproof] ([], [])] infs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
373 |
end |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
374 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
375 |
steps_of_rest (prove [] deps) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
376 |
| _ => steps_of_rest (prove [] deps)) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
377 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
378 |
steps_of_rest |
75124
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
379 |
(if introduces_symbols then |
f12539c8de0c
more handling of Zipperposition definitions in Isar proof construction
blanchet
parents:
75123
diff
changeset
|
380 |
(case introduced_symbols_of ctxt t of |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
381 |
[] => prove [] deps |
72584 | 382 |
| skos => Prove { |
383 |
qualifiers = [], |
|
384 |
obtains = skos, |
|
385 |
label = l, |
|
386 |
goal = t, |
|
387 |
subproofs = [], |
|
388 |
facts = deps, |
|
389 |
proof_methods = meths, |
|
390 |
comment = ""}) |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
391 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
392 |
prove [] deps) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
393 |
end |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
394 |
| isar_steps outer predecessor accum (Cases cases :: infs) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
395 |
let |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
396 |
fun isar_case (c, subinfs) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
397 |
isar_proof false [] [(label_of_clause c, prop_of_clause c)] [] subinfs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
398 |
val c = succedent_of_cases cases |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
399 |
val l = label_of_clause c |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
400 |
val t = prop_of_clause c |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
401 |
val step = |
72584 | 402 |
Prove { |
403 |
qualifiers = maybe_show outer c, |
|
404 |
obtains = [], |
|
405 |
label = l, |
|
406 |
goal = t, |
|
407 |
subproofs = map isar_case (filter_out (null o snd) cases), |
|
408 |
facts = sort_facts (the_list predecessor, []), |
|
409 |
proof_methods = massage_methods systematic_methods', |
|
410 |
comment = ""} |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
411 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
412 |
isar_steps outer (SOME l) (step :: accum) infs |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
413 |
end |
72582 | 414 |
and isar_proof outer fixes assumptions lems infs = |
415 |
let val steps = fold_rev insert_lemma_in_steps lems (isar_steps outer NONE [] infs) in |
|
416 |
Proof {fixes = fixes, assumptions = assumptions, steps = steps} |
|
417 |
end |
|
55214
48a347b40629
better tracing + syntactically correct 'metis' calls
blanchet
parents:
55213
diff
changeset
|
418 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
419 |
val canonical_isar_proof = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
420 |
refute_graph |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
421 |
|> trace ? tap (tracing o prefix "Refute graph:\n" o string_of_refute_graph) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
422 |
|> redirect_graph axioms tainted bot |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
423 |
|> trace ? tap (tracing o prefix "Direct proof:\n" o string_of_direct_proof) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
424 |
|> isar_proof true params assms lems |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
425 |
|> postprocess_isar_proof_remove_show_stuttering |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
426 |
|> postprocess_isar_proof_remove_unreferenced_steps I |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
427 |
|> relabel_isar_proof_canonically |
54754 | 428 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
429 |
val ctxt = ctxt |> enrich_context_with_local_facts canonical_isar_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
430 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
431 |
val preplay_data = Unsynchronized.ref Canonical_Label_Tab.empty |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
432 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
433 |
val _ = fold_isar_steps (fn meth => |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
434 |
K (set_preplay_outcomes_of_isar_step ctxt preplay_timeout preplay_data meth [])) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
435 |
(steps_of_isar_proof canonical_isar_proof) () |
55299 | 436 |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
437 |
fun str_of_preplay_outcome outcome = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
438 |
if Lazy.is_finished outcome then string_of_play_outcome (Lazy.force outcome) else "?" |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
439 |
fun str_of_meth l meth = |
72401
2783779b7dd3
removed obsolete unmaintained experimental prover Pirate
blanchet
parents:
72355
diff
changeset
|
440 |
string_of_proof_method [] meth ^ " " ^ |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
441 |
str_of_preplay_outcome |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
442 |
(preplay_outcome_of_isar_step_for_method (!preplay_data) l meth) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
443 |
fun comment_of l = map (str_of_meth l) #> commas |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
444 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
445 |
fun trace_isar_proof label proof = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
446 |
if trace then |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
447 |
tracing (timestamp () ^ "\n" ^ label ^ ":\n\n" ^ |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
448 |
string_of_isar_proof ctxt subgoal subgoal_count |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
449 |
(comment_isar_proof comment_of proof) ^ "\n") |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
450 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
451 |
() |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
452 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
453 |
fun comment_of l (meth :: _) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
454 |
(case (verbose, |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
455 |
Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth)) of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
456 |
(false, Played _) => "" |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
457 |
| (_, outcome) => string_of_play_outcome outcome) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
458 |
|
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
459 |
val (play_outcome, isar_proof) = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
460 |
canonical_isar_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
461 |
|> tap (trace_isar_proof "Original") |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
462 |
|> compress_isar_proof ctxt compress preplay_timeout preplay_data |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
463 |
|> tap (trace_isar_proof "Compressed") |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
464 |
|> postprocess_isar_proof_remove_unreferenced_steps |
75051
1a8f6cb5efd6
don't perform preplaying steps if preplaying is disabled
blanchet
parents:
75049
diff
changeset
|
465 |
(do_preplay ? keep_fastest_method_of_isar_step (!preplay_data) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
466 |
#> minimize ? minimize_isar_step_dependencies ctxt preplay_data) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
467 |
|> tap (trace_isar_proof "Minimized") |
75123
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
468 |
|> `(if do_preplay then preplay_outcome_of_isar_proof (!preplay_data) |
66eb6fdfc244
handle Zipperposition definitions in Isar proof construction
blanchet
parents:
75057
diff
changeset
|
469 |
else K (Play_Timed_Out Time.zeroTime)) |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
470 |
||> (comment_isar_proof comment_of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
471 |
#> chain_isar_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
472 |
#> kill_useless_labels_in_isar_proof |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
473 |
#> relabel_isar_proof_nicely |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
474 |
#> rationalize_obtains_in_isar_proofs ctxt) |
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
475 |
in |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
476 |
(case (num_chained, add_isar_steps (steps_of_isar_proof isar_proof) 0) of |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
477 |
(0, 1) => |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
478 |
one_line_proof_text |
67560 | 479 |
(if is_less (play_outcome_ord (play_outcome, one_line_play)) then |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
480 |
(case isar_proof of |
79143 | 481 |
Proof {steps = [Prove {qualifiers = [Show], facts = (_, gfs), |
482 |
proof_methods = meth :: _, ...}], ...} => |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
483 |
let |
68668
c9570658e8f1
don't lose facts that were introduced to deal with a theory or some preprocessing in the prover (e.g. the definition of 'abs' in an SMT proof)
blanchet
parents:
67560
diff
changeset
|
484 |
val used_facts' = |
c9570658e8f1
don't lose facts that were introduced to deal with a theory or some preprocessing in the prover (e.g. the definition of 'abs' in an SMT proof)
blanchet
parents:
67560
diff
changeset
|
485 |
map_filter (fn s => |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
486 |
if exists (fn (p, (sc, _)) => content_of_pretty p = s andalso |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
487 |
sc = Chained) used_facts then |
68668
c9570658e8f1
don't lose facts that were introduced to deal with a theory or some preprocessing in the prover (e.g. the definition of 'abs' in an SMT proof)
blanchet
parents:
67560
diff
changeset
|
488 |
NONE |
c9570658e8f1
don't lose facts that were introduced to deal with a theory or some preprocessing in the prover (e.g. the definition of 'abs' in an SMT proof)
blanchet
parents:
67560
diff
changeset
|
489 |
else |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
79730
diff
changeset
|
490 |
SOME (Pretty.str s, (Global, General))) gfs |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
491 |
in |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
492 |
((used_facts', (meth, play_outcome)), banner, subgoal, subgoal_count) |
79143 | 493 |
end |
494 |
| _ => one_line_params) |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
495 |
else |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
496 |
one_line_params) ^ |
75049 | 497 |
(if isar_proofs = SOME true then "\n(No Isar proof available)" else "") |
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
498 |
| (_, num_steps) => |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
499 |
let |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
500 |
val msg = |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
501 |
(if verbose then [string_of_int num_steps ^ " step" ^ plural_s num_steps] |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
502 |
else []) @ |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
503 |
(if do_preplay then [string_of_play_outcome play_outcome] else []) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
504 |
in |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
505 |
one_line_proof_text one_line_params ^ |
75873 | 506 |
(if isar_proofs <> NONE orelse (case play_outcome of Played _ => true | _ => false) then |
507 |
"\n\nIsar proof" ^ (commas msg |> not (null msg) ? enclose " (" ")") ^ ":\n" ^ |
|
508 |
Active.sendback_markup_command |
|
509 |
(string_of_isar_proof ctxt subgoal subgoal_count isar_proof) |
|
510 |
else |
|
511 |
"") |
|
62220
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
512 |
end) |
0e17a97234bd
avoid error in Isar proof reconstruction if no ATP proof is available
blanchet
parents:
60612
diff
changeset
|
513 |
end |
49883 | 514 |
end |
57056 | 515 |
in |
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
516 |
if debug then |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
517 |
generate_proof_text () |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
518 |
else |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
519 |
(case try generate_proof_text () of |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
520 |
SOME s => s |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57286
diff
changeset
|
521 |
| NONE => |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
522 |
one_line_proof_text one_line_params ^ |
63692 | 523 |
(if isar_proofs = SOME true then "\nWarning: Isar proof construction failed" else "")) |
57056 | 524 |
end |
49883 | 525 |
|
72355 | 526 |
fun isar_proof_would_be_a_good_idea (_, play) = |
54824 | 527 |
(case play of |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70931
diff
changeset
|
528 |
Played _ => false |
62826 | 529 |
| Play_Timed_Out time => time > Time.zeroTime |
56093 | 530 |
| Play_Failed => true) |
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
|
531 |
|
55297
1dfcd49f5dcb
renamed 'smt' option 'smt_proofs' to avoid clash with 'smt' prover
blanchet
parents:
55296
diff
changeset
|
532 |
fun proof_text ctxt debug isar_proofs smt_proofs isar_params num_chained |
57739 | 533 |
(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
|
534 |
(if isar_proofs = SOME true orelse |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70931
diff
changeset
|
535 |
(isar_proofs = NONE andalso isar_proof_would_be_a_good_idea preplay) then |
60612
79d71bfea310
removed chained facts from preplaying -- and careful about extra chained facts when removing 'proof -' and 'qed' from one-line Isar proofs
blanchet
parents:
59577
diff
changeset
|
536 |
isar_proof_text ctxt debug num_chained isar_proofs smt_proofs isar_params |
49883 | 537 |
else |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
538 |
one_line_proof_text) one_line_params |
49883 | 539 |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
75956
diff
changeset
|
540 |
fun abduce_text ctxt tms = |
77425 | 541 |
"Candidate missing assumption" ^ plural_s (length tms) ^ ":\n" ^ |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
75956
diff
changeset
|
542 |
cat_lines (map (Syntax.string_of_term ctxt) tms) |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
75956
diff
changeset
|
543 |
|
49883 | 544 |
end; |