Alternating formulas #
An alternating formula of depth d over n variables is a formula in negation normal form
whose unbounded fan-in AND and OR gates alternate along every path from the root, with d gates on
each path and literals at the bottom (AltFormula n d): a literal (i, b) holds when bit i is
b, as in Logic.PL.Literal. Its root operation is given when it is evaluated
(AltFormula.eval), and its size counts the AND and OR gates; literals are free
(AltFormula.size). This is the model of constant-depth circuits in which negations are free and
only at the inputs. At depth two, alternating formulas are formulas in conjunctive or disjunctive
normal form (AltFormula.eval_and_eq_cnf_eval, AltFormula.eval_or_eq_dnf_eval).
Substituting literals for the inputs costs nothing (AltFormula.mapInputs), and negating every
input computes the negation with the dual root operation (AltFormula.eval_neg). Every function
has alternating formulas of depth two of size 2 ^ n + 1 (AltFormula.exists_depth_two).
An alternating formula of depth d is a circuit over the unbounded fan-in basis of AND/OR depth
at most d, and of depth at most d + 1 counting negations, with at most n more gates, computing
the negated inputs first (AltFormula.exists_circuit).
Main definitions #
Cslib.Circuits.Boolean.AltFormula: alternating formulas of a given depth.Cslib.Circuits.Boolean.AltFormula.eval,Cslib.Circuits.Boolean.AltFormula.size: their meaning, for a root operation, and their number of gates.
Main results #
Cslib.Circuits.Boolean.AltFormula.eval_and_eq_cnf_eval,Cslib.Circuits.Boolean.AltFormula.eval_or_eq_dnf_eval: depth two is conjunctive and disjunctive normal form.Cslib.Circuits.Boolean.AltFormula.exists_depth_two: normal forms as alternating formulas.Cslib.Circuits.Boolean.AltFormula.exists_circuit: alternating formulas as circuits over the unbounded fan-in basis.
The operation at the root of an alternating formula.
Instances For
De Morgan duality swaps conjunction and disjunction.
Instances For
Alternating formulas of depth d over n variables: literals at depth zero, and a list of
alternating formulas of depth d below each gate of depth d + 1. It is reducible, so that an
alternating formula of depth two is a formula in conjunctive or disjunctive normal form.
Instances For
The number of AND and OR gates; literals are free.
Instances For
Evaluate an alternating formula with op at the root.
Instances For
Substitute literals for the inputs. This changes no gates.
Instances For
Negate every input; with the dual root operation, this computes the negation
(AltFormula.eval_neg).
Instances For
An alternating formula of depth two with a conjunction at the root is a formula in conjunctive normal form.
An alternating formula of depth two with a disjunction at the root is a formula in disjunctive normal form.
Building alternating formulas #
One gate over a finite family of alternating formulas.
Instances For
Merge the roots of a finite family of alternating formulas into one, without adding a gate layer.
Instances For
A constant, as an alternating formula of any depth at least two.
Instances For
The clause excluding exactly the input y.
Instances For
The formula in conjunctive normal form excluding every false input of f.
Instances For
Normal forms: every Boolean function has alternating formulas of depth two, with either
root operation, of size at most 2 ^ n + 1.
Alternating formulas as circuits #
An alternating formula as a formula over the unbounded fan-in basis, on the positive inputs
0, …, n - 1 followed by the negated inputs n, …, 2 n - 1.
Instances For
The circuit computing the positive and the negated inputs, with one negation gate per input.
Instances For
Negations are free in the AND/OR depth, so the literals have AND/OR depth zero.
Alternating formulas are circuits: an alternating formula of depth d computing f
with root op is a circuit over the unbounded fan-in basis of AND/OR depth at most d, and of
depth at most d + 1 counting negations, with at most n more gates, negating every input
first.