Simple graphs #
This module defines simple graphs on a vertex type V as an irreflexive symmetric relation.
Main definitions #
-
SimpleGraphis a structure for symmetric, irreflexive relations -
SimpleGraph.neighborSetis theSetof vertices adjacent to a given vertex -
SimpleGraph.commonNeighborsis the intersection of the neighbor sets of two given vertices -
SimpleGraph.incidenceSetis theSetof edges containing a given vertex -
CompleteAtomicBooleanAlgebrainstance: Under the subgraph relation,SimpleGraphforms aCompleteAtomicBooleanAlgebra. In other words, this is the complete lattice of spanning subgraphs of the complete graph.
Todo #
- This is the simplest notion of an unoriented graph. This should eventually fit into a more complete combinatorics hierarchy which includes multigraphs and directed graphs. We begin with simple graphs in order to start learning what the combinatorics hierarchy should look like.
A variant of the aesop tactic for use in the graph library. Changes relative
to standard aesop:
- We use the
SimpleGraphrule set in addition to the default rule sets. - We instruct Aesop's
introrule to unfold withdefaulttransparency. - We instruct Aesop to fail if it can't fully solve the goal. This allows us to
use
aesop_graphfor auto-params.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Use aesop_graph? to pass along a Try this suggestion when using aesop_graph
Equations
- One or more equations did not get rendered due to their size.
Instances For
A variant of aesop_graph which does not fail if it is unable to solve the
goal. Use this only for exploration! Nonterminal Aesop is even worse than
nonterminal simp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A simple graph is an irreflexive symmetric relation Adj on a vertex type V.
The relation describes which pairs of vertices are adjacent.
There is exactly one edge for every pair of adjacent vertices;
see SimpleGraph.edgeSet for the corresponding edge set.
- Adj : V → V → Prop
The adjacency relation of a simple graph.
- symm : Symmetric self.Adj
- loopless : Irreflexive self.Adj
Instances For
Constructor for simple graphs using a symmetric irreflexive boolean function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
We can enumerate simple graphs by enumerating all functions V → V → Bool
and filtering on whether they are symmetric and irreflexive.
Equations
- instFintypeSimpleGraph = { elems := Finset.map SimpleGraph.mk' Finset.univ, complete := (_ : ∀ (x : SimpleGraph V), x ∈ Finset.map SimpleGraph.mk' Finset.univ) }
Construct the simple graph induced by the given relation. It symmetrizes the relation and makes it irreflexive.
Equations
- SimpleGraph.fromRel r = SimpleGraph.mk fun (a b : V) => a ≠ b ∧ (r a b ∨ r b a)
Instances For
The complete graph on a type V is the simple graph with all pairs of distinct vertices
adjacent. In Mathlib, this is usually referred to as ⊤.
Equations
- completeGraph V = SimpleGraph.mk Ne
Instances For
The graph with no edges on a given vertex type V. Mathlib prefers the notation ⊥.
Equations
- emptyGraph V = SimpleGraph.mk fun (x x : V) => False
Instances For
Two vertices are adjacent in the complete bipartite graph on two vertex types if and only if they are not from the same side. Any bipartite graph may be regarded as a subgraph of one of these.
Equations
- completeBipartiteGraph V W = SimpleGraph.mk fun (v w : V ⊕ W) => Sum.isLeft v = true ∧ Sum.isRight w = true ∨ Sum.isRight v = true ∧ Sum.isLeft w = true
Instances For
The relation that one SimpleGraph is a subgraph of another.
Note that this should be spelled ≤.
Equations
- SimpleGraph.IsSubgraph x y = ∀ ⦃v w : V⦄, x.Adj v w → y.Adj v w
Instances For
Equations
- SimpleGraph.instLESimpleGraph = { le := SimpleGraph.IsSubgraph }
The supremum of two graphs x ⊔ y has edges where either x or y have edges.
Equations
- SimpleGraph.instSupSimpleGraph = { sup := fun (x y : SimpleGraph V) => SimpleGraph.mk (x.Adj ⊔ y.Adj) }
The infimum of two graphs x ⊓ y has edges where both x and y have edges.
Equations
- SimpleGraph.instInfSimpleGraph = { inf := fun (x y : SimpleGraph V) => SimpleGraph.mk (x.Adj ⊓ y.Adj) }
We define Gᶜ to be the SimpleGraph V such that no two adjacent vertices in G
are adjacent in the complement, and every nonadjacent pair of vertices is adjacent
(still ensuring that vertices are not adjacent to themselves).
Equations
- SimpleGraph.hasCompl = { compl := fun (G : SimpleGraph V) => SimpleGraph.mk fun (v w : V) => v ≠ w ∧ ¬G.Adj v w }
The difference of two graphs x \ y has the edges of x with the edges of y removed.
Equations
- SimpleGraph.sdiff = { sdiff := fun (x y : SimpleGraph V) => SimpleGraph.mk (x.Adj \ y.Adj) }
Equations
- SimpleGraph.supSet = { sSup := fun (s : Set (SimpleGraph V)) => SimpleGraph.mk fun (a b : V) => ∃ G ∈ s, G.Adj a b }
Equations
- SimpleGraph.infSet = { sInf := fun (s : Set (SimpleGraph V)) => SimpleGraph.mk fun (a b : V) => (∀ ⦃G : SimpleGraph V⦄, G ∈ s → G.Adj a b) ∧ a ≠ b }
Equations
- One or more equations did not get rendered due to their size.
Equations
- SimpleGraph.instInhabitedSimpleGraph V = { default := ⊥ }
Equations
- SimpleGraph.instUniqueSimpleGraph = { toInhabited := { default := ⊥ }, uniq := (_ : ∀ (G : SimpleGraph V), G = default) }
Equations
- (_ : Nontrivial (SimpleGraph V)) = (_ : Nontrivial (SimpleGraph V))
Equations
- SimpleGraph.Bot.adjDecidable V = inferInstanceAs (DecidableRel fun (x x : V) => False)
Equations
- SimpleGraph.Sup.adjDecidable V G H = inferInstanceAs (DecidableRel fun (v w : V) => G.Adj v w ∨ H.Adj v w)
Equations
- SimpleGraph.Inf.adjDecidable V G H = inferInstanceAs (DecidableRel fun (v w : V) => G.Adj v w ∧ H.Adj v w)
Equations
- SimpleGraph.Sdiff.adjDecidable V G H = inferInstanceAs (DecidableRel fun (v w : V) => G.Adj v w ∧ ¬H.Adj v w)
Equations
- SimpleGraph.Top.adjDecidable V = inferInstanceAs (DecidableRel fun (v w : V) => v ≠ w)
Equations
- SimpleGraph.Compl.adjDecidable V G = inferInstanceAs (DecidableRel fun (v w : V) => v ≠ w ∧ ¬G.Adj v w)
G.support is the set of vertices that form edges in G.
Equations
- SimpleGraph.support G = Rel.dom G.Adj
Instances For
G.neighborSet v is the set of vertices adjacent to v in G.
Equations
- SimpleGraph.neighborSet G v = {w : V | G.Adj v w}
Instances For
Equations
- SimpleGraph.neighborSet.memDecidable G v = inferInstanceAs (DecidablePred (G.Adj v))
The edges of G consist of the unordered pairs of vertices related by
G.Adj. This is the order embedding; for the edge set of a particular graph, see
SimpleGraph.edgeSet.
The way edgeSet is defined is such that mem_edgeSet is proved by refl.
(That is, s(v, w) ∈ G.edgeSet is definitionally equal to G.Adj v w.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
G.edgeSet is the edge set for G.
This is an abbreviation for edgeSetEmbedding G that permits dot notation.
Equations
Instances For
Alias of the reverse direction of SimpleGraph.edgeSet_subset_edgeSet.
Alias of the reverse direction of SimpleGraph.edgeSet_ssubset_edgeSet.
This lemma, combined with edgeSet_sdiff and edgeSet_from_edgeSet,
allows proving (G \ from_edgeSet s).edge_set = G.edgeSet \ s by simp.
Two vertices are adjacent iff there is an edge between them. The
condition v ≠ w ensures they are different endpoints of the edge,
which is necessary since when v = w the existential
∃ (e ∈ G.edgeSet), v ∈ e ∧ w ∈ e is satisfied by every edge
incident to v.
Equations
- SimpleGraph.decidableMemEdgeSet G = Sym2.fromRel.decidablePred (_ : Symmetric G.Adj)
Equations
- SimpleGraph.fintypeEdgeSet G = Subtype.fintype fun (x : Sym2 V) => x ∈ SimpleGraph.edgeSet G
Equations
- SimpleGraph.fintypeEdgeSetSup G₁ G₂ = Eq.mpr (_ : Fintype ↑(SimpleGraph.edgeSet (G₁ ⊔ G₂)) = Fintype ↑(SimpleGraph.edgeSet G₁ ∪ SimpleGraph.edgeSet G₂)) inferInstance
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.
fromEdgeSet constructs a SimpleGraph from a set of edges, without loops.
Equations
- SimpleGraph.fromEdgeSet s = SimpleGraph.mk (Sym2.ToRel s ⊓ Ne)
Instances For
Equations
- SimpleGraph.instFintypeElemSym2EdgeSetFromEdgeSet s = Eq.mpr (_ : Fintype ↑(SimpleGraph.edgeSet (SimpleGraph.fromEdgeSet s)) = Fintype ↑(s \ {e : Sym2 V | Sym2.IsDiag e})) inferInstance
Incidence set #
Set of edges incident to a given vertex, aka incidence set.
Equations
- SimpleGraph.incidenceSet G v = {e : Sym2 V | e ∈ SimpleGraph.edgeSet G ∧ v ∈ e}
Instances For
Equations
- SimpleGraph.decidableMemIncidenceSet G v = inferInstanceAs (DecidablePred fun (e : Sym2 V) => e ∈ SimpleGraph.edgeSet G ∧ v ∈ e)
The set of common neighbors between two vertices v and w in a graph G is the
intersection of the neighbor sets of v and w.
Equations
Instances For
Equations
- SimpleGraph.decidableMemCommonNeighbors G v w = inferInstanceAs (DecidablePred fun (u : V) => u ∈ SimpleGraph.neighborSet G v ∧ u ∈ SimpleGraph.neighborSet G w)
Given an edge incident to a particular vertex, get the other vertex on the edge.
Equations
- SimpleGraph.otherVertexOfIncident G h = Sym2.Mem.other' (_ : v ∈ e)
Instances For
There is an equivalence between the set of edges incident to a given vertex and the set of vertices adjacent to the vertex.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Edge deletion #
Given a set of vertex pairs, remove all of the corresponding edges from the graph's edge set, if present.
See also: SimpleGraph.Subgraph.deleteEdges.
Equations
- SimpleGraph.deleteEdges G s = SimpleGraph.mk (G.Adj \ Sym2.ToRel s)