Documentation

CslibFrontier.Computability.Complexity.Problems.UGraph.USTCONWriter

Writing instances of undirected connectivity from undirected graphs in logarithmic space #

Many logarithmic-space reductions to undirected s–t connectivity build, from an undirected graph G on n vertices, an instance on N vertices with source 0 and target 1 whose adjacency matrix has entries of two kinds: an entry that copies one entry of the input matrix, and an entry that is arithmetic in n and its row and column. The counter program Cslib.Complexity.UGraphInstance.ustconWriter writes such an instance. It takes four expressions over the registers [n, r, c]: the number of vertices N, a test whether the entry (r, c) copies an input bit, the position of that bit in the encoded graph, and the arithmetic entry. It counts the unary header 1^n 0 of the encoded graph, writes the header 1^N 0 0 1 0 of the instance, and writes its matrix entry by entry. When N is polynomial in the length of the encoded graph, the registers hold logarithmically many bits, and the instance is computed in logarithmic space (Cslib.Complexity.UGraphInstance.computableInLogSpace_of_entryExprs).

Main definitions #

Main results #

The writer of an instance of undirected connectivity with source 0 and target 1, on the encoded graph. The expressions are evaluated on the registers [n, r, c]: numV is the number of vertices of the instance; the entry (r, c) is the input bit at position when within is positive, and otherwise whether endpoint is positive. Register 0 receives n, register 1 counts the unary header and then runs over the rows, register 2 over the columns. Labels 0 and 1 count the header of the input; the loop at label 2 and labels 6 to 9 write the header 1^N 0 0 1 0 of the instance; the nested loops at labels 10 and 13 write the matrix, the entry at labels 16 to 20; label 21 halts.

theorem Cslib.Complexity.UGraphInstance.computableInLogSpace_of_entryExprs {numV within position endpoint : Turing.CounterProgram.Expr} {F : UGraphInstance → USTCONInstance} (k : ℕ) (hN : ∀ (G : UGraphInstance) (r c : ℕ), Turing.CounterProgram.Expr.eval [G.n, r, c] numV = (F G).n) (hbound : ∀ (G : UGraphInstance), (F G).n ≤ (G.encode.length + 1) ^ k) (hs : ∀ (G : UGraphInstance), ↑(F G).s = 0) (ht : ∀ (G : UGraphInstance), ↑(F G).t = 1) (hentry : ∀ (G : UGraphInstance) (r c : Fin (F G).n), (F G).adj r c = if 0 < Turing.CounterProgram.Expr.eval [G.n, ↑r, ↑c] within then G.encode[Turing.CounterProgram.Expr.eval [G.n, ↑r, ↑c] position]?.getD false else decide (0 < Turing.CounterProgram.Expr.eval [G.n, ↑r, ↑c] endpoint)) :

Instances whose entries are input bits or arithmetic are computed in logarithmic space. Let F map undirected graphs to instances of undirected connectivity with source 0 and target 1, on at most (m + 1) ^ k vertices for encoded graphs of length m, and let the expressions describe F over the registers [n, r, c]: numV evaluates to the number of vertices, and the entry (r, c) is the bit of the encoded graph at position when within is positive, and otherwise whether endpoint is positive. Then ustconWriter numV within position endpoint computes F in logarithmic space.