Documentation

CslibFrontier.Computability.Complexity.Problems.StronglyConnected

Strongly connected digraphs #

A digraph instance (Cslib.Complexity.DigraphInstance) is a directed graph on Fin n, given by its adjacency matrix; it belongs to Cslib.Complexity.StronglyConnected when every vertex reaches every vertex by a directed path, of any length, including the empty path. The adjacency matrix need not be symmetric and may have loops; the empty digraph is strongly connected.

Instances are encoded (Cslib.Complexity.encDigraph) as instances of directed connectivity are (Cslib.Complexity.encSTCON), without the source and the target: the unary header 1^n 0 followed by the adjacency matrix row by row (Cslib.Complexity.adjacencyMatrix), so that the bit at n + 1 + a * n + b is the entry of the row a and the column b. This is the encoding of Arora and Barak, Exercise 4.4, which asks to show that the language is NL-complete (Cslib.Complexity.StronglyConnected.logSpaceComplete).

Main definitions #

Main results #

References #

A digraph on Fin n, given by its adjacency matrix.

  • n : ℕ

    The number of vertices.

  • adj : Fin self.n → Fin self.n → Bool

    The adjacency matrix: adj a b when there is an arc from a to b.

The arcs of a digraph: there is an arc from a to b when the entry of the row a and the column b of the adjacency matrix is set.

The encoding of a digraph: the unary header 1^n 0, then the adjacency matrix row by row.

The length of the encoding: the header and the n ^ 2 entries of the matrix.

The header, read by position: the bit at i ≤ n is set exactly when i < n.

theorem Cslib.Complexity.DigraphInstance.getElem?_encode_matrix (G : DigraphInstance) {a b : ℕ} (ha : a < G.n) (hb : b < G.n) :
G.encode[G.n + 1 + (a * G.n + b)]? = some (G.adj ⟨a, ha⟩ ⟨b, hb⟩)

The entries of the matrix, read by position: the bit at n + 1 + (a * n + b) is the entry of the row a and the column b.

The encoding of digraphs: the unary header 1^n 0, then the adjacency matrix row by row.

Strongly connected digraphs: every vertex reaches every vertex by a directed path.