Expand description
elenchus-solver — the inference interpreter (forward pass).
Consumes the Compiled IR from elenchus-compiler and evaluates it under
three-valued Kleene logic (TRUE / FALSE / UNKNOWN, where UNKNOWN ≠ FALSE):
- seed a model from confident
FACT/NOTfacts (and reportFACT X+NOT X); - forward-chain
RULEs to a fixpoint, deriving facts (a derived value that contradicts an existing one is a CONFLICT); - evaluate every
Impossibleclause (the desugaredPREMISEs):- all literals forced TRUE → CONFLICT (the constraint is violated);
- some literal FALSE → satisfied → CONSISTENT;
- otherwise (no FALSE, an UNKNOWN remains): for implication premises this is a WARNING (blocked by missing data), for list premises (EXCLUSIVE/FORBIDS/ ONEOF/ATLEAST) it is CONSISTENT (UNKNOWN means “no conflict yet”).
On CHECK ... BIDIRECTIONAL a backward pass also runs: the premises, rules
and confident facts are encoded as CNF and handed to a small in-crate CDCL SAT
core (sat, replicating varisat’s algorithm) to count models — 0 means the
system is jointly unsatisfiable (a CONFLICT the forward pass may miss), ≥2
means an alternative model exists (UNDERDETERMINED).
Modules§
- sat
- A compact, single-threaded CDCL SAT solver in
no_std, replicating the core algorithm of varisat (jix/varisat) in a readable, lazy style.
Structs§
- Conflict
- A violated constraint (or a fact-level contradiction).
- Core
Item - One construct named in an
Report::unsat_core. - Derived
- A fact produced by a
RULEduring forward chaining. - Memory
Resolver - An in-memory resolver: serves sources from a name → content map. Pure
no_std. Mirrors vsm-grammar’sMemoryResolver. - Report
- The result of solving, self-contained (atom ids already resolved to labels).
- Similar
Atoms - An advisory hint that two atom names look like the same atom typed two
different ways (e.g.
is_rolled_backvsis rolled_back). Purely a suggestion — it never changes the verdict, the warning pool, or the exit code. It exists to catch the silent-typo trap where a misspelling creates a new UNKNOWN atom that quietly never links to the rest of the program. - Trace
Step - One link in a
Conflict’s derivation chain: an atom, the value it was forced to, and why it holds that value. - Warning
- A constraint that could not be checked because a needed atom is UNKNOWN.
Enums§
- Compile
Error - Anything that can go wrong while compiling (and resolving imports).
- Status
- Overall verdict for the system.
- Trace
Reason - Why a
TraceStepatom holds its value. - V3
- Three-valued truth (Kleene). UNKNOWN is a first-class value, not hidden FALSE.
Traits§
- Resolver
- Resolves
IMPORT "path"to source text. The engine is source-agnostic: it consumes strings, so a file is merely one backing store. Mirrors vsm-grammar’sSourceResolver.
Functions§
- compile
- Compile a root source and all its transitive
IMPORTs into one IR. - compile_
source - Convenience: compile a single source into the IR.
IMPORTs are recorded as pending, not resolved (usecompilewith aResolverto resolve them). - solve
- Evaluate a compiled program: the three-valued forward pass, then the backward
pass on
BIDIRECTIONAL. - verify
- Parse → compile (resolving imports) → solve, given a
Resolver. - verify_
source - Parse → compile → solve a single source.