Architecture overview
One engine, several front doors: cargo test, the command line, and an MCP
server are clients of the same calls and the same result types
(DESIGN.md section 5). All of it exists.
cargo test (Rust model) elinvar check model.als --json agents over MCP
| | |
+------------ the same calls and result types --------------+
|
elinvar: the facade (re-exports) and the command line, over
elinvar-engine: the engine
model builder, scopes to bounds, time unrolled into steps
skolemize -> circuit -> clauses -> solver (behind a trait)
symmetry breaking, next instance, shrinking, stories
|
every instance goes back down to be refereed
|
elinvar-logic: the relational core
atoms, tuples, relations, bounds, expressions, formulas,
instances and traces, the evaluator, brute-force enumeration
The crates
| Crate | Role | Phase |
|---|---|---|
elinvar-logic | the logic and its evaluator | 1 |
elinvar-engine | the engine | 2 |
elinvar-als | reads Alloy text into a model | 5 |
elinvar | the one crate a user depends on or installs: re-exports the engine and the Alloy reader, and builds the elinvar binary | 5 |
xtask | the cargo x verbs | 0 |
The referee
The split between the two libraries is the trust boundary. A checker with
a bug says “no holes” when there are some, so every instance the engine
finds is evaluated again by elinvar-logic, directly from the definitions,
before it is returned. elinvar-logic cannot depend on the engine, so the
referee cannot call what it referees
(DESIGN.md section 10, AGENTS.md laws 12 and 13).
The pipeline
A formula and its bounds go through five steps (DESIGN.md section 7):
- A top-level
somebecomes a fresh relation, so its witness has a name. - Each relation becomes a table of boolean values, one per tuple it may hold, and each operator a computation on tables. The formula becomes one boolean circuit with shared parts.
- A predicate that breaks symmetries is added, so renamed copies of a case are skipped.
- The circuit becomes clauses, and a SAT solver gets them with a budget.
- A solution is read back as an instance, refereed, and shrunk.
Every step is a function of its input, so the same model gives the same answer on every machine (DESIGN.md section 7.8).
Working on it
Every operation is a cargo x verb, and cargo x verify is what CI runs
(AGENTS.md law 31). cargo x fetch checks out the pinned Alloy, Kodkod,
and Pardinus sources for reading.
cargo x docs serves this book, rebuilt on change, and cargo x docs --build
builds it into target/book/. Both need cargo install mdbook.