Documentation

Complexitylib.Algebraic.LowerBound.Cutwidth.MultiOutput.MatMul.Tripartite.Internal

Proofs for the terminal graph of matrix multiplication #

The minority function #

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.le_minority {n : ℕ} (m₁ m₂ h₁ h₂ : Finset (Fin n)) :
(if n ≤ m₁.card + m₂.card then (m₁ᶜ ∩ h₁ᶜ).card + (m₂ᶜ ∩ h₂ᶜ).card else (m₁ ∩ h₁).card + (m₂ ∩ h₂).card) ≤ minority n (m₁.card + m₂.card)

A vertex pays for its charged terminals. A vertex with placed neighbours m₁ in one part and m₂ in the other is charged, when light, its placed terminals whose other endpoint is heavy (in h₁, h₂), and when heavy, its unplaced terminals whose other endpoint is light.

Counting the light–heavy terminals #

The two endpoints of a terminal type pay exactly once. For a set a of index pairs and heavy sets X and Y, the charges paid by the first coordinates and by the second coordinates add up to the number of mixed pairs.

The mixed pairs of X and Y number |X| (n - |Y|) + (n - |X|) |Y|.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.ite_add_ite_le_minority {n : ℕ} (m₁ m₂ h₁ h₂ : Finset (Fin n)) {v : Fin n} {H : Finset (Fin n)} (hv : v ∈ H ↔ n ≤ m₁.card + m₂.card) :
((if v ∈ H then (m₁ᶜ ∩ h₁ᶜ).card else (m₁ ∩ h₁).card) + if v ∈ H then (m₂ᶜ ∩ h₂ᶜ).card else (m₂ ∩ h₂).card) ≤ minority n (m₁.card + m₂.card)

The charge paid at a vertex, split by the two kinds of terminals there.

Charging. The light–heavy terminals number at most the total charge.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.three_mul_sq_le_two_mul_lightHeavy {n : ℕ} (a b c : Finset (Fin n × Fin n)) (hlo : 3 * n ≤ 2 * heavyCount a b c) (hhi : 2 * heavyCount a b c ≤ 3 * n + 3) :
3 * n ^ 2 ≤ 2 * lightHeavy a b c + 3

The light–heavy count near the threshold. If the heavy vertices number h with 3 n ≤ 2 h ≤ 3 n + 3, then 3 n² ≤ 2 P + 3 for the number P of light–heavy terminals.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.three_mul_sq_le_two_mul_charge {n : ℕ} (a b c : Finset (Fin n × Fin n)) (hlo : 3 * n ≤ 2 * heavyCount a b c) (hhi : 2 * heavyCount a b c ≤ 3 * n + 3) :
3 * n ^ 2 ≤ 2 * (chargeI a c + chargeJ a b + chargeK b c) + 3

The charging inequality. Near the threshold, 3 n² ≤ 2 (R_I + R_J + R_K) + 3.

Placing one more terminal #

Rows count the pairs.

Columns count the pairs.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.row_mono {n : ℕ} {a a' : Finset (Fin n × Fin n)} (h : a ⊆ a') (i : Fin n) :
rowSet a i ⊆ rowSet a' i
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.col_mono {n : ℕ} {a a' : Finset (Fin n × Fin n)} (h : a ⊆ a') (j : Fin n) :
colSet a j ⊆ colSet a' j
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.card_filter_le_le_add_sum_sub {n : ℕ} (f g : Fin n → ℕ) (hfg : ∀ (x : Fin n), f x ≤ g x) :
{x : Fin n | n ≤ g x}.card ≤ {x : Fin n | n ≤ f x}.card + ∑ x : Fin n, (g x - f x)

