Get Started

The prebuilt core and its clients

Both the Mojo thin client and the Python package call the same compiled shared library on Linux and macOS (libjudgment.so or libjudgment.dylib, plus libjudgment_store.so or libjudgment_store.dylib for Store workflows).

Mojo's .mojoc packages store compiler IR rather than machine code, so compiling a Mojo proof directly against src/ re-optimizes every part of judgment it reaches on every edit. Compiling the facade once into a shared library avoids that cost in both languages:

  • Mojo thin client: rebuilds only your program and thin FFI wrappers (~1–3 s per edit instead of minutes).
  • Python package: calls the same library via ctypes with no compilation step (~30 ms startup).

Neither client adds trusted code. Both hold opaque handles, and every judgment still goes through judgment_core's public rules (trusted base).

Scope of version 1 (ABI 6)

The current C ABI is version 6. Both clients check the ABI version and generator hash on load and refuse a mismatched build.

Included in the prebuilt core

  • Core facade (libjudgment): Session, Expr, TypeExpr, Fact, Step, Frame, Snapshot, Proof, Goal, Focus, BinderFocus, Calculation, Transformation, Tactic, Tactics, all declaration builders (AxiomBuilder, DefinitionBuilder, ClassBuilder, ConstantBuilder, SubsetBuilder, InstanceDefinitionBuilder), *Data values, recipe, hole, StopSignal (__init__, request, requested), and all expression constructors.
  • Scalar (libjudgment): ProfileLevel, ScalarProfile, PolyTheory, ScalarLibrary, ModelTheory, NativeNames, sealed_snapshot(), build_scalar, build_scalar_poly, build_library, build_classical, build_model, build_bridges, build_classes, build_analysis, session, default_context, symbolic proof helpers (transfer, reify, identity, literal_facts, class_split, to_guard, is_generic, TransferResult, Reified, ClassCase, ScalarAtom, ScalarRelation), and the numeric engine (evaluate, decide, refute, ExactValue, ExactPoint, FilterConfig, FilterVerdict, NumericValue, GuardDecision, InfiniteClass, ComplexBall).
  • Store (libjudgment_store):
  • Library (create, open, theorems, categories, find, dependents, snapshot, profile_snapshot, recheck, is_current, version, change);
  • LibraryChange (add, add_snapshot, add_article, replace, withdraw, base, publish, rebase);
  • Article (open, theorems, write) and write_article;
  • Identity.from_hex and Session.import_theorem / import_theorems over both Library and Article;
  • Theory interpretations (TypeImage, PreparedInterpretation, prepare_interpretation, transport_type, transport_term, transport_scoped_term, reuse).

Direct-package Mojo only

Import the Mojo packages directly (pixi run build*) only when you need:

  • Optional packages judgment_nat (Lesson 4.5) or judgment_search (Lesson 5.3).
  • ScalarLibrary.index (returns the internal discrimination-tree index).
  • Native fp_mojo IO / resource combinators (*_io methods and Article.resource; use the synchronous methods above in clients).
  • Low-level judgment_core or termbank internals beyond Session.literal_kind and Session.literal.
  • Driving Session.fork or Proof.fork concurrently from multiple client threads (internal parallelism such as Library.snapshot and Library.recheck still runs multi-threaded inside a single call).

Building and locating the core

Build once from the repository root:

pixi install --locked
pixi run build-core            # builds libjudgment.so / .dylib
pixi run build-core-store      # adds libjudgment_store.so / .dylib
  • Mojo: pixi run core-run PROGRAM.mojo (pass --variant store for Store programs; see Use in your project).
  • Python: PYTHONPATH=bindings/python pixi run python PROGRAM.py (see Proofs from Python).
  • Automatic lookup (Mojo and Python): both clients check $JUDGMENT_CORE first, then an installed conda/Pixi prefix ($CONDA_PREFIX/lib/ or sys.prefix/lib/), then a repository checkout (.cache/prebuilt-core/lib/), preferring libjudgment_store when present and falling back to libjudgment.
  • Mojo dlopen loader: the Mojo client loads the shared library lazily via OwnedDLHandle (reusing already-linked symbols if built with -ljudgment*), so installed users run mojo run and mojo build with no -Xlinker flags.
  • On-demand judgment_mathlib: call judgment.fetch_mathlib() (or judgment.fetch_mathlib(dest)) from either Mojo or Python, or run judgment-fetch-mathlib from the shell, to download and SHA-256-verify the external 591 MiB Isabelle math library into $JUDGMENT_MATHLIB or ~/.local/share/judgment_mathlib.

Client runtime notes

Mojo thin client

  • judgment.exact split: anything involving apn_mojo Integer or Rational lives in judgment.exact (ExactValue, ExactPoint, FilterConfig, FilterVerdict, NumericValue, InfiniteClass, ComplexBall, LiteralValue, PolyValue, PolyTerm, evaluate, decide, refute, literal_facts, and free-function wrappers number, rational, polynomial, literal). Programs that do not import judgment.exact skip compiling apn_mojo.
  • Budgets and errors: Budget, LibError, LibErrorKind, StoreError, and StoreErrorKind are exported directly from judgment. Non-raising accessors retry automatically if a session or object is temporarily BUSY.

Python client

  • Exact numbers: int of any size (binary-encoded, bypassing CPython's decimal-digit limit) and fractions.Fraction.
  • Equality and truthiness: a == b constructs a HOL equation (Expr); use a.same_as(b) for handle identity. bool(expr) raises TypeError.
  • Lifetimes, threads, and processes: each Session holds ~35 MB, so reuse sessions instead of allocating thousands. ctypes releases the GIL during calls; each session, object, or Budget serves one call at a time (BUSY otherwise). GC finalizers queue deferred frees safely. Do not call fork() after import judgment; use "spawn".

Guarantees across the C boundary

Every call through either client preserves the library's core guarantees:

  • Deterministic results and work charges across Mojo and Python.
  • Bounded, charged work: Budget is updated in place even when a call fails.
  • Checked handles: every handle carries a kind, slot, and non-reused generation serial (BAD_HANDLE on stale or freed handles; WRONG_KERNEL on handles from another live session).
  • Atomic failure: a refused call leaves the session, its tables, and any consumed-value arguments unchanged.
judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub