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/simple_graph/hom): add basic definitions and lemmas for finite subgraphs #16382

Closed
wants to merge 18 commits into from

Conversation

jchoules
Copy link
Collaborator

@jchoules jchoules commented Sep 4, 2022

We define finsubgraph and its corresponding vertex- and edge-based singletons, and prove some basic ordering lemmas on the singletons. This is primarily preparatory work for proving the De Bruijn-Erdős theorem (generalised to arbitrary finite codomain graphs).

Open in Gitpod

…phs and prove compactness result for homomorphisms therefrom

The principal new theorem added here is `simple_graph.exists_hom_of_all_finite_homs`, the structure of whose proof is heavily cribbed from that of `finset.all_card_le_bUnion_card_iff_exists_injective` in `combinatorics/hall/basic`.
@jchoules jchoules requested a review from kmill September 4, 2022 23:30
@jchoules jchoules added awaiting-review The author would like community review of the PR t-combinatorics Combinatorics labels Sep 5, 2022
@kmill kmill self-assigned this Sep 8, 2022
Copy link
Collaborator

@kmill kmill left a comment

Choose a reason for hiding this comment

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

Thanks for following up with this! I have a few comments for now.

src/combinatorics/simple_graph/hom.lean Outdated Show resolved Hide resolved
src/combinatorics/simple_graph/hom.lean Outdated Show resolved Hide resolved
adj := λ x y, (x = u ∧ y = v) ∨ (y = u ∧ x = v),
adj_sub := λ x y, by {rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩), exact e, exact e.symm},
edge_vert := λ x _, by {rintro (⟨rfl, _⟩ | ⟨_, rfl⟩); simp}},
by simp only [set.finite.insert, set.finite_singleton]⟩
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a branch that defines these two graphs (not as fin_subgraphs though). I'll create a PR soon, merge in some of this PR, and add you as a co-author.

Naming-wise, the temporary names I came up with were simple_graph.singleton_subgraph and simple_graph.subgraph_of_adj, but your names seem good too.

src/combinatorics/simple_graph/hom.lean Outdated Show resolved Hide resolved
jchoules and others added 2 commits September 8, 2022 22:30
…ding fixes suggested in PR

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
@jchoules jchoules added blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. and removed blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. labels Sep 17, 2022
@jchoules
Copy link
Collaborator Author

@kmill Ought I to rebase these changes onto #16435? I'm not sure what the preferred way is in this project to represent such a dependency.

@kmill
Copy link
Collaborator

kmill commented Sep 17, 2022

@jchoules There are a couple of options. The first is to wait until the other PR is merged then merge master, and another is to merge the other PR if you want to get things ready ahead of time. Make sure to merge rather than rebase, otherwise you can get some odd git histories, where bors will get confused and attribute this PR to a long list of co-authors!

@jchoules
Copy link
Collaborator Author

I went for the proactive merge. Given that I still need to wrap @kmill's singleton definitions in finiteness proofs to arrive at the definitions I require for the proof here, I've opted to keep the more context-applicable names for those local versions.

Things I'm still unsure about: whether this theorem actually merits a new module; whether the module is appropriately named if so; whether its constituent defs/lemmas/theorems are appropriately located/organised.

@kmill
Copy link
Collaborator

kmill commented Nov 3, 2022

Let's just say having a new module is fine. If someone decides otherwise later on it's easy enough to move. This also helps constrain how much category theory affects the combinatorics library.

@kmill kmill added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Nov 3, 2022
@jchoules jchoules requested a review from a team as a code owner November 5, 2022 01:05
Copy link
Collaborator

@kmill kmill left a comment

Choose a reason for hiding this comment

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

Once things are wrapped in a namespace and the names are mathlibified, I think I'll be happy to merge it!

