Skip to content

Commit bdb7bd8

Browse files
Minor refactoring
1 parent df435b0 commit bdb7bd8

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Bipartite.lean

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ lemma between_adj : (G.between s t).Adj v w ↔ G.Adj v w ∧ (v ∈ s ∧ w ∈
289289

290290
lemma between_le : G.between s t ≤ G := fun _ _ h ↦ h.1
291291

292-
lemma between_comm : G.between s t = G.between t s := by
293-
ext v w; simp [between_adj, or_comm]
292+
lemma between_comm : G.between s t = G.between t s := by simp [between, or_comm]
294293

295294
instance [DecidableRel G.Adj] [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] :
296295
DecidableRel (G.between s t).Adj :=
@@ -299,9 +298,7 @@ instance [DecidableRel G.Adj] [DecidablePred (· ∈ s)] [DecidablePred (· ∈
299298
/-- `G.between s t` is bipartite if the sets `s` and `t` are disjoint. -/
300299
theorem between_isBipartiteWith (h : Disjoint s t) : (G.between s t).IsBipartiteWith s t where
301300
disjoint := h
302-
mem_of_adj v w := by
303-
rw [between_adj]
304-
tauto
301+
mem_of_adj _ _ h := h.2
305302

306303
/-- `G.between s t` is bipartite if the sets `s` and `t` are disjoint. -/
307304
theorem between_isBipartite (h : Disjoint s t) : (G.between s t).IsBipartite :=
@@ -311,37 +308,36 @@ theorem between_isBipartite (h : Disjoint s t) : (G.between s t).IsBipartite :=
311308
in `G`. -/
312309
lemma neighborSet_subset_between_union (hv : v ∈ s) :
313310
G.neighborSet v ⊆ (G.between s sᶜ).neighborSet v ∪ s := by
314-
simp_rw [neighborSet, between_adj, Set.setOf_subset, Set.mem_union, Set.mem_setOf]
315311
intro w hadj
312+
rw [neighborSet, Set.mem_union, Set.mem_setOf, between_adj]
316313
by_cases hw : w ∈ s
317-
all_goals tauto
314+
· exact Or.inr hw
315+
· exact Or.inl ⟨hadj, Or.inl ⟨hv, hw⟩⟩
318316

319317
/-- The neighbor set of `w ∈ sᶜ` in `G.between s sᶜ` excludes the vertices in `sᶜ` adjacent to `w`
320318
in `G`. -/
321319
lemma neighborSet_subset_between_union' (hw : w ∈ sᶜ) :
322320
G.neighborSet w ⊆ (G.between s sᶜ).neighborSet w ∪ sᶜ := by
323-
simp_rw [neighborSet, between_adj, Set.setOf_subset, Set.mem_union, Set.mem_setOf]
324321
intro v hadj
322+
rw [neighborSet, Set.mem_union, Set.mem_setOf, between_adj]
325323
by_cases hv : v ∈ s
326-
all_goals tauto
324+
· exact Or.inl ⟨hadj, Or.inr ⟨hw, hv⟩⟩
325+
· exact Or.inr hv
327326

328327
variable [DecidableEq V] [Fintype V] {s t : Finset V} [DecidableRel G.Adj]
329328

330329
/-- The neighbor finset of `v ∈ s` in `G.between s sᶜ` excludes the vertices in `s` adjacent to `v`
331330
in `G`. -/
332331
lemma neighborFinset_subset_between_union (hv : v ∈ s) :
333332
G.neighborFinset v ⊆ (G.between s sᶜ).neighborFinset v ∪ s := by
334-
conv_rhs =>
335-
rhs; rw [← toFinset_coe s]
336-
simp_rw [neighborFinset_def, ← Set.toFinset_union, Set.toFinset_subset_toFinset]
337-
exact neighborSet_subset_between_union hv
333+
simpa [neighborFinset_def] using neighborSet_subset_between_union hv
338334

339335
/-- The degree of `v ∈ s` in `G` is at most the degree in `G.between s sᶜ` plus the excluded
340336
vertices from `s`. -/
341337
theorem degree_le_between_plus (hv : v ∈ s) :
342338
G.degree v ≤ (G.between s sᶜ).degree v + s.card := by
343339
have h_bipartite : (G.between s sᶜ).IsBipartiteWith s ↑(sᶜ) := by
344-
simpa [coe_compl] using between_isBipartiteWith disjoint_compl_right
340+
simpa using between_isBipartiteWith disjoint_compl_right
345341
simp_rw [← card_neighborFinset_eq_degree,
346342
← card_union_of_disjoint (isBipartiteWith_neighborFinset_disjoint h_bipartite hv)]
347343
exact card_le_card (neighborFinset_subset_between_union hv)
@@ -350,19 +346,14 @@ theorem degree_le_between_plus (hv : v ∈ s) :
350346
`w` in `G`. -/
351347
lemma neighborFinset_subset_between_union' (hw : w ∈ sᶜ) :
352348
G.neighborFinset w ⊆ (G.between s sᶜ).neighborFinset w ∪ sᶜ := by
353-
conv_rhs =>
354-
rhs; rw [← toFinset_coe s]
355-
simp_rw [neighborFinset_def, ← Set.toFinset_compl, ← Set.toFinset_union,
356-
Set.toFinset_subset_toFinset]
357-
apply neighborSet_subset_between_union'
358-
rwa [← mem_coe, coe_compl] at hw
349+
simpa [neighborFinset_def] using G.neighborSet_subset_between_union' (by simpa using hw)
359350

360351
/-- The degree of `w ∈ sᶜ` in `G` is at most the degree in `G.between s sᶜ` plus the excluded
361352
vertices from `sᶜ`. -/
362353
theorem degree_le_between_plus' (hw : w ∈ sᶜ) :
363354
G.degree w ≤ (G.between s sᶜ).degree w + sᶜ.card := by
364355
have h_bipartite : (G.between s sᶜ).IsBipartiteWith s ↑(sᶜ) := by
365-
simpa [coe_compl] using between_isBipartiteWith disjoint_compl_right
356+
simpa using between_isBipartiteWith disjoint_compl_right
366357
simp_rw [← card_neighborFinset_eq_degree,
367358
← card_union_of_disjoint (isBipartiteWith_neighborFinset_disjoint' h_bipartite hw)]
368359
exact card_le_card (neighborFinset_subset_between_union' hw)

0 commit comments

Comments
 (0)