Nondeterministic branching programs #
A nondeterministic branching program over inputs x : ι → α is a directed acyclic multigraph
with a source and a target, in which each wire is either unlabelled (a rectifier) or labelled by
a test x i = a (a contact). An input switches on the rectifiers and the contacts whose tests it
passes, and the program accepts it when some path from the source to the target uses only wires
that are switched on. The size of a program is its number of contacts
Jukna, Section 1.3. Over Bool the tests are the literals; tests over a larger
alphabet are those of Jukna, Section 15.2.
NBP ι α n lists n nodes in a topological order, as BranchingProgram.Nodes does for
deterministic programs: the first node is the target, each later node is given by the list of
wires leaving it for earlier nodes, and the last node is the source. The number of paths from a
node to the target that an input switches on is defined by structural recursion (NBP.paths,
NBP.pathCount), so it computes by decide on a concrete program. This one count gives the
modes of acceptance: a nondeterministic program accepts when the count is nonzero (NBP.Accepts),
and a parity branching program when it is odd (NBP.AcceptsParity).
The recursion for NBP.paths recomputes the counts of earlier nodes at every use. Two compiler
replacements avoid this. NBP.pathsVector stores the count of every node in a vector, in
topological order, and the compiler uses it for NBP.paths (NBP.paths_eq_pathsImpl).
For NBP.pathCount (NBP.pathCount_eq_pathCountImpl), the compiler counts the switched-on
wires of the source directly when they all lead to the target, and otherwise pushes the number
of paths from the source down the program in an array ending at the highest head of those wires,
with a private helper. A node that no path from the source reaches is stepped
past without reading its wires, and the push stops below the lowest node other than the target that
a path reaches. The kernel
definitions, their simplification rules and kernel reduction (decide, rfl) are unchanged.
Separate calls of NBP.paths may recompute the vector. Compiler replacements apply to callers
compiled with this module imported, not previously compiled callers. This module does not certify a
runtime bound.
A deterministic branching program is a nondeterministic one in which every input switches on
exactly one way out of each query node: a query node has a contact for each letter and an accepting
sink has a rectifier to the target (BranchingProgram.toNBP). Its path count is 1 on the inputs
it accepts and 0 on the others (BranchingProgram.pathCount_toNBP), and it has at most
Fintype.card α contacts for each node of the deterministic program
(BranchingProgram.size_toNBP_le).
Main definitions #
Cslib.BranchingPrograms.NBP.Wire: a wire to an earlier node, a rectifier or a contact;Cslib.BranchingPrograms.NBP.Wire.equivProdidentifies it with its head and label.Cslib.BranchingPrograms.NBP: a nondeterministic branching program.Cslib.BranchingPrograms.NBP.size: its number of contacts.Cslib.BranchingPrograms.NBP.pathCount: the number of source-to-target paths an input switches on.Cslib.BranchingPrograms.NBP.pathsVector,Cslib.BranchingPrograms.NBP.pathsImpl: the path counts of all nodes stored in a vector, and the compiler implementation ofNBP.pathsreading it.Cslib.BranchingPrograms.NBP.pathCountImpl: the compiler implementation ofNBP.pathCount, which pushes path counts down from the source in an array.Cslib.BranchingPrograms.NBP.Accepts,Cslib.BranchingPrograms.NBP.AcceptsParity: nondeterministic and parity acceptance.Cslib.BranchingPrograms.BranchingProgram.toNBP: a deterministic program as a nondeterministic one.
Main results #
Cslib.BranchingPrograms.NBP.get_pathsVector: the stored counts agree withNBP.paths.Cslib.BranchingPrograms.NBP.paths_eq_pathsImpl,Cslib.BranchingPrograms.NBP.pathCount_eq_pathCountImpl: proved compiler replacements.Cslib.BranchingPrograms.BranchingProgram.pathCount_toNBP: a deterministic program switches on one path on the inputs it accepts and none on the others.Cslib.BranchingPrograms.BranchingProgram.size_toNBP_le: it has at mostFintype.card αcontacts for each of its nodes.
References #
A wire leaving a node of a nondeterministic branching program for one of the n earlier
nodes: a rectifier, or a contact testing one coordinate of the input.
- head : Fin n
The earlier node the wire leads to.
nonefor a rectifier, andsome (i, a)for a contact testingx i = a.
Instances For
A nondeterministic branching program over inputs ι → α, with n nodes in topological
order: the first node is the target, each later node has a list of wires to earlier nodes, and the
last node is the source Jukna, Section 1.3.
Whether the input x switches the wire on: a rectifier always, and a contact when x passes
its test.
The number of paths from each node to the target on which x switches every wire on.
The paths from the last node go through its wires that are switched on.
The target has one path to itself, the empty one.
The number of paths from the source to the target on which x switches every wire on.
The number of paths from each node to the target on which x switches every wire on, computed
node by node in topological order and stored in a vector.
The stored counts agree with NBP.paths.
Compiler implementation of NBP.paths reading the stored counts.
Proved compiler replacement of NBP.paths by NBP.pathsImpl.
Compiler implementation of NBP.pathCount. When every switched-on wire of the source leads to
the target, it counts those wires; otherwise it pushes the source's paths down the program with
the private pathCountFrom, in an array that ends at the highest head of those wires.
Proved compiler replacement of NBP.pathCount by NBP.pathCountImpl.
A nondeterministic branching program accepts an input that switches on some path from the source to the target.
Instances For
A parity branching program accepts an input that switches on an odd number of paths from the source to the target Jukna, Section 1.3.
Instances For
The wires of a node of a deterministic program: a contact for each letter at a query node, a rectifier to the target at an accepting sink, and no wire at a rejecting sink.
A sequence of deterministic nodes as a nondeterministic program: a new target, then the same
nodes with the wires Step.wires.
A deterministic program as a nondeterministic one: a new source with a rectifier to the start node.
The nondeterministic program of a sequence of n deterministic nodes has at most
Fintype.card α contacts for each node.
The nondeterministic program of a deterministic one has at most Fintype.card α contacts for
each node: its size, counting contacts, is at most Fintype.card α times the size, counting
nodes, of the deterministic program.
From each node, a deterministic program switches on one path to the target when it reaches an accepting sink, and none otherwise.
A deterministic branching program is an unambiguous nondeterministic one: it switches on one path from the source to the target on the inputs it accepts, and none on the others.