Command-line reference
Every Elinvar command is a verb (elinvar <verb> ...). Pass --json to any verb for
machine-readable JSON output, or --help for full flag details.
Verbs at a glance
| Command | What it does |
|---|---|
elinvar check FILE [NAME] | Check every assertion in FILE, or only the named command |
elinvar run FILE [NAME] | Find a valid example instance for a run command |
elinvar tests FILE | Generate step reachability and per-guard refusal tests |
elinvar accepts FILE TRACE | Check whether a model allows a trace JSON or SQL DML script |
elinvar fuzz FILE --against CMD | Run dependency-ordered seeded SQL scripts on both a real database and the model (--require-coverage) |
elinvar discover FILE | Discover and prove common invariants of a SQL schema by induction |
elinvar audit FILE --data DUMP | Check table rules and single-state promises directly on a SQL dump (no solver) |
elinvar ci [MANIFEST] | Run a repository manifest under one timeout (Markdown, JUnit, SARIF, JSON) |
elinvar diff OLD NEW | Compare two models or schemas (also diff BASE --migration MIG.sql, --of FUN, --ignore-unread) |
elinvar import FILE|DIR | Convert SQL DDL (or a migrations/ directory) into an Alloy 6 model |
elinvar render RESULT | Render a JSON result’s instance or trace as Graphviz dot, Mermaid, or SQL |
elinvar eval FILE RESULT EXPR | Evaluate an expression or formula on a saved result without re-solving |
elinvar explain [SUBJECT] | Explain an error code, print a JSON Schema (schema[:NAME]), print skill, or list all codes |
elinvar serve --mcp | Run the Model Context Protocol (MCP) server over stdio |
elinvar --version | Print the binary version (also -V) |
Reading from stdin (-)
Pass - for any single input file argument to pipe input without creating temporary files:
# Check a model inline
cat model.als | elinvar check - --json
# Check and immediately render as Mermaid
elinvar check model.als --json | elinvar render - --mermaid
# Import SQL DDL from stdin
pg_dump --schema-only mydb | elinvar import - > schema.als
Two-file commands (diff, eval) accept - for one of the two inputs, not both.
Common flags
| Flag | Applies to | Meaning |
|---|---|---|
--json | all verbs and --version | Output structured JSON (including CLI usage and file errors) |
--explain | check, run | Extract minimal unsatisfiable core of rules on holds or vacuous, or on a run with no instance |
--scope N | check, run, diff | Override the default atom limit per top-level signature |
--steps N | check, run, diff | Override the maximum trace length in states |
--from-any / --from-empty | check, run, diff, import | For .sql schemas, start from any allowed state (diff and import default) or empty tables (check and run default) |
--budget N | check, run, diff | Maximum solver conflicts per solve (default 10000000) |
--no-slicing | check, diff | Solve every check whole instead of slicing away what the assertion cannot see first: slower, and the reference answer |
--symmetry N / --no-symmetry | check, run, diff | Symmetry-breaking predicate length (default 20, matching Alloy; 0 or --no-symmetry disables symmetry breaking) |
--no-overflow | check, run, diff | Forbid signed integer overflow (noOverflow in Alloy); any case whose integer arithmetic wraps is ruled out |
--dot / --mermaid / --format FMT | render | Output format: dot (default), mermaid, or sql |
--state K | eval, render | Pick one state K (0-indexed) of a trace |
--timeout DUR | check, run, diff, tests, fuzz, discover, ci | Wall-clock limit (500ms, 30s, 2m): per solve for check, run, diff, per test for tests, for the whole run for fuzz, discover, and ci. Running out turns an answer into unknown, never into another answer; shrinking has its own conflict budget and no time limit |
--with FILE | check, run, tests, diff, accepts, import, fuzz, discover, audit, eval | Append a sidecar: .als promises, predicates, and commands, or .sql views and queries (repeatable) |
--tables A,B | check, run, tests, diff, accepts, import, fuzz, discover, audit, eval | For a .sql schema, only these tables and the tables their foreign keys point to |
--with-referencing | as --tables | With --tables, also the tables whose foreign keys point into the slice |
--brief | check, run | Leave empty relations and ordering helpers out of the text |
Flags of one verb
| Flag | Verb | Effect |
|---|---|---|
--summary | check | One Markdown table across all checks; with --json, the summary shape of schema:results |
--climb | check | Raise the scope step by step under the budget until a counterexample is found or the budget runs out |
--induction [K] | check | Prove always P for any number of steps by k-induction (default K 1); proved when it succeeds |
--shrink | run | Shrink the instance found to the fewest atoms and tuples |
--all | run | Enumerate every instance up to the scope, one of each group that differ only by renaming atoms |
--limit N | run | With --all, stop after N instances (default 1000) |
--sql | tests, run, render | Render as executable SQL: test cases as replay scripts, run --all instances as inserts, a result as statements (--format sql) |
--values SPEC | tests, render | Sample values for SQL columns: table.col=v1,v2, or @file with one such line each (repeatable) |
--allow-dead S1,S2 | tests | Steps expected never to happen, so they are not reported as dead; also read from -- expect-dead: comments |
--strict | import | Exit 3 if any SQL rule was not read |
--only-ruled | import | Leave out columns that no key, index, constraint, or trigger mentions |
--migration FILE | diff | Compare BASE with BASE plus the migration FILE |
--data FILE | audit | The SQL dump to audit, as INSERT statements (required; - for stdin) |
--show-rejected | discover | Also list the candidates that were refuted, with their counterexamples |
--against CMD | fuzz | The database command to compare with (default sqlite3; for example psql mydb) |
--seed N | fuzz | The seed of the random scripts (default 1); the same seed gives the same scripts |
--scripts N | fuzz | How many random scripts (default 100) |
--length N | fuzz | Statements per script (default 8) |
--junit / --sarif | ci | Write JUnit XML or SARIF 2.1.0 instead of the Markdown table |
--mcp | serve | Serve the verbs as MCP tools over stdio |
Exit codes
| Exit code | Meaning |
|---|---|
0 | Every promise holds (check), instance found (run), models are equivalent (diff), or utility command succeeded |
1 | Counterexample found (check), no instance (run), or models differ (diff: tightened, loosened, diverged) |
2 | Verdict is vacuous (contradictory rules, also diff --of) or unknown (solver budget reached) |
3 | Model error (syntax, unknown name, arity mismatch), bad flag (cli.usage), or unreadable input (cli.input); with --json, a refusal before the verb starts has code, error, and help (schema:usage) |
Names in imported SQL models
A table or column whose name is an Alloy keyword (fact, set, sig, …) or one of
the names the generated model binds itself (a, b, d, r, w, x, and q, v,
or p followed by digits) is renamed with _sql in the model: a column x is the
field x_sql, and a table r the signature r_sql. Promises written in Alloy use the renamed name; SQL scripts given to
accepts, fuzz, and audit keep the SQL name, and SQL rendered by render --sql and
tests --sql uses it too.
Row identity in SQL temporal models
When importing a SQL schema with --temporal, each table T has a pool T_row, a
changing active set T, and a retired set T_retired. Deleting a row moves its atom
into T_retired, and insert_T never reuses a retired atom (just as an autoincrement
rowid is not given out again). Promises quantified over T_row (such as “a closed row
never reopens”) therefore distinguish a deleted row from a later inserted row. If a
promise is instead about a logical entity identified by a business key column (for
example, id or email), quantify over that key column across rows rather than over
the row atom alone.
Self-discovery commands
You never need to look up error codes or JSON formats in the source code:
elinvar explain # list every error code
elinvar explain arity.mismatch # when a code triggers and how to fix it
elinvar explain schema # list every verb's JSON Schema
elinvar explain schema:result # print the JSON Schema (v1) for one check/run result
elinvar explain schema:results # every shape check/run print: one, several, --summary, run --all
elinvar explain schema:diff # also: schema:import, schema:render, schema:eval, schema:tests, schema:accepts, schema:fuzz, schema:discover, schema:ci, schema:audit, schema:usage
elinvar explain skill # print the embedded agent skill guide