Skip to content

Commit fa5f1be

Browse files
committed
refactor(GreensOpenProblems): add tests for Green 51
1 parent 9cddd0a commit fa5f1be

4 files changed

Lines changed: 236 additions & 10 deletions

File tree

FormalConjectures/GreensOpenProblems/51.lean

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ limitations under the License.
1515
-/
1616

1717
import FormalConjectures.Util.ProblemImports
18+
import FormalConjecturesForMathlib.Combinatorics.Additive.Coset
19+
import FormalConjecturesForMathlib.Data.ZMod.F2
1820

1921
/-!
2022
# Green's Open Problem 51
@@ -36,18 +38,9 @@ open scoped Pointwise
3638

3739
namespace Green51
3840

39-
/-- The group $G = \mathbb{F}_2^n = (Z/2Z)^n$. -/
40-
abbrev 𝔽₂ (n : ℕ) := Fin n → ZMod 2
41-
42-
/-- The maximum dimension of a coset contained in the set $A$. -/
43-
noncomputable def maxCosetDim (n : ℕ) (A : Set (𝔽₂ n)) : ℕ :=
44-
sSup { d | ∃ (W : Submodule (ZMod 2) (𝔽₂ n)) (v : 𝔽₂ n),
45-
v +ᵥ (W : Set (𝔽₂ n)) ⊆ A ∧
46-
Module.finrank (ZMod 2) W = d }
47-
4841
/-- The largest dimension of a coset guaranteed to be contained in $2A$ for $A \subseteq \mathbb{F}_2^n$ with density $\alpha$. -/
4942
noncomputable def guaranteedMaxCosetDim (n : ℕ) (α : ℝ) : ℕ :=
50-
sInf { maxCosetDim n ↑(A + A) | (A : Finset (𝔽₂ n)) (_h : A.dens ≥ α) }
43+
sInf { maxCosetDim (ZMod 2) (𝔽₂ n) ↑(A + A) | (A : Finset (𝔽₂ n)) (_h : A.dens ≥ α) }
5144

