elenchus-compiler
⚠️ Experimental. elenchus is mostly an AI-built experiment — written with the help of a small local model (Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf) and various Claude models, in roughly equal measure. Expect non-professional design choices, rough edges, broken behavior, or mistakes. Use it at your own risk.
Compiles the parsed elenchus DSL into a canonical, solver-ready intermediate representation. Preparation only — no solving.
no_std (needs alloc); the optional std feature adds a filesystem-backed
import resolver.
What it does
- Atom interner —
(subject, predicate, object?)→ denseu32ids, canonically sorted so ids (and any later enumeration) are deterministic. - Desugaring to the single
Impossibleprimitive:EXCLUSIVE/FORBIDSpairwise,ONEOF= pairwise + at-least-one,ATLEAST= one all-negated clause,WHEN … THEN→Impossible([A.., NOT C])per consequent.RULEbodies are kept separate as forward-chaining rules. - Source-agnostic
IMPORTvia aResolver(MemoryResolver, or thestd-gatedFileResolver): a flat merge into one shared atom universe, so an imported premise unifies with a local fact by identity. - Content-addressing (sha256): identical clauses/premises are deduped
(idempotent —
P ∧ P ≡ P), import cycles are detected, and a name redefined with a different body is an error.
The actual reasoning (three-valued forward chaining, SAT, all-SAT, the WARNING
pool, the four results) belongs to the planned elenchus-solver.
Usage
use ;
// Single source:
let ir = compile_source.unwrap;
assert_eq!;
// With imports (string-backed; a file is just one backing store):
let mut r = new;
r.add;
r.add;
let ir = compile.unwrap;
assert!;
License
MIT — see LICENSE.