Documentation

CslibFrontier.Foundations.Combinatorics.CornerCutting

Unate grid functions cut corners of few border squares #

A function g : ℕ → ℕ → Bool cuts a corner of the unit square with lower-left corner (i, j) if its mixed difference there is nonzero (CutsCorner): g i j + g (i + 1) (j + 1) ≠ g (i + 1) j + g i (j + 1), as 0/1 values. A function of two bits has zero mixed difference exactly when it is the sum of a function of the first bit and a function of the second. A threshold function of two bits cuts the corner exactly when it is not constant and not a literal.

Ring lemma (card_filter_cutsCorner_gridBorder_le): if g is monotone or antitone in each coordinate, uniformly in the other one, then it cuts a corner of at most 4 of the 4 (m - 1) squares on the border of the grid {0, …, m} ^ 2 (gridBorder, le_card_gridBorder).

After reflecting coordinates, g is monotone in both. Then a cut square (i, j) has g i j = false, g (i + 1) (j + 1) = true and g (i + 1) j = g i (j + 1); it is an outer or an inner corner of the boundary of the up-set {g = true} according to this common value. Two distinct cut squares of the same kind are incomparable in the product order (eq_of_cutsCorner_of_le), so a chain contains at most two cut squares (card_filter_cutsCorner_le_two). The border is the union of the two chains {i = 0} ∪ {j = m - 1} and {j = 0} ∪ {i = m - 1}.

This is the combinatorial step of the lower bound for Andreev's function with two address blocks in cslib-frontier#4640, there phrased as "the boundary of a monotone region in the grid cuts corners of at most four border squares".

Main definitions #

Main results #

def Cslib.Combinatorics.CutsCorner (g : ℕ → ℕ → Bool) (i j : ℕ) :

g cuts a corner of the unit square with lower-left corner (i, j): its mixed difference g i j + g (i + 1) (j + 1) - g (i + 1) j - g i (j + 1) there is nonzero.

Instances For
    @[instance_reducible]

    The unit squares (i, j), i, j < m, on the border of the grid {0, …, m} ^ 2.

    theorem Cslib.Combinatorics.mem_gridBorder {m : ℕ} {p : ℕ × ℕ} :
    p ∈ gridBorder m ↔ p.1 < m ∧ p.2 < m ∧ (p.1 = 0 ∨ p.2 = 0 ∨ p.1 + 1 = m ∨ p.2 + 1 = m)

    The border of the m × m grid of unit squares has at least 4 (m - 1) squares (exactly 4 (m - 1) for m ≥ 2).

    theorem Cslib.Combinatorics.CutsCorner.of_monotone {g : ℕ → ℕ → Bool} (hg : ∀ ⦃i i' j j' : ℕ⦄, i ≤ i' → j ≤ j' → g i j ≤ g i' j') {i j : ℕ} (h : CutsCorner g i j) :
    g i j = false ∧ g (i + 1) (j + 1) = true ∧ g (i + 1) j = g i (j + 1)

    On a grid function monotone in both coordinates, a cut square (i, j) has g i j = false, g (i + 1) (j + 1) = true and g (i + 1) j = g i (j + 1).

    theorem Cslib.Combinatorics.eq_of_cutsCorner_of_le {g : ℕ → ℕ → Bool} (hg : ∀ ⦃i i' j j' : ℕ⦄, i ≤ i' → j ≤ j' → g i j ≤ g i' j') {p q : ℕ × ℕ} (hp : CutsCorner g p.1 p.2) (hq : CutsCorner g q.1 q.2) (hpq : p ≤ q) (hv : g (p.1 + 1) p.2 = g (q.1 + 1) q.2) :
    p = q

    Cut squares of the same kind are incomparable: for a grid function monotone in both coordinates, two cut squares p ≤ q with the same value g (· + 1) · at their lower-right corners are equal.

    theorem Cslib.Combinatorics.card_filter_cutsCorner_le_two {g : ℕ → ℕ → Bool} (hg : ∀ ⦃i i' j j' : ℕ⦄, i ≤ i' → j ≤ j' → g i j ≤ g i' j') (s : Finset (ℕ × ℕ)) (hs : ∀ p ∈ s, ∀ q ∈ s, p ≤ q ∨ q ≤ p) :
    {p ∈ s | CutsCorner g p.1 p.2}.card ≤ 2

    Chains: a grid function monotone in both coordinates cuts a corner of at most two squares of any chain of the product order.

    theorem Cslib.Combinatorics.card_filter_cutsCorner_gridBorder_le_of_monotone {g : ℕ → ℕ → Bool} (hg : ∀ ⦃i i' j j' : ℕ⦄, i ≤ i' → j ≤ j' → g i j ≤ g i' j') (m : ℕ) :
    {p ∈ gridBorder m | CutsCorner g p.1 p.2}.card ≤ 4

    The ring lemma for a grid function monotone in both coordinates.

    theorem Cslib.Combinatorics.cutsCorner_reflect_fst {g : ℕ → ℕ → Bool} {m i j : ℕ} (hi : i < m) :
    CutsCorner (fun (i j : ℕ) => g (m - i) j) i j ↔ CutsCorner g (m - 1 - i) j

    Reflecting the first coordinate, i ↦ m - i, maps cut squares to cut squares.

    theorem Cslib.Combinatorics.cutsCorner_reflect_snd {g : ℕ → ℕ → Bool} {m i j : ℕ} (hj : j < m) :
    CutsCorner (fun (i j : ℕ) => g i (m - j)) i j ↔ CutsCorner g i (m - 1 - j)

    Reflecting the second coordinate, j ↦ m - j, maps cut squares to cut squares.

    theorem Cslib.Combinatorics.card_filter_cutsCorner_gridBorder_reflect_fst (g : ℕ → ℕ → Bool) (m : ℕ) :
    {p ∈ gridBorder m | CutsCorner (fun (i j : ℕ) => g (m - i) j) p.1 p.2}.card = {p ∈ gridBorder m | CutsCorner g p.1 p.2}.card
    theorem Cslib.Combinatorics.card_filter_cutsCorner_gridBorder_reflect_snd (g : ℕ → ℕ → Bool) (m : ℕ) :
    {p ∈ gridBorder m | CutsCorner (fun (i j : ℕ) => g i (m - j)) p.1 p.2}.card = {p ∈ gridBorder m | CutsCorner g p.1 p.2}.card
    theorem Cslib.Combinatorics.card_filter_cutsCorner_gridBorder_le {g : ℕ → ℕ → Bool} (h₁ : (∀ (j : ℕ), Monotone fun (i : ℕ) => g i j) ∨ ∀ (j : ℕ), Antitone fun (i : ℕ) => g i j) (h₂ : (∀ (i : ℕ), Monotone (g i)) ∨ ∀ (i : ℕ), Antitone (g i)) (m : ℕ) :
    {p ∈ gridBorder m | CutsCorner g p.1 p.2}.card ≤ 4

    Ring lemma: if g is monotone or antitone in each coordinate, uniformly in the other coordinate, then g cuts a corner of at most 4 border squares of the m × m grid.