tiny.smt.sat
Defined in tiny.smt.
A SAT solver that learns a new clause from each conflict it analyzes, with the types a caller builds clauses from and reads answers and evidence through.
API (17)
Types and contracts
Public types and contracts.
BoolValue: A truth value that may also be unset.ConflictScratch: Scratch memory for one conflict analysis at a time, in storage its caller hands over: a buffer of up to one literal per variable and one mark bit per variable.LearnedStore: Fixed memory for the replaceable learned clauses of one solver: equal slots in one slab of literals, one clause per slot, with a stack of free slot numbers.Literal: A variable or its negation, packed into one 32-bit number.ProofArtifact: The clauses, assumptions and steps behind one unsatisfiable answer, copied out of the solver and owned by the caller.ProofClause: One starting clause of aProofArtifact: a clause the checker takes as given.ProofStep: One step of a proof trace: a clause that has to follow from the starting clauses, the assumptions and the earlier steps by unit propagation.ProofTrace: Fixed memory for the literals of one solve's proof steps, packed end to end in one slab, with counts of the steps and literals handed out.RestartPolicy: The restart schedule: the search goes back to the first decision after a conflict count that starts atfirst_conflict_intervaland multiplies bygrowthafter each restart.SolveStats: Counts of the work one solve did.Solver: A SAT solver that learns a clause from each conflict above decision level zero over the clauses a caller adds, answers under assumed literals, and records an unsat core and a proof trace after each unsatisfiable answer.Status: The answer of one solve.
Namespaces
Public namespaces.
scratch: Scratch memory for one conflict analysis at a time: room for the literals of the clause being learned and one mark per variable.solver: A SAT solver that learns a new clause from each conflict it analyzes.store: Fixed memory for the learned clauses a solver may remove under a cap, sized before a search and reused slot by slot.trace: Fixed memory for the proof steps of one solve, used when the solve has a conflict limit.types: The values a caller hands to the solver and reads back from it: literals, answers, truth values that may be unset, counts of a solve's work, and the restart schedule.
Source
Source: lib/smt/src/root.zig:95
zig
pub const sat = @import("sat/root.zig");Source: lib/smt/src/sat/root.zig
zig
//! A SAT solver that learns a new clause from each conflict it analyzes, with the types a caller//! builds clauses from and reads answers and evidence through. A caller builds clauses from//! literals over numbered variables and asks whether they can all be true, optionally under assumed//! literals. After a no, a caller wants the assumptions the refutation used and evidence that a//! separate check can confirm on its own. Questions asked of one formula share the solver's//! clauses, and evidence describes the formula of one solve, so any later change to the clauses,//! the variables or the assumptions makes the evidence describe a formula the solver has since//! changed.//!//! [MiniSat](https://doi.org/10.1007/978-3-540-24605-3_37), by Niklas Eén and Niklas Sörensson, is//! a SAT solver that learns a clause from each conflict. The namespace keeps its way of solving://! each clause of two or more literals watches two of them, each conflict above decision level zero//! yields a learned clause, and a solve can run under assumed literals.//!//! A solve under assumptions discards every clause added during it when it completes, the clauses//! learned under those assumptions included. When no cap on learned clauses is set, a solve keeps//! every clause from before it. While a cap on learned clauses is set, every solve starts by//! removing the learned clauses over the cap, clauses from earlier solves included. For callers//! that nest questions, the solver keeps an assumption list of its own, and each push keeps a saved//! length of the assumption list that a pop returns to (an *assumption frame*). After a no under//! assumptions, the solver reports a set of assumptions that the clauses refute together//! (`Solver.lastUnsatCore`). The set can hold an assumption the no does not need in two cases: when//! the solver records a core of a single assumption, and when a conflict limit runs out while the//! solver shrinks the core, which leaves every assumption in it.//!//! After each unsatisfiable answer, the solver keeps a trace for that solve's clauses and//! assumptions: a list of clauses that ends in the empty clause. To check one clause of the trace,//! a checker assumes its literals false together with the assumptions and propagates unit clauses//! over the formula and the earlier clauses of the trace, and the clause passes when that//! propagation reaches a conflict (Reverse Unit Propagation). `Solver.lastProofArtifact` copies the//! clauses, assumptions and steps behind one unsatisfiable answer (a *proof artifact*), and//! `ProofArtifact.valid` checks that copy again without the solver. The clauses of that copy are//! every clause the solver held when the solve began, learned clauses it kept included. Adding a//! variable, a clause or an assumption, changing assumption frames, or solving again clears the//! recorded core and trace, so evidence holds only until the next change to the solver.//!//! A caller that bounds the search sets a conflict limit, and the solver then keeps each solve's//! proof steps in fixed memory sized from that limit (`ProofTrace`). A caller that bounds memory//! sets a cap on learned clauses, and the solver then keeps the learned clauses it may remove in//! fixed memory sized from that cap (`LearnedStore`). The solver analyzes each conflict in scratch//! memory that it sets aside at the start of each solve (`ConflictScratch`). The namespace holds//! the solver (`Solver`) with its literal, status, statistics, restart and proof types, and it//! re-exports `Solver`, `Literal`, `Status`, `BoolValue`, `SolveStats`, `RestartPolicy`,//! `ProofClause`, `ProofStep`, `ProofArtifact` and the three fixed memories by name. The files//! split the parts: `solver` holds the solver, `types` the value types, `store`, `trace` and//! `scratch` the three fixed memories, and a proof file the proof types.const proof = @import("proof.zig");pub const scratch = @import("scratch.zig");pub const solver = @import("solver.zig");pub const store = @import("store.zig");pub const trace = @import("trace.zig");pub const types = @import("types.zig");pub const BoolValue = types.BoolValue;pub const Literal = types.Literal;pub const ProofArtifact = proof.ProofArtifact;pub const ProofClause = proof.ProofClause;pub const ProofStep = proof.ProofStep;pub const RestartPolicy = types.RestartPolicy;pub const Solver = solver.Solver;pub const SolveStats = types.SolveStats;pub const Status = types.Status;pub const LearnedStore = @import("store.zig").Store;pub const ProofTrace = @import("trace.zig").Trace;pub const ConflictScratch = scratch.ConflictScratch;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |