How-to Guides

Scalar workflows

The Scalar profile provides a checked extended-complex number system (finite complex numbers, directed infinities \(\infty \cdot z\), complex infinity \(\tilde{\infty}\), and \(\mathrm{indet}\)) over Session, together with symbolic proof engines and a cut-aware numeric filter.

This guide covers selecting a ProfileLevel, budgeting profile construction, reusing sealed profiles, and combining numeric refutation with symbolic proofs in Mojo or Python. For runnable examples, see Lesson 4.2, Lesson 4.3, and Lesson 4.4.

Selecting a ProfileLevel

Build only up to the level required by your workload; each level extends the preceding one with additional checked theorems:

ProfileLevel Contents Typical budget Use when
FOUNDATION Carrier, G1–G7 axioms, 8 foundational definitions and theorems (finite, zero, one, plus, times, neg, inv, infinities) 10_000_000 (~1 s) Prototyping, G1 case splits (class_split), numeric evaluate / decide / refute on rational expressions
EXACT_ARITHMETIC ACU operators (+, *), exact rational literals (scalar.rationals), domain theorems, and literal_facts 200_000_000 (~1–1.5 min) Exact rational folding, ACU reflexivity, literal_facts, and build_scalar_poly (reify / identity)
POWERS_AND_ROOTS Integer and rational powers, roots, and algebraic lemmas required by transfer 1_000_000_000 (~2.5–3 min) Automatic guarded rational-function equalities via transfer
ELEMENTARY_FUNCTIONS / ALL 24 elementary functions, 14 off-cut predicates (ScalarAtom.OFFCUT), and 282 formula and infinity theorems 2_000_000_000+ Elementary function identities, branch-cut OFFCUT guards, and build_library

ProfileLevel.POLYNOMIALS, LIBRARY, NUMERIC, and HOL_MODEL are not valid arguments to build_scalar; call their dedicated builders (build_scalar_poly, build_library, evaluate/decide/refute, and build_model) instead.

Opening sessions and reusing sealed profiles

Build higher profile levels once and reuse their sealed snapshots:

  • Direct profile session: session(profile, ["x", "y"], work=...) opens a live Session, declares x and y of type scalar.Scalar, and provides a default base() frame assuming scalar.finite(x) and scalar.finite(y).
  • Polynomial or library session: call Session.open(poly.sealed_snapshot()) or Session.open(lib.sealed_snapshot()) (supported in Mojo thin client, direct Mojo, and Python).
  • Persisting a profile: publish profile.sealed_snapshot() to a judgment_store Library via change.add_snapshot(...) so subsequent runs load the checked snapshot instead of rebuilding.

Combining numeric refutation with symbolic proofs

  1. Screen conjectures with refute (FOUNDATION or ALL): pass lhs, rhs, proposed guard, and variables to refute(...). Missing pole or branch-cut conditions produce FilterVerdict.REFUTED with an exact counterexample witness. FilterVerdict.PASSED is testing evidence only, not a proof.
  2. Construct and test guards (ScalarAtom, decide, to_guard, is_generic): form F-5 guard atoms (FINITE, NONZERO, REAL, INTEGER, LT, LE, RE, IM, OFFCUT, UNWOUND), evaluate them at exact points with decide, and translate them to HOL propositions with to_guard.
  3. Derive checked proofs:
  4. Use transfer (POWERS_AND_ROOTS) for rational-function equalities to compute the exact generic guard and derive guard → lhs = rhs.
  5. Use build_scalar_poly with reify / identity (EXACT_ARITHMETIC or higher) for polynomial identities over arbitrary (including opaque) Scalar subexpressions.
  6. Use literal_facts (EXACT_ARITHMETIC or higher) for checked domain steps (real, finite, rational, integer/~integer) of exact rational constants.
  7. Use class_split (any level) to split into G1's four exhaustive carrier cases (finite, Indeterminate, ComplexInfinity, directed infinity with fixed finite nonzero witness).

Analytic laws via the HOL model

The axiomatic profile does not postulate analytic identities as axioms. For checked analytic laws (such as \(\sqrt{(-1)^2} = 1\), \(\log(e^z)\) on the principal strip, inverse trigonometric ranges, and monotonicity of exp and log), construct the conservative HOL model over judgment_mathlib:

  1. Fetch judgment_mathlib (pixi run fetch-judgment-mathlib) and load its rechecked Snapshot via Library.snapshot(...).
  2. Call build_model (discharging G1–G7 conservatively with zero scalar axioms), followed by build_bridges (26 guarded bridge theorems and 14 counterexamples), build_classes (native commutative monoid instances), and build_analysis (105 checked analytic laws).

See the Scalar API reference, Numeric semantics reference, and HOL model and bridges theory.

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