Documentation

Noperthedron.Checker.Local

Local Validity Checker #

A computable, pure-ℚ checker that verifies whether a decision-tree row satisfies the preconditions of the rational local theorem. Everything here is computable — no noncomputable keyword.

@[reducible, inline]
Equations
Instances For
    @[reducible, inline]
    Equations
    Instances For
      @[reducible, inline]
      Equations
      Instances For
        @[reducible, inline]
        Equations
        Instances For
          @[reducible, inline]
          Equations
          Instances For
            @[reducible, inline]
            Equations
            Instances For
              @[reducible, inline]
              Equations
              Instances For

                Spanning condition: hoisted trig, scalarized applied vectors #

                def Noperthedron.Solution.Spanningℚ (θ φ ε : ) (T : Fin 3Fin 3) :

                The rational matrix form of the ε-κ-spanning condition on the triangle T for angles (θ, φ) (cf. Local.Triangle.κSpanning). Named so that its Decidable instance (via Spanningℚ.check) can hoist the trig entries of rotMℚ_mat θ φ out of the i-loop and bind the applied vectors' components as scalars; the generic mulVec/dotProduct instances would re-evaluate the trig partial sums on every component access.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Noperthedron.Solution.Spanningℚ.check (θ φ ε : ) (T : Fin 3Fin 3) :

                  Bool-valued Spanningℚ check: trig partial sums are evaluated once per pose and everything the i-loop touches is bound as a scalar.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    theorem Noperthedron.Solution.Spanningℚ.check_iff (θ φ ε : ) (T : Fin 3Fin 3) :
                    check θ φ ε T = true Spanningℚ θ φ ε T

                    Row.δ: max over per-i BoundDeltaℚi values, hoisting trig once #

                    The ten sin/cos values (of θ₁ φ₁ α θ₂ φ₂) of a rational pose, evaluated once per pose.

                    Instances For
                      @[inline]
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[inline]

                        BoundDeltaℚi for a single i, with the 10 trig values used by M₁, R, M₂ passed in already evaluated.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Integer core #

                          The norm² is assembled exactly at scale 10¹¹⁰ (difference vector at 10⁵⁵) and the upper square root becomes one integer ceiling division plus Nat.sqrt (sqrtNum110, output scale 10¹⁶), so the whole per-i value is (sqrtNum110 … + 6·10⁶) / (2·10¹⁶). The ℚ helpers above stay as the proof-side bridge to BoundDeltaℚi.

                          Integer form of sqrtℚUp16 on inputs S/10¹¹⁰: the inner ceiling ⌈S/10⁷⁸⌉ is -((-S)/10⁷⁸) (floor division). Output scale 10¹⁶.

                          Equations
                          Instances For

                            The ten trig numerators (scale 10¹³) of a rational pose.

                            Instances For
                              @[inline]
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[inline]

                                Integer core of boundDelta_at (up to the final (·+6·10⁶)/(2·10¹⁶)): M₁-rows lifted to scale 10²⁶, dots at 10⁴², the R-rotated and M₂-lifted difference at 10⁵⁵, norm² at 10¹¹⁰.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  The δ bound for a row: max_i ‖R·M₁·P_i − M₂·Q_i‖ / 2 + 3κ. Equivalent to Finset.max' (Finset.image BoundDeltaℚi univ) _ (see Row.δ_eq_max'_BoundDeltaℚi), but the trig partial sums are hoisted once per pose for a ~6× runtime speedup.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Precomputed pairwise vertex-difference norms for Bεℚ #

                                    The n_dv term of the Bεℚ predicate — sqrtApprox16.upper_sqrt.norm (Q_i − v_k) — is pose-independent, but costs a sqrtℚUp16 call on a denominator-10³² input for each of the 270 (i, k) pairs of every local row. sqrtDv reads all 90 × 90 pairs from the source-literal table sqrtDvCurried (generated, see Checker/SqrtDvLiterals.lean), and BεℚPy.check is the pythonVertexA/sqrtApprox16 checker of Bεℚ that reads it (the Bεℚ predicate itself is unchanged). The curried-literal form keeps the table cheap for the kernel too: an access walks a few dozen Fin.cons cells, where reducing an equivalent 8100-entry Array.ofFn push chain made a single high-index access cost tens of gigabytes under decide +kernel.

                                    Decode the flat index 45·ℓ + 15·i + k (see rowDotsGet).

                                    Equations
                                    Instances For

                                      Table-backed pairwise vertex-difference norm: equal to sqrtApprox16.upper_sqrt.norm (pythonVertexA a - pythonVertexA b) by sqrtDv_eq.

                                      Equations
                                      Instances For

                                        Runtime lookup table for sqrtDv, built once per process from the sqrtDvCurried literals; indexed by the flat pair index flat a * 90 + flat b with flat ⟨k, ℓ, i⟩ = 45·ℓ + 15·i + k.

                                        Equations
                                        Instances For

                                          Array-backed implementation of sqrtDv: a per-pair curried lookup costs ~40 Fin.cons dispatches plus a Rat renormalization, which measurably slows the compiled hot loop, so sqrtDv_eq_sqrtDvImpl (@[csimp]) substitutes this O(1) array read in compiled code. The kernel keeps reducing the curried-literal sqrtDv itself.

                                          Equations
                                          Instances For

                                            Per-pose table of the row dot products ((M₂ vⱼ)₀, (M₂ vⱼ)₁) (unrounded) for all 90 vertices, indexed by flat ⟨k, ℓ, i⟩ = 45·ℓ + 15·i + k. check computes it once per pose; by linearity M₂(v₁ - v₂) = M₂v₁ - M₂v₂, each (i, k) dot then costs one lookup and one subtraction instead of three products.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              Read a rowDots table at a vertex index.

                                              Equations
                                              Instances For

                                                Bool-valued checker for Bεℚ at pythonVertexA and sqrtApprox16, with the per-pose work hoisted out of the k-loop:

                                                • the pose-independent n_dv norms come from the sqrtDvCurried literals;
                                                • the unrounded row dots M₂vⱼ come from the per-pose rowDots table, so a pair's d-vector is one lookup and one subtraction (M₂(v₁-v₂) = M₂v₁-M₂v₂);
                                                • the scalars F2, cD, eterm, tenκ, twoκ, bd are loop-invariant.

                                                Each (i, k) pair first tries a cheap sufficient test (the left disjunct) that avoids the per-pair upper_sqrt.f call on the denominator-10²⁶ input d0² + d1²: by Cauchy–Schwarz, d0² + d1² ≤ (F·n_dv + 2·10⁻¹³)² where F is a per-pose Frobenius-norm bound (one sqrt call per pose), so the fixed-point accuracy bound sqrtℚUp16 x ≤ Y + 2·10⁻¹⁶ caps the exact denom2 by F·n_dv + 2·10⁻¹³ + 2·10⁻¹⁶ + 2·√⁺2·ε + 6κ (see cheap_sufficient). Only pairs that fail the cheap test — binding or near-binding k — fall back to the exact test in the right disjunct; the Or/And Decidable instances are macro_inline, so evaluation short-circuits.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  @[instance_reducible, instance 10000]

                                                  Decision procedure for the Bεℚ conjunct of Row.ValidLocal (the only one — the generic-ι checker layer was retired in favor of this specialization).

                                                  Equations

                                                  Kernel-path vertex reads for the remaining Row.ValidLocal conjuncts #

                                                  The Aεℚσ/Spanningℚ/BoundRℚ conjuncts read vertices through pythonVertexA; under decide +kernel its backing Array.ofFn push chain re-reduces as a quadratic List.concat walk (~150k list-step unfoldings per local row — the dominant cost, per kernel diagnostics). These instances transport each conjunct to the curried pythonVertex, whose lookups cost the kernel a few dozen Fin.cons steps; compiled code still gets O(1) array reads via pythonVertex's @[csimp].

                                                  @[instance_reducible, instance 10000]
                                                  Equations

                                                  Assertion that a row constitutes a valid application of the rational global theorem.

                                                  The vertex functions are the table-backed pythonVertexA (equal to pythonVertex by pythonVertexA_eq), so the hot loops of the Decidable instance read precomputed coordinates instead of re-dividing on every access.

                                                  Instances For
                                                    @[instance_reducible]
                                                    Equations
                                                    • One or more equations did not get rendered due to their size.

                                                    Smoke test #

                                                    Row 245 from data/solution_tree_300.csv — the first local leaf.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For