A read machine for undirected connectivity #
Cslib.USTCON.Reader.machine decides undirected s–t connectivity (Cslib.Complexity.USTCON)
on the encodings Cslib.Complexity.encUSTCON, reading its input by address
(Turing.ReadMachine), following Reingold's algorithm Reingold, Theorem 4.1
Arora and Barak, Section 21.4:
- it counts the unary header
1^n 0 1^s 0 1^t 0(hdrN,hdrS,hdrT) and halvesnuntil it vanishes, adding16to the depth and4168to the walk length at each halving (size), so that the depth and the walk length areCslib.Reachability.Reingold.depth aandCslib.Reachability.Reingold.walkLength afora = Nat.size n, withn ≤ 2 ^ a; - for each counter
c = 0, 1, …it walks in Reingold's graph from the vertex(⋯ ((s, s), 0) ⋯, 0)(start,fill) along the labels given by the digits ofcin base|B| = 257 ^ 8(next), each step evaluating the rotation map in place (eval, byCslib.RotationMap.reingoldEvalStep) and reading the adjacency matrix at a step of the slot graph; - it accepts when a walk ends over a slot of
t, and rejects when the counter has more digits than the walk length, all counters having been tried (check).
Its memory is a constant number of numbers bounded by a polynomial in n or by |B| to the power
of the walk length, and two lists of O(log n) labels and program counters, so O(log n) bits.
Main definitions #
Cslib.USTCON.Reader.labelOfNat: the label of a digit.Cslib.USTCON.Reader.slotRotN: the rotation map of the regular rotation map of the input graph, on the slots as pairs of numbers, given the entry of the adjacency matrix.Cslib.USTCON.Reader.Ctl,Cslib.USTCON.Reader.State: the control and the memory.Cslib.USTCON.Reader.step,Cslib.USTCON.Reader.addr: the step and the address read.Cslib.USTCON.Reader.machine: the read machine.
References #
The number of labels is the cardinality of the label type.
The labels numbered by the residues modulo their number.
Instances For
The label of the digit x % numLabels.
Instances For
The rotation map of the regular rotation map of the input graph, on slots written as pairs
of numbers below n, given the entry bit of the adjacency matrix at the slot: the edge of the
graph exchanges the ends of an edge if bit is set, the edges of the cycle of the slots move to the
next or the previous slot, and every other label is a self-loop.
Instances For
The control state of the machine.
- hdrN : Ctl
Counting the ones of the number of vertices.
- hdrS : Ctl
Counting the ones of the source.
- hdrT : Ctl
Counting the ones of the target.
- size : Ctl
Halving the number of vertices, to compute the depth and the walk length.
- start : Ctl
Starting the walk of the counter.
- fill : Ctl
Filling the labels of the start vertex with zeros.
- next : Ctl
Taking the next step of the walk, or ending it.
- eval : Ctl
Evaluating the rotation map of Reingold's graph.
- check : Ctl
Checking the end of the walk.
- done : Ctl
Halted.
Instances For
The memory of the machine.
- ctl : Ctl
The control state.
- cnt : ℕ
The ones counted in the header, or the number of vertices being halved.
- n : ℕ
The number of vertices.
- s : ℕ
The source.
- t : ℕ
The target.
- depth : ℕ
The depth of Reingold's graph.
- len : ℕ
The length of the walks.
- c : ℕ
The counter of the walks.
- w : ℕ
The digits of the counter not yet used.
- j : ℕ
The steps of the walk not yet taken.
The state of the evaluation of the rotation map: the slot, the labels and the frames.
Instances For
The step of the evaluation with the entry bit of the adjacency matrix.
Instances For
The address read by a step: the next bit of the header while counting it, and the entry of the adjacency matrix at the slot at a step of the slot graph.
Instances For
The read machine for undirected connectivity.