Skip to content

Commit 4d5d9a7

Browse files
Add Bipartite section
1 parent 125bc59 commit 4d5d9a7

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Bipartite.lean

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ This file proves results about bipartite simple graphs, including several double
3434
See `SimpleGraph.sum_degrees_eq_twice_card_edges` for the general version, and
3535
`SimpleGraph.isBipartiteWith_sum_degrees_eq_card_edges'` for the version from the "right".
3636
37+
* `SimpleGraph.between`; the simple graph `G.between s t` is the subgraph of `G` containing edges
38+
that connect a vertex in the set `s` to a vertex in the set `t`.
39+
3740
## Implementation notes
3841
3942
For the formulation of double-counting arguments where a bipartite graph is considered as a
@@ -241,4 +244,90 @@ theorem isBipartiteWith_sum_degrees_eq_card_edges' (h : G.IsBipartiteWith s t) :
241244

242245
end IsBipartiteWith
243246

247+
section Between
248+
249+
/-- The subgraph of `G` containing edges that connect a vertex in the set `s` to a vertex in the
250+
set `t`. -/
251+
def between (s t : Set V) (G : SimpleGraph V) : SimpleGraph V where
252+
Adj v w := G.Adj v w ∧ (v ∈ s ∧ w ∈ t ∨ v ∈ t ∧ w ∈ s)
253+
symm v w := by tauto
254+
255+
lemma between_adj : (G.between s t).Adj v w ↔ G.Adj v w ∧ (v ∈ s ∧ w ∈ t ∨ v ∈ t ∧ w ∈ s) := by rfl
256+
257+
lemma between_comm : G.between s t = G.between t s := by
258+
ext v w; simp [between_adj, or_comm]
259+
260+
instance [DecidableRel G.Adj] [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] :
261+
DecidableRel (G.between s t).Adj :=
262+
inferInstanceAs (DecidableRel fun v w ↦ G.Adj v w ∧ (v ∈ s ∧ w ∈ t ∨ v ∈ t ∧ w ∈ s))
263+
264+
/-- `G.between s t` is bipartite if the sets `s` and `t` are disjoint. -/
265+
theorem between_isBipartiteWith (h : Disjoint s t) : (G.between s t).IsBipartiteWith s t where
266+
disjoint := h
267+
mem_of_adj v w := by
268+
rw [between_adj]
269+
tauto
270+
271+
/-- The neighbor set of `v ∈ s` in `G.between s sᶜ` excludes the vertices in `s` adjacent to `v`
272+
in `G`. -/
273+
lemma neighborSet_subset_between_union (hv : v ∈ s) :
274+
G.neighborSet v ⊆ (G.between s sᶜ).neighborSet v ∪ s := by
275+
simp_rw [neighborSet, between_adj, Set.setOf_subset, Set.mem_union, Set.mem_setOf]
276+
intro w hadj
277+
by_cases hw : w ∈ s
278+
all_goals tauto
279+
280+
/-- The neighbor set of `w ∈ sᶜ` in `G.between s sᶜ` excludes the vertices in `sᶜ` adjacent to `w`
281+
in `G`. -/
282+
lemma neighborSet_subset_between_union' (hw : w ∈ sᶜ) :
283+
G.neighborSet w ⊆ (G.between s sᶜ).neighborSet w ∪ sᶜ := by
284+
simp_rw [neighborSet, between_adj, Set.setOf_subset, Set.mem_union, Set.mem_setOf]
285+
intro v hadj
286+
by_cases hv : v ∈ s
287+
all_goals tauto
288+
289+
variable [DecidableEq V] [Fintype V] {s t : Finset V} [DecidableRel G.Adj]
290+
291+
/-- The neighbor finset of `v ∈ s` in `G.between s sᶜ` excludes the vertices in `s` adjacent to `v`
292+
in `G`. -/
293+
lemma neighborFinset_subset_between_union (hv : v ∈ s) :
294+
G.neighborFinset v ⊆ (G.between s sᶜ).neighborFinset v ∪ s := by
295+
conv_rhs =>
296+
rhs; rw [← toFinset_coe s]
297+
simp_rw [neighborFinset_def, ← Set.toFinset_union, Set.toFinset_subset_toFinset]
298+
exact neighborSet_subset_between_union hv
299+
300+
/-- The degree of `v ∈ s` in `G` is at most the degree in `G.between s sᶜ` plus the excluded
301+
vertices from `s`. -/
302+
theorem degree_le_between_plus (hv : v ∈ s) :
303+
G.degree v ≤ (G.between s sᶜ).degree v + s.card := by
304+
have h_bipartite : (G.between s sᶜ).IsBipartiteWith s ↑(sᶜ) := by
305+
simpa [coe_compl] using between_isBipartiteWith disjoint_compl_right
306+
simp_rw [← card_neighborFinset_eq_degree,
307+
← card_union_of_disjoint (isBipartiteWith_neighborFinset_disjoint h_bipartite hv)]
308+
exact card_le_card (neighborFinset_subset_between_union hv)
309+
310+
/-- The neighbor finset of `w ∈ sᶜ` in `G.between s sᶜ` excludes the vertices in `sᶜ` adjacent to
311+
`w` in `G`. -/
312+
lemma neighborFinset_subset_between_union' (hw : w ∈ sᶜ) :
313+
G.neighborFinset w ⊆ (G.between s sᶜ).neighborFinset w ∪ sᶜ := by
314+
conv_rhs =>
315+
rhs; rw [← toFinset_coe s]
316+
simp_rw [neighborFinset_def, ← Set.toFinset_compl, ← Set.toFinset_union,
317+
Set.toFinset_subset_toFinset]
318+
apply neighborSet_subset_between_union'
319+
rwa [← mem_coe, coe_compl] at hw
320+
321+
/-- The degree of `w ∈ sᶜ` in `G` is at most the degree in `G.between s sᶜ` plus the excluded
322+
vertices from `sᶜ`. -/
323+
theorem degree_le_between_plus' (hw : w ∈ sᶜ) :
324+
G.degree w ≤ (G.between s sᶜ).degree w + sᶜ.card := by
325+
have h_bipartite : (G.between s sᶜ).IsBipartiteWith s ↑(sᶜ) := by
326+
simpa [coe_compl] using between_isBipartiteWith disjoint_compl_right
327+
simp_rw [← card_neighborFinset_eq_degree,
328+
← card_union_of_disjoint (isBipartiteWith_neighborFinset_disjoint' h_bipartite hw)]
329+
exact card_le_card (neighborFinset_subset_between_union' hw)
330+
331+
end Between
332+
244333
end SimpleGraph

0 commit comments

Comments
 (0)