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
ctypeswith 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),*Datavalues,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) andwrite_article;Identity.from_hexandSession.import_theorem/import_theoremsover bothLibraryandArticle;- 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) orjudgment_search(Lesson 5.3). ScalarLibrary.index(returns the internal discrimination-tree index).- Native
fp_mojoIO / resource combinators (*_iomethods andArticle.resource; use the synchronous methods above in clients). - Low-level
judgment_coreortermbankinternals beyondSession.literal_kindandSession.literal. - Driving
Session.forkorProof.forkconcurrently from multiple client threads (internal parallelism such asLibrary.snapshotandLibrary.recheckstill 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 storefor 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_COREfirst, then an installed conda/Pixi prefix ($CONDA_PREFIX/lib/orsys.prefix/lib/), then a repository checkout (.cache/prebuilt-core/lib/), preferringlibjudgment_storewhen present and falling back tolibjudgment. - Mojo
dlopenloader: the Mojo client loads the shared library lazily viaOwnedDLHandle(reusing already-linked symbols if built with-ljudgment*), so installed users runmojo runandmojo buildwith no-Xlinkerflags. - On-demand
judgment_mathlib: calljudgment.fetch_mathlib()(orjudgment.fetch_mathlib(dest)) from either Mojo or Python, or runjudgment-fetch-mathlibfrom the shell, to download and SHA-256-verify the external 591 MiB Isabelle math library into$JUDGMENT_MATHLIBor~/.local/share/judgment_mathlib.
Client runtime notes¶
Mojo thin client¶
judgment.exactsplit: anything involvingapn_mojoIntegerorRationallives injudgment.exact(ExactValue,ExactPoint,FilterConfig,FilterVerdict,NumericValue,InfiniteClass,ComplexBall,LiteralValue,PolyValue,PolyTerm,evaluate,decide,refute,literal_facts, and free-function wrappersnumber,rational,polynomial,literal). Programs that do not importjudgment.exactskip compilingapn_mojo.- Budgets and errors:
Budget,LibError,LibErrorKind,StoreError, andStoreErrorKindare exported directly fromjudgment. Non-raising accessors retry automatically if a session or object is temporarilyBUSY.
Python client¶
- Exact numbers:
intof any size (binary-encoded, bypassing CPython's decimal-digit limit) andfractions.Fraction. - Equality and truthiness:
a == bconstructs a HOL equation (Expr); usea.same_as(b)for handle identity.bool(expr)raisesTypeError. - Lifetimes, threads, and processes: each
Sessionholds ~35 MB, so reuse sessions instead of allocating thousands.ctypesreleases the GIL during calls; each session, object, orBudgetserves one call at a time (BUSYotherwise). GC finalizers queue deferred frees safely. Do not callfork()afterimport 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:
Budgetis updated in place even when a call fails. - Checked handles: every handle carries a kind, slot, and non-reused
generation serial (
BAD_HANDLEon stale or freed handles;WRONG_KERNELon handles from another live session). - Atomic failure: a refused call leaves the session, its tables, and any consumed-value arguments unchanged.