Documentation

CslibFrontier.Computability.BranchingProgram.ReadOnce

Read-once branching programs #

A read-once branching program of length L over an alphabet X, with states S, reads a word x : Fin L → X letter by letter in the standard order: it starts in the state start, at time i it moves from its current state s to step i s (x i), and it accepts when the final state satisfies accept (ReadOnceProgram, ReadOnceProgram.eval). Its width is the number of states Fintype.card S. Read-once branching programs of width w and length L model computations of length L with log w bits of memory reading a one-way stream of random letters, the tests fooled by Nisan's generator. These are the standard-order read-once branching programs of Hatami and Hoza, Definition 1.5, the oblivious read-once branching programs of Vadhan, Section 8.2.1 (with layers of states S and edges labelled by letters). A program of length m * n over X regroups into a program of length m over the blocks Fin n → X with the same states (ReadOnceProgram.blocks, ReadOnceProgram.eval_blocks); the words of length m * n are the blocks concatenated by Cslib.BitString.blocksEquiv.symm.

The run of a time-dependent transition function δ : ℕ → S → X → S on a list of letters l, starting at time t in state s, is the indexed fold l.foldlIdx δ s t (List.foldlIdx_append splits runs). A program runs its transition function extended by the identity after time L (ReadOnceProgram.finalState_eq).

Read-once branching programs are a sequential form of monoid programs (Cslib.BranchingPrograms.MonoidProgram) over the transformation monoid Function.End S. That model fixes a monoid element for each letter read, but lets instructions read positions in any order and any number of times, and measures length rather than width. A read-once program is the monoid program whose i-th instruction from the end reads position i and selects step i · a on the letter a; since the last instruction of a program over Function.End S acts first, it maps the start state to the final state (ReadOnceProgram.toMonoidProgram, ReadOnceProgram.eval_toMonoidProgram). The read-once nondeterministic programs Cslib.Circuits.Frontier.ReadOnceNBP instead read sets of coordinates in a layout order, with nondeterministic transitions.

A read-once program with finitely many states is also a deterministic branching program (Cslib.BranchingPrograms.BranchingProgram), which may query any coordinate at any node: its nodes are the pairs of a time and a state, so it has (L + 1) * Fintype.card S of them (ReadOnceProgram.toBranchingProgram, ReadOnceProgram.eval_toBranchingProgram, ReadOnceProgram.size_toBranchingProgram).

Main definitions #

Main results #

References #

structure Cslib.BranchingPrograms.ReadOnceProgram (L : ℕ) (S : Type u_3) (X : Type u_4) :
Type (max u_3 u_4)

A read-once branching program in standard order, of length L over the alphabet X with states S: from the state start, at time i it moves from state s to step i s a on reading the i-th letter a, and it accepts when the final state satisfies accept. Its width is Fintype.card S Hatami and Hoza, Definition 1.5.

  • start : S

    The start state.

  • step : Fin L → S → X → S

    The transition at each time, on the current state and the letter read.

  • accept : S → Bool

    The accepting final states.

def Cslib.BranchingPrograms.ReadOnceProgram.finalState {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) :
S

The state of the program after reading the word x.

def Cslib.BranchingPrograms.ReadOnceProgram.eval {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) :

The output of the program on the word x: whether its final state is accepting.

def Cslib.BranchingPrograms.ReadOnceProgram.stepAt {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (t : ℕ) (s : S) (a : X) :
S

The transition function of the program at every time, the identity from time L on.

theorem Cslib.BranchingPrograms.ReadOnceProgram.finalState_eq {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) :

The final state is the run of the extended transition function stepAt on the word.

def Cslib.BranchingPrograms.ReadOnceProgram.runFrom {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) (t : ℕ) (s : S) :
S

The state reached from the state s at time t by reading the rest of the word x.

theorem Cslib.BranchingPrograms.ReadOnceProgram.runFrom_zero {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) :

Reading the whole word from the start gives the final state.

theorem Cslib.BranchingPrograms.ReadOnceProgram.runFrom_of_le {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) {t : ℕ} (ht : L ≤ t) (s : S) :
P.runFrom x t s = s

From time L on, no more letters are read.

theorem Cslib.BranchingPrograms.ReadOnceProgram.runFrom_step {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) (x : Fin L → X) {t : ℕ} (ht : t < L) (s : S) :
P.runFrom x t s = P.runFrom x (t + 1) (P.step ⟨t, ht⟩ s (x ⟨t, ht⟩))

Before time L, one step of runFrom reads x ⟨t, ht⟩ and advances to t + 1.

Blocks #

def Cslib.BranchingPrograms.ReadOnceProgram.blocks {S : Type u_1} {X : Type u_2} {m n : ℕ} (P : ReadOnceProgram (m * n) S X) :
ReadOnceProgram m S (Fin n → X)

The program of length m on blocks of n letters: at time i it runs P on the i-th block, from time n * i. It has the same states, hence the same width.

theorem Cslib.BranchingPrograms.ReadOnceProgram.finalState_blocks {S : Type u_1} {X : Type u_2} {m n : ℕ} (P : ReadOnceProgram (m * n) S X) (x : Fin m → Fin n → X) :

Regrouping into blocks preserves final states.

theorem Cslib.BranchingPrograms.ReadOnceProgram.eval_blocks {S : Type u_1} {X : Type u_2} {m n : ℕ} (P : ReadOnceProgram (m * n) S X) (x : Fin m → Fin n → X) :

Regrouping into blocks preserves outputs.

Monoid programs #

The program as a monoid program over Function.End S: the i-th instruction from the end reads position i and selects step i · a on the letter a.

Read-once programs are monoid programs: the monoid program P.toMonoidProgram evaluates on x to the map sending the start state to the final state of P on x.

Branching programs #

The program as a graph on the pairs of a time and a state: at a time t < L the node (t, s) queries position t and moves to (t + 1, step t s a) on the letter a, and at time L it is a sink returning accept s.

theorem Cslib.BranchingPrograms.ReadOnceProgram.evalNode_toGraph {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) [Fintype S] (x : Fin L → X) (k : ℕ) (t : Fin (L + 1)) (s : S) :
L - ↑t = k → P.toGraph.evalNode x (t, s) = P.accept (P.runFrom x (↑t) s)

From the node (t, s), the graph of P reaches the output of P run from time t and state s.

noncomputable def Cslib.BranchingPrograms.ReadOnceProgram.toBranchingProgram {S : Type u_1} {X : Type u_2} {L : ℕ} (P : ReadOnceProgram L S X) [Fintype S] :

The program as a deterministic branching program, with a node for each time and state.

@[simp]

Read-once programs are branching programs: P.toBranchingProgram computes the same function as P.

@[simp]

The branching program of a read-once program has (L + 1) * Fintype.card S nodes.