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

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

CommandWhat 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 FILEGenerate step reachability and per-guard refusal tests
elinvar accepts FILE TRACECheck whether a model allows a trace JSON or SQL DML script
elinvar fuzz FILE --against CMDRun dependency-ordered seeded SQL scripts on both a real database and the model (--require-coverage)
elinvar discover FILEDiscover and prove common invariants of a SQL schema by induction
elinvar audit FILE --data DUMPCheck 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 NEWCompare two models or schemas (also diff BASE --migration MIG.sql, --of FUN, --ignore-unread)
elinvar import FILE|DIRConvert SQL DDL (or a migrations/ directory) into an Alloy 6 model
elinvar render RESULTRender a JSON result’s instance or trace as Graphviz dot, Mermaid, or SQL
elinvar eval FILE RESULT EXPREvaluate 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 --mcpRun the Model Context Protocol (MCP) server over stdio
elinvar --versionPrint 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

FlagApplies toMeaning
--jsonall verbs and --versionOutput structured JSON (including CLI usage and file errors)
--explaincheck, runExtract minimal unsatisfiable core of rules on holds or vacuous, or on a run with no instance
--scope Ncheck, run, diffOverride the default atom limit per top-level signature
--steps Ncheck, run, diffOverride the maximum trace length in states
--from-any / --from-emptycheck, run, diff, importFor .sql schemas, start from any allowed state (diff and import default) or empty tables (check and run default)
--budget Ncheck, run, diffMaximum solver conflicts per solve (default 10000000)
--no-slicingcheck, diffSolve every check whole instead of slicing away what the assertion cannot see first: slower, and the reference answer
--symmetry N / --no-symmetrycheck, run, diffSymmetry-breaking predicate length (default 20, matching Alloy; 0 or --no-symmetry disables symmetry breaking)
--no-overflowcheck, run, diffForbid signed integer overflow (noOverflow in Alloy); any case whose integer arithmetic wraps is ruled out
--dot / --mermaid / --format FMTrenderOutput format: dot (default), mermaid, or sql
--state Keval, renderPick one state K (0-indexed) of a trace
--timeout DURcheck, run, diff, tests, fuzz, discover, ciWall-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 FILEcheck, run, tests, diff, accepts, import, fuzz, discover, audit, evalAppend a sidecar: .als promises, predicates, and commands, or .sql views and queries (repeatable)
--tables A,Bcheck, run, tests, diff, accepts, import, fuzz, discover, audit, evalFor a .sql schema, only these tables and the tables their foreign keys point to
--with-referencingas --tablesWith --tables, also the tables whose foreign keys point into the slice
--briefcheck, runLeave empty relations and ordering helpers out of the text

Flags of one verb

FlagVerbEffect
--summarycheckOne Markdown table across all checks; with --json, the summary shape of schema:results
--climbcheckRaise the scope step by step under the budget until a counterexample is found or the budget runs out
--induction [K]checkProve always P for any number of steps by k-induction (default K 1); proved when it succeeds
--shrinkrunShrink the instance found to the fewest atoms and tuples
--allrunEnumerate every instance up to the scope, one of each group that differ only by renaming atoms
--limit NrunWith --all, stop after N instances (default 1000)
--sqltests, run, renderRender as executable SQL: test cases as replay scripts, run --all instances as inserts, a result as statements (--format sql)
--values SPECtests, renderSample values for SQL columns: table.col=v1,v2, or @file with one such line each (repeatable)
--allow-dead S1,S2testsSteps expected never to happen, so they are not reported as dead; also read from -- expect-dead: comments
--strictimportExit 3 if any SQL rule was not read
--only-ruledimportLeave out columns that no key, index, constraint, or trigger mentions
--migration FILEdiffCompare BASE with BASE plus the migration FILE
--data FILEauditThe SQL dump to audit, as INSERT statements (required; - for stdin)
--show-rejecteddiscoverAlso list the candidates that were refuted, with their counterexamples
--against CMDfuzzThe database command to compare with (default sqlite3; for example psql mydb)
--seed NfuzzThe seed of the random scripts (default 1); the same seed gives the same scripts
--scripts NfuzzHow many random scripts (default 100)
--length NfuzzStatements per script (default 8)
--junit / --sarifciWrite JUnit XML or SARIF 2.1.0 instead of the Markdown table
--mcpserveServe the verbs as MCP tools over stdio

Exit codes

Exit codeMeaning
0Every promise holds (check), instance found (run), models are equivalent (diff), or utility command succeeded
1Counterexample found (check), no instance (run), or models differ (diff: tightened, loosened, diverged)
2Verdict is vacuous (contradictory rules, also diff --of) or unknown (solver budget reached)
3Model 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