5245
/--
5346
Suppose that $A \subset \mathbb{F}_2^n$ is a set of density $\alpha$. What is the largest size of coset
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/-
2+
Copyright 2026 The Formal Conjectures Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-/
16+
17+
import Mathlib
18+
19+
noncomputable def maxCosetDim (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
20+
[FiniteDimensional K V] (A : Set V) : ℕ :=
21+
sSup { Module.finrank K S.direction | (S : AffineSubspace K V) (_h : (S : Set V) ⊆ A) }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/-
2+
Copyright 2026 The Formal Conjectures Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-/
16+
17+
import Mathlib
18+
19+
/-- The boolean hypercube $G = \mathbb{F}_2^n = (\mathbb{Z}/2\mathbb{Z})^n$. -/
20+
abbrev 𝔽₂ (n : ℕ) := Fin n → ZMod 2
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/-
2+
Copyright 2026 The Formal Conjectures Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-/
16+
17+
import Mathlib
18+
import FormalConjecturesForMathlib.Combinatorics.Additive.Coset
19+
20+
/-!
21+
# Sanity checks for maxCosetDim
22+
-/
23+
24+
open scoped Pointwise
25+
26+
/--
27+
The maximum coset dimension in the entire vector space $V$ is exactly the dimension of $V$.
28+
-/
29+
theorem maxCosetDim_univ (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
30+
[FiniteDimensional K V] : maxCosetDim K V (Set.univ : Set V) = Module.finrank K V := by
31+
dsimp [maxCosetDim]
32+
apply le_antisymm
33+
· apply csSup_le
34+
· use 0
35+
use ⊥
36+
simp
37+
· rintro _ ⟨S, _, rfl⟩
38+
exact Submodule.finrank_le S.direction
39+
· apply le_csSup
40+
· use Module.finrank K V
41+
rintro _ ⟨S, _, rfl⟩
42+
exact Submodule.finrank_le S.direction
43+
· use ⊤
44+
refine ⟨Set.subset_univ _, ?_⟩
45+
rw [AffineSubspace.direction_top, finrank_top]
46+
47+
/-- The maximum coset dimension in the empty set $\emptyset$ is $0$. -/
48+
theorem maxCosetDim_empty (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
49+
[FiniteDimensional K V] : maxCosetDim K V (∅ : Set V) = 0 := by
50+
dsimp [maxCosetDim]
51+
have h : {Module.finrank K S.direction | (S : AffineSubspace K V) (_h : (S : Set V) ⊆ ∅)} = {0} := by
52+
ext x
53+
simp only [Set.mem_setOf_eq, Set.subset_empty_iff, Set.mem_singleton_iff]
54+
constructor
55+
· rintro ⟨S, hS, rfl⟩
56+
have hbot : S = ⊥ := SetLike.ext'_iff.mpr (by simp [hS])
57+
rw [hbot, AffineSubspace.direction_bot, finrank_bot]
58+
· rintro rfl
59+
use ⊥
60+
simp
61+
rw [h, csSup_singleton]
62+
63+
/--
64+
If $A \subseteq B$, then the maximum coset dimension achievable in $A$
65+
cannot exceed the maximum coset dimension achievable in $B$.
66+
-/
67+
theorem maxCosetDim_mono (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
68+
[FiniteDimensional K V] {A B : Set V} (h : A ⊆ B) :
69+
maxCosetDim K V A ≤ maxCosetDim K V B := by
70+
dsimp [maxCosetDim]
71+
-- We show that any dimension achievable in A is bounded by the supremum in B
72+
apply csSup_le
73+
· use 0
74+
use ⊥
75+
simp [Set.empty_subset]
76+
· rintro d ⟨S, hS, rfl⟩
77+
apply le_csSup
78+
· -- Prove the set of dimensions in B is bounded above
79+
use Module.finrank K V
80+
rintro _ ⟨S', _, rfl⟩
81+
exact Submodule.finrank_le S'.direction
82+
· -- The witness S in A is also a witness in B
83+
use S
84+
exact ⟨Set.Subset.trans hS h, rfl⟩
85+
86+
/--
87+
If the target set $A$ is already an affine subspace, the function
88+
returns exactly the rank of its direction.
89+
-/
90+
theorem maxCosetDim_affineSubspace (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
91+
[FiniteDimensional K V] (S : AffineSubspace K V) :
92+
maxCosetDim K V (S : Set V) = Module.finrank K S.direction := by
93+
dsimp [maxCosetDim]
94+
apply le_antisymm
95+
· apply csSup_le
96+
· use 0
97+
use ⊥
98+
simp [Set.empty_subset]
99+
· rintro _ ⟨S', hS', rfl⟩
100+
exact Submodule.finrank_mono (AffineSubspace.direction_le hS')
101+
· apply le_csSup
102+
· use Module.finrank K V
103+
rintro _ ⟨S', _, rfl⟩
104+
exact Submodule.finrank_le S'.direction
105+
· use S
106+
107+
/--
108+
Similar to the empty set, a set containing exactly one vector should yield
109+
a maximum dimension of 0.
110+
-/
111+
theorem maxCosetDim_singleton (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
112+
[FiniteDimensional K V] (v : V) : maxCosetDim K V ({v} : Set V) = 0 := by
113+
dsimp [maxCosetDim]
114+
have h : {Module.finrank K S.direction | (S : AffineSubspace K V) (_h : (S : Set V) ⊆ {v})} = {0} := by
115+
ext x
116+
simp only [Set.mem_setOf_eq, Set.mem_singleton_iff]
117+
constructor
118+
· rintro ⟨S, hS, rfl⟩
119+
obtain rfl | h_nonempty := eq_bot_or_bot_lt S
120+
· rw [AffineSubspace.direction_bot, finrank_bot]
121+
· have h_dir : S.direction = ⊥ := by
122+
apply eq_bot_iff.mpr
123+
rintro y hy
124+
have h_coe : (S : Set V) ≠ ∅ := by
125+
intro h_emp
126+
apply ne_of_gt h_nonempty
127+
exact (AffineSubspace.coe_eq_bot_iff S).mp h_emp
128+
obtain ⟨p, hp⟩ : (S : Set V).Nonempty := Set.nonempty_iff_ne_empty.mpr h_coe
129+
have hpv : p = v := hS hp
130+
have hpy : y +ᵥ p ∈ S := AffineSubspace.vadd_mem_of_mem_direction hy hp
131+
have hpyv : y +ᵥ p = v := hS hpy
132+
rw [hpv] at hpyv
133+
change y + v = v at hpyv
134+
simpa using hpyv
135+
rw [h_dir, finrank_bot]
136+
· rintro rfl
137+
use ⊥
138+
simp
139+
rw [h, csSup_singleton]
140+
141+
lemma maxCosetDim_vadd_le (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
142+
[FiniteDimensional K V] (v : V) (A : Set V) :
143+
maxCosetDim K V (v +ᵥ A) ≤ maxCosetDim K V A := by
144+
dsimp [maxCosetDim]
145+
apply csSup_le
146+
· use 0
147+
use ⊥
148+
simp [Set.empty_subset]
149+
· rintro d ⟨S, hS, rfl⟩
150+
apply le_csSup
151+
· use Module.finrank K V
152+
rintro _ ⟨S', _, rfl⟩
153+
exact Submodule.finrank_le S'.direction
154+
· let f : V ≃ᵃ[K] V := AffineEquiv.constVAdd K V (-v)
155+
refine ⟨S.map (f : V →ᵃ[K] V), ?_, ?_⟩
156+
· rw [AffineSubspace.coe_map]
157+
rintro x ⟨y, hy, rfl⟩
158+
have h_ya : y ∈ v +ᵥ A := hS hy
159+
rcases h_ya with ⟨a, ha, rfl⟩
160+
change -v + (v + a) ∈ A
161+
rw [neg_add_cancel_left]
162+
exact ha
163+
· have hd : (S.map (f : V →ᵃ[K] V)).direction = S.direction := by
164+
rw [AffineSubspace.map_direction]
165+
change Submodule.map LinearMap.id S.direction = S.direction
166+
exact Submodule.map_id S.direction
167+
rw [hd]
168+
169+
/--
170+
Translating a set by a vector does not change its maximum coset dimension.
171+
-/
172+
theorem maxCosetDim_vadd (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V]
173+
[FiniteDimensional K V] (v : V) (A : Set V) :
174+
maxCosetDim K V (v +ᵥ A) = maxCosetDim K V A := by
175+
apply le_antisymm
176+
· exact maxCosetDim_vadd_le K V v A
177+
· have h := maxCosetDim_vadd_le K V (-v) (v +ᵥ A)
178+
have h_cancel : -v +ᵥ (v +ᵥ A) = A := by
179+
ext x
180+
constructor
181+
· rintro ⟨y, ⟨a, ha, rfl⟩, rfl⟩
182+
change -v + (v + a) ∈ A
183+
rw [neg_add_cancel_left]
184+
exact ha
185+
· rintro hx
186+
use v + x
187+
constructor
188+
· exact ⟨x, hx, rfl⟩
189+
· change -v + (v + x) = x
190+
rw [neg_add_cancel_left]
191+
rw [h_cancel] at h
192+
exact h

0 commit comments

Comments
 (0)