@@ -679,7 +679,7 @@ lemma coe_subgraph_injective (G' : G.subgraph) :
function.injective (subgraph.coe_subgraph : G'.coe.subgraph → G.subgraph) :=
function.left_inverse.injective restrict_coe_subgraph

/-! ### Edge deletion -/
/-! #### Edge deletion -/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/-! #### Edge deletion -/
/-! ### Edge deletion -/

@@ -762,7 +762,7 @@ spanning_coe_le_of_le (delete_edges_le s)

end delete_edges

/-! ### Induced subgraphs -/
/-! #### Induced subgraphs -/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/-! #### Induced subgraphs -/
/-! ### Induced subgraphs -/

It looks like perhaps git did something weird when merging? (Usually sectioning in a module is at level 3, but maybe you have some other intent?)


universes u v
variables {V : Type u} {W : Type v} {G : simple_graph V} {F : simple_graph W}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's wrap all of your code (after or before variables as you prefer) in namespace simple_graph so that every declaration ends up in this namespace. Be sure to remove the simple_graph qualifiers on the two declarations that include it!

local infix ` →fg ` : 50 := fin_subgraph_hom

/-- The finite subgraph of G generated by a single vertex. -/
def vertex_singleton (v : V) : G.fin_subgraph := ⟨simple_graph.singleton_subgraph _ v, by simp⟩
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry to ask you to change the name of this, but for consistency I would suggest this:

Suggested change
def vertex_singleton (v : V) : G.fin_subgraph := ⟨simple_graph.singleton_subgraph _ v, by simp⟩
def singleton_fin_subgraph (v : V) : G.fin_subgraph := ⟨simple_graph.singleton_subgraph _ v, by simp⟩

def vertex_singleton (v : V) : G.fin_subgraph := ⟨simple_graph.singleton_subgraph _ v, by simp⟩

/-- The finite subgraph of G generated by a single edge. -/
def edge_singleton {u v : V} (e : G.adj u v) : G.fin_subgraph :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again for consistency reasons (sorry):

Suggested change
def edge_singleton {u v : V} (e : G.adj u v) : G.fin_subgraph :=
def fin_subgraph_of_adj {u v : V} (e : G.adj u v) : G.fin_subgraph :=


/- Lemmas establishing the ordering between edge- and vertex-generated subgraphs. -/

lemma vertex_left_le_edge {u v : V} {e : G.adj u v} : vertex_singleton u ≤ edge_singleton e :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given the previous suggestions, I might name this as

Suggested change
lemma vertex_left_le_edge {u v : V} {e : G.adj u v} : vertex_singleton u ≤ edge_singleton e :=
lemma singleton_fin_subgraph_le_left {u v : V} {e : G.adj u v} : vertex_singleton u ≤ edge_singleton e :=

and the next lemma as singleton_fin_subgraph_le_right.

These are short forms of the way-too-long names like singleton_fin_subgraph_le_fin_subgraph_of_adj_left (I think I'm putting the "left" and "right" in the correct place, but I can't say I have every mathlib naming rule internalized)

end

/-- Given a homomorphism from a subgraph to `F`, construct its restriction to a sub-subgraph. -/
def fin_subgraph_hom_restrict {G' G'' : G.fin_subgraph} (h : G'' ≤ G') (f : G' →fg F) : G'' →fg F :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you name it like so (assuming it's been put into the simple_graph namespace as suggested), then later on rather than giving the full name you can write f.restrict h using dot notation.

Suggested change
def fin_subgraph_hom_restrict {G' G'' : G.fin_subgraph} (h : G'' ≤ G') (f : G' →fg F) : G'' →fg F :=
def fin_subgraph_hom.restrict {G' G'' : G.fin_subgraph} (h : G'' ≤ G') (f : G' →fg F) : G'' →fg F :=


/-- If every finite subgraph of a graph `G` has a homomorphism to a finite graph `F`, then there is
a homomorphism from the whole of `G` to `F`. -/
lemma simple_graph.exists_hom_of_all_finite_homs [finite W]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be a mathlib name for this lemma:

Suggested change
lemma simple_graph.exists_hom_of_all_finite_homs [finite W]
lemma nonempty_hom_of_forall_fin_subgraph_hom [finite W]

There might also be a variant for pi rather than forall since that's more accurate, but I'd need to check how we do that. In any case, h is morally a forall since you just need it to show all the types in the inverse system are nonempty.

(I still find this lemma to be shocking that it's true. Thanks for formalizing it!)

Comment on lines 53 to 55
begin
unfold vertex_singleton edge_singleton, simp,
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can usually combine unfold and simp, since unfold uses simp under the hood to do its unfolding.

Suggested change
begin
unfold vertex_singleton edge_singleton, simp,
end
by simp [vertex_singleton, edge_singleton]

Comment on lines 35 to 36
abbreviation simple_graph.fin_subgraph (G : simple_graph V) :=
{ G' : G.subgraph // G'.verts.finite }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be much better to do something like

structure finsubgraph {V : Type u} (G : simple_graph V) :=
(verts : finset V)
(adj : V → V → Prop)
(adj_sub : ∀ {v w : V}, adj v w → G.adj v w)
(edge_vert : ∀ {v w : V}, adj v w → v ∈ verts)
(symm : symmetric adj . obviously)

and provide the coercion to subgraph G separately.

Also note that I'm changing fin_subgraph to finsubgraph to avoid confusion with fin.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@YaelDillies For now, I was wanting to treat finite subgraphs as a construction local to the module, and I'm not sure whether we want to have a whole theory of finsubgraph. (I guess we should make sure the main theorem statement doesn't mention fin_subgraph or ->fg.)

I can imagine a different design where we pass in set or finset as an extra argument to a generalized subgraph type constructor, for example, to save on a lot of code duplication.

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.

Isn't there a version for homs G → complete_graph α (aka α-colorings) that doesn't require any finiteness/countability?

It would be much better if you split this PR into finite subgraphs + compactness of homs.

src/combinatorics/simple_graph/fin_subgraph.lean Outdated Show resolved Hide resolved
map := λ G' G'' g f, fin_subgraph_hom_restrict (category_theory.le_of_hom g.unop) f, }

/-- If every finite subgraph of a graph `G` has a homomorphism to a finite graph `F`, then there is
a homomorphism from the whole of `G` to `F`. -/
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose we ought to mention what this is related to in the literature:

Suggested change
a homomorphism from the whole of `G` to `F`. -/
a homomorphism from the whole of `G` to `F`.
This is the graph homomorphism version of the **De Bruijn-Erdős theorem**. -/

@YaelDillies
Copy link
Collaborator

To follow on my previous comment, you can get rid of the countability assumption on the big graph by considering a hom H → F (H : subgraph G, G : simple_graph α, F : simple_graph β) as a map α → β (padded with a junk value), and then applying Tychonoff (because β is compact with the discrete topology) to find a convergent subsequence, which by construction corresponds to a hom G → F.

@jchoules
Copy link
Collaborator Author

Doesn't β have to be finite to be compact under the discrete topology? That's already the only type whose size is constrained in the current proof statement.

@YaelDillies
Copy link
Collaborator

Can you update the PR title/description? It doesn't match the content of this PR at all anymore.

@jchoules jchoules changed the title feat(combinatorics/simple_graph/hom): add definition of finite subgraphs and prove compactness result for homomorphisms therefrom feat(combinatorics/simple_graph/hom): add basic definitions and lemmas for finite subgraphs Nov 19, 2022
@kmill
Copy link
Collaborator

kmill commented Nov 20, 2022

I'm sorry to ask you to do this, but it would be much easier for me if you revert this PR back to this commit, since I would be happy to merge it as-is: https://github.com/leanprover-community/mathlib/blob/1e3380bf80ae9fcc74de8c16bfdf6f4f9d1d4a65/src/combinatorics/simple_graph/finsubgraph.lean

The reason is that the stuff about finsubgraph doesn't make sense without it -- I have a hard time seeing finsubgraph_hom being used for anything except for its use in nonempty_hom_of_forall_finite_subgraph_hom. (I believe we should not develop finsubgraph any more if we can help it, though we can revisit this if someone finds it would be helpful.)

If there exists a reviewer who is happy to review a PR without splitting it, then you generally do not need to split it (especially for such a small PR). PRs that interleave refactors with new material should be split, but this PR is straightforward.

@kmill
Copy link
Collaborator

kmill commented Nov 20, 2022

@YaelDillies What are you referring to regarding countability assumptions? This PR is (or was) the application of the Tychonoff theorem to the maximal generality you can apply it.

The key lemma it uses is https://leanprover-community.github.io/mathlib_docs/topology/category/Top/limits.html#nonempty_sections_of_fintype_inverse_system, which is a specialization of https://leanprover-community.github.io/mathlib_docs/topology/category/Top/limits.html#Top.nonempty_limit_cone_of_compact_t2_cofiltered_system to finite sets (since those are the compact discrete spaces). That lemma in turn uses the Tychonoff theorem directly, and the core part of the proof is showing that the subspace corresponding to the inverse system in the infinite product space is an intersection of nonempty closed subsets.

@jchoules
Copy link
Collaborator Author

If we're agreed that the content of the lemma is what it's desired to be, then yeah I can reinstate it no trouble. I agree that finsubgraph doesn't currently need any development beyond what's convenient for this proof, and with your and Yaël's earlier remarks that it would benefit from restructuring if it were to enter public use in future.

@YaelDillies
Copy link
Collaborator

Sorry Kyle, I think I got variables-confused once again.

@jchoules jchoules added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Feb 9, 2023
@kmill
Copy link
Collaborator

kmill commented Feb 28, 2023

Thanks!

bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Feb 28, 2023
bors bot pushed a commit that referenced this pull request Feb 28, 2023
…s for finite subgraphs (#16382)

We define `finsubgraph` and its corresponding vertex- and edge-based singletons, and prove some basic ordering lemmas on the singletons. This is primarily preparatory work for proving the De Bruijn-Erdős theorem (generalised to arbitrary finite codomain graphs).

<!-- The text above the `

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
@bors
Copy link

bors bot commented Feb 28, 2023

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Feb 28, 2023
…s for finite subgraphs (#16382)

We define `finsubgraph` and its corresponding vertex- and edge-based singletons, and prove some basic ordering lemmas on the singletons. This is primarily preparatory work for proving the De Bruijn-Erdős theorem (generalised to arbitrary finite codomain graphs).

<!-- The text above the `

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
@bors
Copy link

bors bot commented Feb 28, 2023

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(combinatorics/simple_graph/hom): add basic definitions and lemmas for finite subgraphs [Merged by Bors] - feat(combinatorics/simple_graph/hom): add basic definitions and lemmas for finite subgraphs Feb 28, 2023
@bors bors bot closed this Feb 28, 2023
@bors bors bot deleted the graph_homs_compact branch February 28, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-combinatorics Combinatorics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants