{
  "id": "91",
  "ident": "NS.00091",
  "slug": "arxiv-1609-08688-sincreasingrtuples--sequenceproduct-example",
  "title": "The length of an $s$-increasing sequence of $r$-tuples · sequenceProduct_example",
  "status": "test",
  "statement_status": "reviewed",
  "statement_md": null,
  "subjects": [
    "math.CO",
    "msc:05"
  ],
  "tags": [],
  "collection": "arxiv",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Arxiv.«1609.08688».sequenceProduct_example",
  "statement_lean": "theorem sequenceProduct_example :\n    [![1, 1, 1]] ⊗₂ [![1, 1, 1]] = [![toLex (1, 1), toLex (1, 1), toLex (1, 1)]]",
  "challenge_source": "/-\nCopyright 2025 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# The length of an $s$-increasing sequence of $r$-tuples\n\nThis file contains the formalisation of [GoLo21] up to and\nincluding Conjecture 1.8.\n\n*References:*\n- [arxiv/1609.08688](https://arxiv.org/abs/1609.08688)\n  **The length of an $s$-increasing sequence of $r$-tuples** by *W. T. Gowers, J. Long*\n- [GoLo21](https://www.cambridge.org/core/journals/combinatorics-probability-and-computing/article/abs/length-of-an-sincreasing-sequence-of-rtuples/7301418D47DB1ECD6BE71C20E8A98D0A)\n  **The length of an $s$-increasing sequence of $r$-tuples**\n  by *W. T. Gowers, J. Long*, Combinatorics, Probability and Computing (2021), 686-721\n-/\n\n@[expose] public section\n\nnamespace Arxiv.«1609.08688»\n\n/--\nLet $a = (a_1, a_2, a_3)$ and $b = (b_1, b_2, b_3)$ be two triples of integers.\nSay that $a$ is $2$-less than $b$, or $a <_2 b$, if $a_i < b_i$ for at least\ntwo coordinates $i$.\n-/\ndef lt₂ {α : Type*} [LT α] (a b : Fin 3 → α) : Prop :=\n  ∃ (i j : Fin 3), i ≠ j ∧ a i < b i ∧ a j < b j\n\nlocal infix:50 \" <₂ \" => lt₂\n\n@[simp, category API, AMS 5]\ntheorem not_lt₂ {α : Type*} [LinearOrder α] {a b : Fin 3 → α} :\n    ¬a <₂ b ↔ ∀ i j, i ≠ j → a i < b i → b j ≤ a j := by simp [lt₂]\n\n@[category API, AMS 5]\ntheorem not_lt₂_of_forall_le {α : Type*} [LinearOrder α] {a b : Fin 3 → α}\n    (h : ∀ i, b i ≤ a i) : ¬a <₂ b := not_lt₂.2 fun _ _ _ _ => h _\n\n@[category API, AMS 5]\ntheorem not_lt₂_of_exists {α : Type*} [LinearOrder α] {a b : Fin 3 → α}\n    (i j : Fin 3) (hij : i ≠ j) (hi : b i ≤ a i) (hj : b j ≤ a j) :\n    ¬a <₂ b := by\n  refine not_lt₂.2 fun k l hkl h => ?_\n  have : k ≠ i := fun hk => not_lt.2 hi (hk ▸ h)\n  have : k ≠ j := fun hk => not_lt.2 hj (hk ▸ h)\n  have : l = i ∨ l = j := by omega\n  rcases this with (rfl | rfl); exact hi; exact hj\n\n@[category API, AMS 5]\ntheorem not_lt₂_self {α : Type*} [LinearOrder α] (a : Fin 3 → α) : ¬a <₂ a := by\n  simp\n\n/-- For example, $(3, 3, 9) <_2 (5, 6, 1)$. -/\n@[category test, AMS 5]\ntheorem lt₂_example_1 : ![3, 3, 9] <₂ ![5, 6, 1] := ⟨0, 1, zero_ne_one, by simp⟩\n\n/-- $(5, 6, 1) <_2 (7, 7, 7)$ -/\n@[category test, AMS 5]\ntheorem lt₂_example_2 : ![5, 6, 1] <₂ ![7, 7, 7] := ⟨0, 2, by simp, by simp⟩\n\n/-- $(7, 7, 7) <_2 (7, 8, 9)$ -/\n@[category test, AMS 5]\ntheorem lt₂_example_3 : ![7, 7, 7] <₂ ![7, 8, 9] := ⟨1, 2, by simp, by simp⟩\n\n/-- but $(1, 2, 3)$ is not $2$-less than $(1, 2, 4)$. -/\n@[category test, AMS 5]\ntheorem not_lt₂_example : ¬![1, 2, 3] <₂ ![1, 2, 4] := not_lt₂_of_exists 0 1 zero_ne_one (by simp) (by simp)\n\n/-- The $2$-less relation is not transitive on the naturals. -/\n@[category API, AMS 5]\ntheorem not_trans_lt₂_nat : ∃ (a b c : Fin 3 → ℕ),\n    a <₂ b ∧ b <₂ c ∧ ¬a <₂ c :=\n  ⟨![1, 2, 3], ![2, 3, 1], ![3, 1, 2], ⟨0, 1, zero_ne_one, by simp⟩,\n     ⟨0, 2, by simp, by simp⟩, not_lt₂_of_exists 1 2 (by simp) (by simp) (by simp)⟩\n\n/--\nSince the $2$-less relation is not transitive, we make a further definition to\nspecify transivity.\n-/\ndef IsIncreasing₂ {α : Type*} [LT α] (s : List (Fin 3 → α)) : Prop := s.Pairwise lt₂\n\n@[simp, category API, AMS 5]\ntheorem isIncreasing₂_nil {α : Type*} [LT α] : IsIncreasing₂ (α := α) [] := by\n  simp [IsIncreasing₂]\n\n@[simp, category API, AMS 5]\ntheorem isIncreasing₂_singleton {α : Type*} [LT α] (a : Fin 3 → α) : IsIncreasing₂ [a] := by\n  simp [IsIncreasing₂]\n\n@[category API, AMS 5]\ntheorem isIncreasing₂_const_length {α : Type*} [LinearOrder α] {val : α} {s : List (Fin 3 → α)}\n    (h : IsIncreasing₂ s)\n    (h_const : ∀ a ∈ s, ∀ j, a j = val) : s.length < 2 := by\n  by_contra!\n  obtain ⟨i, j, -, hi, -⟩ :=\n    List.pairwise_iff_getElem.1 h 0 1 (by linarith) (by linarith) zero_lt_one\n  rw [h_const _ (List.getElem_mem _) i, h_const _ (List.getElem_mem _) i] at hi\n  exact lt_irrefl _ hi\n\n/--\nLet $F(n)$ be the maximal length of a $2$-increasing sequence of triples with each coordinate\nbelong to $[n]$ ($= \\{1, 2, ..., n\\}$).\n-/\nnoncomputable def maximalLength (n : ℕ) : ℕ :=\n  sSup { List.length s | (s) (_ : ∀ a ∈ s, Set.range a ⊆ Set.Icc 1 n) (_ : IsIncreasing₂ s) }\n\nlocal notation \"F\" => maximalLength\n\n@[category test, AMS 5]\ntheorem maximalLength_zero : maximalLength 0 = 0 := by\n  have (x : ℕ) (s : List (Fin 3 → ℕ)) :\n      IsIncreasing₂ s ∧ (∀ a, a ∉ s) ∧ s.length = x ↔ s = [] ∧ x = 0 := by\n    refine ⟨fun ⟨ha₁, ha₂, rfl⟩ => ?_, fun ⟨h₁, h₂⟩ => by simp [h₁, h₂]⟩\n    simp only [List.length_eq_zero_iff, and_self]\n    refine List.eq_nil_of_subset_nil fun ai hai => ?_\n    simpa using ha₂ ai hai\n  simp [maximalLength, fun x => exists_congr (this x)]\n\n@[category test, AMS 5]\ntheorem maximalLength_one : maximalLength 1 = 1 := by\n  classical\n  have (x : ℕ) (s : List (Fin 3 → ℕ)) :\n      IsIncreasing₂ s ∧ (∀ a ∈ s, ∀ i, a i = 1) ∧ s.length = x ↔\n        s = [fun _ => 1] ∧ x = 1 ∨ s = [] ∧ x = 0 := by\n    refine ⟨fun ⟨hs₁, hs₂, hx⟩ => ?_, fun h => by aesop⟩\n    have := hx ▸ isIncreasing₂_const_length hs₁ hs₂\n    interval_cases x; simp [List.length_eq_zero_iff.1 hx]; simp\n    obtain ⟨a, rfl⟩ := List.length_eq_one_iff.1 hx\n    simp at hs₂\n    rw [show a = fun _ => 1 from funext fun i => by simp [hs₂ i]]\n  simp [maximalLength, fun x => exists_congr (this x)]\n  rw [Nat.sSup_def ⟨1, by aesop⟩, Nat.find_eq_iff]\n  refine ⟨by aesop, fun n hn => ?_⟩\n  simp [Nat.lt_one_iff.1 hn]\n  exact ⟨1, ⟨[fun _ => 1], by simp⟩, one_ne_zero⟩\n\n@[category test, AMS 5]\ntheorem maximalLength_four : maximalLength 4 = 8 := by\n  sorry\n\n/-- In a set of more than $n^2$ triples with coordinates from $\\{1, ..., n\\}$ we must\nhave two triples that are equal in their first two coordinates. -/\n@[category API, AMS 5]\nlemma exists_pair_of_mem_Icc {s : List (Fin 3 → ℕ)} {n : ℕ} (_hn : 2 ≤ n)\n    (hs₁ : ∀ a ∈ s, Set.range a ⊆ Set.Icc 1 n) (hs₂ : s.length > n ^ 2) :\n    ∃ (i j : Fin s.length), i ≠ j ∧ s[i] 0 = s[j] 0 ∧ s[i] 1 = s[j] 1 := by\n  classical\n  let f : Fin s.length → ℕ × ℕ := fun k => (s[k] 0, s[k] 1)\n  let t : Finset (ℕ × ℕ) := Finset.Icc 1 n ×ˢ Finset.Icc 1 n\n  have ht_card : t.card < (Finset.univ : Finset (Fin s.length)).card := by\n    simp only [t, Finset.card_univ, Fintype.card_fin, Finset.card_product,\n      Nat.card_Icc, Nat.add_sub_cancel, ← sq]\n    exact hs₂\n  have hf : ∀ k ∈ (Finset.univ : Finset (Fin s.length)), f k ∈ t := by\n    intro k _\n    have hmem : s[k] ∈ s := List.getElem_mem k.isLt\n    have h0 := hs₁ _ hmem ⟨0, rfl⟩\n    have h1 := hs₁ _ hmem ⟨1, rfl⟩\n    rw [Set.mem_Icc] at h0 h1\n    simp only [t, f, Finset.mem_product, Finset.mem_Icc]\n    exact ⟨h0, h1⟩\n  obtain ⟨i, _, j, _, hij, hfij⟩ :=\n    Finset.exists_ne_map_eq_of_card_lt_of_maps_to ht_card hf\n  exact ⟨i, j, hij, congrArg Prod.fst hfij, congrArg Prod.snd hfij⟩\n\n/--\nFor all $n$ we have $F(n) \\leq n^2$.\n\nThis is the upper bound in [GoLo21, Proposition 1.4], proved by applying the\npigeonhole principle to the first two coordinates.\n-/\n@[category research solved, AMS 5]\ntheorem maximalLength_le (n : ℕ) : F n ≤ n ^ 2 := by\n  by_cases hn : 2 ≤ n\n  · rw [maximalLength]\n    refine csSup_le ?_ ?_\n    · exact ⟨0, ⟨[], by simp, isIncreasing₂_nil, rfl⟩⟩\n    · intro _ hm\n      rcases hm with ⟨s, hs_range, hs_inc, rfl⟩\n      by_contra hle\n      have hs_length : n ^ 2 < s.length := Nat.lt_of_not_ge hle\n      obtain ⟨i, j, hij, h0, h1⟩ :=\n        exists_pair_of_mem_Icc hn hs_range hs_length\n      have hp : s.Pairwise lt₂ := hs_inc\n      rcases lt_or_gt_of_ne hij with hij | hji\n      · exact (not_lt₂_of_exists 0 1 zero_ne_one h0.ge h1.ge)\n          (List.pairwise_iff_get.1 hp i j hij)\n      · exact (not_lt₂_of_exists 0 1 zero_ne_one h0.le h1.le)\n          (List.pairwise_iff_get.1 hp j i hji)\n  · cases n with\n    | zero => simp [maximalLength_zero]\n    | succ n =>\n      cases n with\n      | zero => simp [maximalLength_one]\n      | succ n =>\n        exact (hn (Nat.succ_le_succ (Nat.succ_le_succ (Nat.zero_le _)))).elim\n\n/--\nWhenever $n$ is a perfect square we have $F(n) \\geq n^{3/2}$.\n\nThis is the lower bound in [GoLo21, Proposition 1.4]. The linked Lean proof by Wentao Li\nformalizes that construction. An earlier Lean proof is in `weiyangzen/awesome_theorems`.\n-/\n@[category research solved, AMS 5,\n  formal_proof using lean4 at \"https://palomar-registry.org/entry.html?id=PALOMAR-2026-11-13-000015\"]\ntheorem maximalLength_ge_of_isSquare {n : ℕ} (h : IsSquare n) :\n    n.sqrt ^ 3 ≤ F n := by\n  sorry\n\n/-- Two triples $t_1$ and $t_2$ are $2$-comparable if one of them is $2$-less\nthan the other. -/\ndef IsComparable₂ {α : Type*} [LT α] (t₁ t₂ : Fin 3 → α) : Prop :=\n  t₁ <₂ t₂ ∨ t₂ <₂ t₁\n\n/-- A set of triples is $2$-comparable if any two distinct members of it are $2$-comparable. -/\ndef IsComparableSet₂ {α : Type*} [LT α] (s : List (Fin 3 → α)) : Prop :=\n  ∀ t₁ ∈ s, ∀ t₂ ∈ s, t₁ ≠ t₂ → IsComparable₂ t₁ t₂\n\nopen Filter in\n/-- $F(n) \\leq n^2 / \\exp(\\Omega(\\log^*(n)))$, i.e. there is a constant $c > 0$ such that\n$F(n) \\leq n^2 / \\exp(c \\log^*(n))$ for all sufficiently large $n$. -/\n@[category research solved, AMS 5]\ntheorem maximalLength_le_isBigO : ∃ c > (0 : ℝ), ∀ᶠ n : ℕ in atTop,\n    (F n : ℝ) ≤ (n : ℝ) ^ 2 / Real.exp (c * (Real.iteratedLog n : ℝ)) := by\n  sorry\n\n/-- We define the product of two triples $(a, b, c)$ and $(d, e, f)$ by\n$((a, d), (b, e), (c, f))$, where the pairs are ordered lexicographically. -/\ndef tripleProduct {α : Type*} (a b : Fin 3 → α) : Fin 3 → α ×ₗ α :=\n  fun i => toLex (a i, b i)\n\n@[simp, category API, AMS 5]\ntheorem tripleProduct_const {α : Type*} (a : α) :\n    tripleProduct (fun _ ↦ a) (fun _ ↦ a) = fun _ ↦ toLex (a, a) :=\n  rfl\n\n@[simp, category API, AMS 5]\ntheorem tripleProduct_vecConst_const {α : Type*} (a : α) :\n    tripleProduct ![a, a, a] ![a, a, a] = ![toLex (a, a), toLex (a, a), toLex (a, a)] := by\n  ext i\n  fin_cases i <;> rfl\n\n/-- We define the product $\\otimes$ of two sequences $(a_i, b_i, c_i)$ and\n$(d_i, e_i, f_i)$ by the sequence $((a_i, d_j), (b_i, e_j), (c_i, f_j))$, where\nthe indices $(i, j)$ are arranged lexicographically, and the pairs are also\nordered lexicographically. -/\ndef sequenceProduct {α : Type*} (s t : List (Fin 3 → α)) : List (Fin 3 → α ×ₗ α) :=\n  s.flatMap (fun a => List.map (tripleProduct a) t)\n\nlocal infix:100 \" ⊗₂ \" => sequenceProduct\n\n@[category test, AMS 5]\ntheorem sequenceProduct_example :\n    [![1, 1, 1]] ⊗₂ [![1, 1, 1]] = [![toLex (1, 1), toLex (1, 1), toLex (1, 1)]] := by\n  simp [sequenceProduct]\n\n/-- The product of two $2$-increasing sequences is $2$-increasing; this is the point of\nordering the pairs lexicographically. -/\n@[category test, AMS 5]\ntheorem isIncreasing₂_sequenceProduct_example :\n    IsIncreasing₂ ([![1, 1, 1], ![2, 2, 2]] ⊗₂ [![1, 1, 1], ![2, 2, 2]]) := by\n  unfold IsIncreasing₂ sequenceProduct tripleProduct lt₂\n  decide\n\n/-- Suppose that for some $n$ we have $F(n) = n ^ {\\alpha}$. Then there are arbitrarily\nlarge $m$ such that $F(m) \\geq m^{\\alpha}$. -/\n@[category research solved, AMS 5]\ntheorem maximalLength_pow {n : ℕ} {e : ℝ} (hn : 1 < n) (h : F n = (n : ℝ) ^ e) :\n    ∃ᶠ m : ℕ in Filter.atTop, (m : ℝ) ^ e ≤ F m := by\n  sorry\n\n/-- Moreover, for every $\\beta < \\alpha$ and all sufficiently large $m$ we have\n$F(m) \\geq m^{\\beta}$. -/\n@[category research solved, AMS 5]\ntheorem maximalLength_pow_eventually {n : ℕ} {e : ℝ} (hn : 1 < n) (h : F n = (n : ℝ) ^ e)\n    {b : ℝ} (hb : b < e) :\n    ∀ᶠ m : ℕ in Filter.atTop, (m : ℝ) ^ b ≤ F m := by\n  sorry\n\n/-- $F(n) \\leq n^{3/2}$. -/\n@[category research open, AMS 5]\ntheorem maximalLength_le_strong (n : ℕ) : F n ≤ Real.sqrt n ^ 3 := by\n  sorry\n\nend Arxiv.«1609.08688»\n",
  "statement_hash": "e706aa7627d8aa14aa199026cbb7288a047221c3bd19e02e4c4a342625cae926",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}