/- Copyright 2025 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil

The length of an $s$-increasing sequence of $r$-tuples

This file contains the formalisation of [GoLo21] up to and including Conjecture 1.8.

References:

    arxiv/1609.08688 The length of an $s$-increasing sequence of $r$-tuples by W. T. Gowers, J. Long

    GoLo21 The length of an $s$-increasing sequence of $r$-tuples by W. T. Gowers, J. Long, Combinatorics, Probability and Computing (2021), 686-721

namespace Arxiv.«1609.08688»

Let $a = (a_1, a_2, a_3)$ and $b = (b_1, b_2, b_3)$ be two triples of integers. Say that $a$ is $2$-less than $b$, or $a <_2 b$, if $a_i < b_i$ for at least two coordinates $i$.

def lt₂ {α : Type*} [LT α] (a b : Fin 3 α) : Prop := (i j : Fin 3), i j a i < b i a j < b jlocal infix:50 " <₂ " => lt₂@[simp, category API, AMS 5] theorem not_lt₂ {α : Type*} [LinearOrder α] {a b : Fin 3 α} : ¬a <₂ b i j, i j a i < b i b j a j := α:Type u_1inst✝:LinearOrder αa:Fin 3 αb:Fin 3 α¬a <₂ b (i j : Fin 3), i j a i < b i b j a j All goals completed! 🐙@[category API, AMS 5] theorem not_lt₂_of_forall_le {α : Type*} [LinearOrder α] {a b : Fin 3 α} (h : i, b i a i) : ¬a <₂ b := not_lt₂.2 fun _ _ _ _ => h _α:Type u_1inst✝:LinearOrder αa:Fin 3 αb:Fin 3 αi:Fin 3j:Fin 3hij:i jhi:b i a ihj:b j a jk:Fin 3l:Fin 3hkl:k lh:a k < b kthis✝¹:k ithis✝:k jthis:l = i l = jb l a l α:Type u_1inst✝:LinearOrder αa:Fin 3 αb:Fin 3 αj:Fin 3hj:b j a jk:Fin 3l:Fin 3hkl:k lh:a k < b kthis✝:k jhij:l jhi:b l a lthis:k lb l a lα:Type u_1inst✝:LinearOrder αa:Fin 3 αb:Fin 3 αi:Fin 3hi:b i a ik:Fin 3l:Fin 3hkl:k lh:a k < b kthis✝:k ihij:i lhj:b l a lthis:k lb l a l; α:Type u_1inst✝:LinearOrder αa:Fin 3 αb:Fin 3 αi:Fin 3hi:b i a ik:Fin 3l:Fin 3hkl:k lh:a k < b kthis✝:k ihij:i lhj:b l a lthis:k lb l a l; All goals completed! 🐙@[category API, AMS 5] theorem not_lt₂_self {α : Type*} [LinearOrder α] (a : Fin 3 α) : ¬a <₂ a := α:Type u_1inst✝:LinearOrder αa:Fin 3 α¬a <₂ a All goals completed! 🐙

For example, $(3, 3, 9) <_2 (5, 6, 1)$.

@[category test, AMS 5] theorem lt₂_example_1 : ![3, 3, 9] <₂ ![5, 6, 1] := 0, 1, zero_ne_one, ![3, 3, 9] 0 < ![5, 6, 1] 0 ![3, 3, 9] 1 < ![5, 6, 1] 1 All goals completed! 🐙

$(5, 6, 1) <_2 (7, 7, 7)$

@[category test, AMS 5] theorem lt₂_example_2 : ![5, 6, 1] <₂ ![7, 7, 7] := 0, 2, 0 2 All goals completed! 🐙, ![5, 6, 1] 0 < ![7, 7, 7] 0 ![5, 6, 1] 2 < ![7, 7, 7] 2 All goals completed! 🐙

$(7, 7, 7) <_2 (7, 8, 9)$

@[category test, AMS 5] theorem lt₂_example_3 : ![7, 7, 7] <₂ ![7, 8, 9] := 1, 2, 1 2 All goals completed! 🐙, ![7, 7, 7] 1 < ![7, 8, 9] 1 ![7, 7, 7] 2 < ![7, 8, 9] 2 All goals completed! 🐙

but $(1, 2, 3)$ is not $2$-less than $(1, 2, 4)$.

@[category test, AMS 5] theorem not_lt₂_example : ¬![1, 2, 3] <₂ ![1, 2, 4] := not_lt₂_of_exists 0 1 zero_ne_one (![1, 2, 4] 0 ![1, 2, 3] 0 All goals completed! 🐙) (![1, 2, 4] 1 ![1, 2, 3] 1 All goals completed! 🐙)

