Adjacency list
StructureDirected adjacency graph#✓fully proved
A directed adjacency graph on a type \(V\) consists of a list of vertices that has no duplicates and contains every element of \(V\) (so \(V\) is finite), together with, for each vertex \(v\), an ordered list of the out-neighbors of \(v\), in which entries may repeat.
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
vertices : List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:34
Used by 221
DefinitionEdge of a directed adjacency graph#✓fully proved
For a directed adjacency graph \(G\) on \(V\) and vertices \(s, t \in V\), there is an edge from \(s\) to \(t\) in \(G\) when \(t\) occurs in the adjacency list of \(s\).
def DirectedAdjacency.Edge {V : Type u} (graph : DirectedAdjacency V)
(source target : V) : Prop :=
target ∈ graph.adjacency source
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 1 · Used by 118
AbbreviationWalks of a given length#✓fully proved
For a directed adjacency graph \(G\), a natural number \(n\) and vertices \(s\) and \(t\), there is a walk of length \(n\) from \(s\) to \(t\) in \(G\) when there are vertices \(v_0, \dots, v_n\) with \(v_0 = s\) and \(v_n = t\) such that \((v_i, v_{i+1})\) is an edge of \(G\) for every \(i < n\).
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 2 · Used by 32
DefinitionThe digraph of a directed adjacency graph#✓fully proved
The digraph associated with a directed adjacency graph \(G\) on a vertex type \(V\) is the directed graph on \(V\) in which \(s\) is adjacent to \(t\) exactly when \(G\) has an edge from \(s\) to \(t\). It forgets the order of the adjacency lists and the multiplicity of their entries.
def toDigraph (graph : DirectedAdjacency V) : Digraph V where
Adj := graph.Edge
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 2 · Used by 1
TheoremAdjacency in the associated digraph#✓fully proved
For a directed adjacency graph \(G\) and vertices \(s\) and \(t\), \(s\) is adjacent to \(t\) in the digraph associated with \(G\) if and only if \(G\) has an edge from \(s\) to \(t\), that is, \(t\) occurs in the adjacency list of \(s\).
@[simp]
theorem toDigraph_adj : graph.toDigraph.Adj source target ↔ graph.Edge source target
Uses 3
TheoremWalks of length zero#✓fully proved
In a directed adjacency graph, there is a walk of length \(0\) from a vertex \(s\) to a vertex \(t\) if and only if \(s = t\).
@[simp]
theorem walk_zero_iff : Walk graph 0 source target ↔ source = target
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 3 · Used by 1
TheoremSplitting off the first edge of a walk#✓fully proved
In a directed adjacency graph \(G\), for every natural number \(n\) and all vertices \(s\) and \(t\), there is a walk of length \(n + 1\) from \(s\) to \(t\) if and only if there is a vertex \(v\) such that \((s, v)\) is an edge of \(G\) and there is a walk of length \(n\) from \(v\) to \(t\).
theorem walk_succ_iff :
Walk graph (Nat.succ length) source target ↔
∃ next, graph.Edge source next ∧ Walk graph length next target
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 3 · Used by 1
TheoremConcatenation of walks#✓fully proved
Let \(G\) be a directed adjacency graph on \(V\) and let \(s, m, t \in V\). If \(G\) has a walk of length exactly \(a\) from \(s\) to \(m\) and a walk of length exactly \(b\) from \(m\) to \(t\), then \(G\) has a walk of length exactly \(a + b\) from \(s\) to \(t\).
theorem Walk.append
(left : Walk graph leftLength source middle)
(right : Walk graph rightLength middle target) :
Walk graph (leftLength + rightLength) source target
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 3
DefinitionReachability in a directed graph#✓fully proved
For a directed adjacency graph \(G\) and vertices \(s\) and \(t\), \(t\) is reachable from \(s\) when the pair \((s, t)\) lies in the reflexive-transitive closure of the edge relation of \(G\): either \(s = t\), or a finite sequence of edges of \(G\) leads from \(s\) to \(t\).
def Reachable (graph : DirectedAdjacency V) (source target : V) : Prop :=
Relation.ReflTransGen graph.Edge source target
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 2 · Used by 58
TheoremReachability by walks#✓fully proved
In a directed adjacency graph \(G\), a vertex \(t\) is reachable from a vertex \(s\) if and only if there is a natural number \(n\) such that \(G\) has a walk of length exactly \(n\) from \(s\) to \(t\).
theorem reachable_iff_exists_walk :
graph.Reachable source target ↔ ∃ length, Walk graph length source target
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 4 · Used by 10
TheoremReachability is the reflexive-transitive closure of the edge relation#✓fully proved
In a directed adjacency graph \(G\), a vertex \(t\) is reachable from a vertex \(s\) if and only if \((s, t)\) lies in the reflexive-transitive closure of the edge relation of \(G\).
theorem reachable_iff_reflTransGen :
graph.Reachable source target ↔
Relation.ReflTransGen graph.Edge source target
Uses 3
DefinitionThe transition system of a directed adjacency graph#✓fully proved
The labelled transition system of a directed adjacency graph \(G\) has the vertices of \(G\) as states and a single label, and it has a transition from \(s\) to \(t\) exactly when \(G\) has an edge from \(s\) to \(t\).
def toLTS (graph : DirectedAdjacency V) : _root_.Cslib.LTS V Unit where
Tr source _ target := graph.Edge source target
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 2 · Used by 1
TheoremReachability in the associated transition system#✓fully proved
In a directed adjacency graph \(G\), a vertex \(t\) is reachable from a vertex \(s\) if and only if, in the unit-labelled labelled transition system of \(G\), there is a finite list of labels along which \(s\) reaches \(t\) by a multistep transition.
theorem reachable_iff_lts :
graph.Reachable source target ↔
∃ labels, graph.toLTS.MTr source labels target
DefinitionTranspose of a directed adjacency graph#✓fully proved
For a directed adjacency graph \(G\) on a vertex type with decidable equality, the transpose of \(G\) has the same vertex enumeration as \(G\), and the adjacency list of a vertex \(v\) consists of the vertices \(u\) such that \(v\) occurs in the adjacency list of \(u\) in \(G\), each listed once and in the order of the vertex enumeration.
def transpose [DecidableEq V] (graph : DirectedAdjacency V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency target := graph.vertices.filter fun source => target ∈ graph.adjacency source
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:40
Uses 1 · Used by 8
TheoremEdges of the transpose graph#✓fully proved
Let \(V\) have decidable equality and let \(G\) be a directed adjacency graph on \(V\). For all \(s, t \in V\), the transpose of \(G\) has an edge from \(s\) to \(t\) if and only if \(G\) has an edge from \(t\) to \(s\).
@[simp]
theorem edge_transpose [DecidableEq V] :
(graph.transpose).Edge source target ↔ graph.Edge target source
TheoremWalks in the transpose are reversed walks#✓fully proved
For a directed adjacency graph \(G\) on a vertex type with decidable equality, every natural number \(n\) and all vertices \(s\) and \(t\), there is a walk of length \(n\) from \(s\) to \(t\) in the transpose of \(G\) if and only if there is a walk of length \(n\) from \(t\) to \(s\) in \(G\).
theorem walk_transpose_iff [DecidableEq V] :
Walk graph.transpose length source target ↔ Walk graph length target source
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 5 · Used by 3
TheoremReachability in the transpose graph#✓fully proved
Let \(G\) be a directed adjacency graph on a vertex type with decidable equality, and let \(G^{\mathsf{T}}\) be its transpose. For all vertices \(s\) and \(t\), \(t\) is reachable from \(s\) in \(G^{\mathsf{T}}\) if and only if \(s\) is reachable from \(t\) in \(G\).
theorem reachable_transpose_iff [DecidableEq V] :
graph.transpose.Reachable source target ↔ graph.Reachable target source
Uses 6 · Used by 1
DefinitionSemantic equivalence of directed adjacency graphs#✓fully proved
Two directed adjacency graphs \(G_1\) and \(G_2\) on the same vertex type are semantically equivalent when they have the same edges: for all vertices \(s\) and \(t\), \(G_1\) has an edge from \(s\) to \(t\) if and only if \(G_2\) does.
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 2 · Used by 7
TheoremSemantic equivalence of directed adjacency graphs is reflexive#✓fully proved
Every directed adjacency graph \(G\) is semantically equivalent to itself.
@[refl]
theorem semanticEquivalent_refl : SemanticallyEquivalent graph graph
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
Uses 3
TheoremSemantic equivalence of directed adjacency graphs is symmetric#✓fully proved
If a directed adjacency graph \(G_1\) is semantically equivalent to a directed adjacency graph \(G_2\), then \(G_2\) is semantically equivalent to \(G_1\).
@[symm]
theorem SemanticallyEquivalent.symm
(equivalent : SemanticallyEquivalent graph₁ graph₂) :
SemanticallyEquivalent graph₂ graph₁
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
Uses 3
TheoremSemantic equivalence of directed adjacency graphs is transitive#✓fully proved
If a directed adjacency graph \(G_1\) is semantically equivalent to \(G_2\), and \(G_2\) is semantically equivalent to \(G_3\), then \(G_1\) is semantically equivalent to \(G_3\).
@[trans]
theorem SemanticallyEquivalent.trans
(equivalent₁₂ : SemanticallyEquivalent graph₁ graph₂)
(equivalent₂₃ : SemanticallyEquivalent graph₂ graph₃) :
SemanticallyEquivalent graph₁ graph₃
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
Uses 3
TheoremSemantically equivalent graphs have the same walks#✓fully proved
If two directed adjacency graphs \(G_1\) and \(G_2\) are semantically equivalent, then for every natural number \(n\) and all vertices \(s\) and \(t\), there is a walk of length \(n\) from \(s\) to \(t\) in \(G_1\) if and only if there is a walk of length \(n\) from \(s\) to \(t\) in \(G_2\).
theorem SemanticallyEquivalent.walk_iff
(equivalent : SemanticallyEquivalent graph₁ graph₂) :
Walk graph₁ length source target ↔ Walk graph₂ length source target
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
Uses 4 · Used by 1
TheoremSemantically equivalent graphs have the same reachability#✓fully proved
If two directed adjacency graphs \(G_1\) and \(G_2\) on \(V\) are semantically equivalent, then for all \(s, t \in V\), \(t\) is reachable from \(s\) in \(G_1\) if and only if \(t\) is reachable from \(s\) in \(G_2\).
theorem SemanticallyEquivalent.reachable_iff
(equivalent : SemanticallyEquivalent graph₁ graph₂) :
graph₁.Reachable source target ↔ graph₂.Reachable source target
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
Uses 6 · Used by 1
TheoremTransposition preserves semantic equivalence#✓fully proved
For directed adjacency graphs \(G_1\) and \(G_2\) on a vertex type with decidable equality, if \(G_1\) and \(G_2\) are semantically equivalent, then their transposes are semantically equivalent.
theorem SemanticallyEquivalent.transpose [DecidableEq V]
(equivalent : SemanticallyEquivalent graph₁ graph₂) :
SemanticallyEquivalent graph₁.transpose graph₂.transpose
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
TheoremTransposing twice gives a semantically equivalent graph#✓fully proved
Let \(G\) be a directed adjacency graph on a vertex type with decidable equality. The transpose of the transpose of \(G\) is semantically equivalent to \(G\), that is, it has exactly the same edges as \(G\).
theorem semanticEquivalent_transpose_transpose [DecidableEq V] :
SemanticallyEquivalent graph.transpose.transpose graph
def SemanticallyEquivalent (graph₁ graph₂ : DirectedAdjacency V) : Prop :=
∀ source target, graph₁.Edge source target ↔ graph₂.Edge source target
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:181
DefinitionBoolean edge test#✓fully proved
For a type \(V\) with decidable equality, a directed adjacency graph \(G\) on \(V\) and vertices \(s, t \in V\), the edge test of \(G\) at \((s, t)\) is the Boolean value that is true exactly when \(t\) occurs in the adjacency list of \(s\).
public def hasEdge {α : Type u} [DecidableEq α]
(g : DirectedAdjacency α) (source target : α) : Bool :=
decide (target ∈ g.adjacency source)
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 1 · Used by 10
TheoremThe Boolean edge test is correct#✓fully proved
For a type \(V\) with decidable equality, a directed adjacency graph \(G\) on \(V\) and vertices \(s, t \in V\), the Boolean edge test of \(G\) at \((s, t)\) returns true if and only if \(G\) has an edge from \(s\) to \(t\).
public theorem hasEdge_eq_true {α : Type u} [DecidableEq α]
(g : DirectedAdjacency α) (source target : α) :
g.hasEdge source target = true ↔ g.Edge source target
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
Uses 3 · Used by 2
DefinitionErasing a directed edge#✓fully proved
Given a directed-adjacency graph \(G\) and vertices \(s\) and \(t\), erasing the edge \(s \to t\) gives the directed-adjacency graph with the same vertex enumeration as \(G\) whose out-neighbour list at \(s\) is the out-neighbour list of \(s\) in \(G\) with every occurrence of \(t\) removed (the remaining entries keep their order), and whose out-neighbour list at every other vertex is the same as in \(G\).
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
structure DirectedAdjacency (V : Type u) where
/-- The complete deterministic enumeration of vertices. -/
vertices : List V
/-- The vertex enumeration contains no duplicates. -/
vertices_nodup : vertices.Nodup
/-- Every vertex occurs in the enumeration. -/
vertices_complete : ∀ vertex, vertex ∈ vertices
/-- The ordered outgoing neighbors of each vertex. Entries may repeat. -/
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:32
adjacency : V → List V
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:40
Uses 1 · Used by 8
TheoremErasing an edge keeps the vertex enumeration#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\) and \(t\), the graph obtained from \(G\) by erasing the edge \(s \to t\) has the same vertex enumeration as \(G\): the same list of vertices, in the same order.
@[simp]
theorem vertices_eraseEdge [DecidableEq V] :
(eraseEdge graph source target).vertices = graph.vertices
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 2
TheoremOut-neighbours of the source after erasing an edge#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\) and \(t\), the out-neighbour list of \(s\) in the graph obtained from \(G\) by erasing the edge \(s \to t\) is the out-neighbour list of \(s\) in \(G\) with every occurrence of \(t\) removed, the remaining entries kept in their original order.
@[simp]
theorem adjacency_eraseEdge_source [DecidableEq V] :
(eraseEdge graph source target).adjacency source =
(graph.adjacency source).filter (fun vertex => decide (vertex ≠ target))
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 2
TheoremErasing an edge leaves the other out-neighbour lists unchanged#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\), \(t\) and \(u\) with \(u \ne s\), the out-neighbour list of \(u\) in the graph obtained from \(G\) by erasing the edge \(s \to t\) equals the out-neighbour list of \(u\) in \(G\).
theorem adjacency_eraseEdge_of_ne [DecidableEq V]
(different : left ≠ source) :
(eraseEdge graph source target).adjacency left = graph.adjacency left
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 2
TheoremEdges after erasing an edge#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\), \(t\), \(u\) and \(v\), there is an edge from \(u\) to \(v\) in the graph obtained from \(G\) by erasing the edge \(s \to t\) if and only if there is an edge from \(u\) to \(v\) in \(G\) and it is not the case that both \(u = s\) and \(v = t\).
@[simp]
theorem edge_eraseEdge [DecidableEq V] :
(eraseEdge graph source target).Edge left right ↔
graph.Edge left right ∧ ¬(left = source ∧ right = target)
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 3 · Used by 1
TheoremThe erased edge is absent#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\) and \(t\), the Boolean edge lookup for \(s \to t\) in the graph obtained from \(G\) by erasing the edge \(s \to t\) returns false.
@[simp]
theorem hasEdge_eraseEdge_self [DecidableEq V] :
(eraseEdge graph source target).hasEdge source target = false
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 3
TheoremErasing an edge twice gives the same out-neighbour lists#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\) and \(t\), erasing the edge \(s \to t\) from \(G\) and then erasing it again gives, at every vertex, the same out-neighbour list as erasing it once.
theorem eraseEdge_idempotent [DecidableEq V] :
(eraseEdge (eraseEdge graph source target) source target).adjacency =
(eraseEdge graph source target).adjacency
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 2
TheoremWalks after erasing an edge are walks in the original graph#✓fully proved
For every directed-adjacency graph \(G\), vertices \(s\), \(t\), \(u\) and \(v\), and natural number \(n\), if there is a walk of length \(n\) from \(u\) to \(v\) in the graph obtained from \(G\) by erasing the edge \(s \to t\), then there is a walk of length \(n\) from \(u\) to \(v\) in \(G\).
theorem walk_eraseEdge_imp [DecidableEq V]
(walk : Walk (eraseEdge graph source target) length left right) :
Walk graph length left right
abbrev DirectedAdjacency.Walk {V : Type u} (graph : DirectedAdjacency V)
(length : Nat) (source target : V) : Prop :=
Relation.RelatesInSteps graph.Edge source target length
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency.lean:48
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Uses 5 · Used by 1
TheoremReachability after erasing an edge implies reachability in the original graph#✓fully proved
For every directed-adjacency graph \(G\) and vertices \(s\), \(t\), \(u\) and \(v\), if \(v\) is reachable from \(u\) in the graph obtained from \(G\) by erasing the edge \(s \to t\), then \(v\) is reachable from \(u\) in \(G\).
theorem reachable_eraseEdge_imp [DecidableEq V]
(reachable : (eraseEdge graph source target).Reachable left right) :
graph.Reachable left right
def eraseEdge [DecidableEq V] (graph : DirectedAdjacency V)
(source target : V) : DirectedAdjacency V where
vertices := graph.vertices
vertices_nodup := graph.vertices_nodup
vertices_complete := graph.vertices_complete
adjacency vertex :=
if vertex = source then
(graph.adjacency vertex).filter fun neighbor => decide (neighbor ≠ target)
else
graph.adjacency vertex
CSLibExt/Algorithms/Lean/Graph/DirectedAdjacency/EraseEdge.lean:32
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.