Maps between graphs #
This file defines two functions and three structures relating graphs. The structures directly correspond to the classification of functions as injective, surjective and bijective, and have corresponding notation.
Main definitions #
SimpleGraph.map
: the graph obtained by pushing the adjacency relation through an injective function between vertex types.SimpleGraph.comap
: the graph obtained by pulling the adjacency relation behind an arbitrary function between vertex types.SimpleGraph.induce
: the subgraph induced by the given vertex set, a wrapper aroundcomap
.SimpleGraph.spanningCoe
: the supergraph without any additional edges, a wrapper aroundmap
.SimpleGraph.Hom
,G →g H
: a graph homomorphism fromG
toH
.SimpleGraph.Embedding
,G ↪g H
: a graph embedding ofG
inH
.SimpleGraph.Iso
,G ≃g H
: a graph isomorphism betweenG
andH
.
Note that a graph embedding is a stronger notion than an injective graph homomorphism, since its image is an induced subgraph.
Implementation notes #
Morphisms of graphs are abbreviations for RelHom
, RelEmbedding
and RelIso
.
To make use of pre-existing simp lemmas, definitions involving morphisms are
abbreviations as well.
Map and comap #
Given an injective function, there is a covariant induced map on graphs by pushing forward the adjacency relation.
This is injective (see SimpleGraph.map_injective
).
Equations
- SimpleGraph.map f G = SimpleGraph.mk (Relation.Map G.Adj ⇑f ⇑f)
Instances For
Equations
- SimpleGraph.instDecidableMapAdj G = inst
Given a function, there is a contravariant induced map on graphs by pulling back the
adjacency relation.
This is one of the ways of creating induced graphs. See SimpleGraph.induce
for a wrapper.
This is surjective when f
is injective (see SimpleGraph.comap_surjective
).
Equations
- SimpleGraph.comap f G = SimpleGraph.mk fun (u v : V) => G.Adj (f u) (f v)
Instances For
Equations
- SimpleGraph.instDecidableComapAdj f G x✝ x = inst (f x✝) (f x)
Given a family of vertex types indexed by ι
, pulling back from ⊤ : SimpleGraph ι
yields the complete multipartite graph on the family.
Two vertices are adjacent if and only if their indices are not equal.
Equations
- SimpleGraph.completeMultipartiteGraph V = SimpleGraph.comap Sigma.fst ⊤
Instances For
Equivalent types have equivalent simple graphs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Induced graphs #
Restrict a graph to the vertices in the set s
, deleting all edges incident to vertices
outside the set. This is a wrapper around SimpleGraph.comap
.
Equations
- SimpleGraph.induce s G = SimpleGraph.comap (⇑(Function.Embedding.subtype fun (x : V) => x ∈ s)) G
Instances For
Given a graph on a set of vertices, we can make it be a SimpleGraph V
by
adding in the remaining vertices without adding in any additional edges.
This is a wrapper around SimpleGraph.map
.
Equations
- SimpleGraph.spanningCoe G = SimpleGraph.map (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Homomorphisms, embeddings and isomorphisms #
A graph homomorphism is a map on vertex sets that respects adjacency relations.
The notation G →g G'
represents the type of graph homomorphisms.
Instances For
A graph embedding is an embedding f
such that for vertices v w : V
,
G.Adj (f v) (f w) ↔ G.Adj v w
. Its image is an induced subgraph of G'.
The notation G ↪g G'
represents the type of graph embeddings.
Instances For
A graph isomorphism is a bijective map on vertex sets that respects adjacency relations.
The notation G ≃g G'
represents the type of graph isomorphisms.
Instances For
A graph homomorphism is a map on vertex sets that respects adjacency relations.
The notation G →g G'
represents the type of graph homomorphisms.
Equations
- SimpleGraph.«term_→g_» = Lean.ParserDescr.trailingNode `SimpleGraph.term_→g_ 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " →g ") (Lean.ParserDescr.cat `term 51))
Instances For
A graph embedding is an embedding f
such that for vertices v w : V
,
G.Adj (f v) (f w) ↔ G.Adj v w
. Its image is an induced subgraph of G'.
The notation G ↪g G'
represents the type of graph embeddings.
Equations
- SimpleGraph.«term_↪g_» = Lean.ParserDescr.trailingNode `SimpleGraph.term_↪g_ 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ↪g ") (Lean.ParserDescr.cat `term 51))
Instances For
A graph isomorphism is a bijective map on vertex sets that respects adjacency relations.
The notation G ≃g G'
represents the type of graph isomorphisms.
Equations
- SimpleGraph.«term_≃g_» = Lean.ParserDescr.trailingNode `SimpleGraph.term_≃g_ 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ≃g ") (Lean.ParserDescr.cat `term 51))
Instances For
The identity homomorphism from a graph to itself.
Instances For
Equations
- (_ : Subsingleton (G →g H)) = (_ : Subsingleton (G →g H))
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
The map between edge sets induced by a homomorphism.
The underlying map on edges is given by Sym2.map
.
Equations
- SimpleGraph.Hom.mapEdgeSet f e = { val := Sym2.map ⇑f ↑e, property := (_ : Sym2.map ⇑f ↑e ∈ SimpleGraph.edgeSet G') }
Instances For
The map between neighbor sets induced by a homomorphism.
Equations
- SimpleGraph.Hom.mapNeighborSet f v w = { val := f ↑w, property := (_ : f ↑w ∈ SimpleGraph.neighborSet G' (f v)) }
Instances For
The map between darts induced by a homomorphism.
Equations
- SimpleGraph.Hom.mapDart f d = { toProd := Prod.map (⇑f) (⇑f) d.toProd, is_adj := (_ : G'.Adj (f d.1.1) (f d.1.2)) }
Instances For
The induced map for spanning subgraphs, which is the identity on vertices.
Equations
- SimpleGraph.Hom.mapSpanningSubgraphs h = { toFun := fun (x : V) => x, map_rel' := (_ : ∀ {a b : V}, G.Adj a b → G'.Adj ((fun (x : V) => x) a) ((fun (x : V) => x) b)) }
Instances For
Every graph homomorphism from a complete graph is injective.
There is a homomorphism to a graph from a comapped graph.
When the function is injective, this is an embedding (see SimpleGraph.Embedding.comap
).
Equations
- SimpleGraph.Hom.comap f G = { toFun := f, map_rel' := (_ : ∀ (a a_1 : V), (SimpleGraph.comap f G).Adj a a_1 → G.Adj (f a) (f a_1)) }
Instances For
Composition of graph homomorphisms.
Equations
- SimpleGraph.Hom.comp f' f = RelHom.comp f' f
Instances For
The graph homomorphism from a smaller graph to a bigger one.
Equations
- SimpleGraph.Hom.ofLE h = { toFun := id, map_rel' := h }
Instances For
The identity embedding from a graph to itself.
Equations
- SimpleGraph.Embedding.refl = RelEmbedding.refl G.Adj
Instances For
An embedding of graphs gives rise to a homomorphism of graphs.
Equations
Instances For
A graph embedding induces an embedding of edge sets.
Equations
- SimpleGraph.Embedding.mapEdgeSet f = { toFun := SimpleGraph.Hom.mapEdgeSet (RelEmbedding.toRelHom f), inj' := (_ : Function.Injective (SimpleGraph.Hom.mapEdgeSet (RelEmbedding.toRelHom f))) }
Instances For
A graph embedding induces an embedding of neighbor sets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given an injective function, there is an embedding from the comapped graph into the original graph.
Equations
- SimpleGraph.Embedding.comap f G = { toEmbedding := f, map_rel_iff' := (_ : ∀ (a a_1 : V), G.Adj (f a) (f a_1) ↔ (SimpleGraph.comap (⇑f) G).Adj a a_1) }
Instances For
Given an injective function, there is an embedding from a graph into the mapped graph.
Equations
- SimpleGraph.Embedding.map f G = { toEmbedding := f, map_rel_iff' := (_ : ∀ (a a_1 : V), (SimpleGraph.map f G).Adj (f a) (f a_1) ↔ G.Adj a a_1) }
Instances For
Induced graphs embed in the original graph.
Note that if G.induce s = ⊤
(i.e., if s
is a clique) then this gives the embedding of a
complete graph.
Equations
- SimpleGraph.Embedding.induce s = SimpleGraph.Embedding.comap (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Graphs on a set of vertices embed in their spanningCoe
.
Equations
- SimpleGraph.Embedding.spanningCoe G = SimpleGraph.Embedding.map (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Embeddings of types induce embeddings of complete graphs on those types.
Equations
- SimpleGraph.Embedding.completeGraph f = { toEmbedding := f, map_rel_iff' := (_ : ∀ (a a_1 : α), ⊤.Adj (f a) (f a_1) ↔ ⊤.Adj a a_1) }
Instances For
Composition of graph embeddings.
Equations
- SimpleGraph.Embedding.comp f' f = RelEmbedding.trans f f'
Instances For
The restriction of a morphism of graphs to induced subgraphs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given an inclusion of vertex subsets, the induced embedding on induced graphs.
This is not an abbreviation for induceHom
since we get an embedding in this case.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The identity isomorphism of a graph with itself.
Equations
- SimpleGraph.Iso.refl = RelIso.refl G.Adj
Instances For
An isomorphism of graphs gives rise to an embedding of graphs.
Equations
Instances For
An isomorphism of graphs gives rise to a homomorphism of graphs.
Instances For
The inverse of a graph isomorphism.
Equations
Instances For
An isomorphism of graphs induces an equivalence of edge sets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A graph isomorphism induces an equivalence of neighbor sets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a bijection, there is an embedding from the comapped graph into the original graph.
Equations
- SimpleGraph.Iso.comap f G = { toEquiv := f, map_rel_iff' := (_ : ∀ (a a_1 : V), G.Adj (f a) (f a_1) ↔ (SimpleGraph.comap (⇑f) G).Adj a a_1) }
Instances For
Given an injective function, there is an embedding from a graph into the mapped graph.
Equations
- SimpleGraph.Iso.map f G = { toEquiv := f, map_rel_iff' := (_ : ∀ (a a_1 : V), (SimpleGraph.map (Equiv.toEmbedding f) G).Adj (f a) (f a_1) ↔ G.Adj a a_1) }
Instances For
Equivalences of types induce isomorphisms of complete graphs on those types.
Equations
- SimpleGraph.Iso.completeGraph f = { toEquiv := f, map_rel_iff' := (_ : ∀ (a a_1 : α), ⊤.Adj (f a) (f a_1) ↔ ⊤.Adj a a_1) }
Instances For
Composition of graph isomorphisms.
Equations
- SimpleGraph.Iso.comp f' f = RelIso.trans f f'
Instances For
The graph induced on Set.univ
is isomorphic to the original graph.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a graph over a finite vertex type V
and a proof hc
that Fintype.card V = n
,
G.overFin n
is an isomorphic (as shown in overFinIso
) graph over Fin n
.
Equations
- SimpleGraph.overFin G hc = SimpleGraph.mk fun (x y : Fin n) => G.Adj ((Fintype.equivFinOfCardEq hc).symm x) ((Fintype.equivFinOfCardEq hc).symm y)
Instances For
The isomorphism between G
and G.overFin hc
.
Equations
- One or more equations did not get rendered due to their size.