/-
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
open scoped Topologyopen Filternamespace Erdos36The number of solutions to the equation $a - b = k$, for $a \in A$ and $b \in B$. This represents the "overlap" between sets $A$ and $B$ for a given difference $k$.
def Overlap (A B : Finset ℤ) (k : ℤ) : ℕ := ((A.product B).filter <| fun (a, b) => a - b = k).cardThe maximum overlap for a given pair of sets $A$ and $B$, taken over all possible integer differences $k$.
noncomputable def MaxOverlap (A B : Finset ℤ) : ℕ := iSup <| Overlap A B
Let $A$ and $B$ be two complementary subsets, a splitting of the numbers ${1, 2, \dots, 2n}$,
such that both have the same cardinality $n$.
Define $M(n)$ to be the minimum MaxOverlap that can be achieved,
ranging over all such partitions $(A, B)$.
noncomputable def M (n : ℕ) : ℕ :=
sInf {MaxOverlap A B | (A : Finset ℤ) (B : Finset ℤ)
(_disjoint : Disjoint A B)
(_union : A ∪ B = Finset.Icc (1 : ℤ) (2 * n))
(_same_card : A.card = B.card)}
A small API lemma: every pair (a, b) ∈ A × B contributes to Overlap A B (a - b).
@[category API, AMS 5 11]
private lemma one_le_overlap {A B : Finset ℤ} {a b : ℤ}
(ha : a ∈ A) (hb : b ∈ B) : 1 ≤ Overlap A B (a - b) :=
Finset.card_pos.mpr ⟨(a, b), Finset.mem_filter.mpr
⟨Finset.mem_product.mpr ⟨ha, hb⟩, rfl⟩⟩
For a fixed difference k, the first coordinate determines the second, so an overlap is
never larger than either side. This is what makes MaxOverlap a supremum of a bounded set.
@[category API, AMS 5 11]
private lemma overlap_le_card_left (A B : Finset ℤ) (k : ℤ) : Overlap A B k ≤ A.card := A:Finset ℤB:Finset ℤk:ℤ⊢ Overlap A B k ≤ A.card
A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})⊢ p.1 ∈ ↑AA:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})q:ℤ × ℤhq:q ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})h:p.1 = q.1⊢ p = q
A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})⊢ p.1 ∈ ↑A All goals completed! 🐙
A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})q:ℤ × ℤhq:q ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})h:p.1 = q.1⊢ p = q A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})q:ℤ × ℤhq:q ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})h:p.1 = q.1hpk:match p with
| (a, b) => a - b = k⊢ p = q
A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})q:ℤ × ℤhq:q ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})h:p.1 = q.1hpk:match p with
| (a, b) => a - b = khqk:match q with
| (a, b) => a - b = k⊢ p = q
exact Prod.ext h (A:Finset ℤB:Finset ℤk:ℤp:ℤ × ℤhp:p ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})q:ℤ × ℤhq:q ∈
↑({x ∈ A.product B |
match x with
| (a, b) => a - b = k})h:p.1 = q.1hpk:match p with
| (a, b) => a - b = khqk:match q with
| (a, b) => a - b = k⊢ p.2 = q.2 All goals completed! 🐙)
The range of Overlap A B is bounded, so MaxOverlap is a genuine supremum rather than
the junk value sSup returns on an unbounded set.
@[category API, AMS 5 11]
private lemma bddAbove_range_overlap (A B : Finset ℤ) :
BddAbove (Set.range (Overlap A B)) := A:Finset ℤB:Finset ℤ⊢ BddAbove (Set.range (Overlap A B))
A:Finset ℤB:Finset ℤ⊢ A.card ∈ upperBounds (Set.range (Overlap A B))
A:Finset ℤB:Finset ℤk:ℤ⊢ Overlap A B k ≤ A.card
All goals completed! 🐙@[category API, AMS 5 11]
private lemma maxOverlap_le_card_left (A B : Finset ℤ) : MaxOverlap A B ≤ A.card :=
ciSup_le fun k => overlap_le_card_left A B k
An overlap can only be nonzero for a difference that is actually realised, which confines
the search for MaxOverlap to a finite set.
A:Finset ℤB:Finset ℤk:ℤhk:k ∉ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ ∀ ⦃x : ℤ × ℤ⦄,
x ∈ A.product B →
¬match x with
| (a, b) => a - b = k
rintro ⟨a, b⟩ hab rfl A:Finset ℤB:Finset ℤa:ℤb:ℤhab:(a, b) ∈ A.product Bhk:a - b ∉ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ False
exact hk (Finset.mem_image.mpr ⟨(a, b), hab, rfl⟩) All goals completed! 🐙
MaxOverlap as a supremum over a finite set of differences. This is the form that makes it
possible to evaluate: the iSup in the definition ranges over all of ℤ, but every difference
outside A - B contributes 0.
@[category API, AMS 5 11]
private lemma maxOverlap_eq_sup (A B : Finset ℤ) :
MaxOverlap A B = ((A ×ˢ B).image fun p => p.1 - p.2).sup (Overlap A B) := by A:Finset ℤB:Finset ℤ⊢ MaxOverlap A B = (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B)
refine le_antisymm (ciSup_le fun k => ?_) (Finset.sup_le fun k _ => ?_) refine_1 A:Finset ℤB:Finset ℤk:ℤ⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B)refine_2 A:Finset ℤB:Finset ℤk:ℤx✝:k ∈ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ MaxOverlap A B
· refine_1 A:Finset ℤB:Finset ℤk:ℤ⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B) by_cases hk : k ∈ (A ×ˢ B).image fun p => p.1 - p.2 pos A:Finset ℤB:Finset ℤk:ℤhk:k ∈ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B)neg A:Finset ℤB:Finset ℤk:ℤhk:k ∉ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B)
· pos A:Finset ℤB:Finset ℤk:ℤhk:k ∈ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B) exact Finset.le_sup hk All goals completed! 🐙
· neg A:Finset ℤB:Finset ℤk:ℤhk:k ∉ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ (Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)).sup (Overlap A B) simp [overlap_eq_zero_of_notMem_sub A B hk] All goals completed! 🐙
· refine_2 A:Finset ℤB:Finset ℤk:ℤx✝:k ∈ Finset.image (fun p ↦ p.1 - p.2) (A ×ˢ B)⊢ Overlap A B k ≤ MaxOverlap A B exact le_ciSup (bddAbove_range_overlap A B) k All goals completed! 🐙
The pairs M n ranges over are exactly the n-element subsets of {1, …, 2n}, each paired
with its complement. This turns the sInf over an unbounded family of Finset ℤ into an
infimum over a Finset.
@[category API, AMS 5 11]
private lemma M_eq_image (n : ℕ) :
M n = sInf ((fun A : Finset ℤ => MaxOverlap A (Finset.Icc (1 : ℤ) (2 * n) \ A)) ''
{A | A ⊆ Finset.Icc (1 : ℤ) (2 * n) ∧ A.card = n}) := by n:ℕ⊢ M n = sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n})
rw [M n:ℕ⊢ sInf {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} =
sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) n:ℕ⊢ sInf {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} =
sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n})] n:ℕ⊢ sInf {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} =
sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n})
congr 1 n:ℕ⊢ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} =
(fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
ext m n:ℕm:ℕ⊢ m ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} ↔
m ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
constructor mp n:ℕm:ℕ⊢ m ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} →
m ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}mpr n:ℕm:ℕ⊢ m ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} →
m ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x}
· mp n:ℕm:ℕ⊢ m ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} →
m ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} rintro ⟨A, B, hdisj, hunion, hcard, rfl⟩ mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.card⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
have hA : A ⊆ Finset.Icc (1 : ℤ) (2 * n) := hunion ▸ Finset.subset_union_left mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
have hB : B = Finset.Icc (1 : ℤ) (2 * n) \ A := by n:ℕ⊢ M n = sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ A⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
rw [← hunion, n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)⊢ B = (A ∪ B) \ Amp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ A⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} Finset.union_sdiff_cancel_left hdisj n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)⊢ B = Bmp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ A⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}]mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ A⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ A⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
have hn : A.card = n := by n:ℕ⊢ M n = sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
have := Finset.card_union_of_disjoint hdisj n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Athis:(A ∪ B).card = A.card + B.card⊢ A.card = nmp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
rw [hunion n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Athis:(Finset.Icc 1 (2 * ↑n)).card = A.card + B.card⊢ A.card = n n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Athis:(Finset.Icc 1 (2 * ↑n)).card = A.card + B.card⊢ A.card = nmp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}] at this n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Athis:(Finset.Icc 1 (2 * ↑n)).card = A.card + B.card⊢ A.card = nmp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
simp only [Int.card_Icc] at this n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Athis:(2 * ↑n + 1 - 1).toNat = A.card + B.card⊢ A.card = nmp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
omegamp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}mp n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ MaxOverlap A B ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
exact ⟨A, ⟨hA, hn⟩, by n:ℕA:Finset ℤB:Finset ℤhdisj:Disjoint A Bhunion:A ∪ B = Finset.Icc 1 (2 * ↑n)hcard:A.card = B.cardhA:A ⊆ Finset.Icc 1 (2 * ↑n)hB:B = Finset.Icc 1 (2 * ↑n) \ Ahn:A.card = n⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) A = MaxOverlap A B simp only [← hB] All goals completed! 🐙⟩
· mpr n:ℕm:ℕ⊢ m ∈ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} →
m ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x} rintro ⟨A, ⟨hA, hn⟩, rfl⟩ mpr n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) A ∈
{x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑n)) (_ : A.card = B.card), MaxOverlap A B = x}
refine ⟨A, Finset.Icc (1 : ℤ) (2 * n) \ A, Finset.disjoint_sdiff, ?_, ?_, rfl⟩ mpr.refine_1 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A ∪ Finset.Icc 1 (2 * ↑n) \ A = Finset.Icc 1 (2 * ↑n)mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A.card = (Finset.Icc 1 (2 * ↑n) \ A).card
· mpr.refine_1 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A ∪ Finset.Icc 1 (2 * ↑n) \ A = Finset.Icc 1 (2 * ↑n) rw [Finset.union_sdiff_of_subset hA mpr.refine_1 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ Finset.Icc 1 (2 * ↑n) = Finset.Icc 1 (2 * ↑n) All goals completed! 🐙] All goals completed! 🐙
· mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A.card = (Finset.Icc 1 (2 * ↑n) \ A).card rw [Finset.card_sdiff, mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A.card = (Finset.Icc 1 (2 * ↑n)).card - (A ∩ Finset.Icc 1 (2 * ↑n)).card mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - n Finset.inter_eq_left.mpr hA, mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A.card = (Finset.Icc 1 (2 * ↑n)).card - A.cardmpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - n Int.card_Icc, mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ A.card = (2 * ↑n + 1 - 1).toNat - A.cardmpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - n hn mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - nmpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - n]mpr.refine_2 n:ℕA:Finset ℤhA:A ⊆ Finset.Icc 1 (2 * ↑n)hn:A.card = n⊢ n = (2 * ↑n + 1 - 1).toNat - n
omega All goals completed! 🐙
A computable stand-in for MaxOverlap. Overlap is already computable; the only obstacle
is the iSup, and maxOverlap_eq_sup says it agrees with this Finset.sup.
private def maxOverlapC (A B : Finset ℤ) : ℕ :=
((A ×ˢ B).image fun p => p.1 - p.2).sup (Overlap A B)@[category API, AMS 5 11]
private lemma maxOverlap_eq_maxOverlapC (A B : Finset ℤ) :
MaxOverlap A B = maxOverlapC A B := maxOverlap_eq_sup A B
The n-element subsets of {1, …, 2n}.
private def parts (n : ℕ) : Finset (Finset ℤ) :=
(Finset.Icc (1 : ℤ) (2 * n)).powerset.filter fun A => A.card = n@[category API, AMS 5 11]
private lemma mem_parts {n : ℕ} {A : Finset ℤ} :
A ∈ parts n ↔ A ⊆ Finset.Icc (1 : ℤ) (2 * n) ∧ A.card = n := by n:ℕA:Finset ℤ⊢ A ∈ parts n ↔ A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n
simp [parts, Finset.mem_filter, Finset.mem_powerset] All goals completed! 🐙
@[category API, AMS 5 11]
private lemma parts_nonempty (n : ℕ) : (parts n).Nonempty := by n:ℕ⊢ (parts n).Nonempty
refine ⟨Finset.Icc (1 : ℤ) n, mem_parts.mpr ⟨?_, ?_⟩⟩ refine_1 n:ℕ⊢ Finset.Icc 1 ↑n ⊆ Finset.Icc 1 (2 * ↑n)refine_2 n:ℕ⊢ (Finset.Icc 1 ↑n).card = n
· refine_1 n:ℕ⊢ Finset.Icc 1 ↑n ⊆ Finset.Icc 1 (2 * ↑n) exact Finset.Icc_subset_Icc le_rfl (by n:ℕ⊢ ↑n ≤ 2 * ↑n omega All goals completed! 🐙)
· refine_2 n:ℕ⊢ (Finset.Icc 1 ↑n).card = n rw [Int.card_Icc refine_2 n:ℕ⊢ (↑n + 1 - 1).toNat = n refine_2 n:ℕ⊢ (↑n + 1 - 1).toNat = n] refine_2 n:ℕ⊢ (↑n + 1 - 1).toNat = n; omega All goals completed! 🐙
M n as the minimum of a Finset of naturals, which is what makes it evaluable.
@[category API, AMS 5 11]
private lemma M_eq_min' (n : ℕ) :
M n = ((parts n).image fun A => maxOverlapC A (Finset.Icc (1 : ℤ) (2 * n) \ A)).min'
((parts_nonempty n).image _) := by n:ℕ⊢ M n = (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n)).min' ⋯
rw [M_eq_image, n:ℕ⊢ sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) =
(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n)).min' ⋯ n:ℕ⊢ sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) =
sInf ↑(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n)) ← Finset.Nonempty.csInf_eq_min' n:ℕ⊢ sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) =
sInf ↑(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n)) n:ℕ⊢ sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) =
sInf ↑(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n))] n:ℕ⊢ sInf ((fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}) =
sInf ↑(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n))
congr 1 n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
↑(Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) (parts n))
rw [Finset.coe_image, n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' ↑(parts n) n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
show ((parts n : Finset (Finset ℤ)) : Set (Finset ℤ))
= {A | A ⊆ Finset.Icc (1 : ℤ) (2 * n) ∧ A.card = n} from by n:ℕ⊢ ↑(parts n) = {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} ext A n:ℕA:Finset ℤ⊢ A ∈ ↑(parts n) ↔ A ∈ {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}; simp [mem_parts] All goals completed! 🐙 n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}] n:ℕ⊢ (fun A ↦ MaxOverlap A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n} =
(fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑n) \ A)) '' {A | A ⊆ Finset.Icc 1 (2 * ↑n) ∧ A.card = n}
exact Set.image_congr fun A _ => maxOverlap_eq_maxOverlapC _ _ All goals completed! 🐙
MaxOverlap {1} {2} = 1: the only nonzero overlap is at k = -1.
@[category API, AMS 5 11]
private lemma maxOverlap_singleton_one_two :
MaxOverlap ({1} : Finset ℤ) ({2} : Finset ℤ) = 1 := by ⊢ MaxOverlap {1} {2} = 1
apply le_antisymm a ⊢ MaxOverlap {1} {2} ≤ 1a ⊢ 1 ≤ MaxOverlap {1} {2}
· a ⊢ MaxOverlap {1} {2} ≤ 1 rw [show (1 : ℕ) = ({(1, 2)} : Finset (ℤ × ℤ)).card from by ⊢ 1 = {(1, 2)}.card a ⊢ MaxOverlap {1} {2} ≤ {(1, 2)}.card decide All goals completed! 🐙 a ⊢ MaxOverlap {1} {2} ≤ {(1, 2)}.card]a ⊢ MaxOverlap {1} {2} ≤ {(1, 2)}.card
refine ciSup_le ?_ a ⊢ ∀ (x : ℤ), Overlap {1} {2} x ≤ {(1, 2)}.card
intro k a k:ℤ⊢ Overlap {1} {2} k ≤ {(1, 2)}.card
apply Finset.card_le_card a k:ℤ⊢ {x ∈ {1}.product {2} |
match x with
| (a, b) => a - b = k} ⊆
{(1, 2)}
intro p hp a k:ℤp:ℤ × ℤhp:p ∈
{x ∈ {1}.product {2} |
match x with
| (a, b) => a - b = k}⊢ p ∈ {(1, 2)}
obtain ⟨hp1, _⟩ := Finset.mem_filter.mp hp a k:ℤp:ℤ × ℤhp:p ∈
{x ∈ {1}.product {2} |
match x with
| (a, b) => a - b = k}hp1:p ∈ {1}.product {2}right✝:match p with
| (a, b) => a - b = k⊢ p ∈ {(1, 2)}
obtain ⟨ha, hb⟩ := Finset.mem_product.mp hp1 a k:ℤp:ℤ × ℤhp:p ∈
{x ∈ {1}.product {2} |
match x with
| (a, b) => a - b = k}hp1:p ∈ {1}.product {2}right✝:match p with
| (a, b) => a - b = kha:p.1 ∈ {1}hb:p.2 ∈ {2}⊢ p ∈ {(1, 2)}
simp only [Finset.mem_singleton] at ha hb a k:ℤp:ℤ × ℤhp:p ∈
{x ∈ {1}.product {2} |
match x with
| (a, b) => a - b = k}hp1:p ∈ {1}.product {2}right✝:match p with
| (a, b) => a - b = kha:p.1 = 1hb:p.2 = 2⊢ p ∈ {(1, 2)}
exact Finset.mem_singleton.mpr (Prod.ext ha hb) All goals completed! 🐙
· a ⊢ 1 ≤ MaxOverlap {1} {2} refine le_ciSup_of_le ?_ (-1) ?_ a.refine_1 ⊢ BddAbove (Set.range (Overlap {1} {2}))a.refine_2 ⊢ 1 ≤ Overlap {1} {2} (-1)
· a.refine_1 ⊢ BddAbove (Set.range (Overlap {1} {2})) refine ⟨1, ?_⟩ a.refine_1 ⊢ 1 ∈ upperBounds (Set.range (Overlap {1} {2}))
rintro x ⟨k, rfl⟩ a.refine_1 k:ℤ⊢ Overlap {1} {2} k ≤ 1
exact (Finset.card_filter_le _ _).trans (by k:ℤ⊢ ({1}.product {2}).card ≤ 1 decide All goals completed! 🐙)
· a.refine_2 ⊢ 1 ≤ Overlap {1} {2} (-1) decide All goals completed! 🐙
This example calculates the value of $M 1$. The set is ${1, 2}$, so the only partition is
$A = {1}, B = {2}$ (or vice versa). The possible differences are $1 - 2 = -1$ and $2 - 1 = 1$.
The Overlap for $k=-1$ is 1 (if $A={1}, B={2}$) and for $k=1$ also 1 (if $A={2}, B={1}$ ).
The MaxOverlap is $1$, since the Overlap is $0$ for other $k$.
Thus, $M 1 = 1$.
@[category test, AMS 5 11]
theorem M_one : M 1 = 1 := by ⊢ M 1 = 1
apply le_antisymm a ⊢ M 1 ≤ 1a ⊢ 1 ≤ M 1
· a ⊢ M 1 ≤ 1 apply Nat.sInf_le a ⊢ 1 ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑1)) (_ : A.card = B.card), MaxOverlap A B = x}
refine ⟨{1}, {2}, by ⊢ Disjoint {1} {2} decide All goals completed! 🐙, by ⊢ {1} ∪ {2} = Finset.Icc 1 (2 * ↑1) decide All goals completed! 🐙, by ⊢ {1}.card = {2}.card decide All goals completed! 🐙, maxOverlap_singleton_one_two⟩
· a ⊢ 1 ≤ M 1 apply le_csInf a.h₁ ⊢ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑1)) (_ : A.card = B.card), MaxOverlap A B = x}.Nonemptyh₂ ⊢ ∀ b ∈ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑1)) (_ : A.card = B.card), MaxOverlap A B = x},
1 ≤ b
· a.h₁ ⊢ {x | ∃ A B, ∃ (_ : Disjoint A B) (_ : A ∪ B = Finset.Icc 1 (2 * ↑1)) (_ : A.card = B.card), MaxOverlap A B = x}.Nonempty exact ⟨_, {1}, {2}, by ⊢ Disjoint {1} {2} decide All goals completed! 🐙, by ⊢ {1} ∪ {2} = Finset.Icc 1 (2 * ↑1) decide All goals completed! 🐙, by ⊢ {1}.card = {2}.card decide All goals completed! 🐙,
maxOverlap_singleton_one_two⟩
rintro x ⟨A, B, hd, hu, hsc, rfl⟩ h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ 1 ≤ MaxOverlap A B
-- |A ∪ B| = 2 ∧ |A| = |B| ⇒ each is a singleton.
have hcardsum : A.card + B.card = 2 := by ⊢ M 1 = 1 h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A B
rw [← Finset.card_union_of_disjoint hd, A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ (A ∪ B).card = 2 A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ (Finset.Icc 1 (2 * ↑1)).card = 2 h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A B hu A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ (Finset.Icc 1 (2 * ↑1)).card = 2 A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ (Finset.Icc 1 (2 * ↑1)).card = 2h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A B] A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.card⊢ (Finset.Icc 1 (2 * ↑1)).card = 2h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A B; decideh₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A Bh₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2⊢ 1 ≤ MaxOverlap A B
have hca : A.card = 1 := by ⊢ M 1 = 1 h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1⊢ 1 ≤ MaxOverlap A B omegah₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1⊢ 1 ≤ MaxOverlap A Bh₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1⊢ 1 ≤ MaxOverlap A B
have hcb : B.card = 1 := by ⊢ M 1 = 1 h₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1hcb:B.card = 1⊢ 1 ≤ MaxOverlap A B omegah₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1hcb:B.card = 1⊢ 1 ≤ MaxOverlap A Bh₂ A:Finset ℤB:Finset ℤhd:Disjoint A Bhu:A ∪ B = Finset.Icc 1 (2 * ↑1)hsc:A.card = B.cardhcardsum:A.card + B.card = 2hca:A.card = 1hcb:B.card = 1⊢ 1 ≤ MaxOverlap A B
obtain ⟨a, rfl⟩ := Finset.card_eq_one.mp hca h₂ B:Finset ℤhcb:B.card = 1a:ℤhd:Disjoint {a} Bhu:{a} ∪ B = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = B.cardhcardsum:{a}.card + B.card = 2hca:{a}.card = 1⊢ 1 ≤ MaxOverlap {a} B
obtain ⟨b, rfl⟩ := Finset.card_eq_one.mp hcb h₂ a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ 1 ≤ MaxOverlap {a} {b}
-- MaxOverlap ≥ Overlap at `k = a - b`, and that's ≥ 1.
refine le_ciSup_of_le ?_ (a - b) ?_ h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ BddAbove (Set.range (Overlap {a} {b}))h₂.refine_2 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ 1 ≤ Overlap {a} {b} (a - b)
· h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ BddAbove (Set.range (Overlap {a} {b})) refine ⟨1, ?_⟩ h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ 1 ∈ upperBounds (Set.range (Overlap {a} {b}))
rintro x ⟨k, rfl⟩ h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ Overlap {a} {b} k ≤ 1
refine (Finset.card_filter_le _ _).trans ?_ h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ ({a}.product {b}).card ≤ 1
rw [Finset.product_eq_sprod, h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ ({a} ×ˢ {b}).card ≤ 1 All goals completed! 🐙 Finset.card_product, h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ {a}.card * {b}.card ≤ 1 All goals completed! 🐙
Finset.card_singleton, h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ 1 * {b}.card ≤ 1 All goals completed! 🐙 Finset.card_singleton h₂.refine_1 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2k:ℤ⊢ 1 * 1 ≤ 1 All goals completed! 🐙] All goals completed! 🐙
· h₂.refine_2 a:ℤhca:{a}.card = 1b:ℤhcb:{b}.card = 1hd:Disjoint {a} {b}hu:{a} ∪ {b} = Finset.Icc 1 (2 * ↑1)hsc:{a}.card = {b}.cardhcardsum:{a}.card + {b}.card = 2⊢ 1 ≤ Overlap {a} {b} (a - b) exact one_le_overlap (Finset.mem_singleton.mpr rfl)
(Finset.mem_singleton.mpr rfl) All goals completed! 🐙
For $n = 2$, the set is ${1, 2, 3, 4}$. The balanced partition $A = {1, 4}, B = {2, 3}$
has all four pairwise differences ($\pm 1, \pm 2$) distinct, so MaxOverlap = 1.
Any balanced partition has both pieces nonempty, so MaxOverlap \geq 1.
@[category test, AMS 5 11]
theorem M_two : M 2 = 1 := by ⊢ M 2 = 1
rw [M_eq_min' ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑2) \ A)) (parts 2)).min' ⋯ = 1 ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑2) \ A)) (parts 2)).min' ⋯ = 1] ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑2) \ A)) (parts 2)).min' ⋯ = 1
decide All goals completed! 🐙
For n = 3 the best splitting of {1, …, 6} has maximum overlap 2.
@[category test, AMS 5 11]
theorem M_three : M 3 = 2 := by ⊢ M 3 = 2
rw [M_eq_min' ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑3) \ A)) (parts 3)).min' ⋯ = 2 ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑3) \ A)) (parts 3)).min' ⋯ = 2] ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑3) \ A)) (parts 3)).min' ⋯ = 2
decide All goals completed! 🐙set_option maxRecDepth 8000 in
For n = 4 the best splitting of {1, …, 8} still has maximum overlap 2.
@[category test, AMS 5 11]
theorem M_four : M 4 = 2 := by ⊢ M 4 = 2
rw [M_eq_min' ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑4) \ A)) (parts 4)).min' ⋯ = 2 ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑4) \ A)) (parts 4)).min' ⋯ = 2] ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑4) \ A)) (parts 4)).min' ⋯ = 2
decide All goals completed! 🐙set_option maxRecDepth 40000 in
For n = 5 the best splitting of {1, …, 10} has maximum overlap 3.
@[category test, AMS 5 11]
theorem M_five : M 5 = 3 := by ⊢ M 5 = 3
rw [M_eq_min' ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑5) \ A)) (parts 5)).min' ⋯ = 3 ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑5) \ A)) (parts 5)).min' ⋯ = 3] ⊢ (Finset.image (fun A ↦ maxOverlapC A (Finset.Icc 1 (2 * ↑5) \ A)) (parts 5)).min' ⋯ = 3
decide All goals completed! 🐙The quotient of the minimum maximum overlap $M(N)$ by $N$. The central question of the minimum overlap problem is to determine the asymptotic behavior of this quotient as $N \to \infty$.
noncomputable def MinOverlapQuotient (N : ℕ) := (M N : ℝ) / NA lower bound of $\frac 1 4$. See Some remarks on number theory (in Hebrew) by Paul Erdős, Riveon Lematematika 9, p.45-48,1955
@[category textbook, AMS 5 11]
theorem minimum_overlap.variants.lower.erdos_1955 :
(1 : ℝ) / 4 < atTop.liminf MinOverlapQuotient := by ⊢ 1 / 4 < liminf MinOverlapQuotient atTop
sorry All goals completed! 🐙A lower bound of $1 - frac{1}{\sqrt 2}$. Scherk (written communication), see On the minimal overlap problem of Erdös by Leo Moser, Аста Аrithmetica V, p. 117-119, 1959
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.lower.scherk_1955 :
1 - (√2)⁻¹ < atTop.liminf MinOverlapQuotient := by ⊢ 1 - (√2)⁻¹ < liminf MinOverlapQuotient atTop
sorry All goals completed! 🐙A lower bound of $\frac{4 - \sqrt{6}}{5}$. See On the intersection of a linear set with the translation of its complement by Stanisław Świerczkowski1, Colloquium Mathematicum 5(2), p. 185-197, 1958
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.lower.swierczkowski_1958 :
(4 - 6 ^ ((1 : ℝ) / 2)) / 5 < atTop.liminf MinOverlapQuotient := by ⊢ (4 - 6 ^ (1 / 2)) / 5 < liminf MinOverlapQuotient atTop
sorry All goals completed! 🐙A lower bound of $\sqrt{4 - \sqrt{15}}$.
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.lower.haugland_1996 :
(4 - 15 ^((1 : ℝ) / 2)) ^ ((1 : ℝ) / 2) < atTop.liminf MinOverlapQuotient := by ⊢ (4 - 15 ^ (1 / 2)) ^ (1 / 2) < liminf MinOverlapQuotient atTop
sorry All goals completed! 🐙A lower bound of $0.379005$. See Erdős' minimum overlap problem by Ethan Patrick White, 2022
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.lower.white_2022 : 0.379005 < atTop.liminf MinOverlapQuotient := by ⊢ 0.379005 < liminf MinOverlapQuotient atTop
sorry All goals completed! 🐙The example (with $N$ even), $A = {\frac N 2 + 1, \dots, \frac{3N}{2}}$ shows an upper bound of $\frac 1 2$.
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.upper.erdos_1955 :
atTop.limsup MinOverlapQuotient ≤ (1 : ℝ) / 2 := by ⊢ limsup MinOverlapQuotient atTop ≤ 1 / 2
sorry All goals completed! 🐙An upper bound of $\frac 2 5$. See Minimal overlapping under translation. by T. S. Motzkin, K. E. Ralston and J. L. Selfridge, in "The summer meeting in Seattle" by V. L. Klee Jr., Bull. Amer. Math. Soc.62, p. 558, 1956
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.upper.MRS_1956 :
atTop.limsup MinOverlapQuotient ≤ (2 : ℝ) / 5 := by ⊢ limsup MinOverlapQuotient atTop ≤ 2 / 5
sorry All goals completed! 🐙An upper bound of $0.38200298812318988$. See Advances in the Minimum Overlap Problem by Jan Kristian Haugland, Journal of Number Theory Volume 58, Issue 1, p 71-78, 1996
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.upper.haugland_1996 :
atTop.limsup MinOverlapQuotient ≤ 0.38200298812318988 := by ⊢ limsup MinOverlapQuotient atTop ≤ 0.38200298812318988
sorry All goals completed! 🐙An upper bound of $0.3809268534330870$. See The minimum overlap problem by Jan Kristian Haugland
@[category research solved, AMS 5 11]
theorem minimum_overlap.variants.upper.haugland_2022 :
atTop.limsup MinOverlapQuotient ≤ 0.3809268534330870 := by ⊢ limsup MinOverlapQuotient atTop ≤ 0.3809268534330870 sorry All goals completed! 🐙Find a better lower bound!
@[category research open, AMS 5 11]
theorem erdos_36.variants.lower:
∃ (c : ℝ), 0.379005 < c ∧ c ≤ atTop.liminf MinOverlapQuotient ∧ c = answer(sorry) := by ⊢ ∃ c, 0.379005 < c ∧ c ≤ liminf MinOverlapQuotient atTop ∧ c = sorry
sorry All goals completed! 🐙Find a better upper bound!
@[category research open, AMS 5 11]
theorem erdos_36.variants.upper :
∃ (c : ℝ), c < 0.380926853433087 ∧ atTop.limsup MinOverlapQuotient ≤ c ∧ c = answer(sorry) := by ⊢ ∃ c < 0.380926853433087, limsup MinOverlapQuotient atTop ≤ c ∧ c = sorry
sorry All goals completed! 🐙
The limit of MinOverlapQuotient exists and it is less than $0.385694$.
@[category research solved, AMS 5 11]
theorem erdos_36.variants.exists : ∃ c, atTop.Tendsto MinOverlapQuotient (𝓝 c) ∧ c < 0.385694 := by ⊢ ∃ c, Tendsto MinOverlapQuotient atTop (𝓝 c) ∧ c < 0.385694
sorry All goals completed! 🐙
Find the value of the limit of MinOverlapQuotient!
@[category research open, AMS 5 11]
theorem erdos_36 : atTop.Tendsto MinOverlapQuotient (𝓝 answer(sorry)) := by ⊢ Tendsto MinOverlapQuotient atTop (𝓝 sorry)
sorry All goals completed! 🐙end Erdos36