Documentation

Mathlib.Combinatorics.SimpleGraph.Copy

Containment of graphs #

This file introduces the concept of one simple graph containing a copy of another.

For two simple graph G and H, a copy of G in H is a (not necessarily induced) subgraph of H isomorphic to G.

If there exists a copy of G in H, we say that H contains G. This is equivalent to saying that there is an injective graph homomorphism G → H them (this is not the same as a graph embedding, as we do not require the subgraph to be induced).

If there exists an induced copy of G in H, we say that H inducingly contains G. This is equivalent to saying that there is a graph embedding G ↪ H.

Main declarations #

Containment:

Induced containment:

Notation #

The following notation is declared in locale SimpleGraph:

TODO #

Copies #

Not necessarily induced copies #

A copy of a subgraph G inside a subgraph H is an embedding of the vertices of G into the vertices of H, such that adjacency in G implies adjacency in H.

We capture this concept by injective graph homomorphisms.

structure SimpleGraph.Copy {α : Type u_4} {β : Type u_5} (A : SimpleGraph α) (B : SimpleGraph β) :
Type (max u_4 u_5)

The type of copies as a subtype of injective homomorphisms.

@[reducible, inline]
abbrev SimpleGraph.Hom.toCopy {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A →g B) (h : Function.Injective f) :
A.Copy B

An injective homomorphism gives rise to a copy.

Equations
@[reducible, inline]
abbrev SimpleGraph.Embedding.toCopy {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A ↪g B) :
A.Copy B

An embedding gives rise to a copy.

Equations
@[reducible, inline]
abbrev SimpleGraph.Iso.toCopy {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A ≃g B) :
A.Copy B

An isomorphism gives rise to a copy.

