Documentation

CslibFrontier.Computability.BranchingProgram.ReadOnceParity

Syntactic read-once parity branching programs #

A read-once parity branching program Volk, Definition 1.1 is a directed acyclic multigraph with a source and a target whose edges are labelled by literals or Boolean constants. It accepts an input when an odd number of source-to-target paths are consistent with it, and it is syntactically read-once when no variable is tested twice on any source-to-target path, whether or not the path is consistent with some input. Its size is its number of edges.

In this library such a program is a nondeterministic branching program NBP with parity acceptance (NBP.AcceptsParity). Rectifiers are the edges labelled 1, and contacts testing x i = true and x i = false are the positive and negative literals. An edge labelled 0 is never switched on, so deleting it changes no path count and lowers the number of edges: lower bounds for programs without such edges apply to programs with them. This file adds the read-once condition and the size measure:

Vertices and edges. Parallel wires with the same head and label cancel in pairs under parity acceptance. NBP.reduce keeps one copy of each wire of odd multiplicity at every node. It accepts the same inputs by parity (NBP.acceptsParity_reduce_iff), is read-once when the original is (NBP.IsReadOnce.reduce), and has at most n ^ 2 * (|ι| |α| + 1) wires on n nodes (NBP.wireCount_reduce_le). So for parity acceptance the number of wires and the number of nodes are polynomially related.

Main definitions #

Main results #

References #

Size and routes #

def Cslib.BranchingPrograms.NBP.wireCount {ι : Type u_1} {α : Type u_2} {n : ℕ} :
NBP ι α n → ℕ

The number of wires of a program, rectifiers and contacts: the size of a read-once parity branching program in Volk, Definition 1.1.

theorem Cslib.BranchingPrograms.NBP.size_le_wireCount {ι : Type u_1} {α : Type u_2} {n : ℕ} (P : NBP ι α n) :

Contacts are wires.

def Cslib.BranchingPrograms.NBP.tests {ι : Type u_1} {α : Type u_2} {n : ℕ} :
NBP ι α n → Fin n → List (List (ι × α))

For each path from the node v to the target, the tests of its contacts in order, listed with multiplicity: one list for each path.

@[simp]
theorem Cslib.BranchingPrograms.NBP.tests_node_castSucc {ι : Type u_1} {α : Type u_2} {n : ℕ} (P : NBP ι α n) (wires : List (Wire ι α n)) (v : Fin n) :
(P.node wires).tests v.castSucc = P.tests v

An earlier node has the same paths in a longer program.

@[simp]
theorem Cslib.BranchingPrograms.NBP.tests_node_last {ι : Type u_1} {α : Type u_2} {n : ℕ} (P : NBP ι α n) (wires : List (Wire ι α n)) :
(P.node wires).tests (Fin.last n) = List.flatMap (fun (w : Wire ι α n) => List.map (fun (x : List (ι × α)) => w.label.toList ++ x) (P.tests w.head)) wires

The paths from the last node begin with one of its wires.

def Cslib.BranchingPrograms.NBP.routes {ι : Type u_1} {α : Type u_2} {n : ℕ} :
NBP ι α n → List (List (ι × α))

The routes of a program: for each path from the source to the target, the tests of its contacts in order.

theorem Cslib.BranchingPrograms.NBP.routes_node {ι : Type u_1} {α : Type u_2} {n : ℕ} (P : NBP ι α n) (wires : List (Wire ι α n)) :
(P.node wires).routes = (P.node wires).tests (Fin.last n)

The routes of a program are the paths from its last node, the source.

def Cslib.BranchingPrograms.NBP.IsReadOnce {ι : Type u_1} {α : Type u_2} {n : ℕ} (P : NBP ι α n) :

A program is syntactically read-once when no coordinate is tested twice on any path from the source to the target Volk, Definition 1.1. The condition concerns all paths, also those that no input switches on.

Instances For
    @[instance_reducible]

    Path counts #

    theorem Cslib.BranchingPrograms.NBP.paths_eq_countP {ι : Type u_1} {α : Type u_2} [DecidableEq α] (x : ι → α) {n : ℕ} (P : NBP ι α n) (v : Fin n) :
    paths x P v = List.countP (fun (l : List (ι × α)) => l.all fun (p : ι × α) => decide (x p.1 = p.2)) (P.tests v)

    The input x switches on the paths from v whose tests it passes: their number is the path count P.paths x v.

    theorem Cslib.BranchingPrograms.NBP.pathCount_eq_countP {ι : Type u_1} {α : Type u_2} [DecidableEq α] {n : ℕ} (P : NBP ι α n) (x : ι → α) :
    P.pathCount x = List.countP (fun (l : List (ι × α)) => l.all fun (p : ι × α) => decide (x p.1 = p.2)) P.routes

    Path counts by routes. The number of paths from the source to the target that x switches on is the number of routes whose tests it passes.

    Cancelling parallel wires #

    def Cslib.BranchingPrograms.NBP.oddWires {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} (wires : List (Wire ι α n)) :
    List (Wire ι α n)

    The wires of odd multiplicity in a list, each once.

    def Cslib.BranchingPrograms.NBP.reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} :
    NBP ι α n → NBP ι α n

    Cancel parallel wires in pairs: at every node keep one copy of each wire, with its head and label, that occurs an odd number of times.

    theorem Cslib.BranchingPrograms.NBP.mem_tests_of_mem_tests_reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} (P : NBP ι α n) (v : Fin n) {l : List (ι × α)} :
    l ∈ P.reduce.tests v → l ∈ P.tests v

    Every path of the reduced program is a path of the original one.

    theorem Cslib.BranchingPrograms.NBP.mem_routes_of_mem_routes_reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} (P : NBP ι α n) {l : List (ι × α)} (h : l ∈ P.reduce.routes) :

    Every route of the reduced program is a route of the original one.

    theorem Cslib.BranchingPrograms.NBP.IsReadOnce.reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} {P : NBP ι α n} (h : P.IsReadOnce) :

    Cancelling parallel wires keeps a program read-once.

    theorem Cslib.BranchingPrograms.NBP.paths_reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] (x : ι → α) {n : ℕ} (P : NBP ι α n) (v : Fin n) :
    ↑(paths x P.reduce v) = ↑(paths x P v)

    Cancelling parallel wires keeps the parity of the number of paths switched on from each node.

    theorem Cslib.BranchingPrograms.NBP.pathCount_reduce {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} (P : NBP ι α n) (x : ι → α) :
    ↑(P.reduce.pathCount x) = ↑(P.pathCount x)

    Cancelling parallel wires keeps the parity of the number of paths switched on.

    theorem Cslib.BranchingPrograms.NBP.acceptsParity_reduce_iff {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] {n : ℕ} (P : NBP ι α n) (x : ι → α) :

    Cancelling parallel wires keeps the function computed by parity.

    theorem Cslib.BranchingPrograms.NBP.wireCount_reduce_le {ι : Type u_1} {α : Type u_2} [DecidableEq ι] [DecidableEq α] [Fintype ι] [Fintype α] {n : ℕ} (P : NBP ι α n) :

    Edges against vertices. After cancelling parallel wires, a program on n nodes has at most n ^ 2 * (|ι| |α| + 1) wires: each node keeps at most one wire of each head and label.