Documentation

CslibFrontier.Foundations.Data.BitString.Graph

Graphs encoded by edge bits #

A simple graph on n labelled vertices is encoded by one Boolean coordinate for each unordered pair of distinct vertices. edgeEquiv numbers these coordinates without changing the layout formerly used by the clique function. The common encoding supports graph properties such as clique containment and connectivity without importing either application.

Main definitions #

Main results #

The encoding and its original lemmas were extracted from Samuel Schlesinger's clique module.

@[reducible, inline]

The possible edges of a graph on n vertices: unordered pairs of distinct vertices.

@[reducible, inline]

The number of possible edges of a graph on n vertices.

A graph on n vertices has n.choose 2 possible edges.

noncomputable def Cslib.BitString.Graph.edgeEquiv (n : ℕ) :

A numbering of the possible edges by the inputs of a circuit.

The graph of an input: its edges are the possible edges set to true.

def Cslib.BitString.Graph.edge {n : ℕ} {u v : Fin n} (h : u ≠ v) :

The edge between two distinct vertices.

@[simp]
theorem Cslib.BitString.Graph.toFinset_edge {n : ℕ} {u v : Fin n} (h : u ≠ v) :
(↑(edge h)).toFinset = {u, v}

The endpoints of edge h are {u, v}.

theorem Cslib.BitString.Graph.edge_comm {n : ℕ} {u v : Fin n} (h : u ≠ v) :
edge h = edge ⋯

The edge between u and v is the edge between v and u.

theorem Cslib.BitString.Graph.graph_adj {n : ℕ} {x : Fin (edgeCount n) → Bool} {u v : Fin n} (h : u ≠ v) :
(graph x).Adj u v ↔ x ((edgeEquiv n) (edge h)) = true

Two distinct vertices are adjacent in the graph of an input exactly when the input sets the edge between them.

@[simp]
theorem Cslib.BitString.Graph.mem_edgeSet_graph {n : ℕ} (x : Fin (edgeCount n) → Bool) (e : Edge n) :
↑e ∈ (graph x).edgeSet ↔ x ((edgeEquiv n) e) = true

A possible edge belongs to the encoded graph exactly when its bit is set.

Distinct edge words encode distinct graphs.

theorem Cslib.BitString.Graph.graph_mono {n : ℕ} {x y : Fin (edgeCount n) → Bool} (h : ∀ (i : Fin (edgeCount n)), x i = true → y i = true) :

Setting more edge bits preserves graph inclusion.

@[simp]
@[simp]
theorem Cslib.BitString.Graph.graph_true {n : ℕ} :
(graph fun (x : Fin (edgeCount n)) => true) = ⊤

Clearing a coordinate deletes precisely that edge.

noncomputable def Cslib.BitString.Graph.ofGraph {n : ℕ} (G : SimpleGraph (Fin n)) :

The edge word of a labelled simple graph, in the same numbering as graph.

@[simp]

Encoding a graph and reading its edge word recovers the graph.

@[simp]

Encoding an edge word's graph recovers the edge word.