-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(Combinatorics/SimpleGraph/Bipartite): upper bound on the number of edges of a bipartite graph #34315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(Combinatorics/SimpleGraph/Bipartite): upper bound on the number of edges of a bipartite graph #34315
Changes from 12 commits
7d79324
3738639
cf43a39
58c5b43
19acaef
4e9de3c
1c28de1
71b3a90
28b15c3
8b8497a
5f16c48
fe4b98e
597410d
217b66d
5bba909
9771749
a3b60da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -445,4 +445,56 @@ theorem degree_le_between_add_compl (hw : w ∈ sᶜ) : | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| end Between | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| section completeBipartiteGraph | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| variable {W₁ W₂ : Type*} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| theorem completeBipartiteGraph_edgeSet : (completeBipartiteGraph W₁ W₂).edgeSet = | ||||||||||||||||||||||||||||||||||||||||||||||||
| Set.range (fun x : W₁ × W₂ ↦ s(.inl x.1, .inr x.2)) := by | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+456
to
+457
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| refine Set.ext <| Sym2.ind fun u v ↦ ⟨fun h ↦ ?_, fun ⟨⟨a, b⟩, z⟩ ↦ ?_⟩ | ||||||||||||||||||||||||||||||||||||||||||||||||
| · cases u <;> cases v <;> simp_all | ||||||||||||||||||||||||||||||||||||||||||||||||
| · grind [completeBipartiteGraph_adj, mem_edgeSet] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| theorem completeBipartiteGraph_edgeSet_encard : | ||||||||||||||||||||||||||||||||||||||||||||||||
| (completeBipartiteGraph W₁ W₂).edgeSet.encard = ENat.card W₁ * ENat.card W₂ := by | ||||||||||||||||||||||||||||||||||||||||||||||||
| rw [completeBipartiteGraph_edgeSet, ← ENat.card_prod, ← Set.encard_univ, ← Set.image_univ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| exact Function.Injective.encard_image (by grind [Function.Injective]) Set.univ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| theorem IsBipartiteWith.nonempty_embedding_completeBipartiteGraph_edgeSet | ||||||||||||||||||||||||||||||||||||||||||||||||
| (hG : G.IsBipartiteWith s t) : | ||||||||||||||||||||||||||||||||||||||||||||||||
| Nonempty (G.edgeSet ↪ (completeBipartiteGraph s t).edgeSet) := by | ||||||||||||||||||||||||||||||||||||||||||||||||
| refine ⟨⟨fun ⟨x, hx⟩ ↦ ?_, fun _ _ _ ↦ ?_⟩⟩ | ||||||||||||||||||||||||||||||||||||||||||||||||
| · by_cases! h : x.out.1 ∈ s | ||||||||||||||||||||||||||||||||||||||||||||||||
| · refine ⟨s(.inl ⟨x.out.1, h⟩, .inr ⟨x.out.2, ?_⟩), by simp⟩ | ||||||||||||||||||||||||||||||||||||||||||||||||
| grind [hG.disjoint, hG.mem_of_adj, mem_edgeSet, Sym2.eq_out] | ||||||||||||||||||||||||||||||||||||||||||||||||
| · refine ⟨s(.inr ⟨x.out.1, ?_⟩, .inl ⟨x.out.2, ?_⟩), by simp⟩ | ||||||||||||||||||||||||||||||||||||||||||||||||
| · grind [hG.mem_of_adj <| G.mem_edgeSet.mpr <| x.eq_out ▸ hx] | ||||||||||||||||||||||||||||||||||||||||||||||||
| · grind [hG.disjoint, hG.mem_of_adj, mem_edgeSet, Sym2.eq_out] | ||||||||||||||||||||||||||||||||||||||||||||||||
| · grind [Sym2.eq_out] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| theorem IsBipartiteWith.nonempty_embedding_completeBipartiteGraph_edgeSet | |
| (hG : G.IsBipartiteWith s t) : | |
| Nonempty (G.edgeSet ↪ (completeBipartiteGraph s t).edgeSet) := by | |
| refine ⟨⟨fun ⟨x, hx⟩ ↦ ?_, fun _ _ _ ↦ ?_⟩⟩ | |
| · by_cases! h : x.out.1 ∈ s | |
| · refine ⟨s(.inl ⟨x.out.1, h⟩, .inr ⟨x.out.2, ?_⟩), by simp⟩ | |
| grind [hG.disjoint, hG.mem_of_adj, mem_edgeSet, Sym2.eq_out] | |
| · refine ⟨s(.inr ⟨x.out.1, ?_⟩, .inl ⟨x.out.2, ?_⟩), by simp⟩ | |
| · grind [hG.mem_of_adj <| G.mem_edgeSet.mpr <| x.eq_out ▸ hx] | |
| · grind [hG.disjoint, hG.mem_of_adj, mem_edgeSet, Sym2.eq_out] | |
| · grind [Sym2.eq_out] | |
| /-- An embedding of the edges of a bipartite graph into the edges of the complete bipartite graph -/ | |
| def IsBipartiteWith.edgeSetEmbeddingCompleteBipartiteGraph [DecidableRel (· ∈ · : V → Set V → _)] | |
| (hG : G.IsBipartiteWith s t) : G.edgeSet ↪ (completeBipartiteGraph s t).edgeSet where | |
| toFun := fun ⟨e, he⟩ ↦ | |
| e.hrec (fun u v h ↦ hG.mem_of_adj h |>.by_cases | |
| (fun h ↦ ⟨s(.inl ⟨u, h.left⟩, .inr ⟨v, h.right⟩), .inl ⟨rfl, rfl⟩⟩) | |
| (fun h ↦ ⟨s(.inl ⟨v, h.right⟩, .inr ⟨u, h.left⟩), .inl ⟨rfl, rfl⟩⟩) | |
| ) (fun _ _ ↦ Function.hfunext (by grind) <| by grind [Or.by_cases, hG.disjoint]) he | |
| inj' := by | |
| rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ | |
| change (if _ : _ then _ else _) = (if _ : _ then _ else _) → _ | |
| grind |
The theorem that uses this just needs to call classical before to satisfy the DecidableRel
(edit: fixed after the signature of Sym2.hrec was changed, requires merging master)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we adopt this we can also get rid of Sym2.eq_out, though stylistically I'm unsure which one is preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this version (with a computable function), but I'm not sure too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generally better to use recursion on the quotient rather than .out, and in this case actually not for computability reasons!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think I have a lemma somewhere which combines Sym2.hrec with the hfunext call, let me go looking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have a def that combines the two, I inlined it before posting the code above.
Just PRed it in #34909 if you're interested (but it shouldn't block this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| end completeBipartiteGraph | |
| end completeBipartiteGraph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same below