Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit bf7ef0e

Browse files
committed
feat(combinatorics/simple_graph/regularity): Increment partition (#19051)
Define the increment partition and prove its two crucial properties: * It has size depending only on the size of the original partition * It increases the energy by a fixed amount This is all internal to the proof of SRL, so I made most lemmas `private`. Co-authored-by: Bhavik Mehta <bhavikmehta8@gmail.com>
1 parent f51de87 commit bf7ef0e

7 files changed

Lines changed: 246 additions & 3 deletions

File tree

docs/references.bib

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,29 @@ @Book{ soare1987
20572057
doi = {10.1007/978-3-662-02460-7}
20582058
}
20592059

2060+
@InProceedings{ srl_itp,
2061+
author = {Dillies, Ya\"{e}l and Mehta, Bhavik},
2062+
title = {{Formalising Szemer\'{e}di’s Regularity Lemma in Lean}},
2063+
booktitle = {13th International Conference on Interactive Theorem
2064+
Proving (ITP 2022)},
2065+
pages = {9:1--9:19},
2066+
series = {Leibniz International Proceedings in Informatics
2067+
(LIPIcs)},
2068+
isbn = {978-3-95977-252-5},
2069+
issn = {1868-8969},
2070+
year = {2022},
2071+
volume = {237},
2072+
editor = {Andronick, June and de Moura, Leonardo},
2073+
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
2074+
address = {Dagstuhl, Germany},
2075+
url = {https://drops.dagstuhl.de/opus/volltexte/2022/16718},
2076+
urn = {urn:nbn:de:0030-drops-167185},
2077+
doi = {10.4230/LIPIcs.ITP.2022.9},
2078+
annote = {Keywords: Lean, formalisation, formal proof, graph theory,
2079+
combinatorics, additive combinatorics, Szemer\'{e}di’s
2080+
Regularity Lemma, Roth’s Theorem}
2081+
}
2082+
20602083
@Book{ stanley2012,
20612084
author = {Stanley, Richard P.},
20622085
title = {Enumerative combinatorics},

src/combinatorics/simple_graph/regularity/bound.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ This entire file is internal to the proof of Szemerédi Regularity Lemma.
2121
* `szemeredi_regularity.initial_bound`: The size of the partition we start the induction with.
2222
* `szemeredi_regularity.bound`: The upper bound on the size of the partition produced by our version
2323
of Szemerédi's regularity lemma.
24+
25+
## References
26+
27+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
2428
-/
2529

2630
open finset fintype function real

src/combinatorics/simple_graph/regularity/chunk.lean

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ This entire file is internal to the proof of Szemerédi Regularity Lemma.
2828
2929
Once ported to mathlib4, this file will be a great golfing ground for Heather's new tactic
3030
`rel_congr`.
31+
32+
## References
33+
34+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
3135
-/
3236

3337
open finpartition finset fintype rel nat
@@ -50,9 +54,9 @@ contained in the corresponding witness of non-uniformity.
5054

5155
/-- The portion of `szemeredi_regularity.increment` which partitions `U`. -/
5256
noncomputable def chunk : finpartition U :=
53-
dite (U.card = m * 4 ^ P.parts.card + (card α/P.parts.card - m * 4 ^ P.parts.card))
54-
(λ hUcard, (atomise U $ P.nonuniform_witnesses G ε U).equitabilise $ card_aux₁ hUcard)
55-
(λ hUcard, (atomise U $ P.nonuniform_witnesses G ε U).equitabilise $ card_aux₂ hP hU hUcard)
57+
if hUcard : U.card = m * 4 ^ P.parts.card + (card α/P.parts.card - m * 4 ^ P.parts.card)
58+
then (atomise U $ P.nonuniform_witnesses G ε U).equitabilise $ card_aux₁ hUcard
59+
else (atomise U $ P.nonuniform_witnesses G ε U).equitabilise $ card_aux₂ hP hU hUcard
5660
-- `hP` and `hU` are used to get that `U` has size
5761
-- `m * 4 ^ P.parts.card + a or m * 4 ^ P.parts.card + a + 1`
5862

src/combinatorics/simple_graph/regularity/energy.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Yaël Dillies, Bhavik Mehta
66
import algebra.big_operators.order
77
import algebra.module.basic
88
import combinatorics.simple_graph.density
9+
import data.rat.big_operators
910

1011
/-!
1112
# Energy of a partition
@@ -18,6 +19,10 @@ This file defines the energy of a partition.
1819
The energy is the auxiliary quantity that drives the induction process in the proof of Szemerédi's
1920
Regularity Lemma. As long as we do not have a suitable equipartition, we will find a new one that
2021
has an energy greater than the previous one plus some fixed constant.
22+
23+
## References
24+
25+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
2126
-/
2227

2328
open finset
@@ -44,4 +49,8 @@ div_le_of_nonneg_of_le_mul (sq_nonneg _) zero_le_one $
4449
... = P.parts.off_diag.card : nat.smul_one_eq_coe _
4550
... ≤ _ : by { rw [off_diag_card, one_mul, ←nat.cast_pow, nat.cast_le, sq], exact tsub_le_self }
4651

52+
@[simp, norm_cast] lemma coe_energy {𝕜 : Type*} [linear_ordered_field 𝕜] :
53+
(P.energy G : 𝕜) = (∑ uv in P.parts.off_diag, G.edge_density uv.1 uv.2 ^ 2) / P.parts.card ^ 2 :=
54+
by { rw energy, norm_cast }
55+
4756
end finpartition

src/combinatorics/simple_graph/regularity/equitabilise.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ This file allows to blow partitions up into parts of controlled size. Given a pa
2222
* `finpartition.equitabilise`: `P.equitabilise h` where `h : a * m + b * (m + 1)` is a partition
2323
with `a` parts of size `m` and `b` parts of size `m + 1` which almost refines `P`.
2424
* `finpartition.exists_equipartition_card_eq`: We can find equipartitions of arbitrary size.
25+
26+
## References
27+
28+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
2529
-/
2630

2731
open finset nat
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/-
2+
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yaël Dillies, Bhavik Mehta
5+
-/
6+
import combinatorics.simple_graph.regularity.chunk
7+
import combinatorics.simple_graph.regularity.energy
8+
9+
/-!
10+
# Increment partition for Szemerédi Regularity Lemma
11+
12+
In the proof of Szemerédi Regularity Lemma, we need to partition each part of a starting partition
13+
to increase the energy. This file defines the partition obtained by gluing the parts partitions
14+
together (the *increment partition*) and shows that the energy globally increases.
15+
16+
This entire file is internal to the proof of Szemerédi Regularity Lemma.
17+
18+
## Main declarations
19+
20+
* `szemeredi_regularity.increment`: The increment partition.
21+
* `szemeredi_regularity.card_increment`: The increment partition is much bigger than the original,
22+
but by a controlled amount.
23+
* `szemeredi_regularity.energy_increment`: The increment partition has energy greater than the
24+
original by a known (small) fixed amount.
25+
26+
## TODO
27+
28+
Once ported to mathlib4, this file will be a great golfing ground for Heather's new tactic
29+
`rel_congr`.
30+
31+
## References
32+
33+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
34+
-/
35+
36+
open finset fintype simple_graph szemeredi_regularity
37+
open_locale big_operators classical
38+
39+
local attribute [positivity] tactic.positivity_szemeredi_regularity
40+
41+
variables {α : Type*} [fintype α] {P : finpartition (univ : finset α)} (hP : P.is_equipartition)
42+
(G : simple_graph α) (ε : ℝ)
43+
44+
local notation `m` := (card α/step_bound P.parts.card : ℕ)
45+
46+
namespace szemeredi_regularity
47+
48+
/-- The **increment partition** in Szemerédi's Regularity Lemma.
49+
50+
If an equipartition is *not* uniform, then the increment partition is a (much bigger) equipartition
51+
with a slightly higher energy. This is helpful since the energy is bounded by a constant (see
52+
`szemeredi_regularity.energy_le_one`), so this process eventually terminates and yields a
53+
not-too-big uniform equipartition. -/
54+
noncomputable def increment : finpartition (univ : finset α) := P.bind $ λ U, chunk hP G ε
55+
56+
open finpartition finpartition.is_equipartition
57+
58+
variables {hP G ε}
59+
60+
/-- The increment partition has a prescribed (very big) size in terms of the original partition. -/
61+
lemma card_increment (hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPG : ¬P.is_uniform G ε) :
62+
(increment hP G ε).parts.card = step_bound P.parts.card :=
63+
begin
64+
have hPα' : step_bound P.parts.card ≤ card α :=
65+
(mul_le_mul_left' (pow_le_pow_of_le_left' (by norm_num) _) _).trans hPα,
66+
have hPpos : 0 < step_bound P.parts.card := step_bound_pos (nonempty_of_not_uniform hPG).card_pos,
67+
rw [increment, card_bind],
68+
simp_rw [chunk, apply_dite finpartition.parts, apply_dite card, sum_dite],
69+
rw [sum_const_nat, sum_const_nat, card_attach, card_attach], rotate,
70+
any_goals { exact λ x hx, card_parts_equitabilise _ _ (nat.div_pos hPα' hPpos).ne' },
71+
rw [nat.sub_add_cancel a_add_one_le_four_pow_parts_card, nat.sub_add_cancel ((nat.le_succ _).trans
72+
a_add_one_le_four_pow_parts_card), ←add_mul],
73+
congr,
74+
rw [filter_card_add_filter_neg_card_eq_card, card_attach],
75+
end
76+
77+
lemma increment_is_equipartition (hP : P.is_equipartition) (G : simple_graph α) (ε : ℝ) :
78+
(increment hP G ε).is_equipartition :=
79+
begin
80+
simp_rw [is_equipartition, set.equitable_on_iff_exists_eq_eq_add_one],
81+
refine ⟨m, λ A hA, _⟩,
82+
rw [mem_coe, increment, mem_bind] at hA,
83+
obtain ⟨U, hU, hA⟩ := hA,
84+
exact card_eq_of_mem_parts_chunk hA,
85+
end
86+
87+
private lemma distinct_pairs_increment :
88+
P.parts.off_diag.attach.bUnion
89+
(λ UV, (chunk hP G ε (mem_off_diag.1 UV.2).1).parts ×ˢ
90+
(chunk hP G ε (mem_off_diag.1 UV.2).2.1).parts)
91+
⊆ (increment hP G ε).parts.off_diag :=
92+
begin
93+
rintro ⟨Ui, Vj⟩,
94+
simp only [increment, mem_off_diag, bind_parts, mem_bUnion, prod.exists, exists_and_distrib_left,
95+
exists_prop, mem_product, mem_attach, true_and, subtype.exists, and_imp, mem_off_diag,
96+
forall_exists_index, bex_imp_distrib, ne.def],
97+
refine λ U V hUV hUi hVj, ⟨⟨_, hUV.1, hUi⟩, ⟨_, hUV.2.1, hVj⟩, _⟩,
98+
rintro rfl,
99+
obtain ⟨i, hi⟩ := nonempty_of_mem_parts _ hUi,
100+
exact hUV.2.2 (P.disjoint.elim_finset hUV.1 hUV.2.1 i (finpartition.le _ hUi hi) $
101+
finpartition.le _ hVj hi),
102+
end
103+
104+
/-- The contribution to `finpartition.energy` of a pair of distinct parts of a finpartition. -/
105+
private noncomputable def pair_contrib (G : simple_graph α) (ε : ℝ) (hP : P.is_equipartition)
106+
(x : {x // x ∈ P.parts.off_diag}) : ℚ :=
107+
∑ i in (chunk hP G ε (mem_off_diag.1 x.2).1).parts ×ˢ (chunk hP G ε (mem_off_diag.1 x.2).2.1).parts,
108+
G.edge_density i.fst i.snd ^ 2
109+
110+
lemma off_diag_pairs_le_increment_energy :
111+
∑ x in P.parts.off_diag.attach, pair_contrib G ε hP x / (increment hP G ε).parts.card ^ 2
112+
(increment hP G ε).energy G :=
113+
begin
114+
simp_rw [pair_contrib, ←sum_div],
115+
refine div_le_div_of_le_of_nonneg _ (sq_nonneg _),
116+
rw ←sum_bUnion,
117+
{ exact sum_le_sum_of_subset_of_nonneg distinct_pairs_increment (λ i _ _, sq_nonneg _) },
118+
simp only [set.pairwise_disjoint, function.on_fun, disjoint_left, inf_eq_inter, mem_inter,
119+
mem_product],
120+
rintro ⟨⟨s₁, s₂⟩, hs⟩ _ ⟨⟨t₁, t₂⟩, ht⟩ _ hst ⟨u, v⟩ huv₁ huv₂,
121+
rw mem_off_diag at hs ht,
122+
obtain ⟨a, ha⟩ := finpartition.nonempty_of_mem_parts _ huv₁.1,
123+
obtain ⟨b, hb⟩ := finpartition.nonempty_of_mem_parts _ huv₁.2,
124+
exact hst (subtype.ext_val $ prod.ext
125+
(P.disjoint.elim_finset hs.1 ht.1 a
126+
(finpartition.le _ huv₁.1 ha) $ finpartition.le _ huv₂.1 ha) $
127+
P.disjoint.elim_finset hs.2.1 ht.2.1 b
128+
(finpartition.le _ huv₁.2 hb) $ finpartition.le _ huv₂.2 hb),
129+
end
130+
131+
lemma pair_contrib_lower_bound [nonempty α] (x : {i // i ∈ P.parts.off_diag}) (hε₁ : ε ≤ 1)
132+
(hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPε : 1004^P.parts.card * ε^5) :
133+
↑(G.edge_density x.1.1 x.1.2)^2 - ε^5/25 + (if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3) ≤
134+
pair_contrib G ε hP x / (16^P.parts.card) :=
135+
begin
136+
rw pair_contrib,
137+
push_cast,
138+
split_ifs,
139+
{ rw add_zero,
140+
exact edge_density_chunk_uniform hPα hPε _ _ },
141+
{ exact edge_density_chunk_not_uniform hPα hPε hε₁ (mem_off_diag.1 x.2).2.2 h }
142+
end
143+
144+
lemma uniform_add_nonuniform_eq_off_diag_pairs [nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
145+
(hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPε : 1004^P.parts.card * ε^5)
146+
(hPG : ¬P.is_uniform G ε) :
147+
(∑ x in P.parts.off_diag, G.edge_density x.1 x.2 ^ 2 + P.parts.card^2 * (ε ^ 5 / 4) : ℝ)
148+
/ P.parts.card ^ 2
149+
≤ ∑ x in P.parts.off_diag.attach, pair_contrib G ε hP x / (increment hP G ε).parts.card ^ 2 :=
150+
begin
151+
conv_rhs
152+
{ rw [←sum_div, card_increment hPα hPG, step_bound, ←nat.cast_pow, mul_pow, pow_right_comm,
153+
nat.cast_mul, mul_comm, ←div_div, (show 4^2 = 16, by norm_num), sum_div] },
154+
rw [←nat.cast_pow, nat.cast_pow 16],
155+
refine div_le_div_of_le_of_nonneg _ (nat.cast_nonneg _),
156+
norm_num,
157+
transitivity ∑ x in P.parts.off_diag.attach,
158+
(G.edge_density x.1.1 x.1.2^2 - ε^5/25 + if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3 : ℝ),
159+
swap,
160+
{ exact sum_le_sum (λ i hi, pair_contrib_lower_bound i hε₁ hPα hPε) },
161+
have : ∑ x in P.parts.off_diag.attach,
162+
(G.edge_density x.1.1 x.1.2^2 - ε^5/25 + if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3 : ℝ) =
163+
∑ x in P.parts.off_diag,
164+
(G.edge_density x.1 x.2^2 - ε^5/25 + if G.is_uniform ε x.1 x.2 then 0 else ε^4/3),
165+
{ convert sum_attach, refl },
166+
rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
167+
zero_add, sum_const, nsmul_eq_mul, ←finpartition.non_uniforms],
168+
rw [finpartition.is_uniform, not_le] at hPG,
169+
refine le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le $ by positivity) _),
170+
conv_rhs { congr, congr, skip, rw [off_diag_card], congr, congr,
171+
conv { congr, skip, rw ←mul_one P.parts.card }, rw ←nat.mul_sub_left_distrib },
172+
simp_rw [mul_assoc, sub_add_eq_add_sub, add_sub_assoc, ←mul_sub_left_distrib, mul_div_assoc' ε,
173+
←pow_succ, div_eq_mul_one_div (ε^5), ←mul_sub_left_distrib, mul_left_comm _ (ε^5), sq,
174+
nat.cast_mul, mul_assoc, ←mul_assoc (ε ^ 5)],
175+
refine add_le_add_left (mul_le_mul_of_nonneg_left _ $ by positivity) _,
176+
rw [nat.cast_sub (P.parts_nonempty $ univ_nonempty.ne_empty).card_pos, mul_sub_right_distrib,
177+
nat.cast_one, one_mul, le_sub_comm, ←mul_sub_left_distrib,
178+
←div_le_iff (show (0:ℝ) < 1/3 - 1/25 - 1/4, by norm_num)],
179+
exact le_trans (show _ ≤ (7:ℝ), by norm_num) (by exact_mod_cast hP₇),
180+
end
181+
182+
/-- The increment partition has energy greater than the original one by a known fixed amount. -/
183+
lemma energy_increment [nonempty α] (hP : P.is_equipartition) (hP₇ : 7 ≤ P.parts.card)
184+
(hε : 100 < 4^P.parts.card * ε^5) (hPα : P.parts.card * 16^P.parts.card ≤ card α)
185+
(hPG : ¬P.is_uniform G ε) (hε₁ : ε ≤ 1) :
186+
↑(P.energy G) + ε^5 / 4 ≤ (increment hP G ε).energy G :=
187+
begin
188+
rw coe_energy,
189+
have h := uniform_add_nonuniform_eq_off_diag_pairs hε₁ hP₇ hPα hε.le hPG,
190+
rw [add_div, mul_div_cancel_left] at h,
191+
exact h.trans (by exact_mod_cast off_diag_pairs_le_increment_energy),
192+
positivity,
193+
end
194+
195+
end szemeredi_regularity

src/combinatorics/simple_graph/regularity/uniform.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ is less than `ε`.
3333
* `finpartition.is_uniform`: Uniformity of a partition.
3434
* `finpartition.nonuniform_witnesses`: For each non-uniform pair of parts of a partition, pick
3535
witnesses of non-uniformity and dump them all together.
36+
37+
## References
38+
39+
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
3640
-/
3741

3842
open finset

0 commit comments

Comments
 (0)