walther@60119
|
1 |
(* Title: test/HOL/Tools/Sledgehammer/Try_Sledgehammer.thy
|
walther@60119
|
2 |
Author: Florian Kammüller, Cambridge University Computer Laboratory
|
walther@60119
|
3 |
*)
|
walther@60119
|
4 |
|
walther@60119
|
5 |
theory Try_Sledgehammer
|
walther@60119
|
6 |
imports
|
walther@60119
|
7 |
(** )Main "HOL-Library.FuncSet"( *..for HOL/Metis_Examples/Tarski.thy*)
|
walther@60119
|
8 |
(** )HOL.Real "HOL-Library.Quotient_Product"( *..for HOL/Nitpick_Examples/Manual_Nits.thy*)
|
walther@60119
|
9 |
(** )"HOL-Decision_Procs.Dense_Linear_Order" "HOL-Library.Function_Algebras"
|
walther@60119
|
10 |
"HOL-Library.Set_Algebras"( *..for HOL/Metis_Examples/Big_O.thy*)
|
walther@60119
|
11 |
(**)"~~/src/HOL/Metis_Examples/Type_Encodings"(*..for HOL/Metis_Examples/Proxies.thy*)
|
walther@60119
|
12 |
|
walther@60119
|
13 |
begin
|
walther@60119
|
14 |
|
walther@60120
|
15 |
section \<open>Notes during development\<close>
|
walther@60120
|
16 |
text \<open>
|
walther@60120
|
17 |
Main question at the beginning:
|
walther@60121
|
18 |
How present a structure comprising keywords and terms via PIDE?
|
walther@60121
|
19 |
|
walther@60121
|
20 |
Preliminary conclusion:
|
walther@60121
|
21 |
The above main question could not yet be answered due to the complexity of Isabelle:
|
walther@60121
|
22 |
* typing "sledgehammer" into a theory, e.g. in lemma "inc \<noteq> (\<lambda>y. 0)" below
|
walther@60121
|
23 |
creates an instance of isar_proofs.
|
walther@60121
|
24 |
* this proof is displayed in an <Output> window
|
walther@60121
|
25 |
* clicking the proof transfers to the theory, i.e. below lemma "inc \<noteq> (\<lambda>y. 0)"
|
walther@60121
|
26 |
The latter is what we are interested in, but we cannot find the respective code,
|
walther@60121
|
27 |
which we expect somewhere far off from Outer_Syntax.command..sledgehammer.
|
walther@60120
|
28 |
\<close>
|
walther@60119
|
29 |
subsection \<open>Documentation and papers\<close>
|
walther@60119
|
30 |
text \<open>
|
walther@60119
|
31 |
implementation.pdf
|
walther@60119
|
32 |
Proof_Syntax.read_proof thy b1 b2 s reads in a proof term. The Boolean
|
walther@60119
|
33 |
flags indicate the use of sort and type information. Usually, typing
|
walther@60119
|
34 |
information is left implicit and is inferred during proof reconstruction.
|
walther@60119
|
35 |
sledgehammer.pdf
|
walther@60119
|
36 |
• verit: veriT [6] is an SMT solver developed by David Déharbe,
|
walther@60119
|
37 |
Pascal Fontaine, and their colleagues. It is specifically designed
|
walther@60119
|
38 |
to produce detailed proofs for reconstruction in proof assistants.
|
walther@60119
|
39 |
To use veriT, set the environment variable VERIT_SOLVER to the
|
walther@60119
|
40 |
complete path of the executable, including the file name. Sledge-
|
walther@60119
|
41 |
hammer has been tested with version smtcomp2019. (..NOT Mathias Fleury)
|
walther@60119
|
42 |
isar-ref.pdf //
|
walther@60119
|
43 |
Reconstructing veriT Proofs in Isabelle/HOL
|
walther@60119
|
44 |
https://arxiv.org/pdf/1908.09480.pdf
|
walther@60119
|
45 |
http://fmv.jku.at/fleury/papers/Fleury-thesis.pdf
|
walther@60119
|
46 |
\<close>
|
walther@60119
|
47 |
|
walther@60119
|
48 |
subsection \<open>code\<close>
|
walther@60119
|
49 |
subsubsection \<open>1st approach\<close>
|
walther@60119
|
50 |
text \<open>
|
walther@60119
|
51 |
HOL/ex/Sketch_and_Explore.thy by Haftmann
|
walther@60119
|
52 |
|> Sledgehammer_Isar_Annotate.annotate_types_in_term ctxt
|
walther@60119
|
53 |
HOL/List.thy
|
walther@60119
|
54 |
imports Sledgehammer
|
walther@60119
|
55 |
HOL/Metis_Examples/Proxies.thy
|
walther@60119
|
56 |
:
|
walther@60119
|
57 |
HOL/Metis_Examples/Type_Encodings.thy
|
walther@60119
|
58 |
HOL/Tools/Sledgehammer/sledgehammer_isar.ML
|
walther@60119
|
59 |
:
|
walther@60119
|
60 |
HOL/Sledgehammer.thy
|
walther@60119
|
61 |
keywords "sledgehammer" :: diag and
|
walther@60119
|
62 |
\<close>
|
walther@60121
|
63 |
subsubsection \<open>survey search: "sledgehammer" , search: "isar_proofs"\<close>
|
walther@60120
|
64 |
text \<open>
|
walther@60120
|
65 |
ALL hits concerning ML only (no calls from thy in proofs):
|
walther@60120
|
66 |
src/HOL/Mirabelle/Tools/mirabelle_sledgehammer.ML "isar_proofs" "sledgehammer"
|
walther@60120
|
67 |
src/HOL/Mutabelle/mutabelle_extra.ML "sledgehammer"
|
walther@60120
|
68 |
src/HOL/Tools/Sledgehammer/sledgehammer.ML "sledgehammer"
|
walther@60120
|
69 |
src/HOL/Tools/Sledgehammer/sledgehammer_commands.ML "isar_proofs" "sledgehammer"
|
walther@60120
|
70 |
src/HOL/Tools/Sledgehammer/sledgehammer_isar.ML "isar_proofs"
|
walther@60120
|
71 |
src/HOL/Tools/Sledgehammer/sledgehammer_prover_atp.ML "isar_proofs"
|
walther@60120
|
72 |
src/HOL/Tools/Sledgehammer/sledgehammer_prover_minimize.ML "isar_proofs"
|
walther@60120
|
73 |
src/HOL/Tools/Sledgehammer/sledgehammer_prover.ML "isar_proofs"
|
walther@60120
|
74 |
src/HOL/Tools/Sledgehammer/sledgehammer_prover_smt.ML "isar_proofs"
|
walther@60120
|
75 |
src/HOL/Tools/Sledgehammer/sledgehammer_util.ML "sledgehammer"
|
walther@60120
|
76 |
\<close>
|
walther@60121
|
77 |
subsubsection \<open>Try to trace code from keywords down to isar_proofs\<close>
|
walther@60119
|
78 |
text \<open>
|
walther@60121
|
79 |
HOL/Sledgehammer.thy
|
walther@60121
|
80 |
"sledgehammer" :: diag and "sledgehammer_params" :: thy_decl
|
walther@60121
|
81 |
HOL/Tools/Sledgehammer/sledgehammer_commands.ML
|
walther@60121
|
82 |
Outer_Syntax.command
|
walther@60121
|
83 |
val isar_proofs = lookup_option lookup_bool "isar_proofs"
|
walther@60121
|
84 |
in hammer_away override_params (SOME writeln_result) runN NONE no_fact_override state end
|
walther@60121
|
85 |
val hammer_away: (string * string list) list -> (string -> unit) option -> string ->
|
walther@60121
|
86 |
int option -> fact_override -> Proof.state -> unit
|
walther@60121
|
87 |
^^^^^^^^^^^
|
walther@60121
|
88 |
.. called by (exclusively)
|
walther@60121
|
89 |
Outer_Syntax.command command_keyword>\<open>sledgehammer\<close>
|
walther@60121
|
90 |
Query_Operation.register {name = sledgehammerN, pri = 0}
|
walther@60121
|
91 |
HOL/Tools/Sledgehammer/sledgehammer.ML
|
walther@60121
|
92 |
val run_sledgehammer : params -> mode -> (string -> unit) option -> int -> fact_override ->
|
walther@60121
|
93 |
Proof.state -> bool * (string * string list)
|
walther@60121
|
94 |
^^^^^^^^^^^
|
walther@60121
|
95 |
|
walther@60121
|
96 |
HOL/Tools/Sledgehammer/sledgehammer_isar.ML
|
walther@60121
|
97 |
fun isar_proof_text
|
walther@60121
|
98 |
val ///
|
walther@60121
|
99 |
fun proof_text
|
walther@60121
|
100 |
val proof_text : Proof.context -> bool -> bool option -> bool option -> (unit -> isar_params) ->
|
walther@60121
|
101 |
int -> one_line_params -> string
|
walther@60121
|
102 |
^^^^^^^^^^ is called in ..
|
walther@60121
|
103 |
HOL/Tools/Sledgehammer/sledgehammer_prover_atp.ML
|
walther@60121
|
104 |
fun run_atp ..calls fun proof_text
|
walther@60121
|
105 |
HOL/Tools/Sledgehammer/sledgehammer_prover_smt.ML
|
walther@60121
|
106 |
fun run_smt_solver ..calls fun proof_text
|
walther@60121
|
107 |
|
walther@60121
|
108 |
DIFFICULTY: see conclusion below section \<open>Notes during development\<close>
|
walther@60119
|
109 |
\<close>
|
walther@60119
|
110 |
|
walther@60121
|
111 |
section \<open>Search for an appropriate example\<close>
|
walther@60119
|
112 |
text \<open>
|
walther@60120
|
113 |
Conclusion: from the locations checked the best example is lemma "inc \<noteq> (\<lambda>y. 0)"
|
walther@60121
|
114 |
here at the bottom.
|
walther@60119
|
115 |
\<close>
|
walther@60119
|
116 |
|
walther@60119
|
117 |
subsection \<open>sledgehammer.pdf\<close>
|
walther@60119
|
118 |
text \<open>
|
walther@60121
|
119 |
Summary: There are only two examples and only one is working.
|
walther@60119
|
120 |
And there are no differences between sledgehammer with [isar_proofs] and without.
|
walther@60119
|
121 |
\<close>
|
walther@60119
|
122 |
subsubsection \<open>WITHOUT <Isar proofs> checked in Sledgehammer panel\<close>
|
walther@60119
|
123 |
(*p.5*)
|
walther@60119
|
124 |
lemma "[a] = [b] \<Longrightarrow> a = b"
|
walther@60119
|
125 |
(** )sledgehammer( **)
|
walther@60119
|
126 |
by blast
|
walther@60119
|
127 |
|
walther@60120
|
128 |
(*/----------------------- these tests run into: all provers timed out --------------------\* )
|
walther@60119
|
129 |
(*p.23*)
|
walther@60119
|
130 |
lemma "\<exists>xs. xs 6 = []"
|
walther@60119
|
131 |
(**)sledgehammer [strict] (add: list.distinct)(** ) ..all provers timed out( **)
|
walther@60119
|
132 |
sorry
|
walther@60119
|
133 |
|
walther@60119
|
134 |
subsubsection \<open>with <Isar proofs> checked in Sledgehammer panel\<close>
|
walther@60119
|
135 |
(*p.5*)
|
walther@60119
|
136 |
lemma "[a] = [b] \<Longrightarrow> a = b"
|
walther@60119
|
137 |
(** )sledgehammer(**)[isar_proofs]( **)
|
walther@60119
|
138 |
by simp(** ) ..Check <Isar proofs>: (No Isar proof available.)( **)
|
walther@60119
|
139 |
|
walther@60119
|
140 |
(*p.23*)
|
walther@60119
|
141 |
lemma "\<exists>xs. xs 6 = []"
|
walther@60119
|
142 |
(**)sledgehammer [strict] (add: list.distinct)(** ) ..all provers timed out( **)
|
walther@60119
|
143 |
sorry
|
walther@60120
|
144 |
( *\----------------------- these tests run into: all provers timed out --------------------/*)
|
walther@60119
|
145 |
|
walther@60119
|
146 |
|
walther@60119
|
147 |
subsection \<open>HOL/Metis_Examples/Tarski.thy\<close>
|
walther@60119
|
148 |
text \<open>
|
walther@60119
|
149 |
Summary: We use sledgehammer [isar_proofs] + <Isar proofs> checked in Sledgehammer panel.
|
walther@60119
|
150 |
Little knowledge required: Main + FuncSet.thy (\<in> HOL-Library)
|
walther@60119
|
151 |
-- but the first "sledgehammer" is after ca.10 pages.
|
walther@60119
|
152 |
\<close>
|
walther@60119
|
153 |
|
walther@60119
|
154 |
subsection \<open>HOL/Nitpick_Examples/Manual_Nits.thy\<close>
|
walther@60119
|
155 |
text \<open>
|
walther@60119
|
156 |
Summary: We use sledgehammer [isar_proofs] + <Isar proofs> checked in Sledgehammer panel.
|
walther@60119
|
157 |
Little knowledge required: HOL.Real + "HOL-Library.Quotient_Product"
|
walther@60119
|
158 |
-- and the first "sledgehammer" is already on 2nd page.
|
walther@60119
|
159 |
|
walther@60119
|
160 |
Works with Big_O.thy, Proxies.thy,
|
walther@60119
|
161 |
|
walther@60119
|
162 |
Summary: preparation is simple, and the output has 2 keywords.
|
walther@60119
|
163 |
\<close>
|
walther@60119
|
164 |
(*/------------------------------ preparing the subsequent example ---------------------------\*)
|
walther@60119
|
165 |
(*NONE*)
|
walther@60119
|
166 |
(*\------------------------------ preparing the subsequent example ---------------------------/*)
|
walther@60119
|
167 |
lemma "\<exists>!x. x \<in> A \<Longrightarrow> (THE y. y \<in> A) \<in> A"
|
walther@60119
|
168 |
nitpick [expect = none]
|
walther@60119
|
169 |
nitpick [card 'a = 1-50, expect = none]
|
walther@60119
|
170 |
(** )sledgehammer( **)
|
walther@60119
|
171 |
using the_equality by fastforce
|
walther@60119
|
172 |
|
walther@60119
|
173 |
|
walther@60119
|
174 |
subsection \<open>HOL/Metis_Examples/Big_O.thy\<close>
|
walther@60119
|
175 |
text \<open>
|
walther@60119
|
176 |
We use sledgehammer [isar_proofs] + <Isar proofs> checked in Sledgehammer panel.
|
walther@60119
|
177 |
Little knowledge required: HOL-Library.Set_Algebras
|
walther@60119
|
178 |
-- and the first "sledgehammer" is on 5th page.
|
walther@60119
|
179 |
|
walther@60120
|
180 |
Summary: sledgehammer does NOT work in the 1st example, NOT even in the original theory.
|
walther@60119
|
181 |
\<close>
|
walther@60119
|
182 |
|
walther@60119
|
183 |
subsection \<open>HOL/Metis_Examples/Proxies.thy\<close>
|
walther@60119
|
184 |
text \<open>
|
walther@60121
|
185 |
We use sledgehammer [isar_proofs] + <Isar proofs> checked in Sledgehammer panel.
|
walther@60119
|
186 |
Little knowledge required: session "HOL-Metis_Examples" =
|
walther@60119
|
187 |
"HOL-Library" + "HOL-Decision_Procs" + "HOL-Algebra" + "HOL-Cardinals"
|
walther@60119
|
188 |
-- and the first "sledgehammer" is on 1st page.
|
walther@60119
|
189 |
|
walther@60119
|
190 |
Summary: preparations are simple, and the output is structured perfectly !!
|
walther@60119
|
191 |
\<close>
|
walther@60119
|
192 |
(*/------------------------------ preparing the subsequent example ---------------------------\*)
|
walther@60119
|
193 |
sledgehammer_params [prover = spass, fact_filter = mepo, timeout = 30, preplay_timeout = 0,
|
walther@60119
|
194 |
dont_minimize]
|
walther@60119
|
195 |
lemma plus_1_not_0: "n + (1::nat) \<noteq> 0"
|
walther@60119
|
196 |
by simp
|
walther@60119
|
197 |
definition inc :: "nat \<Rightarrow> nat" where
|
walther@60119
|
198 |
"inc x = x + 1"
|
walther@60119
|
199 |
(*\------------------------------ preparing the subsequent example ---------------------------/*)
|
walther@60119
|
200 |
|
walther@60119
|
201 |
lemma "inc \<noteq> (\<lambda>y. 0)"
|
walther@60119
|
202 |
(** )sledgehammer [isar_proofs, expect = some] (inc_def plus_1_not_0)( **)
|
walther@60119
|
203 |
proof -
|
walther@60119
|
204 |
have "\<exists>n. (n::nat) + 1 \<noteq> 0"
|
walther@60119
|
205 |
by (metis plus_1_not_0)
|
walther@60119
|
206 |
then show ?thesis
|
walther@60119
|
207 |
by (metis inc_def)
|
walther@60119
|
208 |
qed
|
walther@60119
|
209 |
|
walther@60119
|
210 |
|
walther@60121
|
211 |
end
|