| /- | |
| Copyright (c) 2024 Lean FRO, LLC. All rights reserved. | |
| Released under Apache 2.0 license as described in the file LICENSE. | |
| Authors: Henrik Böving | |
| -/ | |
| module | |
| prelude | |
| public import Init.Simproc | |
| public import Init.Grind.Tactics | |
| public import Init.MetaTypes | |
| import Init.Data.Nat.Bitwise.Basic | |
| @[expose] public section | |
| set_option linter.missingDocs true -- keep it documented | |
| namespace Lean.Elab.Tactic.BVDecide | |
| /-- | |
| The various kinds of configurations offered for the SAT solver. | |
| -/ | |
| inductive SolverMode where | |
| /-- | |
| Set SAT solver options to improve proof search. | |
| -/ | |
| | proof | |
| /-- | |
| Set SAT solver options to improve counterexample search. | |
| -/ | |
| | counterexample | |
| /-- | |
| Don't set additional SAT solver flags. | |
| -/ | |
| | default | |
| /-- | |
| The configuration options for `bv_decide`. | |
| -/ | |
| structure BVDecideConfig where | |
| /-- The number of seconds that the SAT solver is run before aborting. -/ | |
| timeout : Nat := 10 | |
| /-- Whether to run the trimming algorithm on LRAT proofs. -/ | |
| trimProofs : Bool := true | |
| /-- | |
| Whether to use the binary LRAT proof format. | |
| -/ | |
| binaryProofs : Bool := true | |
| /-- | |
| Canonicalize with respect to associativity and commutativity. | |
| -/ | |
| acNf : Bool := false | |
| /-- | |
| Split hypotheses of the form `h : (x && y) = true` into `h1 : x = true` and `h2 : y = true`. | |
| This has synergy potential with embedded constraint substitution. Because embedded constraint | |
| substitution is the only use case for this feature it is automatically disabled whenever embedded | |
| constraint substitution is disabled. | |
| -/ | |
| andFlattening : Bool := true | |
| /-- | |
| Look at all hypotheses of the form `h : x = true`, if `x` occurs in another hypothesis substitute | |
| it with `true`. | |
| -/ | |
| embeddedConstraintSubst : Bool := true | |
| /-- | |
| Split up local declarations of structures that are collections of other supported types into their | |
| individual parts automatically. | |
| -/ | |
| structures : Bool := true | |
| /-- | |
| Enable preprocessing with the `int_toBitVec` simp set to reduce `UIntX`/`IntX` to `BitVec` and | |
| thus make them accessible for `bv_decide`. | |
| -/ | |
| fixedInt : Bool := true | |
| /-- | |
| Handle equality on enum inductives by turning them into `BitVec`. | |
| -/ | |
| enums : Bool := true | |
| /-- | |
| Output the AIG of bv_decide as graphviz into a file called aig.gv in the working directory of the | |
| Lean process. | |
| -/ | |
| graphviz : Bool := false | |
| /-- | |
| The maximum number of subexpressions to visit when performing simplification. | |
| -/ | |
| maxSteps : Nat := Lean.Meta.Simp.defaultMaxSteps | |
| /-- | |
| Short-circuit multiplication as an abstraction-style optimization that triggers | |
| if matching multiplications are not needed to proof a goal. | |
| -/ | |
| shortCircuit : Bool := false | |
| /-- | |
| The SAT solver configuration to use. Defaults to `.proof` as that is the most relevant use case | |
| for `bv_decide`. | |
| -/ | |
| solverMode : SolverMode := .proof | |
| /-- | |
| Enable support for uninterpreted functions over `BitVec` and `Bool` by counterexample-guided | |
| abstraction refinement. | |
| -/ | |
| uf : Bool := false | |
| /-- | |
| The number of iterations that the CEGAR refinement loop may run up to. | |
| -/ | |
| cegarRounds : Nat := 64 | |
| /-- | |
| Whether this configuration requires the solver to use incremental solving. | |
| -/ | |
| def BVDecideConfig.needsIncremental (cfg : BVDecideConfig) : Bool := | |
| cfg.uf | |
| end Lean.Elab.Tactic.BVDecide |