The $2$-less relation is not transitive on the naturals.

@[category API, AMS 5] theorem not_trans_lt₂_nat : (a b c : Fin 3 ), a <₂ b b <₂ c ¬a <₂ c := ![1, 2, 3], ![2, 3, 1], ![3, 1, 2], 0, 1, zero_ne_one, ![1, 2, 3] 0 < ![2, 3, 1] 0 ![1, 2, 3] 1 < ![2, 3, 1] 1 All goals completed! 🐙, 0, 2, 0 2 All goals completed! 🐙, ![2, 3, 1] 0 < ![3, 1, 2] 0 ![2, 3, 1] 2 < ![3, 1, 2] 2 All goals completed! 🐙, not_lt₂_of_exists 1 2 (1 2 All goals completed! 🐙) (![3, 1, 2] 1 ![1, 2, 3] 1 All goals completed! 🐙) (![3, 1, 2] 2 ![1, 2, 3] 2 All goals completed! 🐙)

Since the $2$-less relation is not transitive, we make a further definition to specify transivity.

def IsIncreasing₂ {α : Type*} [LT α] (s : List (Fin 3 α)) : Prop := s.Pairwise lt₂@[simp, category API, AMS 5] theorem isIncreasing₂_nil {α : Type*} [LT α] : IsIncreasing₂ (α := α) [] := α:Type u_1inst✝:LT αIsIncreasing₂ [] All goals completed! 🐙@[simp, category API, AMS 5] theorem isIncreasing₂_singleton {α : Type*} [LT α] (a : Fin 3 α) : IsIncreasing₂ [a] := α:Type u_1inst✝:LT αa:Fin 3 αIsIncreasing₂ [a] All goals completed! 🐙α:Type u_1inst✝:LinearOrder αval:αs:List (Fin 3 α)h:IsIncreasing₂ sh_const: a s, (j : Fin 3), a j = valthis:2 s.lengthi:Fin 3j:Fin 3hi:val < valFalse All goals completed! 🐙

Let $F(n)$ be the maximal length of a $2$-increasing sequence of triples with each coordinate belong to $[n]$ ($= {1, 2, ..., n}$).

noncomputable def maximalLength (n : ) : := sSup { List.length s | (s) (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s) }local notation "F" => maximalLengththis: (x : ) (s : List (Fin 3 )), IsIncreasing₂ s (∀ (a : Fin 3 ), a s) s.length = x s = [] x = 0F 0 = 0 All goals completed! 🐙this: (x : ) (s : List (Fin 3 )), IsIncreasing₂ s (∀ a s, (i : Fin 3), a i = 1) s.length = x s = [fun x 1] x = 1 s = [] x = 0(∀ a {x | a, a = [fun x 1] x = 1 a = [] x = 0}, a 1) n < 1, ¬ a {x | a, a = [fun x 1] x = 1 a = [] x = 0}, a n refine this: (x : ) (s : List (Fin 3 )), IsIncreasing₂ s (∀ a s, (i : Fin 3), a i = 1) s.length = x s = [fun x 1] x = 1 s = [] x = 0 a {x | a, a = [fun x 1] x = 1 a = [] x = 0}, a 1 All goals completed! 🐙, fun n hn => ?_ this: (x : ) (s : List (Fin 3 )), IsIncreasing₂ s (∀ a s, (i : Fin 3), a i = 1) s.length = x s = [fun x 1] x = 1 s = [] x = 0n:hn:n < 1 x, (∃ x_1, x_1 = [fun x 1] x = 1 x_1 = [] x = 0) ¬x = 0 exact 1, [fun _ => 1], this: (x : ) (s : List (Fin 3 )), IsIncreasing₂ s (∀ a s, (i : Fin 3), a i = 1) s.length = x s = [fun x 1] x = 1 s = [] x = 0n:hn:n < 1[fun x 1] = [fun x 1] 1 = 1 [fun x 1] = [] 1 = 0 All goals completed! 🐙, one_ne_zero@[category test, AMS 5] theorem maximalLength_four : maximalLength 4 = 8 := F 4 = 8 All goals completed! 🐙

In a set of more than $n^2$ triples with coordinates from ${1, ..., n}$ we must have two triples that are equal in their first two coordinates.

