Get Started

Use judgment in your project

This guide covers integrating judgment v1.0.0 into a standalone Mojo project on Linux (linux-64, linux-aarch64) or Apple Silicon macOS (osx-arm64).

Once the modular-community channel pull request merges, add judgment directly to your project's pixi.toml:

[workspace]
channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-arm64"]
pixi add judgment mojo=1.2

Because judgment.mojoc is installed in $CONDA_PREFIX/lib/mojo and loads $CONDA_PREFIX/lib/libjudgment_store.{so,dylib} automatically via dlopen, both mojo run and mojo build work with no -I and no linker flags:

pixi run mojo run main.mojo
pixi run mojo build main.mojo -o main && ./main

2. Or set up a pinned source checkout

Install Pixi and Git, then create a project directory with a pinned vendor/judgment checkout:

mkdir judgment-app
cd judgment-app
mkdir vendor
git clone https://github.com/Spellbound-Mojo/judgment.git vendor/judgment
git -C vendor/judgment rev-parse HEAD > judgment.commit
git -C vendor/judgment checkout --detach "$(cat judgment.commit)"

app_root="$PWD"
judgment_root="$app_root/vendor/judgment"
pixi install --locked --manifest-path "$judgment_root/pixi.toml"
cp "$judgment_root/docs/examples/certified_rewrite.mojo" "$app_root/main.mojo"

Your directory layout:

judgment-app/
  main.mojo                 your application
  judgment.commit           pinned dependency revision
  vendor/judgment/
    pixi.toml / pixi.lock   compiler and locked dependencies
    bindings/               prebuilt core builder and Mojo/Python clients
    src/                    judgment, judgment_shell, judgment_core, scalar, termbank

Sharing across a team

Commit main.mojo and judgment.commit (or track vendor/judgment as a Git submodule) so every developer uses the same compiler and lockfile.

3. Build against the prebuilt core (from source)

Compiling a Mojo program directly against src/ or build/ re-optimizes every part of judgment it touches on every edit. Building the prebuilt core once into a shared library brings incremental rebuilds down to a few seconds:

pixi run --locked --manifest-path "$judgment_root/pixi.toml" build-core
pixi run --locked --manifest-path "$judgment_root/pixi.toml" core-run "$app_root/main.mojo"

Note three small import differences when using the Mojo thin client:

  • Errors and budgets live in judgment: import Budget, LibError, LibErrorKind, StoreError, and StoreErrorKind from judgment instead of termbank or judgment_shell.
  • Exact apn_mojo numbers live in judgment.exact: ExactValue, ExactPoint, FilterConfig, FilterVerdict, NumericValue, LiteralValue, evaluate, decide, refute, literal_facts, and the helpers number, rational, polynomial, and literal are in judgment.exact. That keeps programs that do not use arbitrary-precision numbers from paying apn_mojo compile time.
  • Store features need --variant store: if your app uses Library, Article, or theory interpretations (TypeImage, prepare_interpretation, reuse), build build-core-store once and run with: pixi run --locked --manifest-path "$judgment_root/pixi.toml" python "$judgment_root/bindings/build_core.py" --variant store --run "$app_root/main.mojo".

For Python apps using the same shared library, see Proofs from Python.

4. Build directly from source or precompiled packages

Use direct package builds when your app needs optional Mojo-only packages (judgment_nat, judgment_search), native fp_mojo IO combinators, or low-level judgment_core / termbank APIs.

From source:

pixi run --locked --manifest-path "$judgment_root/pixi.toml" \
  mojo run -I "$judgment_root/src" "$app_root/main.mojo"

Expected output:

Accepted: f(a) = f(b), under a = b
Rejected: the same evidence for f(a) = f(c)
Retained theorem: a = b implies f(a) = f(b)
Reuse still requires evidence for a = b

Optimized release binary (from precompiled .mojoc packages):

pixi run --locked --manifest-path "$judgment_root/pixi.toml" build
pixi run --locked --manifest-path "$judgment_root/pixi.toml" \
  mojo build --Werror -O3 -I "$judgment_root/build" \
  "$app_root/main.mojo" -o "$app_root/checked-rewrite"
"$app_root/checked-rewrite"

Use absolute paths with --manifest-path

Pixi runs tasks relative to the directory containing pixi.toml. Passing absolute paths ("$app_root/...", "$judgment_root/...") avoids path surprises regardless of your working directory. Do not rebuild $judgment_root/build while another compiler process is reading from it.

If your project maintains its own pixi.toml, pin Mojo 1.2.0 and compatible apn_mojo and fp_mojo versions. Those two are the runtime dependencies.

5. Package a self-contained .mojoc bundle

To ship a single precompiled bundle without copying the whole source tree:

pixi run package              # default packages + apn_mojo + fp_mojo under dist/
pixi run package --with-store # also includes judgment_store

Extract the archive and point Mojo at its lib/mojo directory:

mojo build -I /path/to/extracted/lib/mojo main.mojo -o app

Each archive carries a file-hash manifest pinning the compiler and platform. Upgrade the bundle as a whole.

6. Application boundary conventions

  • Session scoping: pass handles only to the Session that created them. Another Session rejects foreign handles with WRONG_KERNEL.
  • Target verification: when an external solver or application proposes derivations, verify that the returned statement matches the expected target and inspect hypotheses() and axioms().
  • Transaction isolation: execute speculative derivations inside transactions, discarding on failure and retaining only required handles on commit.
  • Explicit persistence: use Session.seal, Session.export, and Library (judgment_store) to carry checked theorems across runs or processes.

See also the Quick reference, the API task map, and Troubleshooting.

judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub