-
Notifications
You must be signed in to change notification settings - Fork 297
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
Conversation
…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`.
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.
Thanks for following up with this! I have a few comments for now.
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]⟩ |
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 have a branch that defines these two graphs (not as fin_subgraph
s 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.
…ding fixes suggested in PR Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@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! |
…ons of edge- and vertex-based singletons
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. |
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. |
…sing from `refine`
…graph` This module has more to do with finite subgraphs than with graph homomorphisms in general.
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.
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 -/ |
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.
/-! #### Edge deletion -/ | |
/-! ### Edge deletion -/ |
@@ -762,7 +762,7 @@ spanning_coe_le_of_le (delete_edges_le s) | |||
|
|||
end delete_edges | |||
|
|||
/-! ### Induced subgraphs -/ | |||
/-! #### Induced subgraphs -/ |
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.
/-! #### 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} | ||
|
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.
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⟩ |
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.
Sorry to ask you to change the name of this, but for consistency I would suggest this:
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 := |
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.
Again for consistency reasons (sorry):
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 := |
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.
Given the previous suggestions, I might name this as
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 := |
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 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.
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] |
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.
This might be a mathlib name for this lemma:
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!)
begin | ||
unfold vertex_singleton edge_singleton, simp, | ||
end |
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.
You can usually combine unfold
and simp
, since unfold
uses simp
under the hood to do its unfolding.
begin | |
unfold vertex_singleton edge_singleton, simp, | |
end | |
by simp [vertex_singleton, edge_singleton] |
abbreviation simple_graph.fin_subgraph (G : simple_graph V) := | ||
{ G' : G.subgraph // G'.verts.finite } |
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 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
.
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.
@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.
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.
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.
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`. -/ |
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 suppose we ought to mention what this is related to in the literature:
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**. -/ |
…ntation from botched merge
…ame module, defs, lemmas
…lemma and restate it without reference to module internals
…lemma for separate pr-ing
To follow on my previous comment, you can get rid of the countability assumption on the big graph by considering a hom |
Doesn't |
Can you update the PR title/description? It doesn't match the content of this PR at all anymore. |
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 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. |
@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. |
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 |
Sorry Kyle, I think I got |
Thanks! bors r+ |
…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>
Build failed (retrying...): |
…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>
Pull request successfully merged into master. Build succeeded: |
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).