s:List (Fin 3 )n:_hn:2 nhs₁: a s, Set.range a Set.Icc 1 nhs₂:s.length > n ^ 2f:Fin s.length × := fun k (s[k] 0, s[k] 1)t:Finset ( × ) := Finset.Icc 1 n ×ˢ Finset.Icc 1 nht_card:t.card < Finset.univ.cardhf: k Finset.univ, f k t i j, i j s[i] 0 = s[j] 0 s[i] 1 = s[j] 1 s:List (Fin 3 )n:_hn:2 nhs₁: a s, Set.range a Set.Icc 1 nhs₂:s.length > n ^ 2f:Fin s.length × := fun k (s[k] 0, s[k] 1)t:Finset ( × ) := Finset.Icc 1 n ×ˢ Finset.Icc 1 nht_card:t.card < Finset.univ.cardhf: k Finset.univ, f k ti:Fin s.lengthleft✝¹:i Finset.univj:Fin s.lengthleft✝:j Finset.univhij:i jhfij:f i = f j i j, i j s[i] 0 = s[j] 0 s[i] 1 = s[j] 1 All goals completed! 🐙

For all $n$ we have $F(n) \leq n^2$.

This is the upper bound in [GoLo21, Proposition 1.4], proved by applying the pigeonhole principle to the first two coordinates.

n:hn:2 nsSup {x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x} n ^ 2 n:hn:2 n{x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x}.Nonemptyn:hn:2 n b {x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x}, b n ^ 2 n:hn:2 n{x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x}.Nonempty exact 0, [], n:hn:2 n a [], Set.range a Set.Icc 1 n All goals completed! 🐙, isIncreasing₂_nil, rfl n:hn:2 n b {x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x}, b n ^ 2 n:hn:2 nb✝:hm:b✝ {x | s, (_ : a s, Set.range a Set.Icc 1 n) (_ : IsIncreasing₂ s), s.length = x}b✝ n ^ 2 n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ ss.length n ^ 2 n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2False n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthFalse n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1False n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1hp:List.Pairwise lt₂ sFalse n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij✝:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1hp:List.Pairwise lt₂ shij:i < jFalsen:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1hp:List.Pairwise lt₂ shji:j < iFalse n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij✝:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1hp:List.Pairwise lt₂ shij:i < jFalse All goals completed! 🐙 n:hn:2 ns:List (Fin 3 )hs_range: a s, Set.range a Set.Icc 1 nhs_inc:IsIncreasing₂ shle:¬s.length n ^ 2hs_length:n ^ 2 < s.lengthi:Fin s.lengthj:Fin s.lengthhij:i jh0:s[i] 0 = s[j] 0h1:s[i] 1 = s[j] 1hp:List.Pairwise lt₂ shji:j < iFalse All goals completed! 🐙 n:hn:¬2 nF n n ^ 2 cases n with hn:¬2 0F 0 0 ^ 2 All goals completed! 🐙 n:hn:¬2 n + 1F (n + 1) (n + 1) ^ 2 cases n with hn:¬2 0 + 1F (0 + 1) (0 + 1) ^ 2 All goals completed! 🐙 n:hn:¬2 n + 1 + 1F (n + 1 + 1) (n + 1 + 1) ^ 2 All goals completed! 🐙

Moreover, whenever $n$ is a perfect square we have $F(n) \geq n^{3/2}$.

@[category research solved, AMS 5] theorem maximalLength_ge_of_isSquare {n : } (h : IsSquare n) : n.sqrt ^ 3 F n := n:h:IsSquare nn.sqrt ^ 3 F n All goals completed! 🐙

Two triples $t_1$ and $t_2$ are $2$-comparable if one of them is $2$-less than the other.

def IsComparable₂ {α : Type*} [LT α] (t₁ t₂ : Fin 3 α) : Prop := t₁ <₂ t₂ t₂ <₂ t₁

A set of triples is $2$-comparable if any two of them are $2$-comparable.

def IsComparableSet₂ {α : Type*} [LT α] (s : List (Fin 3 α)) : Prop := t₁ t₂, t₁ t₂ t₁ s t₂ s IsComparable₂ t₁ t₂open Filter in

$F(n) \leq n^2 / \exp(\Omega(\log^*(n)))$.

@[category research solved, AMS 5] theorem maximalLength_le_isBigO : Ω : , (fun (n : ) => (Real.iteratedLog n : )) =O[atTop] Ω n, F n n ^ 2 / Real.exp (Ω n) := Ω, (fun n (↑n).iteratedLog) =O[atTop] Ω (n : ), (F n) n ^ 2 / Real.exp (Ω n) All goals completed! 🐙

