Tutorials¶
These tutorials walk through judgment from basic natural deduction to
extended-complex symbolic algebra, cut-aware numeric refutation, order-sorted
type classes, natural-number induction, deterministic concurrent search, and
versioned binary proof libraries.
Every lesson uses Mojo or Python programs that construct claims, derive their proofs, and inspect or persist checked results.
Setup¶
Both the Mojo thin client and the Python package call the same compiled
prebuilt core (libjudgment.so / .dylib, plus
libjudgment_store.so / .dylib for Part 5 Store lessons) on Linux and
macOS. Once built, editing proof scripts does not recompile the library:
pixi install --locked
pixi run build-core # builds libjudgment.so / .dylib for Mojo and Python
pixi run build-core-store # adds libjudgment_store.so / .dylib for Part 5
- Mojo: run lessons via the thin client (
pixi run core-run PROGRAM.mojo). See Getting started and Use in your project. - Python: run lessons directly over the same shared library
(
PYTHONPATH=bindings/python pixi run python PROGRAM.py). See Proofs from Python. - Direct-package Mojo lessons:
judgment_nat(4.5),judgment_search(5.3), and low-leveljudgment_core/termbankexamples compile directly against source or precompiled packages (pixi run build,build-nat,build-search,build-store).
Use the Mojo / Python toggle above any example; the selection persists across the site. Each lesson includes runnable code, expected output, and exercises.
Reading order¶
- Part 1 introduces
Session, goal-first and forward proofs, rewrites, calculations, definitions, and proof inspection. - Part 2 covers structured proofs, conditional rewrites, composable and data-driven tactics, checked term transformations, admissions, and sealed snapshots.
- Part 3 covers HOL polymorphism, nonempty subset types, specifications, checked overloading, order-sorted class hierarchies, and custom ACU operators.
- Part 4 covers exact rational and polynomial literals, the extended-complex
Scalarprofile, rational transfer, polynomial reification, cut-aware numeric refutation, and conservative Peano naturals. - Part 5 covers transactions, forks, work budgets, concurrent search,
format-2.2 binary libraries, OpenTheory interchange, theory interpretations,
external-engine verification, memory caps, spill storage, and
judgment_mathlib.
Part 1: Core proofs¶
| Lesson | Topic |
|---|---|
| 1.1 Prove your first theorem | Basic Session, intro, exact, and finish. |
| 1.2 Prove by cases | Disjunction elimination (cases) and introduction (choose_left, choose_right). |
| 1.3 Talk about arbitrary values | Universal and existential quantifiers, parameters, and checked witnesses. |
| 1.4 Rewrite with a reason | Subterm focusing (lhs().at(...)) and targeted equational rewrites. |
| 1.5 Write an equality calculation | Equational chains (calc, eq) with checked intermediate justifications. |
| 1.6 Reuse a theorem | Backward rule application (apply) and subgoal discharge. |
| 1.7 Define names and track assumptions | Transparent vs. opaque definitions, local premises, and tracked axioms. |
| 1.8 Inspect and repair a proof | Checkpoints, diagnosing NO_MATCH refusals, and restoring proof state. |
| 1.9 See what remains to prove | Open obligations, sorry, and dependency auditing. |
Part 2: Structuring proofs and automation¶
| Lesson | Topic |
|---|---|
| 2.1 Negation, equivalence, and using witnesses | Negation (~), contradiction, iff, and existential elimination (obtain). |
| 2.2 Claims, abbreviations, and binders | Intermediate claims (have), local definitions (define/fold/unfold), and binder rewrites (under). |
| 2.3 Conditional rewrites and deferred calculations | Explicit side conditions (premises=[...]), deferred calculation steps (chain.step), and nested branches. |
| 2.4 Tactics, proof holes, and theorem discovery | Tactics, session-free TacticData, hole refinement, and suggest. |
| 2.5 Tactic combinators and deferred rewrites | or_else, repeat, all_goals, nested binders, and deferred occurrence rewrites (rewrite). |
| 2.6 Checked term transformations | Direct term rewriting (Session.transform, Proof.transform) and equality evidence(). |
| 2.7 Admissions, transactions, and sealed theories | sorry vs. recorded admit, sealing verified snapshots (seal), and importing into fresh sessions. |
Part 3: Types, overloading, and type classes¶
| Lesson | Topic |
|---|---|
| 3.1 Instantiate polymorphic theorems | Lambdas, β-reduction, and polymorphic instantiation across types. |
| 3.2 Define nonempty subset types | Introducing types from proved nonemptiness witnesses and using abs/rep laws. |
| 3.3 Specifications, overloading, and type classes | Constant specifications, checked overloading, type classes, generic instances, and sorted type variables. |
| 3.4 Class hierarchies, parameterized subsets, and custom ACU | superclass, class_relation, parameterized SubsetBuilder types, and custom acu_operator declarations. |
Part 4: Symbolic math, Scalar, and naturals¶
| Lesson | Topic |
|---|---|
| 4.1 Compute exact arithmetic and polynomial literals | Exact rational and formal-polynomial literal kinds (with the law setup). |
| 4.2 Extended complex numbers with Scalar | ScalarProfile, finite values, directed infinities, Indeterminate, ACU conversion, and ScalarLibrary. |
| 4.3 Guarded algebra, Scalar polynomials, and the theorem library | Rational transfer, to_guard, class_split, polynomial reify / identity, and literal_facts. |
| 4.4 Test conjectures numerically and find counterexamples | Cut-aware ball evaluation (evaluate), guard checks (decide), and counterexample search (refute). |
| 4.5 Natural numbers, induction, and primitive recursion | Conservative Peano naturals (judgment_nat), nat.induct, and define_primrec (Mojo). |
Part 5: Concurrency, persistence, and integration¶
| Lesson | Topic |
|---|---|
| 5.1 Scope work with transactions, snapshots, and forks | Nested transactions, TheorySnapshot rollbacks, and isolated Session.forks. |
| 5.2 Work budgets, proof forks, and cancellation | work_remaining/spend/add_work, speculative Proof.forks, and StopSignal cancellation. |
| 5.3 Concurrent proof search and parallel lemma checking | Deterministic first tactic racing and concurrent check_lemmas over lemma DAGs (Mojo). |
| 5.4 Save and reopen a binary library | Publishing to a format-2.2 binary library, rechecking proof rows, and loading in a fresh process. |
| 5.5 Evolve a library and track external claims | Withdrawals, dependency protection, rebase on concurrent writes, and external claim records. |
| 5.6 Snapshot publication, replacement, and provenance auditing | add_snapshot, replace, dependents/categories, and auditing instance reliance and claims. |
| 5.7 Exchange proofs with OpenTheory | Exporting OpenTheory v6 articles, checking untrusted imports, and persisting them in a library. |
| 5.8 Verify an exported proof in Isabelle/HOL | Proving Cantor's theorem with zero axioms, exporting an OpenTheory v6 article, and checking it independently in Isabelle/HOL. |
| 5.9 Transport theorems between theories with interpretations | Cross-session TypeImage, transport_type, transport_term, prepare_interpretation, and reuse. |
| 5.10 Check a symbolic transformation | Checking derivations proposed by an external simplifier while preserving domain guards. |
| 5.11 Check a proof against a promised conclusion | Proof-DAG sharing with low-level Step rules and verifying exact conclusions. |
5.12 Manage memory limits, spill storage, and judgment_mathlib |
Workspace caps (set_memory_limit), disk spill, and opening judgment_mathlib. |
Proof checking discipline¶
Every derivation passes through judgment_core, which verifies types,
conclusions, and explicit assumptions. Helpers, tactics, numeric filters (such
as refute), and external solvers never bypass the kernel. A rejected step
means that derivation did not establish the target; it does not prove the
negation.
For full contracts, keep the proof-authoring guide, Scalar workflows, Store guides, and API guide at hand.
Start: 1.1 Prove your first theorem.