Equations
instance SimpleGraph.Copy.instFunLike {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
FunLike (A.Copy B) α β
Equations
theorem SimpleGraph.Copy.injective {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :
theorem SimpleGraph.Copy.ext {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} {f g : A.Copy B} :
(∀ (a : α), f a = g a)f = g
theorem SimpleGraph.Copy.ext_iff {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} {f g : A.Copy B} :
f = g ∀ (a : α), f a = g a
@[simp]
theorem SimpleGraph.Copy.coe_toHom {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :
f.toHom = f
@[simp]
theorem SimpleGraph.Copy.toHom_apply {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) (a : α) :
f.toHom a = f a
@[simp]
theorem SimpleGraph.Copy.coe_mk {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A →g B) (hf : Function.Injective f) :
{ toHom := f, injective' := hf } = f
@[deprecated SimpleGraph.Copy.toHom_apply (since := "2025-03-19")]
theorem SimpleGraph.Copy.coe_toHom_apply {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) (a : α) :
f.toHom a = f a

Alias of SimpleGraph.Copy.toHom_apply.

def SimpleGraph.Copy.mapEdgeSet {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :
A.edgeSet B.edgeSet

A copy induces an embedding of edge sets.

Equations
def SimpleGraph.Copy.mapNeighborSet {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) (a : α) :
(A.neighborSet a) (B.neighborSet (f a))

A copy induces an embedding of neighbor sets.

Equations
def SimpleGraph.Copy.toEmbedding {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :
α β

A copy gives rise to an embedding of vertex types.

Equations
def SimpleGraph.Copy.id {V : Type u_1} (G : SimpleGraph V) :
G.Copy G

The identity copy from a simple graph to itself.

Equations
@[simp]
theorem SimpleGraph.Copy.coe_id {V : Type u_1} {G : SimpleGraph V} :
(id G) = _root_.id
def SimpleGraph.Copy.comp {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (g : B.Copy C) (f : A.Copy B) :
A.Copy C

The composition of copies is a copy.

Equations
@[simp]
theorem SimpleGraph.Copy.comp_apply {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (g : B.Copy C) (f : A.Copy B) (a : α) :
(g.comp f) a = g (f a)
def SimpleGraph.Copy.ofLE {V : Type u_1} (G₁ G₂ : SimpleGraph V) (h : G₁ G₂) :
G₁.Copy G₂

The copy from a subgraph to the supergraph.

Equations
@[simp]
theorem SimpleGraph.Copy.coe_comp {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (g : B.Copy C) (f : A.Copy B) :
(g.comp f) = g f
@[simp]
theorem SimpleGraph.Copy.coe_ofLE {V : Type u_1} {G₁ G₂ : SimpleGraph V} (h : G₁ G₂) :
(ofLE G₁ G₂ h) = _root_.id
@[simp]
theorem SimpleGraph.Copy.ofLE_refl {V : Type u_1} {G : SimpleGraph V} :
ofLE G G = id G
@[simp]
theorem SimpleGraph.Copy.ofLE_comp {V : Type u_1} {G₁ G₂ G₃ : SimpleGraph V} (h₁₂ : G₁ G₂) (h₂₃ : G₂ G₃) :
(ofLE G₂ G₃ h₂₃).comp (ofLE G₁ G₂ h₁₂) = ofLE G₁ G₃
def SimpleGraph.Copy.induce {V : Type u_1} (G : SimpleGraph V) (s : Set V) :

The copy from an induced subgraph to the initial simple graph.

Equations
def SimpleGraph.Copy.bot {α : Type u_4} {β : Type u_5} {B : SimpleGraph β} (f : α β) :

The copy of in any simple graph that can embed its vertices.

Equations
noncomputable def SimpleGraph.Copy.isoSubgraphMap {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) (A' : A.Subgraph) :

The isomorphism from a subgraph of A to its map under a copy f : Copy A B.

Equations
@[reducible, inline]
abbrev SimpleGraph.Copy.toSubgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :

The subgraph of B corresponding to a copy of A inside B.

Equations
noncomputable def SimpleGraph.Copy.isoToSubgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) :

The isomorphism from A to its copy under f : Copy A B.

Equations
@[simp]
theorem SimpleGraph.Copy.range_toSubgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
instance SimpleGraph.Copy.instSubsingletonOfForall {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} [Subsingleton (VW)] :
Equations
  • One or more equations did not get rendered due to their size.
def SimpleGraph.Subgraph.coeCopy {V : Type u_1} {G : SimpleGraph V} (G' : G.Subgraph) :
G'.coe.Copy G

A Subgraph G gives rise to a copy from the coercion to G.

Equations

Induced copies #

An induced copy of a graph G inside a graph H is an embedding from the vertices of G into the vertices of H which preserves the adjacency relation.

This is already captured by the notion of graph embeddings, defined as G ↪g H.

Containment #

Not necessarily induced containment #

A graph H contains a graph G if there is some copy f : Copy G H of G inside H. This amounts to H having a subgraph isomorphic to G.

We denote "G is contained in H" by G ⊑ H (\squb).

@[reducible, inline]
abbrev SimpleGraph.IsContained {α : Type u_4} {β : Type u_5} (A : SimpleGraph α) (B : SimpleGraph β) :

The relation IsContained A B, A ⊑ B says that B contains a copy of A.

This is equivalent to the existence of an isomorphism from A to a subgraph of B.

Equations

The relation IsContained A B, A ⊑ B says that B contains a copy of A.

This is equivalent to the existence of an isomorphism from A to a subgraph of B.

Equations

A simple graph contains itself.

theorem SimpleGraph.IsContained.of_le {V : Type u_1} {G₁ G₂ : SimpleGraph V} (h : G₁ G₂) :
G₁.IsContained G₂

A simple graph contains its subgraphs.

theorem SimpleGraph.IsContained.trans {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} :
A.IsContained BB.IsContained CA.IsContained C

If A contains B and B contains C, then A contains C.

theorem SimpleGraph.IsContained.trans' {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} :
B.IsContained CA.IsContained BA.IsContained C

If B contains C and A contains B, then A contains C.

theorem SimpleGraph.IsContained.mono_right {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B B' : SimpleGraph β} (h_isub : A.IsContained B) (h_sub : B B') :
theorem SimpleGraph.IsContained.trans_le {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B B' : SimpleGraph β} (h_isub : A.IsContained B) (h_sub : B B') :

Alias of SimpleGraph.IsContained.mono_right.

theorem SimpleGraph.IsContained.mono_left {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} {A' : SimpleGraph α} (h_sub : A A') (h_isub : A'.IsContained B) :
theorem SimpleGraph.IsContained.trans_le' {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} {A' : SimpleGraph α} (h_sub : A A') (h_isub : A'.IsContained B) :

Alias of SimpleGraph.IsContained.mono_left.

theorem SimpleGraph.isContained_congr {V : Type u_1} {W : Type u_2} {α : Type u_4} {β : Type u_5} {G : SimpleGraph V} {H : SimpleGraph W} {A : SimpleGraph α} {B : SimpleGraph β} (e₁ : A ≃g H) (e₂ : B ≃g G) :

If A ≃g H and B ≃g G then A is contained in B if and only if H is contained in G.

theorem SimpleGraph.isContained_congr_left {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₁ : A ≃g B) :
theorem SimpleGraph.IsContained.congr_left {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₁ : A ≃g B) :

Alias of the reverse direction of SimpleGraph.isContained_congr_left.

theorem SimpleGraph.isContained_congr_right {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₂ : B ≃g C) :
theorem SimpleGraph.IsContained.congr_right {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₂ : B ≃g C) :

Alias of the reverse direction of SimpleGraph.isContained_congr_right.

theorem SimpleGraph.IsContained.of_isEmpty {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} [IsEmpty α] :

A simple graph having no vertices is contained in any simple graph.

is contained in any simple graph having sufficiently many vertices.

Alias of SimpleGraph.bot_isContained_iff_card_le.


is contained in any simple graph having sufficiently many vertices.

A simple graph G contains all Subgraph G coercions.

@[deprecated SimpleGraph.Copy.isoSubgraphMap (since := "2025-03-19")]
def SimpleGraph.Subgraph.Copy.map {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} (f : A.Copy B) (A' : A.Subgraph) :

Alias of SimpleGraph.Copy.isoSubgraphMap.


The isomorphism from a subgraph of A to its map under a copy f : Copy A B.

Equations
theorem SimpleGraph.isContained_iff_exists_iso_subgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
A.IsContained B ∃ (B' : B.Subgraph), Nonempty (A ≃g B'.coe)

B contains A if and only if B has a subgraph B' and B' is isomorphic to A.

theorem SimpleGraph.IsContained.exists_iso_subgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
A.IsContained B∃ (B' : B.Subgraph), Nonempty (A ≃g B'.coe)

Alias of the forward direction of SimpleGraph.isContained_iff_exists_iso_subgraph.


B contains A if and only if B has a subgraph B' and B' is isomorphic to A.

theorem SimpleGraph.IsContained.of_exists_iso_subgraph {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
(∃ (B' : B.Subgraph), Nonempty (A ≃g B'.coe))A.IsContained B

Alias of the reverse direction of SimpleGraph.isContained_iff_exists_iso_subgraph.


B contains A if and only if B has a subgraph B' and B' is isomorphic to A.

@[reducible, inline]
abbrev SimpleGraph.Free {α : Type u_4} {β : Type u_5} (A : SimpleGraph α) (B : SimpleGraph β) :

A.Free B means that B does not contain a copy of A.

Equations
theorem SimpleGraph.not_free {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} {B : SimpleGraph β} :
theorem SimpleGraph.free_congr {V : Type u_1} {W : Type u_2} {α : Type u_4} {β : Type u_5} {G : SimpleGraph V} {H : SimpleGraph W} {A : SimpleGraph α} {B : SimpleGraph β} (e₁ : A ≃g H) (e₂ : B ≃g G) :
A.Free B H.Free G

If A ≃g H and B ≃g G then B is A-free if and only if G is H-free.

theorem SimpleGraph.free_congr_left {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₁ : A ≃g B) :
A.Free C B.Free C
theorem SimpleGraph.Free.congr_left {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₁ : A ≃g B) :
B.Free CA.Free C

Alias of the reverse direction of SimpleGraph.free_congr_left.

theorem SimpleGraph.free_congr_right {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₂ : B ≃g C) :
A.Free B A.Free C
theorem SimpleGraph.Free.congr_right {α : Type u_4} {β : Type u_5} {γ : Type u_6} {A : SimpleGraph α} {B : SimpleGraph β} {C : SimpleGraph γ} (e₂ : B ≃g C) :
A.Free CA.Free B

Alias of the reverse direction of SimpleGraph.free_congr_right.

theorem SimpleGraph.free_bot {α : Type u_4} {β : Type u_5} {A : SimpleGraph α} (h : A ) :

Induced containment #

A graph H inducingly contains a graph G if there is some graph embedding G ↪ H. This amounts to H having an induced subgraph isomorphic to G.

We denote "G is inducingly contained in H" by G ⊴ H (\trianglelefteq).

def SimpleGraph.IsIndContained {V : Type u_1} {W : Type u_2} (G : SimpleGraph V) (H : SimpleGraph W) :

A simple graph G is inducingly contained in a simple graph H if there exists an induced subgraph of H isomorphic to G. This is denoted by G ⊴ H.

Equations

A simple graph G is inducingly contained in a simple graph H if there exists an induced subgraph of H isomorphic to G. This is denoted by G ⊴ H.

Equations
theorem SimpleGraph.Iso.isIndContained {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} (e : G ≃g H) :

If G is isomorphic to H, then G is inducingly contained in H.

theorem SimpleGraph.Iso.isIndContained' {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} (e : G ≃g H) :

If G is isomorphic to H, then H is inducingly contained in G.

theorem SimpleGraph.IsIndContained.trans {V : Type u_1} {W : Type u_2} {X : Type u_3} {G : SimpleGraph V} {H : SimpleGraph W} {I : SimpleGraph X} :
theorem SimpleGraph.isIndContained_iff_exists_iso_subgraph {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} :
G.IsIndContained H ∃ (H' : H.Subgraph) (_e : G ≃g H'.coe), H'.IsInduced
theorem SimpleGraph.IsIndContained.of_exists_iso_subgraph {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} :
(∃ (H' : H.Subgraph) (_e : G ≃g H'.coe), H'.IsInduced)G.IsIndContained H

Alias of the reverse direction of SimpleGraph.isIndContained_iff_exists_iso_subgraph.

theorem SimpleGraph.IsIndContained.exists_iso_subgraph {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} :
G.IsIndContained H∃ (H' : H.Subgraph) (_e : G ≃g H'.coe), H'.IsInduced

Alias of the forward direction of SimpleGraph.isIndContained_iff_exists_iso_subgraph.

Alias of the reverse direction of SimpleGraph.compl_isIndContained_compl.

Alias of the forward direction of SimpleGraph.compl_isIndContained_compl.

Counting the copies #

If G and H are finite graphs, we can count the number of unlabelled and labelled copies of G in H.

Not necessarily induced copies #

noncomputable def SimpleGraph.labelledCopyCount {V : Type u_1} {W : Type u_2} [Fintype V] [Fintype W] (G : SimpleGraph V) (H : SimpleGraph W) :

G.labelledCopyCount H is the number of labelled copies of H in G, i.e. the number of graph embeddings from H to G. See SimpleGraph.copyCount for the number of unlabelled copies.

Equations
@[simp]
@[simp]
theorem SimpleGraph.labelledCopyCount_eq_zero {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} [Fintype V] [Fintype W] :
@[simp]
theorem SimpleGraph.labelledCopyCount_pos {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} [Fintype V] [Fintype W] :
noncomputable def SimpleGraph.copyCount {V : Type u_1} {W : Type u_2} [Fintype V] (G : SimpleGraph V) (H : SimpleGraph W) :

G.copyCount H is the number of unlabelled copies of H in G, i.e. the number of subgraphs of G isomorphic to H. See SimpleGraph.labelledCopyCount for the number of labelled copies.

Equations
@[simp]
theorem SimpleGraph.copyCount_eq_zero {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} [Fintype V] :
G.copyCount H = 0 H.Free G
@[simp]
theorem SimpleGraph.copyCount_pos {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} [Fintype V] :

There's at least as many labelled copies of H in G than unlabelled ones.

@[simp]
theorem SimpleGraph.copyCount_bot {V : Type u_1} [Fintype V] (G : SimpleGraph V) :
@[simp]
theorem SimpleGraph.copyCount_of_isEmpty {V : Type u_1} {W : Type u_2} [Fintype V] [IsEmpty W] (G : SimpleGraph V) (H : SimpleGraph W) :
G.copyCount H = 1

Induced copies #

TODO

Killing a subgraph #

An important aspect of graph containment is that we can remove not too many edges from a graph H to get a graph H' that doesn't contain G.

Killing not necessarily induced copies #

SimpleGraph.killCopies G H is a subgraph of G where an edge was removed from each copy of H in G. By construction, it doesn't contain H and has at most the number of copies of H edges less than G.

@[irreducible]
noncomputable def SimpleGraph.killCopies {V : Type u_7} {W : Type u_8} (G : SimpleGraph V) (H : SimpleGraph W) :

G.killCopies H is a subgraph of G where an arbitrary edge was removed from each copy of H in G. By construction, it doesn't contain H (unless H had no edges) and has at most the number of copies of H edges less than G. See free_killCopies and le_card_edgeFinset_killCopies for these two properties.

Equations
theorem SimpleGraph.killCopies_def {V : Type u_7} {W : Type u_8} (G : SimpleGraph V) (H : SimpleGraph W) :
G.killCopies H = if hH : H = then G else G.deleteEdges (⋃ (G' : G.Subgraph), ⋃ (hG' : Nonempty (H ≃g G'.coe)), {.some})
theorem SimpleGraph.killCopies_le_left {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} :

Removing an edge from G for each subgraph isomorphic to H results in a subgraph of G.

@[simp]
theorem SimpleGraph.killCopies_bot {V : Type u_1} {W : Type u_2} (G : SimpleGraph V) :
theorem SimpleGraph.killCopies_eq_left {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} (hH : H ) :
G.killCopies H = G H.Free G

G.killCopies H has no effect on G if and only if G already contained no copies of H. See Free.killCopies_eq_left for the reverse implication with no assumption on H.

theorem SimpleGraph.Free.killCopies_eq_left {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} (hHG : H.Free G) :
theorem SimpleGraph.free_killCopies {V : Type u_1} {W : Type u_2} {G : SimpleGraph V} {H : SimpleGraph W} (hH : H ) :

Removing an edge from G for each subgraph isomorphic to H results in a graph that doesn't contain H.

Removing an edge from H for each subgraph isomorphic to G means that the number of edges we've removed is at most the number of copies of G in H.

Removing an edge from H for each subgraph isomorphic to G means that the number of edges we've removed is at most the number of copies of G in H.

Killing induced copies #

TODO