Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

CrateRolePhase
elinvar-logicthe logic and its evaluator1
elinvar-enginethe engine2
elinvar-alsreads Alloy text into a model5
elinvarthe one crate a user depends on or installs: re-exports the engine and the Alloy reader, and builds the elinvar binary5
xtaskthe cargo x verbs0

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):

  1. A top-level some becomes a fresh relation, so its witness has a name.
  2. 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.
  3. A predicate that breaks symmetries is added, so renamed copies of a case are skipped.
  4. The circuit becomes clauses, and a SAT solver gets them with a budget.
  5. 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.