EP-0242: Exact Symbolic Integration, Hermite & Gosper Reduction, Creative Telescoping & Multivariate Taylor Jets¶
| Field | Value |
|---|---|
| EP | 0242 |
| Title | Exact Symbolic Integration, Hermite & Gosper Reduction, Creative Telescoping & Multivariate Taylor Jets |
| Author | Eran Rivlis eran@rivlis.info, Antigravity |
| Sponsor | Core Maintainers |
| Delegate | ⚡ Shannon (Zero-AST Speedup), 🔬 Popper (FTC & Gosper Oracles) & 🛡️ Golem (Safe Jet Factory) |
| Status | Draft |
| Type | Standards Track |
| Created | 2026-11-15 |
| Updated | 2026-11-26 |
| Replaces | — |
| Superseded-By | — |
Abstract¶
This proposal completes AlgebraX’s differential and difference calculus stack (algebrax.differential) with four exact, AST-free algebraic algorithms:
- Exact Rational Integration (
square_free_decomposition,hermite_reduce,rothstein_trager_resultant): Pure-Python integration over exact fields (StandardField(Fraction)) reducing any rational function \(A(x)/D(x)\) to \(P(x) + G_{\text{num}}/G_{\text{den}} + \int H(x)/S(x)\,dx\) with strictly square-free \(S(x)\)—avoiding complex root factorization and achieving 37.7x speedups oversympy.integrateinEXP-0011. - Discrete Hypergeometric Summation (
gosper_sum): Exact Gosper dispersion resultant \(R(h)\) and certificate solver \(r(n)\) for indefinite hypergeometric sums, including rigorous non-summability proofs (None). - Creative Telescoping (
creative_telescope): Zeilberger/Chyzak Ore elimination synthesizing telescoping operator certificates \((L, B)\) for definite hypergeometric and holonomic integrals/sums. - Univariate & Multivariate
TaylorJetAlgebra[V]: A safe ergonomic factory wrappingCommQuotientRing(EP-0250) overPolynomialTruncationIdeal(order + 1, ...)and multivariate \(k[x_1, \dots, x_n]/\mathfrak{m}^{r+1}\) quotients, generalizingDualNumberAlgebra(\(n=1, r=1\)) to arbitrary-order exact partial/Lie derivatives, Newton series reciprocals (inv), Lagrange reversion, and Newton–Picard nonlinear ODE solvers (solve_ode_jet).
Motivation¶
- Calculus Without AST Bloat or Complex Factorization:
Expression-tree CAS engines spend substantial overhead reconstructing symbolic parse trees (
111.35 msinEXP-0011Experiment 3 vs.2.95 msfor pure unboxed Hermite reduction). Algebraic Hermite reduction and Gosper's algorithm run strictly via univariategcd, extended Bézout inverses, and small exact linear solves. - Fixing
PolynomialTruncationIdealErgonomics for Jets:EXP-0011Experiment 4 revealed thatPolynomialTruncationIdealtakes(max_degree, zero_coeff)positionally and truncates degrees \(\ge \text{max\_degree}\) (requiringorder + 1for degree-orderTaylor jets). A dedicatedTaylorJetAlgebra(field, order=..., n_vars=...)factory eliminates this footgun and extendsDualNumberAlgebrafrom \((n=1, r=1)\)floatpairs to arbitrary-order multivariate exact arithmetic.
Rationale¶
Validated in EXP-0011 (Experiments 3, 4, 6, and 7) and aligned with the Grand Council and Phase 8.5 (EP-0250–EP-0254):
- ⚡ Claude Shannon (Sparse Polynomial Algorithms > Symbolic Trees & Shared Exact Kernels):
Unboxed
dict[int, Fraction]Yun/Hermite reduction achieved a 37.7x speedup oversympy.integrate(2.95 msvs.111.35 ms). KeepingDualNumberAlgebra(tuple[float, float]) untouched for ultra-lightweight 1st-order AD while introducingTaylorJetAlgebrafor arbitrary order/variables preserves performance across both regimes. Linear solves ingosper_sumandcreative_telescopereuse Phase 8.5EP-0251's exactmatrix.solve(..., field=...)/nullspacekernels and widenedtyping.N(Fraction). - 🔬 Karl Popper (Exact FTC, Gosper & Creative Telescoping Oracles):
Prototyping in
EXP-0011caught sign/index bugs in Yun (z / a_i), Hermite (-(m-1)), and Gosper (c(n)shift-j) immediately through derivative/shift residual checks andSymPydifferential comparison. Both Hermite and Creative Telescoping return explicit proof-carrying rational/operator certificates verified directly in \(O(\deg)\) arithmetic (EP-0186alignment) and obey Phase 8.5EP-0253non-vacuous sample contracts. - 🛡️ The Golem (Safe Factory, Hygiene & Deliberate Deferrals):
Wrapping
PolynomialTruncationIdeal(order + 1, field.zero)insideTaylorJetAlgebraprevents off-by-one truncation bugs. Full transcendental Risch integration towers and Ritt–Wu nonlinear characteristic sets are deliberately deferred toSymPyunder the Dennis Point. Modules obeyEP-0254hygiene (public-only cross-package imports, zeroEP-XXXXcitations insrc/). - 🧩 Bertrand Russell (
CommQuotientRing&invvs. Kleenestar): WhileDualNumberAlgebraexposesstar(a) = 1/(1-a)as aStarSemiring, generalTaylorJetAlgebrawraps Phase 8.5EP-0250'sCommQuotientRing(distinguishing commutative quotients from general non-commutativeQuotientRing) whose unit group consists of jets with invertible constant term \(a_0 \ne 0\), computed via quadratic Newton reciprocalinv(a)(\(y_{k+1} = y_k(2 - a y_k)\)) rather than conflating division with Kleene star.
Specification¶
1. Exact Rational Integration (src/algebrax/differential/integrate.py)¶
from __future__ import annotations
from dataclasses import dataclass
from typing import Generic, TypeVar
from algebrax.algebra import Field
V = TypeVar("V")
UniPoly = dict[int, V]
@dataclass(frozen=True)
class HermiteDecomposition(Generic[V]):
r"""Exact Hermite integral decomposition $\int \frac{A}{D} dx = P + \frac{G_{\text{num}}}{G_{\text{den}}} + \int \frac{H}{S} dx$."""
poly_integral: UniPoly[V]
rational_num: UniPoly[V]
rational_den: UniPoly[V]
log_num: UniPoly[V]
log_den: UniPoly[V] # Guaranteed strictly square-free: deg(gcd(log_den, log_den')) == 0
def square_free_decomposition(poly: UniPoly[V], field: Field[V]) -> tuple[UniPoly[V], ...]:
"""Compute Yun's square-free decomposition P = prod_{k=1}^m A_k^k over characteristic-0 exact Field."""
...
def hermite_reduce(num: UniPoly[V], den: UniPoly[V], field: Field[V]) -> HermiteDecomposition[V]:
"""Compute exact Hermite rational-part extraction without algebraic factorization."""
...
def rothstein_trager_resultant(log_num: UniPoly[V], log_den: UniPoly[V], field: Field[V]) -> dict[tuple[int, int], V]:
r"""Compute bivariate Rothstein–Trager resultant $R(t) = \operatorname{Res}_x(S(x), H(x) - t S'(x))$ characterizing logarithmic residues."""
...
2. Gosper Summation & Creative Telescoping (src/algebrax/differential/summation.py)¶
@dataclass(frozen=True)
class TelescopingCertificate(Generic[V]):
"""Proof-carrying creative telescoping output L(n, S_n) F(n, k) = Delta_k(B(n, k, S_k) F(n, k))."""
telescoper: dict[int, UniPoly[V]]
certificate: dict[tuple[int, ...], V]
def gosper_sum(
ratio_num: UniPoly[V],
ratio_den: UniPoly[V],
field: Field[V],
) -> tuple[UniPoly[V], UniPoly[V]] | None:
r"""Exact Gosper indefinite hypergeometric summation for $t_{n+1}/t_n = f(n)/g(n)$.
Returns reduced rational certificate $(R_{\text{num}}, R_{\text{den}})$ with $S(n) = r(n)t_n$,
or `None` when proven non-summable in hypergeometric form.
"""
...
def creative_telescope(
annihilator_gens: Sequence[dict[tuple[Monomial, Monomial], V]],
field: Field[V],
max_order: int = 6,
) -> TelescopingCertificate[V]:
"""Synthesize a creative telescoping operator pair (L, B) via Ore/Weyl elimination (`EP-0240`/`EP-0241`)."""
...
3. Univariate & Multivariate Taylor Jet Algebras (src/algebrax/differential/jets.py)¶
class TaylorJetAlgebra(CommRing[dict[Monomial, V]], HasDerivation[dict[Monomial, V]], HasIntegrate[dict[Monomial, V]], Generic[V]):
r"""Exact truncated Taylor Jet algebra $k[x_1, \dots, x_n] / \mathfrak{m}^{r+1}$ (total degree $\le r$).
Generalizes `DualNumberAlgebra` (n=1, r=1) over any exact `Field[V]`.
When $n = 1$, wraps `CommQuotientRing(PolynomialAlgebra(field), PolynomialTruncationIdeal(order + 1, field.zero))`.
"""
def __init__(self, field: Field[V], order: int, n_vars: int = 1) -> None: ...
def inv(self, jet: dict[Monomial, V]) -> dict[Monomial, V]:
"""Compute exact multiplicative reciprocal via quadratic Newton iteration when constant term != 0."""
...
def compose(self, outer: UniPoly[V], inner: dict[Monomial, V]) -> dict[Monomial, V]:
"""Compose univariate Taylor series outer(inner) truncated modulo m^{r+1}."""
...
def partial_derivative(self, jet: dict[Monomial, V], multi_index: Monomial) -> V:
r"""Extract exact derivative $\left.\frac{\partial^{|\alpha|} f}{\partial x^\alpha}\right|_0 = \alpha!\, c_\alpha$."""
...
def solve_ode_jet(
rhs_fn: Callable[[TaylorJetAlgebra[V], dict[int, V]], dict[int, V]],
initial_value: V,
field: Field[V],
order: int,
) -> dict[int, V]:
"""Solve initial value problem y'(x) = F(x, y(x)), y(0) = y_0 exactly mod x^{order+1} via Picard/Newton iteration."""
...
def solve_hamiltonian_jet(
poisson_alg: "CanonicalPoissonAlgebra[V]",
hamiltonian: SparseMPoly[V],
q0: Sequence[V],
p0: Sequence[V],
order: int,
) -> tuple[tuple[UniPoly[V], ...], tuple[UniPoly[V], ...]]:
r"""Solve Hamilton's equations $\dot{q}_i = \partial_{p_i} H$, $\dot{p}_i = -\partial_{q_i} H$ exactly mod $t^{\text{order}+1}$."""
...
4. Verification Oracles (src/algebrax/verification/_differential.py)¶
Exported publicly via algebrax.verification (complying with Phase 8.5 EP-0253 non-vacuous sample contracts):
verify_hermite_decomposition(num, den, decomp, field): Verifies exact rational reconstruction \((P + G_{\text{num}}/G_{\text{den}})' + H/S \equiv A/D\) and \(\deg\gcd(S, S') == 0\).verify_gosper_certificate(f, g, cert, field): Verifies \(r(n+1)\frac{f(n)}{g(n)} - r(n) \equiv 1\) in \(\mathbb{Q}(n)\) (and compares withsympy.concrete.gosper.gosper_sumin verification tests).verify_creative_telescoping(cert, operator_action): Verifies \((L - \Delta_k B)(F) \equiv 0\) on sample holonomic sequences/integrands (EP-0186certificate model).verify_jet_and_rota_baxter_laws(jet_alg): Verifiesjet_integrateobeysLawRotaBaxterwith weight \(\lambda = 0\) (integration by parts), pairsTaylorJetAlgebraexpansions withguess_ore_operator(EP-0241) for closed-loop \(D\)-finite operator recovery, and certifiessolve_hamiltonian_jetpreserves exact energy \(H(q(t), p(t)) \equiv H(q_0, p_0) \pmod{t^{r+1}}\) and symplectic variational Jacobian \(D\Phi_t^T J D\Phi_t \equiv J \pmod{t^{r+1}}\).
Backwards Compatibility¶
100% additive and backwards compatible. DualNumberAlgebra and PolynomialTruncationIdeal keep their existing public signatures unchanged.
How to Teach This / Documentation Plan¶
- User Guide: Add
docs/guide/differential/integration_and_jets.mdcontrasting numerical quadratures/RK4 against exact Hermite reduction, Gosper certificates, and Newton–Picard Jet ODE solving. - Recipe: Add
recipes/exact_calculus_hermite_gosper_jets.pydemonstrating 37x rational Hermite reduction, factorial/rational Gosper telescoping, and exact \(\tan(x)\) / 2D Hessian extraction via Taylor Jets.
Reference Implementation¶
Prototyped and verified in references/explorations/EXP-0011-differential-and-ore-algebras/sources/prototype_differential_algebra.py (Experiments 3, 4, 6, 7, 9, and 10).
Rejected Ideas¶
- Full Transcendental Risch Integration Towers:
- Rejected: Requires recursive differential field extensions, structure-theorem case splits, and AST-heavy symbolic manipulation misaligned with Shannon's unboxed sparse carriers; SymPy remains the fallback oracle when full elementary closed forms are needed.
- Replacing
DualNumberAlgebraDirectly with Dictionary Carriers: - Rejected: Breaks backwards compatibility and adds unnecessary dict-allocation overhead to fast 1st-order
tuple[float, float]dual-number differentiation.
Open Questions¶
- [ ] Whether
rothstein_trager_resultantshould automatically split irreducible quadratic/cubic factors overEP-0221companion-matrix algebraic extensions or leave the resultant unfactored by default.
Change Log¶
- 2026-11-15:
- Initial Draft authored for Phase 11 from
EXP-0011. - Added
LawRotaBaxter(weight 0) andguess_ore_operator(EP-0241) integration verification notes fromEXP-0011Experiment 9. - Added
solve_hamiltonian_jetwith exact truncated energy & symplectic Jacobian conservation checks fromEXP-0011Experiment 10. - 2026-11-26:
- Aligned with Phase 8.5 (
EP-0250–EP-0254): updatedTaylorJetAlgebrato wrapCommQuotientRing(EP-0250), switched privatealgebra._fieldimport to publicalgebrax.algebra, documentedEP-0251exact linear-algebra kernel reuse, updated verification path tosrc/algebrax/verification/_differential.py, and notedEP-0253/EP-0254contracts.