src/HOL/SMT.thy
changeset 61799 4cf66f21b764
parent 61626 c304402cc3df
child 66298 5ff9fe3fee66
equal deleted inserted replaced
61798:27f3c10b0b50 61799:4cf66f21b764
   121 
   121 
   122 
   122 
   123 subsection \<open>Integer division and modulo for Z3\<close>
   123 subsection \<open>Integer division and modulo for Z3\<close>
   124 
   124 
   125 text \<open>
   125 text \<open>
   126 The following Z3-inspired definitions are overspecified for the case where @{text "l = 0"}. This
   126 The following Z3-inspired definitions are overspecified for the case where \<open>l = 0\<close>. This
   127 Schönheitsfehler is corrected in the @{text div_as_z3div} and @{text mod_as_z3mod} theorems.
   127 Schönheitsfehler is corrected in the \<open>div_as_z3div\<close> and \<open>mod_as_z3mod\<close> theorems.
   128 \<close>
   128 \<close>
   129 
   129 
   130 definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where
   130 definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where
   131   "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))"
   131   "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))"
   132 
   132 
   180 
   180 
   181 subsection \<open>Configuration\<close>
   181 subsection \<open>Configuration\<close>
   182 
   182 
   183 text \<open>
   183 text \<open>
   184 The current configuration can be printed by the command
   184 The current configuration can be printed by the command
   185 @{text smt_status}, which shows the values of most options.
   185 \<open>smt_status\<close>, which shows the values of most options.
   186 \<close>
   186 \<close>
   187 
   187 
   188 
   188 
   189 subsection \<open>General configuration options\<close>
   189 subsection \<open>General configuration options\<close>
   190 
   190 
   191 text \<open>
   191 text \<open>
   192 The option @{text smt_solver} can be used to change the target SMT
   192 The option \<open>smt_solver\<close> can be used to change the target SMT
   193 solver. The possible values can be obtained from the @{text smt_status}
   193 solver. The possible values can be obtained from the \<open>smt_status\<close>
   194 command.
   194 command.
   195 \<close>
   195 \<close>
   196 
   196 
   197 declare [[smt_solver = z3]]
   197 declare [[smt_solver = z3]]
   198 
   198 
   256 
   256 
   257 
   257 
   258 subsection \<open>Certificates\<close>
   258 subsection \<open>Certificates\<close>
   259 
   259 
   260 text \<open>
   260 text \<open>
   261 By setting the option @{text smt_certificates} to the name of a file,
   261 By setting the option \<open>smt_certificates\<close> to the name of a file,
   262 all following applications of an SMT solver a cached in that file.
   262 all following applications of an SMT solver a cached in that file.
   263 Any further application of the same SMT solver (using the very same
   263 Any further application of the same SMT solver (using the very same
   264 configuration) re-uses the cached certificate instead of invoking the
   264 configuration) re-uses the cached certificate instead of invoking the
   265 solver. An empty string disables caching certificates.
   265 solver. An empty string disables caching certificates.
   266 
   266 
   267 The filename should be given as an explicit path. It is good
   267 The filename should be given as an explicit path. It is good
   268 practice to use the name of the current theory (with ending
   268 practice to use the name of the current theory (with ending
   269 @{text ".certs"} instead of @{text ".thy"}) as the certificates file.
   269 \<open>.certs\<close> instead of \<open>.thy\<close>) as the certificates file.
   270 Certificate files should be used at most once in a certain theory context,
   270 Certificate files should be used at most once in a certain theory context,
   271 to avoid race conditions with other concurrent accesses.
   271 to avoid race conditions with other concurrent accesses.
   272 \<close>
   272 \<close>
   273 
   273 
   274 declare [[smt_certificates = ""]]
   274 declare [[smt_certificates = ""]]
   275 
   275 
   276 text \<open>
   276 text \<open>
   277 The option @{text smt_read_only_certificates} controls whether only
   277 The option \<open>smt_read_only_certificates\<close> controls whether only
   278 stored certificates are should be used or invocation of an SMT solver
   278 stored certificates are should be used or invocation of an SMT solver
   279 is allowed. When set to @{text true}, no SMT solver will ever be
   279 is allowed. When set to \<open>true\<close>, no SMT solver will ever be
   280 invoked and only the existing certificates found in the configured
   280 invoked and only the existing certificates found in the configured
   281 cache are used;  when set to @{text false} and there is no cached
   281 cache are used;  when set to \<open>false\<close> and there is no cached
   282 certificate for some proposition, then the configured SMT solver is
   282 certificate for some proposition, then the configured SMT solver is
   283 invoked.
   283 invoked.
   284 \<close>
   284 \<close>
   285 
   285 
   286 declare [[smt_read_only_certificates = false]]
   286 declare [[smt_read_only_certificates = false]]
   288 
   288 
   289 subsection \<open>Tracing\<close>
   289 subsection \<open>Tracing\<close>
   290 
   290 
   291 text \<open>
   291 text \<open>
   292 The SMT method, when applied, traces important information. To
   292 The SMT method, when applied, traces important information. To
   293 make it entirely silent, set the following option to @{text false}.
   293 make it entirely silent, set the following option to \<open>false\<close>.
   294 \<close>
   294 \<close>
   295 
   295 
   296 declare [[smt_verbose = true]]
   296 declare [[smt_verbose = true]]
   297 
   297 
   298 text \<open>
   298 text \<open>
   299 For tracing the generated problem file given to the SMT solver as
   299 For tracing the generated problem file given to the SMT solver as
   300 well as the returned result of the solver, the option
   300 well as the returned result of the solver, the option
   301 @{text smt_trace} should be set to @{text true}.
   301 \<open>smt_trace\<close> should be set to \<open>true\<close>.
   302 \<close>
   302 \<close>
   303 
   303 
   304 declare [[smt_trace = false]]
   304 declare [[smt_trace = false]]
   305 
   305 
   306 
   306 
   307 subsection \<open>Schematic rules for Z3 proof reconstruction\<close>
   307 subsection \<open>Schematic rules for Z3 proof reconstruction\<close>
   308 
   308 
   309 text \<open>
   309 text \<open>
   310 Several prof rules of Z3 are not very well documented. There are two
   310 Several prof rules of Z3 are not very well documented. There are two
   311 lemma groups which can turn failing Z3 proof reconstruction attempts
   311 lemma groups which can turn failing Z3 proof reconstruction attempts
   312 into succeeding ones: the facts in @{text z3_rule} are tried prior to
   312 into succeeding ones: the facts in \<open>z3_rule\<close> are tried prior to
   313 any implemented reconstruction procedure for all uncertain Z3 proof
   313 any implemented reconstruction procedure for all uncertain Z3 proof
   314 rules;  the facts in @{text z3_simp} are only fed to invocations of
   314 rules;  the facts in \<open>z3_simp\<close> are only fed to invocations of
   315 the simplifier when reconstructing theory-specific proof steps.
   315 the simplifier when reconstructing theory-specific proof steps.
   316 \<close>
   316 \<close>
   317 
   317 
   318 lemmas [z3_rule] =
   318 lemmas [z3_rule] =
   319   refl eq_commute conj_commute disj_commute simp_thms nnf_simps
   319   refl eq_commute conj_commute disj_commute simp_thms nnf_simps