Finite row networks for grid tensors
DefinitionRow network of a grid tensor#✓fully proved
Merge every grid row into one vertex of a factored tensor network. The state and label
carriers may be infinite; only the supplied alphabets are enumerated. Capacity metadata charges
L per vertical edge and the supplied cut capacity for each active rectangle.
TensorNetwork.gridRowNetwork · 33 lines
def gridRowNetwork [Fintype ρ] [LinearOrder ρ] [Fintype γ] [LinearOrder γ]
[DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ) :
Factored ρ (γ → ρ × γ → A)
((γ → A) × ({k : γ × γ // k ∈ orderedPairs γ} → T)) := by
classical
exact
{ S := fun a => Fintype.piFinset fun i =>
Fintype.piFinset fun w => if w = (a, i) then diagonalLabels else labels
W := fun a z =>
(∏ i, R (a, i) (z i)) *
∏ q ∈ orderedPairs γ,
if z q.1 (a, q.2) = z q.2 (a, q.1) then 1 else 0
Θ := fun a b => if a < b then
(Fintype.piFinset fun _ : γ => labels) ×ˢ
Fintype.piFinset fun k : {k : γ × γ // k ∈ orderedPairs γ} =>
cutLabels ((a, b), k)
else ∅
f := fun a b z θ => if a < b then
(∏ i, if z i (b, i) = θ.1 i then 1 else 0) *
∏ k : {k : γ × γ // k ∈ orderedPairs γ},
top ((a, b), k) (z k.1.1 (b, k.1.2))
(z k.1.2 (b, k.1.1)) (θ.2 k)
else
(∏ i, if z i (b, i) = θ.1 i then 1 else 0) *
∏ k : {k : γ × γ // k ∈ orderedPairs γ},
bottom ((b, a), k) (z k.1.1 (b, k.1.2))
(z k.1.2 (b, k.1.1)) (θ.2 k)
c := fun a b => Fintype.card γ * L +
∑ k : γ × γ with k ∈ orderedPairs γ, cap ((min a b, max a b), k) }
abbrev Instance (J A : Type*) := J → (J → A) → ℤ
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:67
structure Factored (J σ τ : Type*) where
/-- The finite set of states allowed at each vertex. -/
S : J → Finset σ
/-- The integer weight of a state at a vertex. -/
W : J → σ → ℤ
/-- The finite label set stored in increasing vertex order. -/
Θ : J → J → Finset τ
/-- The factor contributed on one vertex's side of an edge label. -/
f : J → J → σ → τ → ℤ
/-- The directed capacity table; the bare structure does not require symmetry. -/
c : J → J → ℕ
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:84
def orderedPairs (J : Type*) [Fintype J] [LinearOrder J] : Finset (J × J) :=
univ.filter fun p => p.1 < p.2
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:37
Uses 3 · Used by 7
TheoremInteraction between rows of the grid row network#✓fully proved
The interaction between increasing rows is the rectangle-kernel product times vertical
equality indicators. For finite alphabets, an equal vertical value contributes only when it is
in labels.
TensorNetwork.gridRowNetwork_interaction · 17 lines
theorem gridRowNetwork_interaction [Fintype ρ] [LinearOrder ρ]
[Fintype γ] [LinearOrder γ] [DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ)
(G : ((ρ × ρ) × (γ × γ)) → A → A → A → A → ℤ)
(hG : ∀ ω x y u v,
G ω x y u v = ∑ θ ∈ cutLabels ω, top ω x y θ * bottom ω u v θ)
{a b : ρ} (hab : a < b) (z z' : γ → ρ × γ → A) :
(gridRowNetwork labels diagonalLabels R cutLabels top bottom cap L).interaction
a b z z' =
(∏ i, if z i (b, i) = z' i (a, i) ∧ z i (b, i) ∈ labels then 1 else 0) *
∏ k : {k : γ × γ // k ∈ orderedPairs γ},
G ((a, b), k)
(z k.1.1 (b, k.1.2)) (z k.1.2 (b, k.1.1))
(z' k.1.1 (a, k.1.2)) (z' k.1.2 (a, k.1.1))
abbrev Instance (J A : Type*) := J → (J → A) → ℤ
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:67
def gridRowNetwork [Fintype ρ] [LinearOrder ρ] [Fintype γ] [LinearOrder γ]
[DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ) :
Factored ρ (γ → ρ × γ → A)
((γ → A) × ({k : γ × γ // k ∈ orderedPairs γ} → T)) := by
classical
exact
{ S := fun a => Fintype.piFinset fun i =>
Fintype.piFinset fun w => if w = (a, i) then diagonalLabels else labels
⋯
MathlibExt/Combinatorics/TensorNetwork/GridRows.lean:40
def orderedPairs (J : Type*) [Fintype J] [LinearOrder J] : Finset (J × J) :=
univ.filter fun p => p.1 < p.2
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:37
Uses 6 · Used by 2
TheoremRow interaction for enumerated left states#✓fully proved
When the left state is enumerated by the row network, the alphabet-membership condition is automatic, so the interaction recovers the source vertical-equality formula. The right state may be arbitrary because equality with an allowed left value already forces its vertical value.
TensorNetwork.gridRowNetwork_interaction_of_mem · 18 lines
theorem gridRowNetwork_interaction_of_mem [Fintype ρ] [LinearOrder ρ]
[Fintype γ] [LinearOrder γ] [DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ)
(G : ((ρ × ρ) × (γ × γ)) → A → A → A → A → ℤ)
(hG : ∀ ω x y u v,
G ω x y u v = ∑ θ ∈ cutLabels ω, top ω x y θ * bottom ω u v θ)
{a b : ρ} (hab : a < b) (z z' : γ → ρ × γ → A)
(hz : z ∈ (gridRowNetwork labels diagonalLabels R cutLabels top bottom cap L).S a) :
(gridRowNetwork labels diagonalLabels R cutLabels top bottom cap L).interaction
a b z z' =
(∏ i, if z i (b, i) = z' i (a, i) then 1 else 0) *
∏ k : {k : γ × γ // k ∈ orderedPairs γ},
G ((a, b), k)
(z k.1.1 (b, k.1.2)) (z k.1.2 (b, k.1.1))
(z' k.1.1 (a, k.1.2)) (z' k.1.2 (a, k.1.1))
abbrev Instance (J A : Type*) := J → (J → A) → ℤ
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:67
def gridRowNetwork [Fintype ρ] [LinearOrder ρ] [Fintype γ] [LinearOrder γ]
[DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ) :
Factored ρ (γ → ρ × γ → A)
((γ → A) × ({k : γ × γ // k ∈ orderedPairs γ} → T)) := by
classical
exact
{ S := fun a => Fintype.piFinset fun i =>
Fintype.piFinset fun w => if w = (a, i) then diagonalLabels else labels
⋯
MathlibExt/Combinatorics/TensorNetwork/GridRows.lean:40
def orderedPairs (J : Type*) [Fintype J] [LinearOrder J] : Finset (J × J) :=
univ.filter fun p => p.1 < p.2
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:37
TheoremGrid row network computes the grid value#✓fully proved
If each rectangle kernel is the finite sum of its top and bottom factors, contracting the constructed row network gives the canonical finite grid value.
theorem gridRowNetwork_value [Fintype ρ] [LinearOrder ρ]
[Fintype γ] [LinearOrder γ] [DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(G : ((ρ × ρ) × (γ × γ)) → A → A → A → A → ℤ)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ)
(hG : ∀ ω x y u v,
G ω x y u v = ∑ θ ∈ cutLabels ω, top ω x y θ * bottom ω u v θ) :
(gridRowNetwork labels diagonalLabels R cutLabels top bottom cap L).value =
gridValue labels diagonalLabels R G
abbrev Instance (J A : Type*) := J → (J → A) → ℤ
MathlibExt/Combinatorics/TensorNetwork/Basic.lean:67
def gridRowNetwork [Fintype ρ] [LinearOrder ρ] [Fintype γ] [LinearOrder γ]
[DecidableEq A]
(labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(cutLabels : ((ρ × ρ) × (γ × γ)) → Finset T)
(top bottom : ((ρ × ρ) × (γ × γ)) → A → A → T → ℤ)
(cap : ((ρ × ρ) × (γ × γ)) → ℕ) (L : ℕ) :
Factored ρ (γ → ρ × γ → A)
((γ → A) × ({k : γ × γ // k ∈ orderedPairs γ} → T)) := by
classical
exact
{ S := fun a => Fintype.piFinset fun i =>
Fintype.piFinset fun w => if w = (a, i) then diagonalLabels else labels
⋯
MathlibExt/Combinatorics/TensorNetwork/GridRows.lean:40
def gridValue [Fintype ρ] [LinearOrder ρ] [Fintype γ] [LinearOrder γ]
[DecidableEq A] (labels diagonalLabels : Finset A) (R : Instance (ρ × γ) A)
(G : ((ρ × ρ) × (γ × γ)) → A → A → A → A → ℤ) : ℤ :=
∑ ℓ ∈ gridLabelings labels diagonalLabels,
(∏ w, R w (ℓ w)) *
((∏ a, ∏ q ∈ orderedPairs γ,
if ℓ (a, q.1) (a, q.2) = ℓ (a, q.2) (a, q.1) then 1 else 0) *
(∏ i, ∏ p ∈ orderedPairs ρ,
if ℓ (p.1, i) (p.2, i) = ℓ (p.2, i) (p.1, i) then 1 else 0) *
∏ ω ∈ gridRectangles ρ γ, rectangleApply (G ω) ℓ ω)
MathlibExt/Combinatorics/TensorNetwork/Grid.lean:89
Uses 13
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.