Paper
The commutativity problem for effective varieties of formal series, and applications
41 pages · 11 marked passages · pdflatex · download PDF · lax-619925
-
def✓
Lax619925.SeriesFormal power series
Formal power series over an alphabet are functions from words to the rationals. They carry the pointwise vector-space structure, the left and right derivatives (the series analogues of language quotients), the reversal, the support, and the Parikh image. A series is commutative when it is constant on words with the same Parikh image. This module records the basic definitions of §2 of the paper together with the elementary facts about derivatives and reversal that the later sections use.
- def✓
Lax619925.Series(1st statement) - def✓
Lax619925.Series(2nd statement) - def✓
Lax619925.Series(3rd statement)
1 import Mathlib.Data.Real.Basic 2 import Mathlib.Data.List.Basic 3 import Mathlib.Data.Finite.Defs 4 import Mathlib.Data.Multiset.Basic 5 … module docstring, 13 lines 19 20 namespace Lax619925.Series 21 22 -- the type and the module carrying it have the same name on purpose 23 set_option linter.dupNamespace false in 24 /-- A formal power series over the alphabet `α`: a function from words to `ℚ`. -/ 25 abbrev Series (α : Type*) := List α → ℚ 26 27 /-- The left derivative with respect to the letter `a`: 28 `(leftDeriv a f) w = f (a :: w)`, i.e. the coefficient of `a · w` in `f`. -/ 29 def leftDeriv (α : Type*) (a : α) (f : Series α) : Series α := fun w => f (a :: w) 30 31 /-- The right derivative with respect to the letter `a`: 32 `(rightDeriv a f) w = f (w ++ [a])`, i.e. the coefficient of `w · a` in `f`. -/ 33 def rightDeriv (α : Type*) (a : α) (f : Series α) : Series α := fun w => f (w ++ [a]) 34 35 /-- The left derivative with respect to a word `w`, extended homomorphically: 36 `(leftDerivWord w f) v = f (w ++ v)`. This agrees with the paper's recursive 37 definition `δ^L_ε f = f` and `δ^L_{a·w} f = δ^L_w (δ^L_a f)`. -/ 38 def leftDerivWord (α : Type*) (w : List α) (f : Series α) : Series α := fun v => f (w ++ v) 39 40 /-- The right derivative with respect to a word `w`, extended homomorphically: 41 `(rightDerivWord w f) v = f (v ++ w.reverse)`. This agrees with the paper's 42 recursive definition `δ^R_ε f = f` and `δ^R_{w·a} f = δ^R_a (δ^R_w f)`, which 43 appends the letters of `w` in reversed order. -/ 44 def rightDerivWord (α : Type*) (w : List α) (f : Series α) : Series α := fun v => f (v ++ w.reverse) 45 46 /-- The reversal of a series: `(reversal f) w = f (w.reverse)`. -/ 47 def reversal (α : Type*) (f : Series α) : Series α := fun w => f w.reverse 48 49 /-- The support of a series: the set of words on which it is nonzero. -/ 50 def support (α : Type*) (f : Series α) : Set (List α) := {w | f w ≠ 0} 51 52 /-- A series is a *polynomial* if its support is finite. -/ 53 def IsPolynomial (α : Type*) (f : Series α) : Prop := (support α f).Finite 54 55 /-- The Parikh image (commutative image) of a word: the function counting, for each 56 letter, its number of occurrences in the word. The paper indexes this vector by a 57 fixed ordering of the alphabet; the function form is equivalent and needs no order. 58 Counting occurrences requires decidable equality on the alphabet. -/ 59 def parikh (α : Type*) [DecidableEq α] (w : List α) : α → ℕ := fun a => w.count a 60 61 /-- Two words are *commutatively equivalent* if they have the same multiset of letters, 62 i.e. one is obtained from the other by permuting the positions of the letters. 63 (Equivalently, when the alphabet has decidable equality, they have the same Parikh 64 image.) -/ 65 def CommutativelyEquivalent (α : Type*) (u v : List α) : Prop := 66 Multiset.ofList u = Multiset.ofList v 67 68 /-- A series is *commutative* (échangeable) if it takes the same value on all 69 commutatively equivalent words. -/ 70 def IsCommutative (α : Type*) (f : Series α) : Prop := 71 ∀ u v, CommutativelyEquivalent α u v → f u = f v 72 73 /-- Left and right derivatives commute: for all letters `a, b`, 74 `leftDeriv a ∘ rightDeriv b = rightDeriv b ∘ leftDeriv a`. 75 (Paper, §2, lemma `leftRightComm`.) Both sides send a series `f` to the series 76 `w ↦ f (a :: w ++ [b])`. -/ 77 axiom LeftRightDerivativesCommute (α : Type*) (a b : α) : 78 leftDeriv α a ∘ rightDeriv α b = rightDeriv α b ∘ leftDeriv α a 79 80 /-- Reversal is an involution on series. -/ 81 axiom ReversalInvolution (α : Type*) (f : Series α) : reversal α (reversal α f) = f 82 83 /-- Reversal interchanges left and right derivatives: 84 `reversal (leftDeriv a f) = rightDeriv a (reversal f)`. 85 Composing with the involution gives the paper's double-reversal identity 86 `rightDeriv a f = reversal (leftDeriv a (reversal f))` used in §4. -/ 87 axiom ReversalSwapsDerivatives (α : Type*) (a : α) (f : Series α) : 88 reversal α (leftDeriv α a f) = rightDeriv α a (reversal α f) 89 90 end Lax619925.Series 91 - def✓
-
Prevarieties and effective prevarieties of series
A prevariety of series over an alphabet is a -subspace of the series closed under the left and right derivatives (paper §2.3, conditions (V.1) and (V.2)). An effective prevariety is a prevariety whose elements admit finite presentations (a type with a semantics map) such that the closure operations are carried out algorithmically on presentations and the equality problem is decidable (paper §2.3, conditions (1)–(3)). These are definitions only; the decidability results built on them live in the module.
1 import Lax619925.Series 2 import Mathlib.Data.Real.Basic 3 import Mathlib.Algebra.Module.Basic 4 import Mathlib.Algebra.Module.Pi 5 import Mathlib.Algebra.Module.Submodule.Basic 6 7 universe u 8 9 /-! 10 --- 11 title: Prevarieties and effective prevarieties of series 12 type: definition 13 --- 14 A *prevariety* of series over an alphabet `α` is a `ℚ`-subspace of the series 15 closed under the left and right derivatives (paper §2.3, conditions (V.1) and 16 (V.2)). An *effective prevariety* is a prevariety whose elements admit finite 17 presentations (a type `Rep` with a semantics map) such that the closure 18 operations are carried out algorithmically on presentations and the equality 19 problem is decidable (paper §2.3, conditions (1)–(3)). These are definitions 20 only; the decidability results built on them live in the `Commutativity` module. 21 -/ 22 23 namespace Lax619925.Prevariety 24 25 open Lax619925.Series 26 27 -- the type and the module carrying it have the same name on purpose 28 set_option linter.dupNamespace false in 29 /-- A prevariety of series over `α`: a `ℚ`-subspace of `Series α` (the field 30 `carrier`) that is closed under the left and right derivatives. -/ 31 structure Prevariety (α : Type*) where 32 carrier : Submodule ℚ (Series α) 33 closedLeftDeriv : ∀ {f : Series α} (_hf : f ∈ carrier), ∀ a, leftDeriv α a f ∈ carrier 34 closedRightDeriv : ∀ {f : Series α} (_hf : f ∈ carrier), ∀ a, rightDeriv α a f ∈ carrier 35 36 /-- Coercion from a prevariety to its underlying `ℚ`-submodule. -/ 37 instance (α : Type*) : Coe (Prevariety α) (Submodule ℚ (Series α)) where 38 coe P := P.carrier 39 40 /-- Membership in a prevariety: `f ∈ P` means that `f` belongs to the underlying 41 `ℚ`-subspace of `P`. -/ 42 instance (α : Type*) : Membership (Series α) (Prevariety α) where 43 mem P f := f ∈ P.carrier 44 45 /-- An effective prevariety of series over `α`: a prevariety given by a type `Rep` 46 of finite presentations with a semantics map `sem`, in which the vector-space 47 operations and the left and right derivatives are computed by operations on 48 presentations (the `sem_*` fields record their correctness), and on which the 49 equality problem is decidable. The fields `prevariety` and `mem` record that 50 the image of the semantics is a prevariety. -/ 51 structure EffectivePrevariety (α : Type u) where 52 Rep : Type u 53 sem : Rep → Series α 54 prevariety : Prevariety α 55 mem : ∀ r, sem r ∈ prevariety 56 zero : Rep 57 add : Rep → Rep → Rep 58 smul : ℚ → Rep → Rep 59 derivL : α → Rep → Rep 60 derivR : α → Rep → Rep 61 sem_zero : sem zero = 0 62 sem_add : ∀ r s, sem (add r s) = sem r + sem s 63 sem_smul : ∀ c r, sem (smul c r) = c • sem r 64 sem_derivL : ∀ a r, sem (derivL a r) = leftDeriv α a (sem r) 65 sem_derivR : ∀ a r, sem (derivR a r) = rightDeriv α a (sem r) 66 decEq : ∀ r s, Decidable (sem r = sem s) 67 68 end Lax619925.Prevariety 69 -
The commutativity problem
The commutativity problem asks whether a series is commutative, i.e. constant on words with the same Parikh image. The key observation (paper §3) is that commutativity is characterised by two finite families of equations, swap and rotate, which makes it decidable for effective prevarieties (the meta-theorem). Conversely, the zeroness problem reduces to commutativity: given , one builds a series over a two-letter-enlarged alphabet, supported on words beginning with the two fresh letters, such that is commutative exactly when .
- thm✓
Lax619925.Commutativity(1st statement) - thm✓
Lax619925.Commutativity(2nd statement) - thm✓
Lax619925.Commutativity(3rd statement)
1 import Lax619925.Series 2 import Lax619925.Prevariety 3 import Mathlib.Data.Real.Basic 4 import Mathlib.Data.Fintype.Basic 5 … module docstring, 13 lines 19 20 namespace Lax619925.Commutativity 21 22 open Lax619925.Series Lax619925.Prevariety 23 24 /-- The *swap* equation: for all letters `a, b`, 25 `leftDeriv a (leftDeriv b f) = leftDeriv b (leftDeriv a f)`. 26 It expresses that exchanging the first two letters of a word does not change 27 the coefficient. -/ 28 def SatisfiesSwap (α : Type*) (f : Series α) : Prop := 29 ∀ a b, leftDeriv α a (leftDeriv α b f) = leftDeriv α b (leftDeriv α a f) 30 31 /-- The *rotate* equation: for all letters `a`, 32 `leftDeriv a f = rightDeriv a f`. 33 It expresses that moving the first letter to the end does not change the 34 coefficient. -/ 35 def SatisfiesRotate (α : Type*) (f : Series α) : Prop := 36 ∀ a, leftDeriv α a f = rightDeriv α a f 37 38 /-- A series `g` is a *left anti-derivative* of the tuple of series `f` if 39 `leftDeriv a g = f a` for every letter `a`. Once the value `g ε` is fixed, 40 left anti-derivatives are unique. -/ 41 def IsLeftAntiDerivative (α : Type*) (g : Series α) (f : α → Series α) : Prop := 42 ∀ a, leftDeriv α a g = f a 43 44 /-- The alphabet `α` extended by two fresh letters `fresh0` and `fresh1`, modelling 45 the paper's enlarged alphabet `Γ = Σ ∪ {a, b}`. -/ 46 inductive Fresh2 (α : Type*) where 47 | letter : α → Fresh2 α 48 | fresh0 : Fresh2 α 49 | fresh1 : Fresh2 α 50 51 /-- Lift a word over the extended alphabet back to a word over `α`, returning 52 `some` of the original word when no fresh letter occurs and `none` otherwise. -/ 53 def liftWordOpt (α : Type*) (w : List (Fresh2 α)) : Option (List α) := 54 match w with 55 | [] => some [] 56 | s :: w' => 57 match s with 58 | .letter a => (liftWordOpt α w').map (fun rest => a :: rest) 59 | .fresh0 | .fresh1 => none 60 61 /-- The extension of a series over `α` to the extended alphabet `Fresh2 α`, by zero 62 on words containing one of the two fresh letters. -/ 63 def extendSeries (α : Type*) (f : Series α) : Series (Fresh2 α) := fun w => 64 match liftWordOpt α w with 65 | some rest => f rest 66 | none => 0 67 68 /-- The series `g` over the extended alphabet associated to `f` in the paper's 69 equality-reduces-to-commutativity construction: `g` is zero except on words 70 beginning with the two fresh letters, where `g (fresh0 :: fresh1 :: rest) = f (rest)` 71 (with `f` extended by zero). Hence `leftDeriv b (leftDeriv a g) = extendSeries f` 72 for `a = fresh0`, `b = fresh1`, while every other second left derivative vanishes; 73 in particular `g ε = g x = 0` for every letter `x`. -/ 74 def antiDerivativeSeries (α : Type*) (f : Series α) : Series (Fresh2 α) := fun w => 75 match w with 76 | .fresh0 :: .fresh1 :: rest => extendSeries α f rest 77 | _ => 0 78 79 /-- A series is commutative if and only if it satisfies the swap and rotate equations 80 for all letters (paper §3, lemma `commutativity`). Swaps and rotations generate 81 all commutatively equivalent words, so the two finite families of equations 82 characterise commutativity. -/ 83 axiom FiniteAxiomatisation (α : Type*) (f : Series α) : 84 IsCommutative α f ↔ SatisfiesSwap α f ∧ SatisfiesRotate α f 85 86 /-- The commutativity problem is decidable for effective prevarieties of series 87 (paper §3, theorem `commutativity for effective prevarieties`): over a finite 88 alphabet, there is a procedure that, given a presentation `r`, decides whether 89 `sem r` is commutative — it returns `true` exactly when `sem r` is commutative. 90 By the finite axiomatisation this reduces to finitely many equality tests on 91 presentations, decided by the prevariety's `decEq`. -/ 92 axiom EffectivePrevarietyCommutativityDecidable (α : Type*) [Fintype α] 93 (P : EffectivePrevariety α) : 94 ∃ d : P.Rep → Bool, ∀ r, d r = true ↔ IsCommutative α (P.sem r) 95 96 /-- The series `antiDerivativeSeries f` is commutative if and only if `f = 0` 97 (paper §3, lemma `equality reduces to commutativity`). If `f ≠ 0` with 98 `f (w) ≠ 0` for some word `w`, then `g (fresh0 · fresh1 · w) = f (w) ≠ 0` while 99 `g (fresh1 · fresh0 · w) = 0`, and the two words are commutatively equivalent, 100 so `g` is not commutative; conversely `f = 0` forces `g = 0`. -/ 101 axiom AntiDerivativeCommutativeIffZero (α : Type*) (f : Series α) : 102 IsCommutative (Fresh2 α) (antiDerivativeSeries α f) ↔ f = 0 103 104 end Lax619925.Commutativity 105 - thm✓
-
Linearly-finite and recognisable series
A series is linearly finite if it lies in a finitely generated -space of series closed under left derivatives; it is recognisable if it is recognised by a linear representation , i.e. . The two notions coincide (a classical result). The class of recognisable series is an effective prevariety — equality is decidable by linear algebra — and hence the commutativity problem is decidable for it (paper §4). This is the only chain in the proof network that does not depend on the ideal-membership statement.
- thm✓
Lax619925.Recognisable(1st statement) - thm✓
Lax619925.Recognisable(2nd statement) - thm✓
Lax619925.Recognisable(3rd statement) - thm✓
Lax619925.Recognisable(4th statement) - thm✓
Lax619925.Recognisable(5th statement) - thm✓
Lax619925.Recognisable(6th statement) - thm✓
Lax619925.Recognisable(7th statement) - thm✓
Lax619925.Recognisable(8th statement)
1 import Lax619925.Series 2 import Lax619925.Prevariety 3 import Lax619925.Commutativity 4 import Mathlib.Data.Real.Basic 5 import Mathlib.Data.Fin.Basic 6 import Mathlib.Data.Fintype.Basic 7 import Mathlib.Data.Finset.Basic 8 import Mathlib.Data.Matrix.Basic 9 import Mathlib.LinearAlgebra.Span.Basic 10 … module docstring, 13 lines 24 25 namespace Lax619925.Recognisable 26 27 open Lax619925.Series Lax619925.Prevariety Lax619925.Commutativity 28 29 /-- A linear representation over `α`: a dimension `k`, a row vector `init` of 30 initial weights, a column vector `final` of final weights, and a transition 31 function `M` assigning to each letter a `k × k` matrix. The transition function 32 extends homomorphically to words by `M(ε) = 1` and `M(a·w) = M(a) · M(w)` (the 33 definition `Mword`), and the series recognised is `f (w) = x · M(w) · y` (the 34 definition `sem`). Both are computed from the four core fields. -/ 35 structure LinearRepresentation (α : Type*) where 36 dim : ℕ 37 init : Fin dim → ℚ 38 final : Fin dim → ℚ 39 M : α → Matrix (Fin dim) (Fin dim) ℚ 40 41 /-- The word product `M(w)`: `M(ε) = 1` and `M(a·w) = M(a) · M(w)`, the transition 42 matrices composed right-to-left along the word. -/ 43 def LinearRepresentation.Mword {α : Type*} (r : LinearRepresentation α) (w : List α) : 44 Matrix (Fin r.dim) (Fin r.dim) ℚ := 45 w.foldr (fun a A => r.M a * A) 1 46 47 /-- The series recognised by the representation: `f (w) = x · M(w) · y`, the dot 48 product of the initial vector with the word product applied to the final vector. -/ 49 def LinearRepresentation.sem {α : Type*} (r : LinearRepresentation α) (w : List α) : ℚ := 50 dotProduct r.init (Matrix.mulVec (r.Mword w) r.final) 51 52 /-- A series is *recognisable* if it is recognised by some linear representation. -/ 53 def IsRecognisable (α : Type*) (f : Series α) : Prop := 54 ∃ r : LinearRepresentation α, r.sem = f 55 56 /-- A series is *linearly finite* if it belongs to a finitely generated `ℚ`-space of 57 series (the span of a finite set of generators `G`) that is closed under left 58 derivatives: `f ∈ span G` and `leftDeriv a g ∈ span G` for all `a` and `g ∈ G`. -/ 59 def IsLinearlyFinite (α : Type*) (f : Series α) : Prop := 60 ∃ G : Finset (Series α), f ∈ Submodule.span ℚ G ∧ ∀ a, ∀ g ∈ G, leftDeriv α a g ∈ Submodule.span ℚ G 61 62 /-- A series is recognisable if and only if it is linearly finite 63 (paper §4, the classical coincidence lemma). -/ 64 axiom RecognisableLinearlyFinite (α : Type*) (f : Series α) : 65 IsRecognisable α f ↔ IsLinearlyFinite α f 66 67 /-- The class of linearly finite series is closed under scalar product, addition, 68 and left derivatives (paper §4, lemma `recognisable closure properties`). The 69 closure is effective: each operation is witnessed by an explicit finite set of 70 generators. These three parts hold over any alphabet. -/ 71 axiom LinearlyFiniteClosure (α : Type*) : 72 (∀ (f g : Series α), IsLinearlyFinite α f → IsLinearlyFinite α g → IsLinearlyFinite α (f + g)) ∧ 73 (∀ (c : ℚ) (f : Series α), IsLinearlyFinite α f → IsLinearlyFinite α (c • f)) ∧ 74 (∀ (a : α) (f : Series α), IsLinearlyFinite α f → IsLinearlyFinite α (leftDeriv α a f)) 75 76 /-- The class of linearly finite series over a *finite* alphabet is closed under left 77 anti-derivatives (paper §4, lemma `recognisable closure properties`): if `g` is a 78 left anti-derivative of a tuple `f` of linearly finite series, then `g` is linearly 79 finite. The finiteness of the alphabet is essential — the witnessing generator set 80 is `{g} ∪ ⋃ₐ Gₐ`, one finite set `Gₐ` per letter, so it is finite only when the 81 alphabet is. -/ 82 axiom LinearlyFiniteAntiDerivativeClosure (α : Type*) [Fintype α] : 83 ∀ (g : Series α) (f : α → Series α), IsLeftAntiDerivative α g f → 84 (∀ a, IsLinearlyFinite α (f a)) → IsLinearlyFinite α g 85 86 /-- If `f` is recognisable, then its reversal is recognisable (paper §4): the 87 transposed representation `(k, yᵀ, xᵀ, Mᵀ)` recognises `reversal f`. -/ 88 axiom RecognisableReversal (α : Type*) (f : Series α) (hf : IsRecognisable α f) : 89 IsRecognisable α (reversal α f) 90 91 /-- If `f` is recognisable, then its right derivative is recognisable 92 (paper §4, corollary `recognisable derive right`), by double reversal: 93 `rightDeriv a f = reversal (leftDeriv a (reversal f))`. -/ 94 axiom RecognisableRightDeriv (α : Type*) (a : α) (f : Series α) (hf : IsRecognisable α f) : 95 IsRecognisable α (rightDeriv α a f) 96 97 /-- The equality (zeroness) problem is decidable for recognisable series over a finite 98 alphabet (paper §4): there is a procedure that, given a linear representation, 99 decides whether the series it recognises is the zero series. It checks, by linear 100 algebra, that the initial vector annihilates the subspace reachable from the final 101 vector. This is condition (3) in the definition of effective prevariety. -/ 102 axiom RecognisableEqualityDecidable (α : Type*) [Fintype α] : 103 ∃ d : LinearRepresentation α → Bool, ∀ r, d r = true ↔ r.sem = 0 104 105 /-- The class of recognisable (= linearly finite) series is an effective prevariety 106 (paper §4, theorem): there is an effective prevariety whose image is exactly the 107 recognisable series, with presentations given by linear representations. -/ 108 axiom RecognisableEffectivePrevariety (α : Type*) [Fintype α] : 109 ∃ P : EffectivePrevariety α, ∀ f, IsRecognisable α f ↔ ∃ r : P.Rep, P.sem r = f 110 111 /-- In particular, the commutativity problem is decidable for recognisable series over 112 a finite alphabet (paper §4): there is a procedure that, given a linear 113 representation, decides whether the series it recognises is commutative. This is 114 the meta-theorem applied to the effective prevariety of recognisable series. -/ 115 axiom RecognisableCommutativityDecidable (α : Type*) [Fintype α] : 116 ∃ d : LinearRepresentation α → Bool, ∀ r, d r = true ↔ IsCommutative α (r.sem) 117 118 end Lax619925.Recognisable 119 - thm✓
-
Hadamard automata and Hadamard-finite series
A series is Hadamard-finite if it lies in the Hadamard algebra generated by a finite tuple of series that is closed under left derivatives (paper §5): the Hadamard product is the pointwise product of the underlying functions, so the Hadamard algebra is just the (pointwise) ring of series. Equivalently (the coincidence), it is recognised by a Hadamard automaton : a configuration space , a final-weight functional , and a transition that extends to an endomorphism of the configuration space. The Hadamard-finite series form an effective prevariety, so equality and the commutativity problem are decidable for them; the equality decision reduces to ideal membership in the configuration polynomial ring (the ideal-membership statement).
- thm✓
Lax619925.Hadamard(1st statement) - thm✓
Lax619925.Hadamard(2nd statement) - thm✓
Lax619925.Hadamard(3rd statement) - thm✓
Lax619925.Hadamard(4th statement) - thm✓
Lax619925.Hadamard(5th statement) - thm✓
Lax619925.Hadamard(6th statement)
1 import Lax619925.Series 2 import Lax619925.Prevariety 3 import Lax619925.Commutativity 4 import Mathlib.Data.Real.Basic 5 import Mathlib.Data.Fin.Basic 6 import Mathlib.Data.Fintype.Basic 7 import Mathlib.Data.Finset.Basic 8 import Mathlib.Algebra.MvPolynomial.Basic 9 import Mathlib.Algebra.MvPolynomial.Eval 10 import Mathlib.Algebra.Algebra.Basic 11 … module docstring, 16 lines 28 29 namespace Lax619925.Hadamard 30 31 open Lax619925.Series Lax619925.Prevariety Lax619925.Commutativity 32 33 /-- The Hadamard product of two series, defined element-wise: 34 `(hadamard f g) w = f w * g w`. It is the pointwise product of the 35 underlying functions, hence associative, commutative, and distributive over 36 addition, with identity the constant-1 series. -/ 37 def hadamard (α : Type*) (f g : Series α) : Series α := fun w => f w * g w 38 39 /-- The Hadamard-algebra evaluation of the polynomial `p` at the series `fs`: 40 `hadamardEval fs p = Σ_m p m · ∏_i (fs i)^{m i}`, the interpretation of `p` in 41 the (pointwise) ring of series, where the variable `X_i` is mapped to `fs i` and 42 the multiplication is the Hadamard (pointwise) product. -/ 43 def hadamardEval (α : Type*) (k : ℕ) (fs : Fin k → Series α) (p : MvPolynomial (Fin k) ℚ) : 44 Series α := 45 fun w => p.support.sum fun m => p.coeff m * ∏ i : Fin k, (fs i) w ^ (m i) 46 47 /-- A series is *Hadamard-finite* (working definition, paper §5) if it is a Hadamard 48 polynomial in a finite tuple of series `fs` that is closed under left 49 derivatives: `f = p(fs)` for some polynomial `p`, and `leftDeriv a (fs i)` is 50 again a Hadamard polynomial in `fs` for every letter `a` and index `i`. Here 51 `p(fs)` is the evaluation of `p` in the (pointwise) ring of series, i.e. the 52 Hadamard algebra. -/ 53 def IsHadamardFinite (α : Type*) (f : Series α) : Prop := 54 ∃ k : ℕ, ∃ fs : Fin k → Series α, ∃ p : MvPolynomial (Fin k) ℚ, 55 f = hadamardEval α k fs p ∧ 56 ∀ a : α, ∀ i : Fin k, ∃ q : MvPolynomial (Fin k) ℚ, 57 leftDeriv α a (fs i) = hadamardEval α k fs q 58 59 /-- A *Hadamard automaton* over `α`: a dimension `k ≥ 1` (the number of 60 nonterminals `X_1, …, X_k`), a final-weight functional `F`, and a transition 61 `Δ` assigning to each letter `a` and nonterminal `X_i` a polynomial `Δ a i` in 62 the nonterminals. The configuration space is the polynomial ring 63 `ℚ[X_1, …, X_k] = MvPolynomial (Fin k) ℚ`. -/ 64 structure HadamardAutomaton (α : Type*) where 65 dim : ℕ 66 hdim : 0 < dim 67 F : Fin dim → ℚ 68 Δ : α → Fin dim → MvPolynomial (Fin dim) ℚ 69 70 /-- The word extension of the transition: `Δ_w` is the endomorphism of the 71 configuration space obtained by composing the letter endomorphisms 72 `aeval (Δ a)` along the word, right-to-left. `Δ_ε` is the identity and 73 `Δ_{a·w} = Δ_w ∘ Δ_a`. -/ 74 noncomputable def HadamardAutomaton.Mword {α : Type*} (A : HadamardAutomaton α) (w : List α) : 75 MvPolynomial (Fin A.dim) ℚ → MvPolynomial (Fin A.dim) ℚ := 76 w.foldr (fun a φ => fun β => φ (MvPolynomial.aeval (A.Δ a) β)) id 77 78 /-- The series recognised by the automaton at a configuration `cfg`: 79 `⟦A⟧_cfg (w) = F(Δ_w cfg)`, the final-weight functional applied to the 80 configuration reached after reading `w`. -/ 81 noncomputable def HadamardAutomaton.sem {α : Type*} (A : HadamardAutomaton α) 82 (cfg : MvPolynomial (Fin A.dim) ℚ) : Series α := 83 fun w => MvPolynomial.eval (fun i => A.F i) (A.Mword w cfg) 84 85 /-- The series recognised by the automaton: the semantics at the initial 86 configuration `X_0` (the first nonterminal). -/ 87 noncomputable def HadamardAutomaton.recognised {α : Type*} (A : HadamardAutomaton α) : 88 Series α := 89 A.sem (MvPolynomial.X (Fin.mk 0 A.hdim)) 90 91 /-- A series is *Hadamard-recognisable* if it is recognised by some Hadamard automaton. -/ 92 def IsHadamardRecognisable (α : Type*) (f : Series α) : Prop := 93 ∃ A : HadamardAutomaton α, A.recognised = f 94 95 /-- A series is Hadamard-finite if and only if it is Hadamard-recognisable 96 (paper §5, the coincidence lemma). -/ 97 axiom HadamardCoincidence (α : Type*) (f : Series α) : 98 IsHadamardFinite α f ↔ IsHadamardRecognisable α f 99 100 /-- The class of Hadamard-finite series is closed under addition, scalar 101 multiplication, the Hadamard product, and right derivatives (paper §5, the 102 closure lemma). These four parts hold over any alphabet. -/ 103 axiom HadamardClosure (α : Type*) : 104 (∀ (f g : Series α), IsHadamardFinite α f → IsHadamardFinite α g → IsHadamardFinite α (f + g)) ∧ 105 (∀ (c : ℚ) (f : Series α), IsHadamardFinite α f → IsHadamardFinite α (c • f)) ∧ 106 (∀ (f g : Series α), IsHadamardFinite α f → IsHadamardFinite α g → IsHadamardFinite α (hadamard α f g)) ∧ 107 (∀ (a : α) (f : Series α), IsHadamardFinite α f → IsHadamardFinite α (rightDeriv α a f)) 108 109 /-- The class of Hadamard-finite series over a *finite* alphabet is closed under left 110 anti-derivatives (paper §5): if `g` is a left anti-derivative of a tuple `f` of 111 Hadamard-finite series, then `g` is Hadamard-finite. The finiteness of the 112 alphabet is essential — the witnessing generator tuple is extended by one series 113 per letter, so it is finite only when the alphabet is. -/ 114 axiom HadamardAntiDerivativeClosure (α : Type*) [Fintype α] : 115 ∀ (g : Series α) (f : α → Series α), IsLeftAntiDerivative α g f → 116 (∀ a, IsHadamardFinite α (f a)) → IsHadamardFinite α g 117 118 /-- The class of Hadamard-finite series is an effective prevariety over a finite 119 alphabet (paper §5, theorem): there is an effective prevariety whose image is 120 exactly the Hadamard-finite series, with presentations given by Hadamard 121 automata. -/ 122 axiom HadamardEffectivePrevariety (α : Type*) [Fintype α] : 123 ∃ P : EffectivePrevariety α, ∀ f, IsHadamardFinite α f ↔ ∃ r : P.Rep, P.sem r = f 124 125 /-- The equality (zeroness) problem is decidable for Hadamard automata over a finite 126 alphabet (paper §5): there is a procedure that, given a Hadamard automaton, 127 decides whether the series it recognises is the zero series. The decision 128 reduces to ideal membership in the configuration polynomial ring, the open 129 leaf. -/ 130 axiom HadamardEqualityDecidable (α : Type*) [Fintype α] : 131 ∃ d : HadamardAutomaton α → Bool, ∀ A, d A = true ↔ A.recognised = 0 132 133 /-- In particular, the commutativity problem is decidable for Hadamard-finite series 134 over a finite alphabet (paper §5): there is a procedure that, given a Hadamard 135 automaton, decides whether the series it recognises is commutative. This is the 136 meta-theorem applied to the effective prevariety of Hadamard-finite series. -/ 137 axiom HadamardCommutativityDecidable (α : Type*) [Fintype α] : 138 ∃ d : HadamardAutomaton α → Bool, ∀ A, d A = true ↔ IsCommutative α (A.recognised) 139 140 end Lax619925.Hadamard 141 - thm✓
-
Multivariate polynomial recursive sequences
A multivariate polynomial recursive sequence (polyrec sequence) in variables is a -tuple of sequences satisfying polynomial equations (paper §5.4), where is the shift in the -th coordinate and are polynomials evaluated pointwise in the sequences. The consistency problem asks whether, given the equations and an initial condition , a solution exists. This is decidable (paper §5.4, theorem ): the polyrec system is isomorphic to a Hadamard system over the -letter alphabet, so a solution exists exactly when the companion Hadamard series are commutative, which is decidable.
1 import Lax619925.Series 2 import Lax619925.Hadamard 3 import Mathlib.Data.Real.Basic 4 import Mathlib.Data.Fin.Basic 5 import Mathlib.Data.Fintype.Basic 6 import Mathlib.Data.Finset.Basic 7 import Mathlib.Algebra.MvPolynomial.Basic 8 … module docstring, 15 lines 24 25 namespace Lax619925.Polyrec 26 27 open Lax619925.Series Lax619925.Hadamard 28 29 /-- A multivariate sequence in `d` variables: a function `ℕ^d → ℚ`, represented 30 as a function on the multi-index type `Fin d → ℕ`. -/ 31 abbrev Seq (d : ℕ) := (Fin d → ℕ) → ℚ 32 33 /-- The shift of a multivariate sequence in the `j`-th coordinate: 34 `(shift d j f) n = f (n + e_j)`, where `e_j` is the `j`-th unit vector. 35 The shifts in different coordinates commute. -/ 36 def shift (d : ℕ) (j : Fin d) (f : Seq d) : Seq d := 37 fun n => f (fun i => n i + if i = j then 1 else 0) 38 39 /-- The pointwise (Hadamard-algebra) evaluation of the polynomial `p` at the tuple 40 of sequences `fs`: `evalSeq d k fs p n = Σ_m p.coeff m · ∏_i (fs i n)^{m i}`, 41 the interpretation of `p` in the pointwise ring of sequences, where the 42 variable `X_i` is mapped to `fs i` and the multiplication is pointwise. -/ 43 def evalSeq (d k : ℕ) (fs : Fin k → Seq d) (p : MvPolynomial (Fin k) ℚ) : Seq d := 44 fun n => p.support.sum fun m => p.coeff m * ∏ i : Fin k, (fs i) n ^ (m i) 45 46 /-- A `k`-tuple of multivariate sequences `f` *solves* the polyrec system 47 `(p, c)` if it satisfies the initial condition `f_i(0) = c_i` and the 48 polynomial equations `shift_j f_i = p^{(j)}_i(f_1, …, f_k)` for all `i, j`, 49 where `p^{(j)}_i` is evaluated pointwise in the sequences (the Hadamard 50 algebra). Here `0` is the zero multi-index, the origin of `ℕ^d`. -/ 51 def SolvesPolyrec (d k : ℕ) (f : Fin k → Seq d) 52 (p : Fin k → Fin d → MvPolynomial (Fin k) ℚ) (c : Fin k → ℚ) : Prop := 53 (∀ i, f i 0 = c i) ∧ ∀ i j, shift d j (f i) = evalSeq d k f (p i j) 54 55 /-- The polyrec consistency problem is decidable (paper §5.4, theorem 56 `polyrec consistency`): there is a procedure that, given the polynomial 57 equations `p` and the initial condition `c`, decides whether a solution 58 exists. The decision reduces to the commutativity of the companion Hadamard 59 series, which is decidable. -/ 60 axiom PolyrecConsistency (d k : ℕ) (hd : 0 < d) (hk : 0 < k) : 61 ∃ dec : (Fin k → Fin d → MvPolynomial (Fin k) ℚ) → (Fin k → ℚ) → Bool, 62 ∀ p c, dec p c = true ↔ ∃ f : Fin k → Seq d, SolvesPolyrec d k f p c 63 64 end Lax619925.Polyrec 65 -
Shuffle automata and shuffle-finite series
A series is shuffle-finite if it belongs to a finitely generated differential shuffle algebra (paper §6.2.2): it is a shuffle polynomial in a finite tuple of series that is closed under left derivatives. Equivalently (the coincidence), it is recognised by a shuffle automaton : a configuration space , a final-weight functional , and a transition that extends to a derivation of the configuration space (the paper's differential- algebra structure, §6). The shuffle-finite series form an effective prevariety, so equality and the commutativity problem are decidable for them; the equality decision reduces to ideal membership in the configuration polynomial ring (the ideal-membership statement), via the same ideal-chain argument as for the Hadamard and infiltration automata.
- thm✓
Lax619925.Shuffle(1st statement) - thm✓
Lax619925.Shuffle(2nd statement) - thm✓
Lax619925.Shuffle(3rd statement) - thm✓
Lax619925.Shuffle(4th statement) - thm✓
Lax619925.Shuffle(5th statement) - thm✓
Lax619925.Shuffle(6th statement)
1 import Lax619925.Series 2 import Lax619925.Prevariety 3 import Lax619925.Commutativity 4 import Mathlib.Data.Real.Basic 5 import Mathlib.Data.Fin.Basic 6 import Mathlib.Data.Fintype.Basic 7 import Mathlib.Data.Finset.Basic 8 import Mathlib.Data.Finsupp.Basic 9 import Mathlib.Algebra.MvPolynomial.Basic 10 import Mathlib.Algebra.MvPolynomial.Eval 11 … module docstring, 17 lines 29 30 namespace Lax619925.Shuffle 31 32 open Lax619925.Series Lax619925.Prevariety Lax619925.Commutativity 33 34 /-- The recursive core of the shuffle product, defined by primitive recursion on the 35 word: `(f ⧢ g) ε = f ε · g ε` and 36 `(f ⧢ g) (a·w) = ((leftDeriv a f) ⧢ g) w + (f ⧢ (leftDeriv a g)) w`, the Leibniz 37 rule. This is the unique series satisfying the characterisation. The recursion 38 measure is the word length (the series arguments `f`, `g` change at each step, so 39 structural recursion on the word alone does not apply). -/ 40 noncomputable def shuffleRec (α : Type*) (f g : Series α) (w : List α) : ℚ := 41 match w with 42 | [] => f [] * g [] 43 | a :: w' => shuffleRec α (leftDeriv α a f) g w' + shuffleRec α f (leftDeriv α a g) w' 44 termination_by w.length 45 46 /-- The shuffle product of two series, characterised by the Leibniz rule 47 `leftDeriv a (f ⧢ g) = (leftDeriv a f) ⧢ g + f ⧢ (leftDeriv a g)` and the 48 initial condition `(f ⧢ g) ε = f ε · g ε`. Equivalently, 49 `(f ⧢ g) w = Σ_{u·v = w} f u · g v`, the sum over all interleavings of `u` 50 and `v` that yield `w`. -/ 51 noncomputable def shuffle (α : Type*) (f g : Series α) : Series α := 52 fun w => shuffleRec α f g w 53 54 /-- The unit of the shuffle product: the delta series, `1` on the empty word and `0` 55 elsewhere. Unlike the constant-`1` series (the unit of the pointwise product), the 56 delta series is the unit of the *shuffle* product. -/ 57 def shuffleUnit (α : Type*) : Series α := fun w => if w = [] then 1 else 0 58 59 /-- The `n`-fold iterated shuffle power of `f`: `shufflePow α f 0 = shuffleUnit α` (the 60 shuffle unit) and `shufflePow α f (n+1) = f ⧢ shufflePow α f n`. This is the shuffle 61 analogue of the pointwise power `f ^ n` used in `hadamardEval`. -/ 62 noncomputable def shufflePow (α : Type*) (f : Series α) (n : ℕ) : Series α := 63 match n with 64 | 0 => shuffleUnit α 65 | n + 1 => shuffle α f (shufflePow α f n) 66 67 /-- The shuffle product of the iterated shuffle powers `fs 0 ⧢^[d 0] ⧢ ⋯ ⧢ fs (k-1) ⧢^[d (k-1)]`, 68 where `⧢` is the shuffle product and `⧢^[n]` is the iterated shuffle power 69 (`shufflePow`). This is the shuffle analogue of the pointwise monomial product 70 `∏ i, (fs i) ^ (d i)` used in `hadamardEval`; it is the shuffle fold of the 71 commutative-associative shuffle operation over all indices (the zero-exponent terms 72 contribute the shuffle unit, which is the identity). It is computed as a right-fold 73 over the index list, so that the definition does not depend on the `Std.Commutative`/ 74 `Std.Associative` instances (which the axiom-free concept package cannot carry); the 75 proof package shows it equals the corresponding `Finset.fold` (`shuffleProd_eq_fold`). -/ 76 noncomputable def shuffleProd (α : Type*) (k : ℕ) (fs : Fin k → Series α) (d : Fin k →₀ ℕ) : Series α := 77 (((Finset.univ : Finset (Fin k)).toList).map (fun i => shufflePow α (fs i) (d i))).foldr 78 (fun x acc => shuffle α x acc) (shuffleUnit α) 79 80 /-- The evaluation of the polynomial `p` in the *shuffle* algebra, sending `X_i` to 81 `fs i`: `shuffleEval α k fs p = ∑ d ∈ p.support, p.coeff d · (fs 0 ⧢^[d 0] ⧢ ⋯ ⧢ 82 fs (k-1) ⧢^[d (k-1)])`, where `⧢` is the shuffle product and `⧢^[n]` is the iterated 83 shuffle power. This is the shuffle analogue of `hadamardEval` (which evaluates in the 84 pointwise ring); because the shuffle ring cannot be a `CommRing` instance on `Series α` 85 (which already carries the pointwise ring), it is defined directly as the sum over the 86 polynomial's support of the coefficients times the shuffle product of the iterated 87 powers. -/ 88 noncomputable def shuffleEval (α : Type*) (k : ℕ) (fs : Fin k → Series α) 89 (p : MvPolynomial (Fin k) ℚ) : Series α := 90 p.support.sum fun m => p.coeff m • shuffleProd α k fs m 91 92 /-- The unique derivation of the polynomial ring `MvPolynomial σ R` sending the 93 variable `X i` to `φ i`, defined by the Leibniz rule on monomials: 94 `δ_φ(X^m) = Σ_i m_i · X^{m - e_i} · φ i`. This is the extension of the 95 letter transition `Δ_a` (a map on the variables) to a derivation of the whole 96 configuration space. -/ 97 noncomputable def derivationExt {σ : Type*} [Fintype σ] {R : Type*} [CommRing R] 98 (φ : σ → MvPolynomial σ R) : MvPolynomial σ R → MvPolynomial σ R := 99 fun p => p.support.sum fun m => 100 p.coeff m • (∑ i : σ, ((m i : R) • MvPolynomial.monomial (m - Finsupp.single i 1) 1) * φ i) 101 102 /-- A *shuffle automaton* over `α`: a dimension `k ≥ 1` (the number of 103 nonterminals `X_1, …, X_k`), a final-weight functional `F`, and a transition 104 `Δ` assigning to each letter `a` and nonterminal `X_i` a polynomial `Δ a i` in 105 the nonterminals. The configuration space is the polynomial ring 106 `ℚ[X_1, …, X_k] = MvPolynomial (Fin k) ℚ`. -/ 107 structure ShuffleAutomaton (α : Type*) where 108 dim : ℕ 109 hdim : 0 < dim 110 F : Fin dim → ℚ 111 Δ : α → Fin dim → MvPolynomial (Fin dim) ℚ 112 113 /-- The word extension of the transition: `Δ_w` is the map of the configuration 114 space obtained by composing the letter derivations `derivationExt (Δ a)` along 115 the word, right-to-left. The law is unchanged from the Hadamard case: 116 `Δ_ε` is the identity and `Δ_{a·w} = Δ_w ∘ Δ_a`; the only difference is that 117 each `Δ_a` is now a derivation rather than an endomorphism. -/ 118 noncomputable def ShuffleAutomaton.Mword {α : Type*} (A : ShuffleAutomaton α) (w : List α) : 119 MvPolynomial (Fin A.dim) ℚ → MvPolynomial (Fin A.dim) ℚ := 120 w.foldr (fun a φ => fun β => φ (derivationExt (A.Δ a) β)) id 121 122 /-- The series recognised by the automaton at a configuration `cfg`: 123 `⟦A⟧_cfg (w) = F(Δ_w cfg)`, the final-weight functional applied to the 124 configuration reached after reading `w`. -/ 125 noncomputable def ShuffleAutomaton.sem {α : Type*} (A : ShuffleAutomaton α) 126 (cfg : MvPolynomial (Fin A.dim) ℚ) : Series α := 127 fun w => MvPolynomial.eval (fun i => A.F i) (A.Mword w cfg) 128 129 /-- The series recognised by the automaton: the semantics at the initial 130 configuration `X_0` (the first nonterminal). -/ 131 noncomputable def ShuffleAutomaton.recognised {α : Type*} (A : ShuffleAutomaton α) : 132 Series α := 133 A.sem (MvPolynomial.X (Fin.mk 0 A.hdim)) 134 135 /-- A series is *shuffle-finite* (working definition, paper §6.2.2) if it belongs to a 136 finitely generated differential shuffle algebra: it is a shuffle polynomial in a 137 finite tuple of series `fs` that is closed under left derivatives, i.e. 138 `f = shuffleEval k fs p` for some polynomial `p`, and `leftDeriv a (fs i)` is again a 139 shuffle polynomial in `fs` for every letter `a` and index `i`. Here `shuffleEval k fs` 140 is the evaluation in the shuffle algebra generated by `fs`. -/ 141 def IsShuffleFinite (α : Type*) (f : Series α) : Prop := 142 ∃ k : ℕ, ∃ fs : Fin k → Series α, ∃ p : MvPolynomial (Fin k) ℚ, 143 f = shuffleEval α k fs p ∧ 144 ∀ a : α, ∀ i : Fin k, ∃ q : MvPolynomial (Fin k) ℚ, 145 leftDeriv α a (fs i) = shuffleEval α k fs q 146 147 /-- A series is *shuffle-recognisable* if it is recognised by some shuffle automaton. -/ 148 def IsShuffleRecognisable (α : Type*) (f : Series α) : Prop := 149 ∃ A : ShuffleAutomaton α, A.recognised = f 150 151 /-- A series is shuffle-finite if and only if it is shuffle-recognisable 152 (paper §6, the coincidence lemma): the finitely generated differential shuffle 153 algebras are exactly the languages of shuffle automata. -/ 154 axiom ShuffleCoincidence (α : Type*) (f : Series α) : 155 IsShuffleFinite α f ↔ IsShuffleRecognisable α f 156 157 /-- The class of shuffle-finite series is closed under addition, scalar 158 multiplication, the shuffle product, and right derivatives (paper §6, the 159 closure lemma). These four parts hold over any alphabet. -/ 160 axiom ShuffleClosure (α : Type*) : 161 (∀ (f g : Series α), IsShuffleFinite α f → IsShuffleFinite α g → IsShuffleFinite α (f + g)) ∧ 162 (∀ (c : ℚ) (f : Series α), IsShuffleFinite α f → IsShuffleFinite α (c • f)) ∧ 163 (∀ (f g : Series α), IsShuffleFinite α f → IsShuffleFinite α g → IsShuffleFinite α (shuffle α f g)) ∧ 164 (∀ (a : α) (f : Series α), IsShuffleFinite α f → IsShuffleFinite α (rightDeriv α a f)) 165 166 /-- The class of shuffle-finite series over a *finite* alphabet is closed under left 167 anti-derivatives (paper §6): if `g` is a left anti-derivative of a tuple `f` of 168 shuffle-finite series, then `g` is shuffle-finite. The finiteness of the 169 alphabet is essential — the witnessing generator set is extended by one series 170 per letter, so it is finite only when the alphabet is. -/ 171 axiom ShuffleAntiDerivativeClosure (α : Type*) [Fintype α] : 172 ∀ (g : Series α) (f : α → Series α), IsLeftAntiDerivative α g f → 173 (∀ a, IsShuffleFinite α (f a)) → IsShuffleFinite α g 174 175 /-- The class of shuffle-finite series is an effective prevariety over a finite 176 alphabet (paper §6, theorem): there is an effective prevariety whose image is 177 exactly the shuffle-finite series, with presentations given by shuffle 178 automata. -/ 179 axiom ShuffleEffectivePrevariety (α : Type*) [Fintype α] : 180 ∃ P : EffectivePrevariety α, ∀ f, IsShuffleFinite α f ↔ ∃ r : P.Rep, P.sem r = f 181 182 /-- The equality (zeroness) problem is decidable for shuffle automata over a finite 183 alphabet (paper §6): there is a procedure that, given a shuffle automaton, 184 decides whether the series it recognises is the zero series. The decision 185 reduces to ideal membership in the configuration polynomial ring, the open 186 leaf. -/ 187 axiom ShuffleEqualityDecidable (α : Type*) [Fintype α] : 188 ∃ d : ShuffleAutomaton α → Bool, ∀ A, d A = true ↔ A.recognised = 0 189 190 /-- In particular, the commutativity problem is decidable for shuffle-finite series 191 over a finite alphabet (paper §6): there is a procedure that, given a shuffle 192 automaton, decides whether the series it recognises is commutative. This is the 193 meta-theorem applied to the effective prevariety of shuffle-finite series. -/ 194 axiom ShuffleCommutativityDecidable (α : Type*) [Fintype α] : 195 ∃ d : ShuffleAutomaton α → Bool, ∀ A, d A = true ↔ IsCommutative α (A.recognised) 196 197 end Lax619925.Shuffle 198 - thm✓
-
thm✓
Lax619925.CDAMultivariate constructible differentially algebraic power series
An exponential multivariate power series in variables is a series (paper §6.4), identified with its coefficient sequence . It carries a binomial-convolution product and commuting partial derivatives (the shift in the -th coordinate). A CDA system is a -tuple of such series satisfying , the right-hand side a polynomial in the binomial-convolution algebra. The solvability problem asks whether, given the equations and an initial condition , a solution exists. This is decidable (paper §6.4): the CDA system is isomorphic to a shuffle system over the -letter alphabet, so a solution exists exactly when the companion shuffle series are commutative, which is decidable.
1 import Lax619925.Series 2 import Lax619925.Shuffle 3 import Mathlib.Data.Real.Basic 4 import Mathlib.Data.Fin.Basic 5 import Mathlib.Data.Fintype.Basic 6 import Mathlib.Data.Finset.Basic 7 import Mathlib.Data.Nat.Choose.Basic 8 import Mathlib.Algebra.MvPolynomial.Basic 9 … module docstring, 17 lines 27 28 namespace Lax619925.CDA 29 30 open Lax619925.Series Lax619925.Shuffle 31 32 /-- An exponential multivariate power series in `d` variables, identified with 33 its coefficient sequence (the series is `Σ_n f_n x^n / n!`). -/ 34 abbrev ExpPowerSeries (d : ℕ) := (Fin d → ℕ) → ℚ 35 36 /-- The binomial-convolution product of two exponential power series: 37 `(expMul d f g) n = Σ_{m ≤ n} binom(n, m) f m · g (n - m)`, the product in the 38 exponential (binomial) algebra, where the sum is over the multi-indices 39 `m ≤ n` (coordinate-wise) and `binom(n, m) = ∏_i binom(n_i, m_i)` is the 40 multinomial coefficient. -/ 41 noncomputable def expMul (d : ℕ) (f g : ExpPowerSeries d) : ExpPowerSeries d := 42 fun n => 43 (Finset.univ.pi (fun i => Finset.range (n i + 1))).sum fun m => 44 let m' : Fin d → ℕ := fun i => m i (Finset.mem_univ i) 45 (Finset.univ : Finset (Fin d)).prod (fun i => Nat.choose (n i) (m' i)) * f m' * g (fun i => n i - m' i) 46 47 /-- The partial derivative in the `j`-th coordinate: 48 `(expDeriv d j f) n = f (n + e_j)`. In the exponential normalisation this is 49 the shift in the `j`-th coordinate; the partial derivatives commute. -/ 50 def expDeriv (d : ℕ) (j : Fin d) (f : ExpPowerSeries d) : ExpPowerSeries d := 51 fun n => f (fun i => n i + if i = j then 1 else 0) 52 53 /-- The `n`-fold binomial-convolution power of an exponential power series: 54 `expPow d f 0` is the constant-1 series and `expPow d f (n+1) = expMul d (expPow d f n) f`. -/ 55 noncomputable def expPow (d : ℕ) (f : ExpPowerSeries d) (n : ℕ) : ExpPowerSeries d := 56 match n with 57 | 0 => fun idx => if idx = 0 then 1 else 0 58 | n + 1 => expMul d (expPow d f n) f 59 60 /-- The evaluation of the polynomial `p` at the tuple of exponential power series 61 `fs`, in the binomial-convolution algebra: the variable `X_i` is mapped to 62 `fs i` and the multiplication is the binomial-convolution product. -/ 63 noncomputable def evalCDA (d k : ℕ) (fs : Fin k → ExpPowerSeries d) (p : MvPolynomial (Fin k) ℚ) : 64 ExpPowerSeries d := 65 p.support.sum fun m => 66 p.coeff m • (Finset.univ : Finset (Fin k)).toList.foldr 67 (fun i acc => expMul d acc (expPow d (fs i) (m i))) 68 (fun idx => if idx = 0 then 1 else 0) 69 70 /-- A `k`-tuple of exponential power series `f` *solves* the CDA system `(p, c)` 71 if it satisfies the initial condition `f_i(0) = c_i` and the differential 72 equations `∂_{x_j} f_i = p^{(j)}_i(f_1, …, f_k)` for all `i, j`, the 73 right-hand side a polynomial in the binomial-convolution algebra. Here `0` 74 is the zero multi-index. -/ 75 def SolvesCDA (d k : ℕ) (f : Fin k → ExpPowerSeries d) 76 (p : Fin k → Fin d → MvPolynomial (Fin k) ℚ) (c : Fin k → ℚ) : Prop := 77 (∀ i, f i 0 = c i) ∧ ∀ i j, expDeriv d j (f i) = evalCDA d k f (p i j) 78 79 /-- The CDA solvability problem is decidable (paper §6.4, theorem `decidability 80 of CDA solvability`): there is a procedure that, given the polynomial 81 equations `p` and the initial condition `c`, decides whether a power series 82 solution exists. The decision reduces to the commutativity of the companion 83 shuffle series, which is decidable. -/ 84 axiom CDASolvability (d k : ℕ) (hd : 0 < d) (hk : 0 < k) : 85 ∃ dec : (Fin k → Fin d → MvPolynomial (Fin k) ℚ) → (Fin k → ℚ) → Bool, 86 ∀ p c, dec p c = true ↔ ∃ f : Fin k → ExpPowerSeries d, SolvesCDA d k f p c 87 88 end Lax619925.CDA 89 -
Infiltration automata and infiltration-finite series
A series is infiltration-finite if it belongs to a finitely generated differential infiltration algebra (paper §7): it is an infiltration polynomial in a finite tuple of series that is closed under left derivatives. Equivalently (the coincidence), it is recognised by an infiltration automaton : a configuration space , a final-weight functional , and a transition that extends to an infiltration of the configuration space (the paper's infiltration-algebra structure, §7). By the fundamental relationship an infiltration is for the endomorphism , so the extension is computed by substituting and subtracting the identity. The infiltration-finite series form an effective prevariety, so equality and the commutativity problem are decidable for them; the equality decision reduces to ideal membership in the configuration polynomial ring (the ideal-membership statement), via the same ideal-chain argument as for the Hadamard and shuffle automata.
- thm✓
Lax619925.Infiltration(1st statement) - thm✓
Lax619925.Infiltration(2nd statement) - thm✓
Lax619925.Infiltration(3rd statement) - thm✓
Lax619925.Infiltration(4th statement) - thm✓
Lax619925.Infiltration(5th statement) - thm✓
Lax619925.Infiltration(6th statement)
1 import Lax619925.Series 2 import Lax619925.Prevariety 3 import Lax619925.Commutativity 4 import Mathlib.Data.Real.Basic 5 import Mathlib.Data.Fin.Basic 6 import Mathlib.Data.Fintype.Basic 7 import Mathlib.Data.Finset.Basic 8 import Mathlib.Data.Finsupp.Basic 9 import Mathlib.Algebra.MvPolynomial.Basic 10 import Mathlib.Algebra.MvPolynomial.Eval 11 … module docstring, 20 lines 32 33 namespace Lax619925.Infiltration 34 35 open Lax619925.Series Lax619925.Prevariety Lax619925.Commutativity 36 37 /-- The recursive core of the infiltration product, defined by primitive recursion on 38 the word: `(f ↑ g) ε = f ε · g ε` and 39 `(f ↑ g) (a·w) = ((leftDeriv a f) ↑ g) w + (f ↑ (leftDeriv a g)) w 40 + ((leftDeriv a f) ↑ (leftDeriv a g)) w`. The recursion measure is the word 41 length (the series arguments change at each step). -/ 42 noncomputable def infiltrationRec (α : Type*) (f g : Series α) (w : List α) : ℚ := 43 match w with 44 | [] => f [] * g [] 45 | a :: w' => infiltrationRec α (leftDeriv α a f) g w' 46 + infiltrationRec α f (leftDeriv α a g) w' 47 + infiltrationRec α (leftDeriv α a f) (leftDeriv α a g) w' 48 termination_by w.length 49 50 /-- The infiltration product of two series, characterised by the base case 51 `(f ↑ g) ε = f ε · g ε` and the step rule 52 `leftDeriv a (f ↑ g) = (leftDeriv a f) ↑ g + f ↑ (leftDeriv a g) 53 + (leftDeriv a f) ↑ (leftDeriv a g)`. It is the synchronising-interleaving 54 analogue of the shuffle product (the extra last term allows the two series to 55 consume the letter jointly). -/ 56 noncomputable def infiltration (α : Type*) (f g : Series α) : Series α := 57 fun w => infiltrationRec α f g w 58 59 /-- The unit of the infiltration product: the delta series, `1` on the empty word and 60 `0` elsewhere. Unlike the constant-`1` series (the unit of the pointwise product), 61 the delta series is the unit of the *infiltration* product. -/ 62 def infiltrationUnit (α : Type*) : Series α := fun w => if w = [] then 1 else 0 63 64 /-- The `n`-fold iterated infiltration power of `f`: `infiltrationPow α f 0 = 65 infiltrationUnit α` (the infiltration unit) and `infiltrationPow α f (n+1) = f ↑ 66 infiltrationPow α f n`. This is the infiltration analogue of the pointwise power 67 `f ^ n` used in `hadamardEval`. -/ 68 noncomputable def infiltrationPow (α : Type*) (f : Series α) (n : ℕ) : Series α := 69 match n with 70 | 0 => infiltrationUnit α 71 | n + 1 => infiltration α f (infiltrationPow α f n) 72 73 /-- The infiltration product of the iterated infiltration powers 74 `fs 0 ↑^[d 0] ⋯ fs (k-1) ↑^[d (k-1)]`, where `↑` is the infiltration product and 75 `↑^[n]` is the iterated infiltration power (`infiltrationPow`). This is the 76 infiltration analogue of the pointwise monomial product `∏ i, (fs i) ^ (d i)` used in 77 `hadamardEval`; it is the infiltration fold of the commutative-associative infiltration 78 operation over all indices (the zero-exponent terms contribute the infiltration unit, 79 which is the identity). It is computed as a right-fold over the index list, so that 80 the definition does not depend on the `Std.Commutative`/`Std.Associative` instances 81 (which the axiom-free concept package cannot carry); the proof package shows it equals 82 the corresponding `Finset.fold` (`infiltrationProd_eq_fold`). -/ 83 noncomputable def infiltrationProd (α : Type*) (k : ℕ) (fs : Fin k → Series α) (d : Fin k →₀ ℕ) : Series α := 84 (((Finset.univ : Finset (Fin k)).toList).map (fun i => infiltrationPow α (fs i) (d i))).foldr 85 (fun x acc => infiltration α x acc) (infiltrationUnit α) 86 87 /-- The evaluation of the polynomial `p` in the *infiltration* algebra, sending `X_i` to 88 `fs i`: `infiltrationEval α k fs p = ∑ d ∈ p.support, p.coeff d · (fs 0 ↑^[d 0] ⋯ 89 fs (k-1) ↑^[d (k-1)])`, where `↑` is the infiltration product and `↑^[n]` is the 90 iterated infiltration power. This is the infiltration analogue of `hadamardEval` 91 (which evaluates in the pointwise ring); because the infiltration ring cannot be a 92 `CommRing` instance on `Series α` (which already carries the pointwise ring), it is 93 defined directly as the sum over the polynomial's support of the coefficients times 94 the infiltration product of the iterated powers. -/ 95 noncomputable def infiltrationEval (α : Type*) (k : ℕ) (fs : Fin k → Series α) 96 (p : MvPolynomial (Fin k) ℚ) : Series α := 97 p.support.sum fun m => p.coeff m • infiltrationProd α k fs m 98 99 /-- An *infiltration automaton* over `α`: a dimension `k ≥ 1` (the number of 100 nonterminals `X_1, …, X_k`), a final-weight functional `F`, and a transition 101 `Δ` assigning to each letter `a` and nonterminal `X_i` a polynomial `Δ a i` in 102 the nonterminals. The configuration space is the polynomial ring 103 `ℚ[X_1, …, X_k] = MvPolynomial (Fin k) ℚ`. -/ 104 structure InfiltrationAutomaton (α : Type*) where 105 dim : ℕ 106 hdim : 0 < dim 107 F : Fin dim → ℚ 108 Δ : α → Fin dim → MvPolynomial (Fin dim) ℚ 109 110 /-- The word extension of the transition: `Δ_w` is the map of the configuration 111 space obtained by composing the letter infiltrations along the word, 112 right-to-left. Each letter infiltration `Δ_a` is `S_a − id`, where `S_a` is 113 the endomorphism substituting `X_i ↦ X_i + Δ_a X_i` (the fundamental 114 relationship). The composition law is unchanged from the Hadamard case: 115 `Δ_ε` is the identity and `Δ_{a·w} = Δ_w ∘ Δ_a`. -/ 116 noncomputable def InfiltrationAutomaton.Mword {α : Type*} (A : InfiltrationAutomaton α) 117 (w : List α) : MvPolynomial (Fin A.dim) ℚ → MvPolynomial (Fin A.dim) ℚ := 118 w.foldr (fun a φ => fun β => 119 φ (MvPolynomial.aeval (fun i => MvPolynomial.X i + A.Δ a i) β - β)) id 120 121 /-- The series recognised by the automaton at a configuration `cfg`: 122 `⟦A⟧_cfg (w) = F(Δ_w cfg)`, the final-weight functional applied to the 123 configuration reached after reading `w`. -/ 124 noncomputable def InfiltrationAutomaton.sem {α : Type*} (A : InfiltrationAutomaton α) 125 (cfg : MvPolynomial (Fin A.dim) ℚ) : Series α := 126 fun w => MvPolynomial.eval (fun i => A.F i) (A.Mword w cfg) 127 128 /-- The series recognised by the automaton: the semantics at the initial 129 configuration `X_0` (the first nonterminal). -/ 130 noncomputable def InfiltrationAutomaton.recognised {α : Type*} 131 (A : InfiltrationAutomaton α) : Series α := 132 A.sem (MvPolynomial.X (Fin.mk 0 A.hdim)) 133 134 /-- A series is *infiltration-finite* (working definition, paper §7) if it belongs to a 135 finitely generated differential infiltration algebra: it is an infiltration polynomial 136 in a finite tuple of series `fs` that is closed under left derivatives, i.e. 137 `f = infiltrationEval k fs p` for some polynomial `p`, and `leftDeriv a (fs i)` is 138 again an infiltration polynomial in `fs` for every letter `a` and index `i`. Here 139 `infiltrationEval k fs` is the evaluation in the infiltration algebra generated by 140 `fs`. -/ 141 def IsInfiltrationFinite (α : Type*) (f : Series α) : Prop := 142 ∃ k : ℕ, ∃ fs : Fin k → Series α, ∃ p : MvPolynomial (Fin k) ℚ, 143 f = infiltrationEval α k fs p ∧ 144 ∀ a : α, ∀ i : Fin k, ∃ q : MvPolynomial (Fin k) ℚ, 145 leftDeriv α a (fs i) = infiltrationEval α k fs q 146 147 /-- A series is *infiltration-recognisable* if it is recognised by some infiltration 148 automaton. -/ 149 def IsInfiltrationRecognisable (α : Type*) (f : Series α) : Prop := 150 ∃ A : InfiltrationAutomaton α, A.recognised = f 151 152 /-- A series is infiltration-finite if and only if it is infiltration-recognisable 153 (paper §7, the coincidence lemma): the finitely generated differential infiltration 154 algebras are exactly the languages of infiltration automata. -/ 155 axiom InfiltrationCoincidence (α : Type*) (f : Series α) : 156 IsInfiltrationFinite α f ↔ IsInfiltrationRecognisable α f 157 158 /-- The class of infiltration-finite series is closed under addition, scalar 159 multiplication, the infiltration product, and right derivatives (paper §7, the 160 closure lemma). These four parts hold over any alphabet. -/ 161 axiom InfiltrationClosure (α : Type*) : 162 (∀ (f g : Series α), IsInfiltrationFinite α f → IsInfiltrationFinite α g → IsInfiltrationFinite α (f + g)) ∧ 163 (∀ (c : ℚ) (f : Series α), IsInfiltrationFinite α f → IsInfiltrationFinite α (c • f)) ∧ 164 (∀ (f g : Series α), IsInfiltrationFinite α f → IsInfiltrationFinite α g → IsInfiltrationFinite α (infiltration α f g)) ∧ 165 (∀ (a : α) (f : Series α), IsInfiltrationFinite α f → IsInfiltrationFinite α (rightDeriv α a f)) 166 167 /-- The class of infiltration-finite series over a *finite* alphabet is closed under 168 left anti-derivatives (paper §7): if `g` is a left anti-derivative of a tuple 169 `f` of infiltration-finite series, then `g` is infiltration-finite. The 170 finiteness of the alphabet is essential — the witnessing generator set is 171 extended by one series per letter, so it is finite only when the alphabet is. -/ 172 axiom InfiltrationAntiDerivativeClosure (α : Type*) [Fintype α] : 173 ∀ (g : Series α) (f : α → Series α), IsLeftAntiDerivative α g f → 174 (∀ a, IsInfiltrationFinite α (f a)) → IsInfiltrationFinite α g 175 176 /-- The class of infiltration-finite series is an effective prevariety over a finite 177 alphabet (paper §7, theorem): there is an effective prevariety whose image is 178 exactly the infiltration-finite series, with presentations given by infiltration 179 automata. -/ 180 axiom InfiltrationEffectivePrevariety (α : Type*) [Fintype α] : 181 ∃ P : EffectivePrevariety α, ∀ f, IsInfiltrationFinite α f ↔ ∃ r : P.Rep, P.sem r = f 182 183 /-- The equality (zeroness) problem is decidable for infiltration automata over a 184 finite alphabet (paper §7): there is a procedure that, given an infiltration 185 automaton, decides whether the series it recognises is the zero series. The 186 decision reduces to ideal membership in the configuration polynomial ring, the 187 ideal-membership statement. -/ 188 axiom InfiltrationEqualityDecidable (α : Type*) [Fintype α] : 189 ∃ d : InfiltrationAutomaton α → Bool, ∀ A, d A = true ↔ A.recognised = 0 190 191 /-- In particular, the commutativity problem is decidable for infiltration-finite 192 series over a finite alphabet (paper §7): there is a procedure that, given an 193 infiltration automaton, decides whether the series it recognises is commutative. 194 This is the meta-theorem applied to the effective prevariety of 195 infiltration-finite series. -/ 196 axiom InfiltrationCommutativityDecidable (α : Type*) [Fintype α] : 197 ∃ d : InfiltrationAutomaton α → Bool, ∀ A, d A = true ↔ IsCommutative α (A.recognised) 198 199 end Lax619925.Infiltration 200 - thm✓
-
Ideal membership in multivariate polynomials
The ideal-membership statement on which the paper's unified ideal-chain argument rests. It says that ideal membership in is decidable in the propositional sense: for every finite set of generators , there exists a -valued function such that exactly when lies in the ideal generates — the same shape as the other statements. It is proven in the proofs package by a classical argument: excluded middle supplies the characteristic function of the ideal. The constructive Gröbner-basis decision procedure (Buchberger's algorithm) — the Gröbner-basis fact mathlib does not yet provide, its file implementing division only — is the algorithmic content of the paper's decidability claims and is out of scope for this submission. The paper's unified ideal-chain argument (the chain of ideals stabilising by Hilbert's basis theorem) reduces the equality problem for the Hadamard, shuffle, and infiltration automata to this statement.
1 import Mathlib.Data.Real.Basic 2 import Mathlib.Data.Fin.Basic 3 import Mathlib.Data.Fintype.Basic 4 import Mathlib.Data.Finset.Basic 5 import Mathlib.Algebra.MvPolynomial.Basic 6 import Mathlib.RingTheory.Ideal.Basic 7 … module docstring, 20 lines 28 29 namespace Lax619925.IdealMembership 30 31 /-- Ideal membership in the multivariate polynomial ring over `ℚ` is decidable: 32 given a finite set of generators, there is a decision procedure `dec` such 33 that `dec p = true` iff `p` lies in the ideal the generators span. Proven 34 in the proofs package by a classical argument (excluded middle supplies the 35 characteristic function); the constructive Gröbner-basis procedure is out 36 of scope. -/ 37 axiom IdealMembershipDecidable (k : ℕ) (gens : Finset (MvPolynomial (Fin k) ℚ)) : 38 ∃ dec : MvPolynomial (Fin k) ℚ → Bool, ∀ p, dec p = true ↔ p ∈ Ideal.span ↑gens 39 40 end Lax619925.IdealMembership 41 -
Polynomial automata and Hadamard automata
A polynomial automaton (paper appendix) is a weighted automaton whose configuration space is the vector space and whose letter actions are polynomial maps. It is the dual of the Hadamard automaton: here the configuration is a point and the final weight is a polynomial, whereas the Hadamard automaton's configuration is a polynomial and its final weight is a point. The main result (paper appendix) is that a series is recognisable by a polynomial automaton if and only if its reversal is Hadamard-recognisable: the duality swaps the configuration and the final weight, and the reversal accounts for the order in which the transitions are composed.
1 import Lax619925.Series 2 import Lax619925.Hadamard 3 import Mathlib.Data.Real.Basic 4 import Mathlib.Data.Fin.Basic 5 import Mathlib.Data.Fintype.Basic 6 import Mathlib.Algebra.MvPolynomial.Basic 7 import Mathlib.Algebra.MvPolynomial.Eval 8 … module docstring, 15 lines 24 25 namespace Lax619925.PolynomialAutomata 26 27 open Lax619925.Series Lax619925.Hadamard 28 29 /-- A *polynomial automaton* over `α`: a dimension `k ≥ 1`, an initial 30 configuration `qI : ℚ^k`, a final polynomial `F : ℚ[X_1, …, X_k]`, and a 31 transition `Δ` assigning to each letter `a` a polynomial map 32 `Δ_a : ℚ^k → ℚ^k` (a `k`-tuple of polynomials). The configuration space is 33 the vector space `ℚ^k`, and the letter action is `q · a = Δ_a(q)` (evaluate 34 the transition polynomials at the point `q`). -/ 35 structure PolynomialAutomaton (α : Type*) where 36 dim : ℕ 37 hdim : 0 < dim 38 qI : Fin dim → ℚ 39 F : MvPolynomial (Fin dim) ℚ 40 Δ : α → Fin dim → MvPolynomial (Fin dim) ℚ 41 42 /-- The action of a letter `a` on a configuration `q`: `q · a = Δ_a(q)`, 43 evaluate the transition polynomials at the point `q`. -/ 44 noncomputable def PolynomialAutomaton.action {α : Type*} (A : PolynomialAutomaton α) 45 (q : Fin A.dim → ℚ) (a : α) : Fin A.dim → ℚ := 46 fun i => MvPolynomial.eval q (A.Δ a i) 47 48 /-- The action of a word `w` on a configuration `q`: `q · w`, the letter actions 49 iterated left-to-right. -/ 50 noncomputable def PolynomialAutomaton.wordAction {α : Type*} (A : PolynomialAutomaton α) 51 (q : Fin A.dim → ℚ) (w : List α) : Fin A.dim → ℚ := 52 w.foldl (fun q a => A.action q a) q 53 54 /-- The series recognised by the automaton at a configuration `q`: 55 `⟦A⟧_q (w) = F(q · w)`, the final polynomial `F` evaluated at the point 56 `q · w` reached after reading `w`. -/ 57 noncomputable def PolynomialAutomaton.sem {α : Type*} (A : PolynomialAutomaton α) 58 (q : Fin A.dim → ℚ) : Series α := 59 fun w => MvPolynomial.eval (A.wordAction q w) A.F 60 61 /-- The series recognised by the automaton: the semantics at the initial 62 configuration `qI`. -/ 63 noncomputable def PolynomialAutomaton.recognised {α : Type*} (A : PolynomialAutomaton α) : Series α := 64 A.sem A.qI 65 66 /-- A series is *polynomial-recognisable* if it is recognised by some polynomial 67 automaton. -/ 68 def IsPolynomialRecognisable (α : Type*) (f : Series α) : Prop := 69 ∃ A : PolynomialAutomaton α, A.recognised = f 70 71 /-- A series is recognisable by a polynomial automaton if and only if its 72 reversal is Hadamard-recognisable (paper appendix). The duality swaps the 73 configuration (point ↔ polynomial) and the final weight (polynomial ↔ 74 point), and the reversal accounts for the order of composition of the 75 transitions. -/ 76 axiom PolynomialHadamardEquivalence (α : Type*) (f : Series α) : 77 IsPolynomialRecognisable α f ↔ IsHadamardRecognisable α (reversal α f) 78 79 end Lax619925.PolynomialAutomata 80
Loading the paper…