Architecture overview¶
scalar is a package of the unified judgment repository, built from the
same checkout, version and toolchain as the kernel and the authoring library.
The whole system is described by its architecture note:
the source of truth for the system's architecture, with which this
package's design must agree. Component contracts are in
integration, and kernel additions in
extensions. Read the note's sections 1 to 5, then
the integration contracts; scalar's own theory and specification are in
this part of the site.
Role¶
A semantic profile gives CAS symbols their meaning. scalar
is the first one: extended complex numbers with explicit arithmetic conventions.
It provides:
| Part | What it gives | Contract | Reference |
|---|---|---|---|
| The profile builder | a function that declares the profile in a session, seals it into a checked Snapshot, and returns a profile that reads each declaration by name |
X-profile | Builder and axioms |
| Axioms | G1–G7, their model, categoricity (axioms) | X-profile | Builder and axioms |
| The literal kind and ACU operators | exact rationals as literals; addition and multiplication associative and commutative in the kernel's conversion, with their laws proved | X-profile | Literals and arithmetic |
| Order and domains | the extended real order; real, integer, rational, positive, … |
X-profile | Literals and arithmetic |
| Powers and roots | integer and general powers, sqrt, surd |
X-profile | Powers and roots |
| Elementary functions | exp, log, the trigonometric and hyperbolic functions and their inverses, with the guard language |
X-profile | Elementary functions |
Polynomials over Scalar |
Poly, the kernel's polynomial kind bound to Scalar's rationals, peval, reification |
X-profile | Polynomial theory |
| The lemma library | the guarded field laws, the transfer lemmas, order and domain lemmas, function identities and real-domain laws, special values | X-profile | Lemma library |
| Law bundles | CommutativeRing, OrderedField, PolynomialEvaluation filled for the profile |
L-bundles (filled) | Lemma library |
| Numeric semantics | cut-aware ball evaluation, the numeric filter that finds mistakes | X-profile | Numeric semantics |
| The HOL model and bridges | the carrier built inside HOL from judgment_mathlib's complex, the axioms proved there, the bridge theorems, the lemmas that need analysis |
X-bridge | HOL model and bridges |
Boundaries¶
- Imports.
std,termbank,judgment_core,judgment_shell,fp, and apn_mojo (for ball arithmetic), asscripts/packages.pyrecords; the publicjudgmentfacade importsscalar, not the other way round. Tests also usejudgment_store(to ship the profile as a bundle), judgment_mathlib (the proof library of Isabelle/HOL theories used to prove the model and bridge results, opened withjudgment_store'sLibrary), andpolyand itspolynomialscore (for the end-to-end polynomial identity integration check), as test-only dependencies. Scalar reads the library's entities only through aNativeNamestable that the caller fills. - Trust. The axioms G1 to G7 are admitted axioms of the profile, in
every dependent result's label; the HOL model proves them as theorems of the
model theory built from judgment_mathlib's
complex(Theorem H-1). Everything else the profile declares is a definition or aProventheorem. In the model theory, judgment_mathlib's theorems appear in labels as imported statements with their Isabelle sources when only their statements are imported; over the library's whole version, which the kernel rechecks as it loads it, they are checked theorems, and the bridges, class instances and analytic library accept only those. Nothing is admitted on numeric evidence. The code of this package is untrusted: it builds declarations and recipes that the kernel checks. - Consumers. Session theories extend the profile; the law bundles
and the indexed lemma library are its interfaces for proof tools, such
as
judgment_shell'srewrite. No engine importsscalar(the system's package rule 1).
The package¶
Construction captures operation handles by role separately from the G1–G7
evidence used by proof recipes. Shared statement and definition builders use
those captured handles, including elementary functions, rather than declaration
offsets or lookup in a later theory. The model therefore assembles its carrier
and 71 operations without placeholder axiom handles. Generic propositional
decisions and simplification belong to judgment_shell; Scalar retains its
conditional and constructor reduction policy.
The builder records each declaration's role as it makes it; that list fixes declaration and export order, and a sealed profile reopens it by name in any session over its snapshot. This preserves the XG1 axioms and the XG3 declaration identities. XG4's recipe is the theorem's checked proof rows, kept with the profile's sealed snapshot and rechecked by the checker.
scalar → std, termbank, judgment_core, judgment_shell, apn_mojo, fp
The package map lists every module of
src/scalar/ with the feature it supports.
The profile as data¶
The profile is built by code, deterministically, in a session that
build_scalar seals into a checked Snapshot; its theorems' checked proof
rows are kept for replay and audit (ground rule XG4). judgment_store can
write it as a proof library (contract S-format,
profile export); a session either
builds it or loads the library, and gets the same declarations (by
identity).
Shared proof and syntax infrastructure¶
Scalar delegates constructive existential and connective rules, weakening,
and equality composition to judgment_shell. Its adapters preserve kernel-error
provenance at Scalar's boundary. The library's iterative equality traversal
also runs native constant replacement and model reduction. Scalar retains
eta contraction, binary folding of native ACU images, mathematical leaf rules,
and model-specific Boolean and conditional decisions. Boolean decisions use
an explicit stack as required by G2; all proof traversal shares the caller's
work allowance (G3, XG3).
Numeric evaluation, guard classification, rational transfer, polynomial reification, and imaginary-factor decomposition share operation identities, arity rules, and structural recognition. The catalog consumes captured operation handles and has no profile-builder dependency; profile validation and coordinate policies are separate adapters. Mathematical acceptance and proof construction remain with each consumer.
Numeric compilation validates every root before DAG deduplication, supports session declarations newer than the profile, and prunes unknown or partially applied numeric heads. Proof-context readers use checked core decomposition. Scalar does not decode termbank application layouts or literal bytes.
Closed internal forms¶
An F-5 atom's public tag is validated once, in tag, arity, function, and
relation order, and decoded into a closed internal sum type (fp_mojo
Choice). Guard construction (to_guard) and numeric decision (decide)
each read an atom's meaning through one exhaustive fp.match over that type,
so neither has a fallback branch; each keeps its own validation messages.
The numeric filter classifies each sample as discarded, checked, undecided, or
refuted (an internal Choice), and one exhaustive match counts it toward the
verdict's totals. Recipe families are classified by an unrolled comparison
with the compile-time table of first kinds.