Skip to content
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

[Merged by Bors] - feat(Combinatorics/SimpleGraph): A graph has 3-clique iff it has a cycle of length 3 #11434

Closed
wants to merge 11 commits into from

Conversation

Rida-Hamadani
Copy link
Collaborator

This is nice to have because when combined with is3Clique_iff, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.


Open in Gitpod

Mathlib/Combinatorics/SimpleGraph/Clique.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/SimpleGraph/Clique.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/SimpleGraph/Clique.lean Outdated Show resolved Hide resolved
@Rida-Hamadani Rida-Hamadani added the awaiting-review The author would like community review of the PR label Mar 16, 2024
@Rida-Hamadani Rida-Hamadani changed the title feat(Combinatorics/SimpleGraph): Prove that graphs with 3-clique must have a cycle. feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle Mar 16, 2024
@Rida-Hamadani Rida-Hamadani changed the title feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle of size 3 Mar 18, 2024
@Rida-Hamadani Rida-Hamadani changed the title feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle of size 3 feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle of length 3 Mar 18, 2024
@Rida-Hamadani Rida-Hamadani marked this pull request as draft March 18, 2024 20:55
@Rida-Hamadani Rida-Hamadani changed the title feat(Combinatorics/SimpleGraph): Graphs with 3-clique have a cycle of length 3 feat(Combinatorics/SimpleGraph): A graph has 3-clique iff it has a cycle of length 3 Mar 18, 2024
@Rida-Hamadani Rida-Hamadani marked this pull request as ready for review March 18, 2024 22:47
Comment on lines +205 to +210
theorem is3Clique_iff_exists_cycle_length_three :
(∃ s : Finset α, G.IsNClique 3 s) ↔ ∃ (u : α) (w : G.Walk u u), w.IsCycle ∧ w.length = 3 := by
simp_rw [is3Clique_iff, isCycle_def]
exact
⟨(fun ⟨_, a, _, _, hab, hac, hbc, _⟩ => ⟨a, cons hab (cons hbc (cons hac.symm nil)), by aesop⟩),
(fun ⟨_, .cons hab (.cons hbc (.cons hca nil)), _, _⟩ => ⟨_, _, _, _, hab, hca.symm, hbc, rfl⟩)⟩
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in saying this is true as an Equiv between subtypes too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too, but I'm not sure how to state it that way (I'm new to Lean). Do you have any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in the FRO office hours this morning, and I think @Rida-Hamadani is looking into this now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'm doubting the existence of an Equiv now. At least this Equiv:

{s : Finset α // G.IsNClique 3 s} ≃ (u : α) × {w : G.Walk u u // w.IsCycle ∧ w.length = 3}

My reasoning is that any function that maps length 3 cycles to 3-cliques will not be injective, since let's say s = {a, b, c}, then the following cycles will map to s: abc, bca, cab, etc.

As I understand the way walks are defined in mathlib, lean treats the cycles above as different. Maybe an Equiv can be established if there is a way to tell lean that these cycles are the same?

Do you agree @eric-wieser ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To state this Equiv right, you need to quotient the right-hand side by cycle rotation and reversal. That seems like more trouble than it's worth if no one needs it right now, so I'm happy with this theorem stated as an iff.

By the way, the mathlib way of defining a cycle is how many graph theory textbooks define them. One of those technical details combinatorialists sweep under the rug is the difference between (1) a cycle graph, (2) a subgraph that's a cycle, (3) a collection of vertices that form a cycle, and (4) a walk that's a cycle. The definition of G.Walk is the fourth, and this theorem is relating the third and the fourth. At least the second and third are "the same" using induced graphs, but there are more of the fourth than the third due to reflections and rotations.

Combinatorialists can navigate these by force of pure intuition, but in mathlib we have to fill in the gaps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the insights! I think that if someone has to go through the trouble of formulating this Equiv and proving it, then it should be between (3) and (4) in general instead of it being just the case where the number of vertices is 3, and as far as I know, the general definition of (3) doesn't seem to exist yet, adding even more work to be done.

Maybe I (or someone else) will work on this later on, but until then, I think it is convenient to have a way to deduce that 3 adjacent vertices give a cycle. The whole reason I proved this statement is to use that fact in a proof of the Hoffman-Singleton theorem.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To state this Equiv right, you need to quotient the right-hand side by cycle rotation and reversal. That seems like more trouble than it's worth if no one needs it right now, so I'm happy with this theorem stated as an iff.

Actually, there is another solution, which is to add the cycle rotation and reversal on the LHS:
{f : Fin 3 → α // G.IsNClique 3 s} ≃ ∑ u : α, {w : G.Walk u u // w.IsCycle ∧ w.length = 3}
But that's far enough away from the current statement that it's worth having the statement anyway.

@Rida-Hamadani Rida-Hamadani added t-combinatorics Combinatorics new-contributor This PR was made by a contributor with fewer than 5 merged PRs. Welcome to the community! labels Mar 24, 2024
Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

maintainer merge

Copy link

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🎉

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Mar 29, 2024
mathlib-bors bot pushed a commit that referenced this pull request Mar 29, 2024
…cle of length 3 (#11434)

This is nice to have because when combined with `is3Clique_iff`, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.



Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com>
@mathlib-bors
Copy link

mathlib-bors bot commented Mar 29, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(Combinatorics/SimpleGraph): A graph has 3-clique iff it has a cycle of length 3 [Merged by Bors] - feat(Combinatorics/SimpleGraph): A graph has 3-clique iff it has a cycle of length 3 Mar 29, 2024
@mathlib-bors mathlib-bors bot closed this Mar 29, 2024
@mathlib-bors mathlib-bors bot deleted the rida/SimpleGraph branch March 29, 2024 15:34
Louddy pushed a commit that referenced this pull request Apr 15, 2024
…cle of length 3 (#11434)

This is nice to have because when combined with `is3Clique_iff`, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.



Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com>
atarnoam pushed a commit that referenced this pull request Apr 16, 2024
…cle of length 3 (#11434)

This is nice to have because when combined with `is3Clique_iff`, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.



Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com>
uniwuni pushed a commit that referenced this pull request Apr 19, 2024
…cle of length 3 (#11434)

This is nice to have because when combined with `is3Clique_iff`, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.



Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com>
callesonne pushed a commit that referenced this pull request Apr 22, 2024
…cle of length 3 (#11434)

This is nice to have because when combined with `is3Clique_iff`, we will be able to prove that a graph has a cycle by just proving that 3 vertices are pairwise adjacent.



Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer-merge new-contributor This PR was made by a contributor with fewer than 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-combinatorics Combinatorics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants