Skip to content

Commit 08b234f

Browse files
committed
chore(SimpleGraph): fix DecidableEq/Fintype assumptions (#16079)
Found by a linter in #10235 Mostly repeats @grunweg's #15306 accidentally reverted by @semorrison's #15726
1 parent e6c72d0 commit 08b234f

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

Mathlib/Combinatorics/SimpleGraph/Connectivity/WalkCounting.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ theorem set_walk_length_succ_eq (u v : V) (n : ℕ) :
5858
· rintro ⟨w, huw, pwv, rfl, rfl, rfl⟩
5959
rfl
6060

61-
variable [DecidableEq V]
62-
6361
/-- Walks of length two from `u` to `v` correspond bijectively to common neighbours of `u` and `v`.
6462
Note that `u` and `v` may be the same. -/
6563
@[simps]
@@ -73,7 +71,7 @@ def walkLengthTwoEquivCommonNeighbors (u v : V) :
7371

7472
section LocallyFinite
7573

76-
variable [LocallyFinite G]
74+
variable [DecidableEq V] [LocallyFinite G]
7775

7876
/-- The `Finset` of length-`n` walks from `u` to `v`.
7977
This is used to give `{p : G.walk u v | p.length = n}` a `Fintype` instance, and it
@@ -143,7 +141,7 @@ end LocallyFinite
143141

144142
section Finite
145143

146-
variable [Fintype V] [DecidableRel G.Adj]
144+
variable [DecidableEq V] [Fintype V] [DecidableRel G.Adj]
147145

148146
theorem reachable_iff_exists_finsetWalkLength_nonempty (u v : V) :
149147
G.Reachable u v ↔ ∃ n : Fin (Fintype.card V), (G.finsetWalkLength n u v).Nonempty := by
@@ -172,8 +170,12 @@ instance instDecidableMemSupp (c : G.ConnectedComponent) (v : V) : Decidable (v
172170
c.recOn (fun w ↦ decidable_of_iff (G.Reachable v w) <| by simp)
173171
(fun _ _ _ _ ↦ Subsingleton.elim _ _)
174172

175-
lemma odd_card_iff_odd_components : Odd (Nat.card V) ↔
173+
end Finite
174+
175+
lemma odd_card_iff_odd_components [Finite V] : Odd (Nat.card V) ↔
176176
Odd (Nat.card ({(c : ConnectedComponent G) | Odd (Nat.card c.supp)})) := by
177+
classical
178+
cases nonempty_fintype V
177179
rw [Nat.card_eq_fintype_card]
178180
simp only [← (set_fintype_card_eq_univ_iff _).mpr G.iUnion_connectedComponentSupp,
179181
ConnectedComponent.mem_supp_iff, Fintype.card_subtype_compl,
@@ -184,8 +186,6 @@ lemma odd_card_iff_odd_components : Odd (Nat.card V) ↔
184186
rw [Nat.card_eq_fintype_card, Fintype.card_ofFinset]
185187
exact (Finset.odd_sum_iff_odd_card_odd (fun x : G.ConnectedComponent ↦ Nat.card x.supp))
186188

187-
end Finite
188-
189189
end WalkCounting
190190

191191
end SimpleGraph

Mathlib/Combinatorics/SimpleGraph/Turan.lean

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ end Defs
124124

125125
namespace IsTuranMaximal
126126

127-
variable {s t u : V} [DecidableEq V]
127+
variable {s t u : V}
128128

129129
/-- In a Turán-maximal graph, non-adjacent vertices have the same degree. -/
130130
lemma degree_eq_of_not_adj (h : G.IsTuranMaximal r) (hn : ¬G.Adj s t) :
@@ -186,15 +186,15 @@ instance : DecidableRel h.setoid.r :=
186186
/-- The finpartition derived from `h.setoid`. -/
187187
def finpartition [DecidableEq V] : Finpartition (univ : Finset V) := Finpartition.ofSetoid h.setoid
188188

189-
lemma not_adj_iff_part_eq :
189+
lemma not_adj_iff_part_eq [DecidableEq V] :
190190
¬G.Adj s t ↔ h.finpartition.part s = h.finpartition.part t := by
191191
change h.setoid.r s t ↔ _
192192
rw [← Finpartition.mem_part_ofSetoid_iff_rel]
193193
let fp := h.finpartition
194194
change t ∈ fp.part s ↔ fp.part s = fp.part t
195195
rw [fp.mem_part_iff_part_eq_part (mem_univ t) (mem_univ s), eq_comm]
196196

197-
lemma degree_eq_card_sub_part_card :
197+
lemma degree_eq_card_sub_part_card [DecidableEq V] :
198198
G.degree s = Fintype.card V - (h.finpartition.part s).card :=
199199
calc
200200
_ = (univ.filter (G.Adj s)).card := by
@@ -207,7 +207,7 @@ lemma degree_eq_card_sub_part_card :
207207
simp [setoid]
208208

209209
/-- The parts of a Turán-maximal graph form an equipartition. -/
210-
theorem isEquipartition : h.finpartition.IsEquipartition := by
210+
theorem isEquipartition [DecidableEq V] : h.finpartition.IsEquipartition := by
211211
set fp := h.finpartition
212212
by_contra hn
213213
rw [Finpartition.not_isEquipartition] at hn
@@ -227,7 +227,7 @@ theorem isEquipartition : h.finpartition.IsEquipartition := by
227227
have : large.card ≤ Fintype.card V := by simpa using card_le_card large.subset_univ
228228
omega
229229

230-
lemma card_parts_le : h.finpartition.parts.card ≤ r := by
230+
lemma card_parts_le [DecidableEq V] : h.finpartition.parts.card ≤ r := by
231231
by_contra! l
232232
obtain ⟨z, -, hz⟩ := h.finpartition.exists_subset_part_bijOn
233233
have ncf : ¬G.CliqueFree z.card := by
@@ -240,7 +240,7 @@ lemma card_parts_le : h.finpartition.parts.card ≤ r := by
240240
/-- There are `min n r` parts in a graph on `n` vertices satisfying `G.IsTuranMaximal r`.
241241
`min` handles the `n < r` case, when `G` is complete but still `r + 1`-cliquefree
242242
for having insufficiently many vertices. -/
243-
theorem card_parts : h.finpartition.parts.card = min (Fintype.card V) r := by
243+
theorem card_parts [DecidableEq V] : h.finpartition.parts.card = min (Fintype.card V) r := by
244244
set fp := h.finpartition
245245
apply le_antisymm (le_min fp.card_parts_le_card h.card_parts_le)
246246
by_contra! l
@@ -280,8 +280,6 @@ theorem nonempty_iso_turanGraph :
280280

281281
end IsTuranMaximal
282282

283-
variable [DecidableEq V]
284-
285283
/-- **Turán's theorem**, reverse direction.
286284
287285
Any graph isomorphic to `turanGraph n r` is itself Turán-maximal if `0 < r`. -/
@@ -293,7 +291,7 @@ theorem isTuranMaximal_of_iso (f : G ≃g turanGraph n r) (hr : 0 < r) : G.IsTur
293291
fun H _ cf ↦ (f.symm.comp g).card_edgeFinset_eq ▸ j.2 H cf
294292

295293
/-- Turán-maximality with `0 < r` transfers across graph isomorphisms. -/
296-
theorem IsTuranMaximal.iso {W : Type*} [DecidableEq W] [Fintype W] {H : SimpleGraph W}
294+
theorem IsTuranMaximal.iso {W : Type*} [Fintype W] {H : SimpleGraph W}
297295
[DecidableRel H.Adj] (h : G.IsTuranMaximal r) (f : G ≃g H) (hr : 0 < r) : H.IsTuranMaximal r :=
298296
isTuranMaximal_of_iso (h.nonempty_iso_turanGraph.some.comp f.symm) hr
299297

0 commit comments

Comments
 (0)