Raising the degrees raises the number of heavy vertices by at most the total increase.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.heavyCount_le_add_two {n : ℕ} {a b c a' b' c' : Finset (Fin n × Fin n)} (ha : a ⊆ a') (hb : b ⊆ b') (hc : c ⊆ c') (hcard : a'.card + b'.card + c'.card ≤ a.card + b.card + c.card + 1) :
heavyCount a' b' c' ≤ heavyCount a b c + 2

Placing one more terminal adds at most two heavy vertices. The degrees sum to twice the number of placed terminals.

The threshold prefix #

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.place_mono {n N s : ℕ} (t : Fin n × Fin n → Wire N s) {S S' : Finset (Wire N s)} (h : S ⊆ S') :
place t S ⊆ place t S'
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.card_place_add {n N s : ℕ} (tA tB tC : Fin n × Fin n → Wire N s) (S : Finset (Wire N s)) :
(place tA S).card + (place tB S).card + (place tC S).card = {x : Fin n × Fin n ⊕ Fin n × Fin n ⊕ Fin n × Fin n | Sum.elim tA (Sum.elim tB tC) x ∈ S}.card

The placed terminals of the three kinds, counted together.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.card_filter_rank_lt_succ_le {N s : ℕ} {ι : Type u_1} [Fintype ι] (term : ι → Wire N s) (hterm : Function.Injective term) (rank : Wire N s → ℕ) (hrank : Function.Injective rank) (t : ℕ) :
{x : ι | rank (term x) < t + 1}.card ≤ {x : ι | rank (term x) < t}.card + 1

A prefix gains at most one terminal per rank.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.exists_cross (g : ℕ → ℕ) (hzero : g 0 = 0) {h : ℕ} (hh : 1 ≤ h) (T : ℕ) (hT : h ≤ g T) :
∃ (t : ℕ), g t < h ∧ h ≤ g (t + 1)

A function from 0 that reaches h ≥ 1 crosses h at some step.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.exists_threshold {n N s : ℕ} (hn : 0 < n) (tA tB tC : Fin n × Fin n → Wire N s) (hinj : Function.Injective (Sum.elim tA (Sum.elim tB tC))) (rank : Wire N s → ℕ) (hrank : Function.Injective rank) (T : ℕ) (hT : ∀ (w : Wire N s), rank w < T) :
∃ (t : ℕ), (∃ (x : Fin n × Fin n ⊕ Fin n × Fin n ⊕ Fin n × Fin n), rank (Sum.elim tA (Sum.elim tB tC) x) = t) ∧ 3 * n ≤ 2 * heavyCount (place tA (prefixBelow rank (t + 1))) (place tB (prefixBelow rank (t + 1))) (place tC (prefixBelow rank (t + 1))) ∧ 2 * heavyCount (place tA (prefixBelow rank (t + 1))) (place tB (prefixBelow rank (t + 1))) (place tC (prefixBelow rank (t + 1))) ≤ 3 * n + 3

The threshold prefix. Along an injective ranking of the wires, if the 3 n² terminals lie on distinct wires, some prefix ending at a terminal has h heavy vertices with 3 n ≤ 2 h ≤ 3 n + 3.

Exploratory probes mixing the I and J charges #

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.minority_add_eq {n x y : ℕ} (hx : x ≤ n) (hy : y ≤ n) :
minority n (x + y) = min x (n - y) + min (n - x) y

At a vertex of degree 2 n whose terminals split into two groups of n, with x and y placed, the minority is min x (n - y) + min (n - x) y.

The minority, the excess d - n and the deficit n - d of d ≤ 2 n add up to n.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.sum_card_colSetIn {n : ℕ} (a : Finset (Fin n × Fin n)) (R : Finset (Fin n)) :
∑ j : Fin n, (colSetIn a R j).card = ∑ i ∈ R, (rowSet a i).card
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.sum_card_complColSetIn {n : ℕ} (a : Finset (Fin n × Fin n)) (R : Finset (Fin n)) :
∑ j : Fin n, (complColSetIn a R j).card = ∑ i ∈ R, (n - (rowSet a i).card)
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.min_colSetIn_add_min_complColSetIn_add_eq {n : ℕ} (a b : Finset (Fin n × Fin n)) (I₀ I₁ : Finset (Fin n)) (j : Fin n) :
min (colSetIn a I₀ᶜ j).card (n - (rowSet b j).card) + min (complColSetIn a I₁ᶜ j).card (rowSet b j).card + ((colSetIn a I₀ᶜ j).card + (rowSet b j).card - n) + ((complColSetIn a I₁ᶜ j).card - (rowSet b j).card) = (colSetIn a I₀ᶜ j).card + (complColSetIn a I₁ᶜ j).card

The two J-summands of twoSubsetProbeIJ at j fall short of the restricted counts x and x' of A-terminals by x + y - n and x' - y.

The single-subset case of min_colSetIn_add_min_complColSetIn_add_eq: the two J-summands restricted to the rows of R and their shortfalls add up to R.card.

theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.twoSubsetProbeIJ_add_eq {n : ℕ} (a b c : Finset (Fin n × Fin n)) (I₀ I₁ : Finset (Fin n)) :
twoSubsetProbeIJ a b c I₀ I₁ + ∑ i ∈ I₀, excessI a c i + ∑ i ∈ I₁, deficitI a c i + ∑ j : Fin n, ((colSetIn a I₀ᶜ j).card + (rowSet b j).card - n + ((complColSetIn a I₁ᶜ j).card - (rowSet b j).card)) = n * n
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.probeIJ_add_eq {n : ℕ} (a b c : Finset (Fin n × Fin n)) (I₀ : Finset (Fin n)) :
probeIJ a b c I₀ + ∑ i ∈ I₀, (excessI a c i + deficitI a c i) + ∑ j : Fin n, ((colSetIn a I₀ᶜ j).card + (rowSet b j).card - n + ((complColSetIn a I₀ᶜ j).card - (rowSet b j).card)) = n * n
theorem Algebraic.Cutwidth.MultiOutput.Tripartite.Internal.sum_light_heavy_le_probeIJ {n : ℕ} (a b c : Finset (Fin n × Fin n)) :
((∑ i : Fin n, if i ∈ heavyI a c then 0 else (rowSet a i).card + (rowSet c i).card) + ∑ j : Fin n, if j ∈ heavyJ a b then ((colSet a j)ᶜ ∩ heavyI a c).card else (colSet a j ∩ heavyI a c).card) ≤ probeIJ a b c (heavyI a c)ᶜ