Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file solver_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163(* SPDX-License-Identifier: MIT *)(* Copyright (C) 2023-2025 formalsec *)(* Written by the Smtml programmers *)(** Solver Interface Module. This module defines interfaces for interacting with
SMT solvers, including batch and incremental modes. It provides a generic
interface for working with different SMT solvers and their functionalities.
*)(** {1 Module Types} *)(** The [S] module type defines the core interface for interacting with SMT
solvers, including solver creation, constraint management, and result
retrieval. *)moduletypeS=sig(** The type of solvers. *)typet(** The type of underlying solver instances. *)typesolver(** [solver_time] tracks the time spent inside the SMT solver. *)valsolver_time:floatref(** [solver_count] tracks the number of queries made to the SMT solver. *)valsolver_count:intref(** [pp_statistics fmt solver] pretty-prints solver statistics using the
formatter [fmt]. *)valpp_statistics:tFmt.t(** [create ?params ?logic ()] creates a new solver.
- [?params] is of type {!type:Params.t} and is used to modify/set
parameters inside the solver.
- [?logic] is of type {!type:Logic.t} and is used to set the theory of the
assertions used. When the underlying theory is known, setting this
parameter can improve solver performance. The default logic is {e ALL}.
*)valcreate:?params:Params.t->?logic:Logic.t->unit->t(** [interrupt solver] interrupts the current solver operation. *)valinterrupt:t->unit(** [clone solver] creates a copy of the solver [solver]. *)valclone:t->t(** [push solver] creates a backtracking point in the solver [solver]. *)valpush:t->unit(** [pop solver n] backtracks [n] backtracking points in the solver [solver].
*)valpop:t->int->unit(** [reset solver] resets the solver [solver], removing all assertions. *)valreset:t->unit(** [add solver exprs] asserts one or multiple constraints [exprs] into the
solver [solver]. *)valadd:t->Expr.tlist->unit(** [add_set solver set] asserts constraints from the set [set] into the
solver [solver]. *)valadd_set:t->Expr.Set.t->unit(** [get_assertions solver] retrieves the set of assertions in the solver
[solver]. *)valget_assertions:t->Expr.tlist[@@deprecated"Please use 'get_statistics' instead"](** [get_statistics solver] retrieves statistics from the solver [solver]. *)valget_statistics:t->Statistics.t(** [check solver es] checks the satisfiability of the assertions in the
solver [solver] using the assumptions in [es]. Returns [`Sat], [`Unsat],
or [`Unknown]. *)valcheck:t->Expr.tlist->[`Sat|`Unsat|`Unknown](** [check_set solver set] checks the satisfiability of the assertions in the
solver [solver] using the assumptions in the set [set]. Returns [`Sat],
[`Unsat], or [`Unknown]. *)valcheck_set:t->Expr.Set.t->[`Sat|`Unsat|`Unknown](** [get_value solver expr] retrieves an expression denoting the model value
of the given expression [expr]. Requires that the last {!val:check} query
returned [`Sat]. *)valget_value:t->Expr.t->Expr.t(** [model ?symbols solver] retrieves the model of the last [check] query. If
[?symbols] is provided, only the values of the specified symbols are
included. Returns [None] if [check] was not invoked before or its result
was not [`Sat].
Not compatible with cached solver mode - use {!get_sat_model} instead
@see 'get_sat_model' For cached solver-compatible alternative *)valmodel:?symbols:Symbol.tlist->t->Model.toption(** Compute and retrieve a model for specific constraints.
[get_sat_model ?symbols solver exprs] performs: 1. [check_set] with
[exprs] constraints 2. Returns model if result is [`Sat]
Filters output using [?symbols] when provided. Designed for cached
solvers.
@see 'model'
For non-cached solvers when you have already performed your own
[check]/[check_set] and want to retrieve the results *)valget_sat_model:?symbols:Symbol.tlist->t->Expr.Set.t->[`ModelofModel.t|`Unsat|`Unknown]end(** The [Intf] module type defines the interface for creating and working with
solvers, including batch, cached, and incremental modes. *)moduletypeIntf=sig(** The [S] module type, which defines the core solver interface. *)moduletypeS=S(** {1 Batch Mode}
In this module, constraints are handled in a 'batch' mode, meaning that
the solver delays all interactions with the underlying SMT solver until it
becomes necessary. It communicates with the underlying solver only when a
call to {!val:Solver_intf.S.check}, {!val:Solver_intf.S.get_value}, or
{!val:Solver_intf.S.model} is made. *)(** The {!module:Batch} module is parameterized by the mapping module [M]
implementing {!module-type:Mappings_intf.S}. In this mode, the solver
delays all interactions with the underlying SMT solver until necessary. *)moduleBatch(_:Mappings_intf.S):S(** {1 Cached Mode}
(Experimental) Similar to the Batch mode, but queries are cached for
improved performance. *)moduleCached(_:Mappings_intf.S):sig(** Include the core solver interface. *)includeS(** [cache_hits ()] Returns the number of hits that have already occurred in
the cache *)valcache_hits:unit->int(** [cache_misses ()] Same as [cache_hits] but for misses *)valcache_misses:unit->intend(** {1 Incremental Mode}
In the Incremental module, constraints are managed incrementally, meaning
that every interaction with the solver prompts a corresponding interaction
with the underlying SMT solver. Unlike the batch solver, nearly every
interaction with this solver involves the underlying SMT solver. *)(** The {!module:Incremental} module, like {!module:Batch}, presents a solver
parameterized by the mapping module [M]. In this mode, the Incremental
solver engages with the underlying SMT solver in nearly every interaction.
*)moduleIncremental(_:Mappings_intf.S):Send