Exact verification of the skeleton risk ========================================= This page records how the results in :doc:`skeleton_risk_theory` are checked and supplies the reference polynomials used for its computer-assisted risk comparison. Finite checks validate implementations and printed values; the all-degree claims rely on the proofs in the theory chapter. The exact helpers in ``tests/sampling.py`` use :class:`fractions.Fraction`. The assembled-domain helpers are in ``tests/simploidal_risk.py``. They do not add a computer-algebra dependency to the normal test suite. ``tests/fitting.py`` separately checks the statistical risks by simulation. Independent checks ------------------ .. list-table:: Checks and their roles :header-rows: 1 * - Result - Independent reference and checked range * - General scalar sum - Full Gram recursion at :math:`M=2,3,4`, :math:`D=1,\ldots,5`. * - :math:`a_{D-3}` quartic - Every polynomial coefficient at :math:`D=3,\ldots,8`; independent Gram/orbit generation at :math:`D=9`; top-face boundaries through :math:`D=30`. * - Codimension-one sum - General scalar sum at face sizes :math:`1,\ldots,4` and four degrees per size. * - Codimension-one harmonic evaluation - Independent positive mode-norm sum at face sizes :math:`2,\ldots,10`, including the top-face boundary, and degrees 100 and 250; tetrahedral facets also checked by full Gram propagation at :math:`D=3,4,5`. * - Triangle edge coefficient - Every Jacobi mode, its propagation controls and the Gram trace at :math:`D=2,\ldots,10`; harmonic simplification also checked through :math:`D=100`. * - Triangle vertex coefficient - Full Gram recursion at :math:`D=1,\ldots,10`, kernel sum at :math:`D=1,\ldots,12`, and the single sum at :math:`D=81,100`; the telescoping certificate includes both endpoints. * - Dimension polynomials and limits - Every polynomial through :math:`D=8` is regenerated by Gram/orbit counting; every leading coefficient is checked against the general limit. * - Winning vertex counts - Exact polynomial evaluation with a floating-point rounding bound on square roots, together with a proven tail bound, at :math:`D\leq8`. * - Simploid coefficients and allocation by face shape - Exact scalar factor sums versus full product-face Gram propagation in the 12 cases below, including inactive dimensions and mixed degrees. The high-degree triangle checks are outside the exploratory range :math:`D\leq80` used before the vertex proof was obtained. Degree 1000 was also checked during development. These observations are not used as a proof of an all-degree formula. On the development machine, the independent :math:`D=9` quartic check took about 0.23 seconds. Complete triangular edge mode/risk checks took about 0.14, 0.27 and 0.52 seconds at :math:`D=8,9,10`. Regenerating all reference polynomials took about 0.09, 0.75 and 6.6 seconds at :math:`D=6,7,8`. These checks remain in normal CI; timings are observations, not performance guarantees. The unreduced :math:`D=6,m=0` computation took 31.6 seconds, versus 0.04 seconds with propagation reduction. Assembled simploidal sets ------------------------- ``tests/simploidal_risk.py`` checks :prf:ref:`thm-skeleton-assembled-risk` in two independent ways. Exact Dirichlet moments are scattered into global proper-control coordinates, retaining repeated local IDs. Rational elimination solves the global block triangular equations. Separately, Gauss quadrature after stick breaking integrates each chart, and successive calls to the public :func:`~torch_bsf.fit` with :class:`~torch_bsf.FixedControls` propagate a full matrix of deterministic innovations. The resulting influence matrices and weighted covariance traces agree with the rational expressions. The cases are a vertex, a cubic segment, loops of degrees one and three, two joined or disconnected quadratic segments, two cubic triangles with a shared edge, a triangle-square pair with compatible anisotropic degrees, a quadratic torus and a quadratic sphere with collapsed edges. Additional exact checks cover the quadratic chain and loop printed in :doc:`simploidal_risk`, reduction to the existing simplex coefficients at degrees one through four and mixed-degree product coefficients, and a singular evaluation metric that sees only one endpoint. Nonuniform sampling fractions and nonuniform evaluation weights, including weights on lower cells, are checked separately. Weighted covariance traces are compared against direct integration of the public basis in every evaluation chart. The cell and dimension allocation optima and their ordering are checked over the reference domains. The grouped formula is also checked against the original cell objective under equal within-group shares, both at the group optimum and at a nonoptimal allocation. These finite checks validate the formulas and their assembly, rather than prove the expectation limit. The same independent Fraction and chart-integral references also check the public coefficients, propagation and both allocation modes, with nonuniform evaluation weights and sampling shares. Public sampling, inductive fitting and chart predictions recover known global coefficients for these domains, including isolated vertices and vertex-only sets. Boundary-row tests verify single assignment through shared and degenerate faces. The all-at-once count uses global proper controls, not a sum of local control counts. Quadrature and the public joint solver also check :prf:ref:`cor-skeleton-assembled-aao` with matching design/evaluation weights and with different weights, over the reference domains. ``tests/simploidal_incidence.py`` independently checks :prf:ref:`thm-skeleton-regular-incidence` against exact assembled population solves on shared triangles, a triangle-square pair, shared tetrahedra, nonpure complexes and nonmanifold gluing, as well as graphs and disconnected sets. Unequal evaluation weights on all charts and on maximal charts check both the incidence formula and the pure-complex face-vector reduction. The same file checks the explicit corner-collision formula :prf:ref:`thm-skeleton-linear-assembled`, including repeated vertices of a loop and torus and the collapsed edges of a sphere, and its strict risk bound when a positive-weight chart sees distinct vertices. ``tests/simploidal_graph_risk.py`` checks :prf:ref:`thm-skeleton-graph-risk` on mixed-degree graphs with parallel edges, loops and isolated vertices. Vertex and edge evaluation weights are varied independently. Endpoint self and cross norms are checked by exact Bernstein Gram elimination at :math:`D=1,\ldots,12`, then by exact power-polynomial integration at :math:`D=32,33`. Exact assembled solves check the dimension-allocation threshold, the quadratic chain's loss to all-at-once fitting, and the single-loop comparison at :math:`D=1,\ldots,14`. The all-degree graph and loop claims rely on their proofs, rather than these finite checks or the OEIS sequence match. Products of simplices --------------------- :prf:ref:`thm-skeleton-product-risk` and :prf:ref:`cor-skeleton-product-shape-ratio` are checked in ``tests/sampling.py`` independently of the runtime factor-by-factor algorithm. ``_scalar_product_risk`` substitutes the exact simplex scalar sums into :eq:`skeleton-product-coefficients`. ``_rational_face_traces`` instead constructs the full product Bernstein Gram matrices from Dirichlet moments, propagates errors face by face by rational Gauss-Jordan elimination, and retains every face trace as a :class:`fractions.Fraction`. The dimension coefficients agree exactly. The runtime numerical coefficients are also checked against those exact values with the documented relative tolerance :math:`10^{-6}`. The same 12 cases also check every entry of the propagated error matrix against the Kronecker product of the factors' matrices, evaluated by the independent simplex recursion. This equality is checked in rational arithmetic before taking any trace, directly testing :prf:ref:`lem-skeleton-product-propagation`. Since elementary tensors of factor control vectors span all source-face controls, the same matrix check verifies the polynomial identity in :prf:ref:`rem-skeleton-product-polynomials` for arbitrary boundary modes. Grouping the independent face traces by the vector of factor face dimensions checks that the faces of one shape have equal traces, that all active shapes occur, and that each shape coefficient is exactly :math:`\prod_i a^{(i)}_{r_i}`. The two evaluations of the optimal shape-based risk, by summing square roots of those coefficients and by multiplying the factor optima, agree within a bound on floating-point rounding. Its comparison with the dimension-based optimum allows the same rounding bound. These checks cover the following cases; the type lists factor dimensions, as in :doc:`simploidal`. .. list-table:: Exact product-risk checks :header-rows: 1 * - Type - Factor degrees * - :math:`(1,1)` - :math:`(1,1),(2,2),(3,1),(2,3)` * - :math:`(2,1)` - :math:`(2,2),(2,3),(2,1)` * - :math:`(1,1,1)` - :math:`(2,1,2),(1,2,3)` * - :math:`(3,1)` - :math:`(2,2)` * - :math:`(2,2)` - :math:`(2,2)` * - :math:`(1,1,1,1)` - :math:`(1,1,1,1)` The square of degrees :math:`(2,3)` in :doc:`skeleton_sampling` is also a Sphinx doctest. It checks the printed coefficients and both optimal risk values, including the strict improvement when shape shares are allowed. The proofs, rather than these finite checks, establish the formulas for all factor dimensions and degrees. Sampling by independent shape shares is a theoretical design here; the current ``ratio`` API is indexed by total dimension. The allocation checks also group the exact traces by total dimension. They verify that the dimension and face optima agree exactly when each dimension has equal face traces, using the rounding bound above to compare the numerical risks. Two additional cases, type :math:`(2,1)` with degrees :math:`(3,1)` and type :math:`(1,2,1)` with degrees :math:`(1,2,1)`, check the sufficient condition that at most one factor has degree above one. This also includes the cubic-triangle example below. The mixed-degree square provides a case with strict inequality. Separate numerical checks cover :prf:ref:`cor-skeleton-product-closed-forms`: the top coefficient on types :math:`(1,2)` and :math:`(2,2)` with degrees :math:`(2,3)` and :math:`(3,4)`, respectively; the vertex coefficient and inactive dimensions at degree one on types :math:`(1,1)`, :math:`(2,3)` and :math:`(1,1,1,1)`; and products of one, two and three segments at each of degrees one through three. The segment products also check the binomial optimal dimension fractions, the closed-form optimal risk and its strict improvement over all-at-once fitting. Coefficient comparisons allow the runtime relative error bound plus the reference's rounding error; derived quantities also allow for square roots, sums and normalization. The cubic triangle times a linear segment checks the printed risks :math:`10.65` and :math:`14.20`, and that the factor loses while the product wins. Reproducing the vertex certificate ---------------------------------- The certificate can also be regenerated with the existing SymPy dependency. This optional search is outside the test suite; the proof of :prf:ref:`thm-skeleton-triangle-vertex-risk` only needs the rational identity and its boundary values: .. code-block:: python from sympy import binomial, cancel, symbols from sympy.concrete.gosper import gosper_sum d, h = symbols("d h", integer=True, nonnegative=True) denominator = d * (d + 1) * (d + 2) * (d + 3) w = binomial(d + 1, h + 2) * binomial(d + 1, h) c = (2 * d + 3) * (d**2 + 2 * d - 1) / denominator r = (h + 2) * ((d**2 + 2 * d - 1) * h - 1) / (denominator * (h + 1)) assert cancel(gosper_sum(w * (1 / (h + 2) - c), h) / w - r) == 0 ratio = (d - 1 - h) * (d + 1 - h) / ((h + 1) * (h + 3)) assert cancel(ratio * r.subs(h, h + 1) - r - 1 / (h + 2) + c) == 0 Reference dimension polynomials -------------------------------- The table is regenerated independently of the scalar sum by exact Gram solves and orbit counting. For a face of size :math:`m+1`, use a simplex with :math:`V=2D-m-1` vertices, which contains every control-pair support. :prf:ref:`thm-skeleton-propagation-reduction` reduces the propagation solve to :math:`m+2` vertices. For a union with :math:`j` outside vertices, its multiplicity on :math:`M` vertices is its multiplicity on :math:`V` vertices times :math:`(M-m-1)_{\underline j}/(V-m-1)_{\underline j}`, where the underline denotes a falling factorial. The pair sum keeps one first control per permutation orbit outside the fixed face, then one second control per orbit of its stabilizer. If the outside exponents have multiplicities :math:`n_k`, including zeros, the first orbit has size :math:`(2D-2m-2)!/\prod_kn_k!`; the second multiplicity is the product of the same expression within the equal-exponent groups. This gives every polynomial coefficient over the rationals, without interpolation in the dimension or reliance on the closed forms. The :math:`m=D-1,D-2,D-3` rows agree with the corresponding general formulas. .. list-table:: :math:`P_{D,m}(M)` for :math:`D \leq 8` :header-rows: 1 :stub-columns: 2 * - :math:`D` - :math:`m` - :math:`P_{D,m}(M)` * - 1 - 0 - :math:`2` * - 2 - 0 - :math:`\frac32 (3M^2 - 15M + 28)` * - 2 - 1 - :math:`120` * - 3 - 0 - :math:`\frac12 (9M^4 - 114M^3 + 835M^2 - 2610M + 3320)` * - 3 - 1 - :math:`360 (3M^2 - 21M + 58)` * - 3 - 2 - :math:`20160` * - 4 - 0 - :math:`\frac58 (5M^6 - 115M^5 + 1825M^4 - 14765M^3 + 71250M^2 - 174840M + 181152)` * - 4 - 1 - :math:`\frac{105}{2} (63M^4 - 1050M^3 + 9481M^2 - 38654M + 67512)` * - 4 - 2 - :math:`136080 (3M^2 - 27M + 94)` * - 4 - 3 - :math:`6652800` * - 5 - 0 - :math:`\frac{1}{128} (225M^8 - 8100M^7 + 223650M^6 - 3352440M^5 + 33885265M^4 - 210684820M^3 + 810530924M^2 - 1692775952M + 1526667648)` * - 5 - 1 - :math:`840 (7M^6 - 203M^5 + 3573M^4 - 34441M^3 + 201644M^2 - 629700M + 867312)` * - 5 - 2 - :math:`56700 (45M^4 - 930M^3 + 9971M^2 - 49694M + 106152)` * - 5 - 3 - :math:`79833600 (3M^2 - 33M + 136)` * - 5 - 4 - :math:`3632428800` * - 6 - 0 - :math:`\frac{7}{1536} (189M^{10} - 9765M^{9} + 416010M^{8} - 9917418M^{7} + 170241981M^{6} - 1939736421M^{5} + 15319824604M^{4} - 79461497164M^{3} + 261855225632M^{2} - 485208011456M + 394380100608)` * - 6 - 1 - :math:`\frac{63}{40} (4725M^{8} - 207900M^{7} + 5933250M^{6} - 99912240M^{5} + 1132957965M^{4} - 8261943780M^{3} + 38361752764M^{2} - 100723167440M + 118578731904)` * - 6 - 2 - :math:`155925 (55M^{6} - 1925M^{5} + 38401M^{4} - 431519M^{3} + 2952160M^{2} - 11026484M + 18273744)` * - 6 - 3 - :math:`21621600 (117M^{4} - 2886M^{3} + 35695M^{2} - 208734M + 519368)` * - 6 - 4 - :math:`68108040000 (3M^{2} - 39M + 184)` * - 6 - 5 - :math:`2964061900800` * - 7 - 0 - :math:`\frac{1}{10368} (3969M^{12} - 277830M^{11} + 16911909M^{10} - 585892314M^{9} + 15245701191M^{8} - 274563067842M^{7} + 3631411308511M^{6} - 34078439471286M^{5} + 227106974533684M^{4} - 1028193132036840M^{3} + 3014866953859072M^{2} - 5083595030097792M + 3804385671687168)` * - 7 - 1 - :math:`\frac{315}{8} (189M^{10} - 11655M^{9} + 488100M^{8} - 12550518M^{7} + 229047537M^{6} - 2894482743M^{5} + 25831659094M^{4} - 156730040300M^{3} + 621915070424M^{2} - 1437930406240M + 1507450665216)` * - 7 - 2 - :math:`\frac{31185}{4} (2475M^{8} - 128700M^{7} + 4016430M^{6} - 76100640M^{5} + 969732275M^{4} - 8107098420M^{3} + 43614175604M^{2} - 135327928048M + 189756997248)` * - 7 - 3 - :math:`151351200 (91M^{6} - 3731M^{5} + 83699M^{4} - 1072645M^{3} + 8358906M^{2} - 36008544M + 68795424)` * - 7 - 4 - :math:`363242880000 (9M^{4} - 258M^{3} + 3607M^{2} - 24086M + 67896)` * - 7 - 5 - :math:`80029671321600 (3M^{2} - 45M + 238)` * - 7 - 6 - :math:`3379030566912000` * - 8 - 0 - :math:`\frac{1}{1536} (243M^{14} - 22113M^{13} + 1822905M^{12} - 86413257M^{11} + 3170012139M^{10} - 82654759071M^{9} + 1640539616043M^{8} - 24125599635171M^{7} + 266382561743494M^{6} - 2157428183555988M^{5} + 12638903353801912M^{4} - 51381774261439680M^{3} + 137262734136374272M^{2} - 214224590422872576M + 149755742713294848)` * - 8 - 1 - :math:`\frac{55}{384} (43659M^{12} - 3580038M^{11} + 206363619M^{10} - 7485895494M^{9} + 199202107797M^{8} - 3823026542874M^{7} + 54535243641473M^{6} - 568795558812642M^{5} + 4306623724542524M^{4} - 22811488486847928M^{3} + 80426058871064384M^{2} - 168310145729971584M + 161038581507542016)` * - 8 - 2 - :math:`\frac{27027}{16} (19305M^{10} - 1383525M^{9} + 61604400M^{8} - 1734571410M^{7} + 34500231285M^{6} - 483666978405M^{5} + 4831926907690M^{4} - 33375332254980M^{3} + 152661774969416M^{2} - 413966621739552M + 513284796940032)` * - 8 - 3 - :math:`\frac{4729725}{2} (20475M^{8} - 1228500M^{7} + 42200550M^{6} - 891274440M^{5} + 12638555275M^{4} - 118800088180M^{3} + 722231576084M^{2} - 2559256843376M + 4107713331840)` * - 8 - 4 - :math:`1543782240000 (17M^{6} - 799M^{5} + 19941M^{4} - 286433M^{3} + 2496802M^{2} - 12115512M + 26028000)` * - 8 - 5 - :math:`31678411564800 (171M^{4} - 5586M^{3} + 86965M^{2} - 650590M + 2040000)` * - 8 - 6 - :math:`124179373334016000 (3M^{2} - 51M + 298)` * - 8 - 7 - :math:`5129368400572416000`