Documentation

Formalizations.Analysis.ODE.RungeKutta.OrderConditions

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 #

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 #

structure Butcher.Q15 :

ℚ(√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
    def Butcher.instDecidableEqQ15.decEq (x✝ x✝¹ : Q15) :
    Decidable (x✝ = x✝¹)
    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[instance_reducible]
        Equations
        theorem Butcher.Q15.ext' {x y : Q15} (hr : x.re = y.re) (hi : x.im = y.im) :
        x = y
        theorem Butcher.Q15.ext'_iff {x y : Q15} :
        x = y ↔ x.re = y.re ∧ x.im = y.im
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[simp]
        theorem Butcher.Q15.zero_re :
        re 0 = 0
        @[simp]
        theorem Butcher.Q15.zero_im :
        im 0 = 0
        @[simp]
        theorem Butcher.Q15.one_re :
        re 1 = 1
        @[simp]
        theorem Butcher.Q15.one_im :
        im 1 = 0
        @[simp]
        theorem Butcher.Q15.add_re (x y : Q15) :
        (x + y).re = x.re + y.re
        @[simp]
        theorem Butcher.Q15.add_im (x y : Q15) :
        (x + y).im = x.im + y.im
        @[simp]
        theorem Butcher.Q15.neg_re (x : Q15) :
        (-x).re = -x.re
        @[simp]
        theorem Butcher.Q15.neg_im (x : Q15) :
        (-x).im = -x.im
        @[simp]
        theorem Butcher.Q15.sub_re (x y : Q15) :
        (x - y).re = x.re - y.re
        @[simp]
        theorem Butcher.Q15.sub_im (x y : Q15) :
        (x - y).im = x.im - y.im
        @[simp]
        theorem Butcher.Q15.mul_re (x y : Q15) :
        (x * y).re = x.re * y.re + 15 * x.im * y.im
        @[simp]
        theorem Butcher.Q15.mul_im (x y : Q15) :
        (x * y).im = x.re * y.im + x.im * y.re
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[simp]
        theorem Butcher.Q15.natCast_eq (n : ℕ) :
        ↑n = { re := ↑n, im := 0 }
        structure Butcher.Z15 :

        ℤ[√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
          def Butcher.instDecidableEqZ15.decEq (x✝ x✝¹ : Z15) :
          Decidable (x✝ = x✝¹)
          Equations
          Instances For
            @[instance_reducible]
            Equations
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Butcher.Z15.ext' {x y : Z15} (hr : x.re = y.re) (hi : x.im = y.im) :
              x = y
              theorem Butcher.Z15.ext'_iff {x y : Z15} :
              x = y ↔ x.re = y.re ∧ x.im = y.im
              @[instance_reducible]
              Equations
              @[instance_reducible]
              Equations
              @[instance_reducible]
              Equations
              @[instance_reducible]
              Equations
              @[instance_reducible]
              Equations
              @[instance_reducible]
              Equations
              @[simp]
              theorem Butcher.Z15.zero_re :
              re 0 = 0
              @[simp]
              theorem Butcher.Z15.zero_im :
              im 0 = 0
              @[simp]
              theorem Butcher.Z15.one_re :
              re 1 = 1
              @[simp]
              theorem Butcher.Z15.one_im :
              im 1 = 0
              @[simp]
              theorem Butcher.Z15.add_re (x y : Z15) :
              (x + y).re = x.re + y.re
              @[simp]
              theorem Butcher.Z15.add_im (x y : Z15) :
              (x + y).im = x.im + y.im
              @[simp]
              theorem Butcher.Z15.neg_re (x : Z15) :
              (-x).re = -x.re
              @[simp]
              theorem Butcher.Z15.neg_im (x : Z15) :
              (-x).im = -x.im
              @[simp]
              theorem Butcher.Z15.sub_re (x y : Z15) :
              (x - y).re = x.re - y.re
              @[simp]
              theorem Butcher.Z15.sub_im (x y : Z15) :
              (x - y).im = x.im - y.im
              @[simp]
              theorem Butcher.Z15.mul_re (x y : Z15) :
              (x * y).re = x.re * y.re + 15 * x.im * y.im
              @[simp]
              theorem Butcher.Z15.mul_im (x y : Z15) :
              (x * y).im = x.re * y.im + x.im * y.re
              @[instance_reducible]
              Equations
              • One or more equations did not get rendered due to their size.
              inductive Butcher.RTree :
              Instances For
                @[instance_reducible]
                Equations
                @[reducible, inline]
                Equations
                Instances For

                  order and density (γ) #

                  density γ(t) = |t| · ∏_children γ. γ(•)=1, γ(•–•)=2, γ(cherry)=3, γ(ladder₃)=6.

                  Equations
                  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. 
                    
                    def Butcher.dot {K : Type u_1} [CommRing K] (u v : List K) :
                    K
                    Equations
                    Instances For
                      def Butcher.pmul {K : Type u_1} [CommRing K] (u v : List K) :
                      Equations
                      Instances For
                        def Butcher.mulMatVec {K : Type u_1} [CommRing K] (A : List (List K)) (v : List K) :
                        Equations
                        Instances For
                          def Butcher.phiVec {K : Type u_1} [CommRing K] (A : List (List K)) :
                          RTree → List K
                          Equations
                          Instances For
                            def Butcher.phiForest {K : Type u_1} [CommRing K] (A : List (List K)) :
                            Forest → List K

                            ∏ over children of (A · phiVec child), pointwise; empty forest ↦ all-ones (length s).

                            Equations
                            Instances For
                              def Butcher.Phi {K : Type u_1} [CommRing K] (A : List (List K)) (b : List K) (t : RTree) :
                              K

                              elementary weight Φ(t) = bᵀ·g(t).

                              Equations
                              Instances For
                                @[reducible, inline]
                                abbrev Butcher.orderCond {K : Type u_1} [CommRing K] (A : List (List K)) (b : List K) (t : RTree) :

                                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
                                Instances For

                                  the classical methods (exact rationals) #

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

                                                        discharge a Q15 order condition: unfold the engine + cast, split into ℚ components, norm_num.

                                                        Equations
                                                        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
                                                          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.

                                                            Equations
                                                            Instances For
                                                              Equations
                                                              Instances For
                                                                theorem Butcher.mem_build_trees (n : ℕ) (t : RTree) :
                                                                order t ≤ n → t ∈ (build n).1
                                                                theorem Butcher.mem_build_forests (n : ℕ) (F : Forest) :
                                                                orderF F ≤ n → F ∈ (build n).2

                                                                the finite catalogue of all rooted trees with |t| ≤ p.

                                                                Equations
                                                                Instances For
                                                                  def Butcher.satisfiesOrderConditions {K : Type u_1} [CommRing K] (A : List (List K)) (b : List K) (p : ℕ) :

                                                                  a method (A,b) satisfies the order-p conditions: every order condition holds through order p.

                                                                  Equations
                                                                  Instances For
                                                                    theorem Butcher.satisfiesOrderConditions_iff {K : Type u_1} [CommRing K] (A : List (List K)) (b : List K) (p : ℕ) :

                                                                    The order-p conditions ⟺ a finite check over the catalogue (sound and complete).

                                                                    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. 
                                                                    
                                                                    theorem Butcher.pmul_comm (u v : List ℚ) :
                                                                    pmul u v = pmul v u
                                                                    theorem Butcher.pmul_assoc (u v w : List ℚ) :
                                                                    pmul (pmul u v) w = pmul u (pmul v w)
                                                                    theorem Butcher.phiForest_perm (A : List (List ℚ)) {F G : Forest} (h : List.Perm F G) :
                                                                    theorem Butcher.orderF_perm {F G : Forest} (h : List.Perm F G) :
                                                                    theorem Butcher.gammaF_perm {F G : Forest} (h : List.Perm F G) :
                                                                    theorem Butcher.Phi_node_perm (A : List (List ℚ)) (b : List ℚ) {F G : Forest} (h : List.Perm F G) :
                                                                    Phi A b (RTree.node F) = Phi A b (RTree.node G)

                                                                    Φ is invariant under permuting the children of the root.

                                                                    γ is invariant under permuting the children of the root.

                                                                    theorem Butcher.orderCond_node_perm (A : List (List ℚ)) (b : List ℚ) {F G : Forest} (h : List.Perm F G) :

                                                                    The order condition depends only on the abstract tree: permuting children is invisible.

                                                                    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
                                                                      Equations
                                                                      Instances For
                                                                        Equations
                                                                        Instances For
                                                                          @[reducible, inline]
                                                                          abbrev Butcher.orderCondInt (A : List (List Z15)) (b : List Z15) (D : ℤ) (t : RTree) :

                                                                          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
                                                                          Instances For
                                                                            theorem Butcher.satisfiesOrderConditionsInt_iff (A : List (List Z15)) (b : List Z15) (D : ℤ) (p : ℕ) :

                                                                            Same reduction as satisfiesOrderConditions_iff, for the integer condition: the order-p conditions reduce to the finite catalogue check (reuses the generic build/catalog completeness).

                                                                            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.