CLI Reference

The imandrax-cli tool provides command-line access to ImandraX for verification, OCaml extraction, interactive sessions, server management, and CI/CD integration.

Commands overview

CommandDescription
checkCheck (verify) files in batch mode
extractExtract IML files to valid OCaml
replOpen an interactive REPL session
serve-httpStart an HTTP server for exploring sessions
lspRun the LSP server (used by VS Code extension)
analyze-duneAnalyze a Dune project
versionDisplay the version

imandrax-cli check

Verify all theorems, lemmas, and verification goals in one or more files:

imandrax-cli check myfile.iml
imandrax-cli check src/model.iml src/properties.iml

This is the primary command for CI/CD pipelines — add it to your build process to ensure all proofs pass before merging.

Key options:

OptionDescription
--api-key <key>API key (or set IMANDRAX_API_KEY env var)
--api-key-file <path>File containing the API key
--timeout <seconds>Timeout in seconds for verification
-j <n>Number of worker processes
--check=falseParse and type-check only, skip proof verification
--po-filter="Foo.bar"Only check proof obligations from symbol Foo.bar
--po-save-into <dir>Save proof obligations to a directory
--db <path>Store results in a database on disk
--db-as-cache rw|ro|noCache results in the database
--proof-check <val>Do proof checking if PO is successful
--serve=trueSpawn HTTP server in the background alongside checking
--serve-port <port>Port for the background HTTP server
-c <path>, --config <path>Configuration file
--dump-eval-results=falseSuppress evaluation results output
--dump-po-results=falseSuppress proof obligation results output
--dump-decomp-results=falseSuppress decomposition results output
--dump-stats=falseSuppress statistics output

Exit codes:

CodeMeaning
0Success — all goals verified
123Errors reported on standard error
124Command-line parsing errors
125Unexpected internal errors

imandrax-cli extract

Extract IML definitions to valid OCaml source code:

# Extract to stdout
imandrax-cli extract myfile.iml
 
# Extract to a file
imandrax-cli extract myfile.iml -o myfile.ml
 
# Add deriving annotations
imandrax-cli extract myfile.iml --deriving yojson

This generates OCaml code from your verified IML definitions, suitable for integration with Dune build projects. See Evaluation & Extraction for details on the extraction workflow.

Key options:

OptionDescription
-o <file>, --out <file>Output file (default: stdout)
--deriving <val>Add [@@deriving ...] annotations
--no-line-numbersOmit line number directives in output
--no-preludeDo not open the prelude

imandrax-cli repl

Open an interactive REPL (read-eval-print loop) session:

# Start a fresh REPL
imandrax-cli repl
 
# Load files before starting
imandrax-cli repl -l prelude.iml -l model.iml

The REPL lets you interactively define functions, run verifications, and explore your models. It supports all IML commands including verify, instance, theorem, and eval.

Key options:

OptionDescription
--api-key <key>API key (or set IMANDRAX_API_KEY env var)
-l <files>, --load <files>Files to load before starting the REPL
-j <n>Number of worker processes
--prelude=falseDo not load the prelude
--syntax <val>Syntax for the code
--color=falseDisable colorized output
--proof-check <val>Do proof checking if PO is successful
--serve=trueSpawn HTTP server in the background
--serve-port <port>Port for the background HTTP server
-c <path>, --config <path>Configuration file

imandrax-cli serve-http

Start an HTTP server for exploring existing sessions:

imandrax-cli serve-http -p 8080

Key options:

OptionDescription
--api-key <key>API key (or set IMANDRAX_API_KEY env var)
-p <port>, --port <port>Port for the HTTP server
-j <n>Number of worker processes
--db <path>Database path
--db-as-cache rw|ro|noCache results in the database
-c <path>, --config <path>Configuration file

See HTTP API for details on the API endpoints.

imandrax-cli lsp

Run the Language Server Protocol server. This is used internally by the VS Code extension — you typically don't need to run it directly:

imandrax-cli lsp

imandrax-cli analyze-dune

Analyze a Dune project to discover IML files and their dependencies:

imandrax-cli analyze-dune --from-dir ./my-project

imandrax-cli version

Display the installed version:

imandrax-cli version

CI/CD integration

GitHub Actions

- name: Verify IML files
  run: |
    imandrax-cli check src/model.iml
    imandrax-cli check src/properties.iml
  env:
    IMANDRAX_API_KEY: ${{ secrets.IMANDRAX_API_KEY }}

General CI

#!/bin/bash
set -e
 
# Verify all .iml files
for f in src/*.iml; do
  echo "Checking $f..."
  imandrax-cli check "$f"
done
 
echo "All verifications passed!"

Extract and build

#!/bin/bash
set -e
 
# Extract verified IML to OCaml
imandrax-cli extract src/model.iml -o src/model.ml
 
# Build with Dune
dune build

Environment variables

VariableDescription
IMANDRAX_API_KEYYour ImandraX API key (also checks IMANDRA_UNI_KEY and IMANDRA_KEY)
IMANDRAX_DEPLOYMENTDeployment target: local, prod, or net
IMANDRAX_BACKTRACESEnable backtraces for debugging

Common options

These options are available across most commands:

OptionDescription
--helpShow help for a command
-d, --debugEnable debug mode
--log-level <val>Set log level
--log-file <file>Log to a file
--log-stderrLog to stderr
--gc-space-overhead <n>GC space overhead (default: 60)
--thread-pool-size <n>Size of internal thread pool