We define the product of two triples $(a, b, c)$ and $(d, e, f)$ by $((a, d), (b, e), (c, f))$, where the pairs are arranged in lexicographical order.

def tripleProduct {α : Type*} (a b : Fin 3 α) : Πₗ (_ : Fin 3), α × α := toLex (Function.prod a b)@[simp, category API, AMS 5] theorem tripleProduct_const {α : Type*} (a : α) : tripleProduct (fun _ => a) (fun _ => a) = toLex (fun _ => (a, a)) := α:Type u_1a:α(tripleProduct (fun x a) fun x a) = toLex fun x (a, a) simpa [tripleProduct] using funext fun i => α:Type u_1a:αi:Fin 3Function.prod (fun x a) (fun x a) i = (a, a) All goals completed! 🐙@[simp, category API, AMS 5] theorem tripleProduct_vecConst_const {α : Type*} (a : α) : tripleProduct ![a, a, a] ![a, a, a] = toLex ![(a, a), (a, a), (a, a)] := α:Type u_1a:αtripleProduct ![a, a, a] ![a, a, a] = toLex ![(a, a), (a, a), (a, a)] α:Type u_1a:αFunction.prod ![a, a, a] ![a, a, a] = ![(a, a), (a, a), (a, a)] α:Type u_1a:αi:Fin 3(Function.prod ![a, a, a] ![a, a, a] i).1 = (![(a, a), (a, a), (a, a)] i).1α:Type u_1a:αi:Fin 3(Function.prod ![a, a, a] ![a, a, a] i).2 = (![(a, a), (a, a), (a, a)] i).2 α:Type u_1a:αi:Fin 3(Function.prod ![a, a, a] ![a, a, a] i).1 = (![(a, a), (a, a), (a, a)] i).1α:Type u_1a:αi:Fin 3(Function.prod ![a, a, a] ![a, a, a] i).2 = (![(a, a), (a, a), (a, a)] i).2 α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 0, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 0, )).2α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 1, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 1, )).2α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 2, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 2, )).2 α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 0, )).1 = (![(a, a), (a, a), (a, a)] ((fun i i) 0, )).1α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 1, )).1 = (![(a, a), (a, a), (a, a)] ((fun i i) 1, )).1α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 2, )).1 = (![(a, a), (a, a), (a, a)] ((fun i i) 2, )).1α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 0, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 0, )).2α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 1, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 1, )).2α:Type u_1a:α(Function.prod ![a, a, a] ![a, a, a] ((fun i i) 2, )).2 = (![(a, a), (a, a), (a, a)] ((fun i i) 2, )).2 All goals completed! 🐙

We define the product $\otimes$ of two sequences $(a_i, b_i, c_i)$ and $(d_i, e_i, f_i)$ by the sequence $((a_i, d_j), (b_i, e_j), (c_i, f_j))$, where the indices $(i, j)$ are arranged lexicographically, and the pairs are also ordered lexicographically.

def sequenceProduct {α : Type*} (s t : List (Fin 3 α)) : Lex (List (Πₗ (_ : Fin 3), α × α)) := toLex (s.flatMap (fun a => List.map (tripleProduct a) t))local infix:100 " ⊗₂ " => sequenceProduct@[category test, AMS 5] theorem sequenceProduct_example : [![1, 1, 1]] ⊗₂ [![1, 1, 1]] = toLex [toLex ![(1, 1), (1, 1), (1, 1)]] := [![1, 1, 1]] ⊗₂ [![1, 1, 1]] = toLex [toLex ![(1, 1), (1, 1), (1, 1)]] All goals completed! 🐙

Suppose that for some $n$ we have $F(n) = n ^ {\alpha}$. Then there are arbitrarily large $m$ such that $F(m) \geq m^{\alpha}$.

@[category research solved, AMS 5] theorem maximalLength_pow {n : } {e : } (hn : 1 < n) (h : F n = (n : ) ^ e) : ∀ᶠ m : in Filter.atTop, (m : ) ^ e F m := n:e:hn:1 < nh:(F n) = n ^ e∀ᶠ (m : ) in Filter.atTop, m ^ e (F m) All goals completed! 🐙

$F(n) \leq n^{3/2}$.

@[category research open, AMS 5] theorem maximalLength_le_strong (n : ) : F n Real.sqrt n ^ 3 := n:(F n) n ^ 3 All goals completed! 🐙end Arxiv.«1609.08688»