Scalar mathematical theory

Numeric semantics

The profile's values are exact, but some of its tools need numbers: the numeric filter tests a rule before anyone tries to prove or import it, and finds mistakes (the architecture note's admission gate, section 31.3, which admits nothing). This page defines evaluation with balls, cut-aware, and the filter.

Balls

Definition N-1 (ball evaluation). A complex ball is apn_mojo's ComplexBall, a rectangle formed from two real midpoint-radius balls. It encloses \(w \in \mathbb C\) when its real and imaginary intervals contain the corresponding coordinates of \(w\). The ball evaluation \(\mathcal B(e, a, p)\) of a closed expression \(e\) of the profile at an exact point \(a\) (rational coordinates, possibly with \(\pi\) and \(\sqrt{}\) of rationals), at working precision \(p\), returns one of:

  • a ball, which encloses the value of \(e\) at \(a\) in \(\hat S\), a finite number;
  • INFINITE(class) when the value is provably a non-finite element (\(D(\theta)\) with \(\theta\) enclosed by a ball, \(C_\infty\), or \(I\));
  • INCONCLUSIVE when neither can be established at that precision.

It evaluates bottom-up with apn_mojo's ball operations [Johansson 2017], and handles each elementary function's cut explicitly:

  1. If the argument's ball lies entirely off the cut, apply the ball function.
  2. If the argument is exactly on the cut (an exact point whose coordinates make it so, for example a negative rational argument of \(\log\)), evaluate the formula with the closure of Proposition F-1 (for \(\log\) of a negative real, \(\ln\lvert x\rvert + i\pi\)).
  3. If the ball meets the cut but is not exactly on it, raise the precision and retry; past the precision limit, return INCONCLUSIVE.

Divisions and other operations whose result depends on whether an operand is \(0\) (or infinite) branch the same way: decided when the ball excludes \(0\) or the operand is exactly \(0\), otherwise retried and finally INCONCLUSIVE.

Theorem N-2 (enclosure). If \(\mathcal B(e, a, p)\) returns a ball \(B\), the value of \(e\) at \(a\) in \(\hat S\) is finite and lies in \(B\); if it returns INFINITE(class), the value is of that class.

Proof. By induction on \(e\). apn_mojo's ball operations enclose the exact results of their operands' enclosed values (the enclosure property of midpoint-radius arithmetic [Johansson 2017], which apn_mojo's own documentation states and tests). Step 1 evaluates an analytic function on a ball where it is continuous; step 2 evaluates the exact formula at an exact point; step 3 never returns a ball; a branch on \(0\) is taken only when it is decided. \(\square\)

Requirement N-R1. apn_mojo's ComplexBall functions enclose their exact values; scalar relies on this and tests it against tests/scalar_tests/reference/elementary_reference.py at random points.

Deciding guards at points

Proposition N-3. An atom of the guard language (Definition F-5) is decided at an exact point \(a\) when ball evaluation separates it: for \(s < t\), the balls of \(s\) and \(t\) are disjoint and real; for \(t \ne 0\), the ball of \(t\) excludes \(0\) or \(t\) is exactly \(0\); for \(\mathrm{offcut}_f(t)\), the ball of \(t\) is off the cut or exactly on it; for \(\mathrm{real}(t)\), \(t\)'s imaginary part is exactly \(0\) or its ball excludes \(0\). Otherwise the atom is undecided at \(a\). \(\square\)

The numeric filter

Algorithm N-4 (the filter). To test a rule \(\ell = r\) with guard \(G\):

  1. Sample points. Choose, deterministically:
  2. one exact point in each cell of the decomposition of the plane by the cuts of every function in \(\ell\) and \(r\) (the cells' interiors);
  3. one exact point on each piece of each cut, and at each branch point;
  4. the singular points: the exact zeros of each denominator and of each argument at which a function has a pole or a branch point, where they can be found exactly (a factor linear in one variable, with rational or \(\pi\)-rational coefficients);
  5. points near the boundary of \(G\) (the zero sets of its atoms), on both sides;
  6. points from SplitMix64 with a fixed seed, in boxes of several scales.
  7. Certify the guard at each point (Proposition N-3); discard the points where \(G\) is false, and count those where it is undecided.
  8. Evaluate \(\ell\) and \(r\) by ball evaluation at the remaining points.
  9. Verdict. REFUTED with the point as witness, if at some point both are balls and the balls are disjoint, or one is finite and the other provably not, or both are certified distinct nonfinite values; INCONCLUSIVE if no guard-satisfying point was checked conclusively or too large a fraction of points were undecided; PASSED otherwise.

Theorem N-5 (what the filter establishes). If the filter returns REFUTED, the rule is false in \(\hat S\), so no proof of it exists and assuming it would contradict the profile's intended model (Corollary A-3). PASSED establishes nothing about the rule's truth.

Proof. At the witness point, \(G\) holds (it was certified), and the values of \(\ell\) and \(r\) differ (Theorem N-2). PASSED is a statement about finitely many points. \(\square\)

The filter finds mistakes; it never admits anything. A rule that passes still needs a proof, in the kernel or from judgment_mathlib's theorems, imported from Isabelle2025-2, through the checked HOL model and bridges. It is worth running before either: a wrong guard is found in milliseconds. The points on cuts matter: a ball straddling a cut cannot refute \(\log(1/z) = -\log z\), which fails exactly on the negative real axis (Theorem E-2(4)), but an exact point there does [Beaumont, Bradford, Davenport and Phisanbut 2007].

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