Runge–Kutta order conditions over rooted trees #
A Runge–Kutta method with tableau (A, b) has order p when the elementary weight Φ(t)(A, b)
equals 1/γ(t) for every rooted tree t with at most p nodes, where γ is the density
(Butcher). This file builds a computable engine over planar rooted trees (order |t|, density
γ(t), elementary weight Φ(t)(A, b)), states the order conditions in the division-free form
γ(t) · Φ(t) = 1, reduces "order p" to a finite catalogue check, and certifies concrete methods.
Main results #
Butcher.satisfiesOrderConditions_iff: "orderp" holds iff the condition holds on the finite catalogue of trees with at mostpnodes (sound and complete).Butcher.euler_ord1,Butcher.heun_ord2,Butcher.heun_not_ord3: Euler has order 1, Heun order 2 and not 3.Butcher.rk4_order4,Butcher.rk4_not_ord5: the classical RK4 has order 4 and not 5.Butcher.dp_order5: Dormand–Prince (DOPRI5) has order 5.Butcher.gauss_order4: Gauss–Legendre with 3 stages has order 4, coefficients inℚ(√15).Butcher.gauss_order6: the Gauss–Legendre tableau with 3 stages, cleared of denominators byD = 360intoℤ[√15], satisfiesγ(t) · Φ(D·A, D·b, t) = D^{|t|}for every tree with at most 6 nodes (bydecide). The equivalence with the unscaled conditions (homogeneity ofΦ) is not formalized.Butcher.orderCond_node_perm:Φandγare invariant under permuting a node's children, so the conditions on planar trees subsume those on abstract trees.
Implementation notes #
Only the algebraic order conditions are certified, not Butcher's theorem that they are equivalent
to a local error O(h^{p+1}). Trees are planar (ordered children), with their own inductive type
Butcher.RTree, of the same shape as ConnesKreimer.RTree; Mathlib's order-theoretic RootedTree
is not used (see Formalizations.RingTheory.HopfAlgebra.ConnesKreimer.Coproduct).
Butcher.Q15 and Butcher.Z15 are computable models of ℚ(√15) and ℤ[√15] as pairs. Mathlib
has Zsqrtd 15 and QuadraticAlgebra; the concrete pairs are kept because the certificates
unfold them with simp and decide. Over ℚ the kernel cannot reduce the Nat.gcd inside
Rat normalization, so the ℚ conditions are closed by norm_num and the order-6 certificate
works over integers.
References #
- J. C. Butcher, Coefficients for the study of Runge–Kutta integration processes, J. Austral. Math. Soc. 3 (1963) 185–201.
- E. Hairer, C. Lubich, G. Wanner, Geometric Numerical Integration, Springer (2006).
- L. Foissy, Les algèbres de Hopf des arbres enracinés décorés, I, Bull. Sci. Math. 126 (2002) 193–239.
- C. Marín, What Order a Method Knows: certified Runge–Kutta order conditions over rooted trees,
machine-checked in Lean 4 (2026), doi:10.5281/zenodo.20787666. Ported from
ButcherOrder.leanof karlesmarin/runge-kutta-order-conditions-lean (Lean v4.30.0-rc2).
ℚ(√15) as a computable CommRing: ⟨a, b⟩ means a + b·√15; the relation √15²=15 is baked
into mul. Coefficient ring for the Gauss–Legendre s=3 tableau (gauss_order4). Working in
this concrete pair ring keeps the order-condition checks a pure ℚ component computation closed by
norm_num — no algebraic-number tactic needed.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Butcher.instReprQ15 = { reprPrec := Butcher.instReprQ15.repr }
Equations
- One or more equations did not get rendered due to their size.
ℤ[√15] as a computable CommRing: ⟨a,b⟩ means a + b·√15 with a,b : ℤ. Identical in shape to
Q15 but over the INTEGERS, so equality is decided by the kernel's GMP Int arithmetic with no
rational Nat.gcd normalization. Used in gauss_order6 to certify Gauss order 6 by decide after the
tableau is cleared of denominators (scaled by D=360).
Instances For
Equations
- Butcher.instReprZ15 = { reprPrec := Butcher.instReprZ15.repr }
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.
Equations
- Butcher.instReprRTree = { reprPrec := Butcher.instReprRTree.repr }
Equations
Equations
Instances For
Equations
Instances For
order and density (γ) #
Equations
- Butcher.order (Butcher.RTree.node F) = 1 + Butcher.orderF F
Instances For
Equations
- Butcher.orderF [] = 0
- Butcher.orderF (t :: ts) = Butcher.order t + Butcher.orderF ts
Instances For
density γ(t) = |t| · ∏_children γ. γ(•)=1, γ(•–•)=2, γ(cherry)=3, γ(ladder₃)=6.
Equations
Instances For
Equations
- Butcher.gammaF [] = 1
- Butcher.gammaF (t :: ts) = Butcher.gamma t * Butcher.gammaF ts
Instances For
the Butcher elementary weight Φ(t)(A,b) #
A method is a tableau: `A` the stage matrix (rows), `b` the weights; #stages s = A.length.
Internal weight vector g(t)ᵢ = ∏_children (A·g(child))ᵢ , leaf ↦ 𝟙.
Elementary weight Φ(t) = bᵀ g(t). Order conditions: Φ(t) = 1/γ(t) for all |t| ≤ p.
Equations
- Butcher.dot u v = (List.zipWith (fun (x1 x2 : K) => x1 * x2) u v).sum
Instances For
Equations
- Butcher.pmul u v = List.zipWith (fun (x1 x2 : K) => x1 * x2) u v
Instances For
Equations
- Butcher.mulMatVec A v = List.map (fun (row : List K) => Butcher.dot row v) A
Instances For
Equations
- Butcher.phiVec A (Butcher.RTree.node F) = Butcher.phiForest A F
Instances For
∏ over children of (A · phiVec child), pointwise; empty forest ↦ all-ones (length s).
Equations
- Butcher.phiForest A [] = List.map (fun (x : List K) => 1) A
- Butcher.phiForest A (t :: ts) = Butcher.pmul (Butcher.mulMatVec A (Butcher.phiVec A t)) (Butcher.phiForest A ts)
Instances For
elementary weight Φ(t) = bᵀ·g(t).
Equations
- Butcher.Phi A b t = Butcher.dot b (Butcher.phiVec A t)
Instances For
the order condition at a single tree, in MULTIPLICATIVE form γ(t)·Φ(t) = 1 (⟺ Φ(t)=1/γ(t)
since γ(t) ≥ 1); stated this way it needs only a commutative ring, no division.
Equations
- Butcher.orderCond A b t = (↑(Butcher.gamma t) * Butcher.Phi A b t = 1)
Instances For
the classical methods (exact rationals) #
Instances For
Instances For
Instances For
Instances For
Instances For
Instances For
Equations
Instances For
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
discharge a Q15 order condition: unfold the engine + cast, split into ℚ components, norm_num.
Equations
- Butcher.tacticGauss_check = Lean.ParserDescr.node `Butcher.tacticGauss_check 1024 (Lean.ParserDescr.nonReservedSymbol "gauss_check" false)
Instances For
certificates — the order conditions, machine-checked (axiom-free) #
Each `orderCond` unfolds the computable engine on the concrete tree/tableau to a closed ℚ
arithmetic goal, closed by `norm_num` (symbolic — sidesteps the kernel's stuck `Nat.gcd`
reduction in `Rat` normalization that defeats `decide`).
unfold the engine on a concrete instance to a closed ℚ goal, then norm_num.
Equations
- Butcher.tacticButcher_check = Lean.ParserDescr.node `Butcher.tacticButcher_check 1024 (Lean.ParserDescr.nonReservedSymbol "butcher_check" false)
Instances For
Completeness: "order p" is exactly a finite check (order-budget generator) #
A method satisfies the order-p conditions iff Φ(t)=1/γ(t) for the FINITE catalogue of trees
with |t| ≤ p. This turns the infinite quantifier (∀ rooted trees) into a decidable
finite enumeration. The generator `build` is bounded by an ORDER BUDGET (not by length), so the
catalogue stays Catalan-small (|trees of order ≤ p| = 1,2,4,9,23,…) and `fin_cases` is feasible
up to order 5+ (Dormand–Prince). Structural on the budget → reduces in the kernel; completeness
is mutual induction with measure (budget, structure).
ORDER-BUDGET generator (structural on the budget n; no length over-generation).
(build n).1 = all trees of order ≤ n; (build n).2 = all forests of orderF ≤ n. The filter
bounds each forest by the remaining budget, keeping intermediate lists Catalan-small.
Instances For
Equations
- Butcher.treesB n = (Butcher.build n).1
Instances For
the finite catalogue of all rooted trees with |t| ≤ p.
Equations
- Butcher.catalog p = List.filter (fun (t : Butcher.RTree) => decide (Butcher.order t ≤ p)) (Butcher.treesB p)
Instances For
a method (A,b) satisfies the order-p conditions: every order condition holds through order p.
Equations
- Butcher.satisfiesOrderConditions A b p = ∀ (t : Butcher.RTree), Butcher.order t ≤ p → Butcher.orderCond A b t
Instances For
classic RK4 satisfies ALL order-≤4 conditions, certified, axiom-free.
The planar → abstract bridge: Φ is symmetric in a node's children #
Our trees are PLANAR (ordered children). The numerical literature uses ABSTRACT rooted trees
(multiset children); the abstract Connes–Kreimer algebra is the abelianization (Foissy 2002) of
our noncommutative one. Here we prove the order condition descends along that symmetrization:
permuting the children of a node leaves Φ, γ and hence the order condition unchanged. So
certifying all PLANAR trees of order ≤ p genuinely subsumes the abstract order conditions —
mirror planar trees (same abstract shape) share a single condition. Engine of the bridge:
`pmul` (pointwise ℚ-product of stage vectors) is commutative and associative UNconditionally.
γ is invariant under permuting the children of the root.
A higher-order method: Dormand–Prince certified order 5 #
The order-budget generator makes `catalog 5` (23 planar trees) small enough that `fin_cases`
discharges every order-≤5 condition for the 7-stage DOPRI5 tableau (the default method of
MATLAB `ode45` and SciPy `RK45`). (Heartbeat bump: `fin_cases` whnf-reduces the 23-tree catalogue — a
finite computation, just slow in the elaborator; no effect on the axiom set.)
An implicit method with algebraic coefficients: Gauss–Legendre s=3 #
Gauss–Legendre with 3 stages is fully implicit, with a tableau living in ℚ(√15). Working in the
computable pair ring `Q15` (where √15²=15 is baked into multiplication), every order condition
collapses to a pair of ℚ identities that `gauss_check` closes by `norm_num` — no algebraic-number
tactic. This certifies the framework on implicit methods with irrational (algebraic) coefficients.
We certify order 4 here by this route; by `fin_cases` over `catalog 6` (65 planar trees) with
`norm_num` it does not complete in practical time. Order 6 is certified below over the integers.
Gauss–Legendre s=3 to order 6 (integer ℤ[√15] + decide) #
`gauss_order4` above unfolds the engine symbolically and closes the ℚ(√15) components by `norm_num`.
At order 6 that route dies: the 65 per-tree `norm_num` calls exhaust memory,
because ℚ's `Nat.gcd` normalization does not reduce in the kernel and the unfolded Q15 products are
huge. The fix is to clear all denominators. Scaling the tableau by `D = 360` (the lcm of the denominators
36,9,15,30,24,18) lands it in the INTEGER ring `Z15 = ℤ[√15]`. The elementary weight is homogeneous,
`Φ(D·A, D·b, t) = D^{|t|}·Φ(A,b,t)`, so the order condition `γ(t)·Φ = 1` becomes the integer identity
`γ(t)·Φ(D·A,D·b,t) = D^{|t|}`. Over `Z15` (a pair of `Int`) this closes by `decide`: the kernel's
GMP `Int` arithmetic evaluates it directly — no rational normalization, negligible memory. The whole
certificate (all 65 planar trees of `catalog 6`) checks in about a second.
Not formalized here: the homogeneity of `Φ`, and that `gaussI_A`, `gaussI_b` are `D` times
`gauss_A`, `gauss_b` entrywise; together they make the integer conditions equivalent to the
unscaled ones. `gauss_order6` is the statement about the scaled integer tableau.
The scaled integer tableau: entry `a + b√15` with denominator cleared by 360 becomes `⟨360a, 360b⟩`.
E.g. `2/9 - √15/15 ↦ ⟨80, -24⟩`, `5/18 ↦ ⟨100,0⟩`.
Equations
- One or more equations did not get rendered due to their size.
Instances For
the order condition with denominators cleared: γ(t)·Φ(D·A,D·b,t) = D^{|t|} in Z15. Equivalent
to orderCond on the unscaled ℚ(√15) tableau by homogeneity of Φ, but decidable by the kernel.
Equations
- Butcher.orderCondInt A b D t = ({ re := ↑(Butcher.gamma t), im := 0 } * Butcher.Phi A b t = { re := D ^ Butcher.order t, im := 0 })
Instances For
Equations
- Butcher.satisfiesOrderConditionsInt A b D p = ∀ (t : Butcher.RTree), Butcher.order t ≤ p → Butcher.orderCondInt A b D t
Instances For
Gauss–Legendre s=3 satisfies ALL order-≤6 conditions: the full order-6 certificate, axiom-free.
fin_cases enumerates the 65-tree catalogue; each condition is closed by the kernel (decide)
over Z15 integer arithmetic. (Heartbeat bump bounds only fin_cases' elaboration; the per-tree
decide is cheap and has no effect on the axiom set.)
Examples #
Orders and densities of the small trees, and the sizes of the catalogues: the numbers of planar
rooted trees with at most p nodes (1, 2, 4, 9, 23, partial sums of Catalan numbers), not of
abstract rooted trees.