Documentation

Strata.DL.SMT.AbstractSolver

Abstract Solver Interface #

Defines AbstractSolver τ σ m, a generic solver interface parameterized by an opaque term type τ, an opaque sort type σ, and a monad m. All operations that can fail throw IO.Error via MonadExceptOf. The monad m captures any state or effects the backend needs.

For the incremental SMT-LIB backend, τ = SMT.Term, σ = SMT.TermType, m = StateT IncrementalSolverState IO.

Design #

Handles for a single datatype constructor returned by declareDatatype.

  • constr is the constructor function (use with mkApp to build values)
  • tester is the recognizer predicate (use with mkApp to test membership)
  • selectors are the field accessors in declaration order
  • constr : τ
  • tester : τ
  • selectors : List τ
Instances For
    structure Strata.SMT.DatatypeInfo (τ σ : Type) :

    Result of declaring a datatype: the sort and handles for each constructor.

    Instances For
      structure Strata.SMT.AbstractSolver (τ σ : Type) (m : TypeType) [Monad m] [MonadExceptOf IO.Error m] :

      Abstract solver interface parameterized by term type τ, sort type σ, and monad m.

      All term constructors are fallible. Solvers might not accept certain constructs (e.g., wrong sorts, unsupported combinations) and we need to surface the issue precisely via MonadExceptOf IO.Error.

      • setLogic : Stringm Unit
      • setOption : StringStringm Unit
      • comment : Stringm Unit
      • boolSort : m σ
      • intSort : m σ
      • realSort : m σ
      • stringSort : m σ
      • regexSort : m σ
      • bitvecSort : Natm σ
      • arraySort : σσm σ
      • constrSort : StringList σm σ

        Construct a sort for a named type (datatype or user-defined sort) with the given type arguments.

      • mkBool : Boolm τ
      • mkInt : Intm τ
      • mkPrim : TermPrimm τ
      • mkAppOp : OpList τσm τ

        Fallback for operations not covered by specific mk* methods (e.g. bitvectors, strings, regex). The backend receives the raw Op, the already-encoded arguments, and the result sort.

      • mkAnd : List τm τ
      • mkOr : List τm τ
      • mkNot : τm τ
      • mkImplies : ττm τ
      • mkAdd : List τm τ
      • mkSub : List τm τ
      • mkMul : List τm τ
      • mkDiv : ττm τ
      • mkMod : ττm τ
      • mkNeg : τm τ
      • mkAbs : τm τ
      • mkEq : List τm τ
      • mkLt : List τm τ
      • mkLe : List τm τ
      • mkGt : List τm τ
      • mkGe : List τm τ
      • mkIte : τττm τ
      • mkSelect : ττm τ
      • mkStore : τττm τ
      • mkApp : τList τm τ
      • mkForall : List (String × σ)(List τm (τ × List (List τ)))m τ

        Construct a universally quantified term. Takes name-sort pairs for bound variables and a monadic callback that receives the bound variable terms and returns the body and trigger groups. The callback is monadic so callers can encode sub-terms using the bound variable handles. Bound variables cannot escape the quantifier scope.

      • mkExists : List (String × σ)(List τm (τ × List (List τ)))m τ

        Construct an existentially quantified term. Same callback pattern as mkForall.

      • declareNew : Stringσm τ

        Declare a new variable. Shadowing is allowed: declaring the same name twice creates two distinct variables. The backend handles disambiguation internally.

      • declareFun : StringList σσm τ

        Declare an uninterpreted function.

      • defineFun : StringList (String × σ)στm Unit

        Define an interpreted function with a body term.

      • declareSort : StringNatm σ

        Declare a new sort with the given arity. Returns the declared sort.

      • declareDatatype : StringList String(σList σExcept String (List (String × List (String × σ))))m (DatatypeInfo τ σ)

        Declare an algebraic datatype. Takes the datatype name, type parameter names, and a callback that receives (selfSort, typeParamSorts) and returns the constructors. Returns the declared sort and constructor/tester/selector handles. This callback pattern (like mkForall) allows recursive and parametric datatypes: the sort being declared does not exist yet when selectors need to reference it.

      • declareDatatypes : List (String × List String)(List σList (List σ)Except String (List (List (String × List (String × σ)))))m (List (DatatypeInfo τ σ))

        Declare mutually recursive algebraic datatypes. Takes a list of (name, typeParams) and a callback that receives (selfSorts, typeParamSorts) and returns constructors for each datatype. Returns the declared sorts and constructor/tester/selector handles.

      • assert : τm Unit

        Assert a term (must be Bool-typed).

      • checkSat : m Decision

        Check satisfiability of the current assertions.

      • checkSatAssuming : List τm Decision

        Check satisfiability under additional assumptions.

      • getUnsatAssumptions : m (List τ)

        After an unsat result from checkSatAssuming, retrieve the subset of assumptions that contributed to unsatisfiability.

      • getModel : m (List ((String × Nat) × τ))

        Retrieve the model after a sat result. Keys are (name, shadow_depth) where 0 = most recently declared.

      • getValue : List τm (List (τ × τ))

        Get values of specific terms in the current model.

      • termToSMTLibString : τm String

        Convert a term to its SMT-LIB string representation, making model values inspectable. The returned string must be valid SMT-LIB syntax.

      • reset : m Unit

        Reset the solver session to its initial state.

      • close : m Unit

        Close the solver session and release resources.

      Instances For