Shared-site coefficient context · Shuffle
DefinitionMarkovScatteringCharged_Shufflemarkov-scattering
Source context from the finite shared-site cubic model and its supporting definitions and checked lemmas.
Definition code
import Lean.Elab.Tactic.Omega
import Mathlib.Algebra.Field.Basic
/-!
# The two-sequence shuffle identity
This is Lemma 2.1 in `proofs/tree-theorem.md`. The two coordinates count the entries
used from the two sequences. Each interleaving is a lattice path with unit steps.
Grouping paths by their last step gives the recursion for their total weight.
-/
namespace MarkovScattering
variable {K : Type*} [Field K]
/-- Cancellation of the common factor at an interior lattice point. -/
theorem shuffle_step (X Y P : K) (h : X + Y ≠ 0) :
(X * P + Y * P) / (X + Y) = P := by
apply (div_eq_iff h).2
rw [← add_mul, mul_comm P]
/-- The sum of the weights of all paths from `(0, 0)` to `(p, q)`, computed by
partitioning at the last step. Entering `(a, b)` contributes `(x a + y b)⁻¹`.
The origin counts the empty path with weight one. -/
def shuffleWeight (x y : ℕ → K) : ℕ → ℕ → K
| 0, 0 => 1
| a + 1, 0 => shuffleWeight x y a 0 / (x (a + 1) + y 0)
| 0, b + 1 => shuffleWeight x y 0 b / (x 0 + y (b + 1))
| a + 1, b + 1 =>
(shuffleWeight x y a (b + 1) + shuffleWeight x y (a + 1) b) /
(x (a + 1) + y (b + 1))
termination_by a b => a + b
decreasing_by all_goals omega
/-- The product of the reciprocals of `x 1, …, x n`. -/
def prefixProduct (x : ℕ → K) : ℕ → K
| 0 => 1
| n + 1 => prefixProduct x n * (x (n + 1))⁻¹
/-- On the vertical axis there is a single path. -/
theorem shuffleWeight_zero_left (x y : ℕ → K) (q : ℕ) (hx : x 0 = 0) :
shuffleWeight x y 0 q = prefixProduct y q := by
induction q with
| zero => simp [shuffleWeight, prefixProduct]
| succ q ih => simp [shuffleWeight, ih, hx, div_eq_mul_inv, prefixProduct]
/-- On the horizontal axis there is a single path. -/
theorem shuffleWeight_zero_right (x y : ℕ → K) (p : ℕ) (hy : y 0 = 0) :
shuffleWeight x y p 0 = prefixProduct x p := by
induction p with
| zero => simp [shuffleWeight, prefixProduct]
| succ p ih => simp [shuffleWeight, ih, hy, div_eq_mul_inv, prefixProduct]
private theorem mul_prefixProduct (x : ℕ → K) (n : ℕ) (h : x (n + 1) ≠ 0) :
x (n + 1) * prefixProduct x (n + 1) = prefixProduct x n := by
rw [prefixProduct, mul_left_comm, mul_inv_cancel₀ h, mul_one]
/-- The shuffle sum factors into the two prefix products. The nonvanishing
condition ranges only over the rectangle up to `(p, q)`, excluding its origin. -/
theorem shuffleWeight_eq_prefixProducts (x y : ℕ → K) (p q : ℕ)
(hx : x 0 = 0) (hy : y 0 = 0)
(h : ∀ a ≤ p, ∀ b ≤ q, (a, b) ≠ (0, 0) → x a + y b ≠ 0) :
shuffleWeight x y p q = prefixProduct x p * prefixProduct y q := by
induction p generalizing q with
| zero => simp [shuffleWeight_zero_left x y q hx, prefixProduct]
| succ p ihp =>
induction q with
| zero => simp [shuffleWeight_zero_right x y (p + 1) hy, prefixProduct]
| succ q ihq =>
have hpx : x (p + 1) ≠ 0 := by
simpa [hy] using h (p + 1) (by omega) 0 (by omega) (by simp)
have hqy : y (q + 1) ≠ 0 := by
simpa [hx] using h 0 (by omega) (q + 1) (by omega) (by simp)
have hxy := h (p + 1) (by omega) (q + 1) (by omega) (by simp)
have prevX : prefixProduct x p * prefixProduct y (q + 1) =
x (p + 1) * (prefixProduct x (p + 1) * prefixProduct y (q + 1)) := by
rw [← mul_assoc, mul_prefixProduct x p hpx]
have prevY : prefixProduct x (p + 1) * prefixProduct y q =
y (q + 1) * (prefixProduct x (p + 1) * prefixProduct y (q + 1)) := by
rw [mul_left_comm, mul_prefixProduct y q hqy]
rw [shuffleWeight,
ihp (q + 1) (fun a ha b hb hab => h a (by omega) b hb hab),
ihq (fun a ha b hb hab => h a ha b (by omega) hab),
prevX, prevY, shuffle_step _ _ _ hxy]
end MarkovScattering
Source