Alloy, and what Elinvar takes from it
Alloy is a language and a tool for describing designs and searching them for holes, by Daniel Jackson and the Alloy team at MIT. Its engine, Kodkod, is by Emina Torlak. The time extension of Alloy 6 comes from the Electrum project and its engine, Pardinus. Elinvar is inspired by all three and affiliated with none.
The parts of Alloy
| Part | What it does | In Elinvar |
|---|---|---|
| the language | signatures, fields, facts, predicates, assertions, run and check | a documented subset is the text form of a model (DESIGN.md section 9.4) |
| Kodkod | relational logic with bounds, turned into a boolean circuit, then clauses for a SAT solver | the core, rebuilt in Rust after its design (DESIGN.md sections 6 and 7) |
| symmetry breaking | skips cases that differ only by renaming | the same method (DESIGN.md section 7.5) |
| time, from Pardinus | changing relations, always, eventually, traces that loop | bounded lasso traces (DESIGN.md section 8) |
| the visualizer | draws an instance | text stories, plus Graphviz dot and Mermaid (elinvar render) |
| integers, strings, and sequences | bounded, wrapping arithmetic, string literals, and seq | supported with configurable bitwidth (LOGIC.md section 16), String with each command’s literals, and util/sequniv |
| the library modules | util/ordering, util/relation, util/graph, util/boolean, util/ternary, util/natural, util/integer, util/time, util/sequence, util/seqrel, util/sequniv | each read, in Elinvar’s own statement of it with Alloy’s names and parameters (LOGIC.md section 15.1) |
The same, on purpose
The logic is Alloy’s: sets and relations, join, closure, quantifiers, and bounds on what each relation may hold (LOGIC.md). It is kept the same so that answers can be compared. A corpus of Alloy’s own example models is checked both ways: the verdict must match Alloy’s, and where the cases can be counted, so must the count (CORPUS.md).
Alloy is never needed to build or test Elinvar. Its answers are recorded once and kept in the repository.
Different, on purpose
- No Java. One binary, built by
cargoalone. - Built for agents first: results as data, error codes with fixes, a budget on every search (DESIGN.md section 9.1).
- The smallest counterexample, not the first one found.
- A model can be written in Rust, beside the code, and checked in
cargo test. - A helper that says what a step leaves unchanged, the thing most often forgotten.
- “Holds” is told apart from “the rules allow nothing”.
A fact that matters when comparing
Alloy puts 16 integer atoms in the universe of every command, whether the
model uses integers or not. univ, iden, and * range over them. A
comparison with Alloy on a model that mentions those has to account for it
(LOGIC.md section 10).