Restrictions of De Morgan formulas #
Restricting a De Morgan formula by a partial assignment ρ (Formula.restrict) replaces the
leaves of the fixed inputs by constants and simplifies bottom up: constants are propagated through
the gates, and double negations cancel. The result computes the restricted function
F.eval ∘ ρ.fill (Formula.eval_restrict) and keeps only the leaves of the free inputs
(Formula.leafSize_restrict_le). It is a constant or a simplified formula
(Formula.IsSimplified): one without constants or double negations, which has at most 3 L - 2
operation nodes for L leaves (Formula.IsSimplified.size_add_two_le). In particular a formula
whose restriction has no leaves restricts to a constant (Formula.exists_restrict_eq_const).
The formula size Boolean.formulaSize f of a Boolean function is the least leaf size of a De
Morgan formula computing it, Jukna's L(f) Jukna, Chapter 6. Restrictions do not
increase it (Boolean.formulaSize_comp_fill_le), and a function depending only on a set S of
inputs has a formula of least leaf size whose leaves all read inputs in S
(Boolean.leafSizeIn_eq_leafSize_of_dependsOn). Every function has a formula of least leaf size
with at most 3 L(f) - 2 operation nodes, or a constant (Boolean.exists_computes_size_le).
Main definitions #
Cslib.Circuits.Formula.mkNot,Cslib.Circuits.Formula.mkAnd,Cslib.Circuits.Formula.mkOr: negation, conjunction and disjunction, simplifying constants and double negations.Cslib.Circuits.Formula.restrict: the restriction of a formula by a partial assignment.Cslib.Circuits.Formula.IsSimplified: formulas without constants or double negations.Cslib.Circuits.Boolean.formulaSize: the least leaf size of a De Morgan formula computing a function.
Main results #
Cslib.Circuits.Formula.eval_restrict: a restriction computes the restricted function.Cslib.Circuits.Formula.leafSize_restrict_le: a restriction keeps only the leaves of the free inputs.Cslib.Circuits.Formula.restrict_eq_const_or_isSimplified: a restriction is a constant or simplified.Cslib.Circuits.Boolean.formulaSize_le,Cslib.Circuits.Boolean.exists_computes_leafSize_eq: the formula size is the least leaf size, and it is attained.Cslib.Circuits.Boolean.formulaSize_comp_fill_le_leafSizeIn,Cslib.Circuits.Boolean.formulaSize_comp_fill_le: restrictions do not increase the formula size.Cslib.Circuits.Boolean.exists_computes_size_le: a formula of least leaf size with few operation nodes.
References #
Simplifying gates #
The value of a constant formula, and none for every other formula.
Instances For
A formula with a constant value is that constant.
A formula is either a constant or has constValue? = none.
Negation, cancelling a double negation and evaluating a negated constant.
Instances For
Conjunction, simplifying constant arguments.
Instances For
Disjunction, simplifying constant arguments.
Instances For
A unary node is the negation of its argument.
A binary .and node is the conjunction of its arguments.
A binary .or node is the disjunction of its arguments.
Restriction #
The restriction of a formula by a partial assignment ρ: the leaves of the inputs fixed by
ρ become constants, and constants and double negations are simplified bottom up.
Instances For
A restriction computes the restricted function: it reads the fixed inputs from ρ.
A restriction keeps only the leaves of the free inputs.
Restricting by an assignment of a single input removes its leaves.
Simplified formulas #
A De Morgan formula is simplified when it has no constants and no double negations: it is built from inputs by conjunctions and disjunctions, and negations of inputs, conjunctions and disjunctions.
- input {n : ℕ} (i : Fin n) : (Formula.input i).IsSimplified
An input.
- not_input {n : ℕ} (i : Fin n) : (Formula.input i).not.IsSimplified
A negated input.
- and {n : ℕ} {F G : Formula Boolean.signature n} : F.IsSimplified → G.IsSimplified → (F.and G).IsSimplified
A conjunction of simplified formulas.
- or {n : ℕ} {F G : Formula Boolean.signature n} : F.IsSimplified → G.IsSimplified → (F.or G).IsSimplified
A disjunction of simplified formulas.
- not_and {n : ℕ} {F G : Formula Boolean.signature n} : F.IsSimplified → G.IsSimplified → (F.and G).not.IsSimplified
A negated conjunction of simplified formulas.
- not_or {n : ℕ} {F G : Formula Boolean.signature n} : F.IsSimplified → G.IsSimplified → (F.or G).not.IsSimplified
A negated disjunction of simplified formulas.
Instances For
A simplified formula has a leaf.
A simplified formula with L leaves has at most 3 L - 2 operation nodes.
A restriction is a constant or a simplified formula.
A restriction without leaves is a constant.
Formula size #
The formula size of a Boolean function: the least leaf size of a De Morgan formula computing
it, Jukna's L(f) Jukna, Chapter 6. Every function has a formula
(Formula.exists_computes), so the least leaf size exists.
Instances For
The formula size is at most the leaf size of every formula computing the function.
Some formula computing the function has the least leaf size.
Lower bounds on the formula size are lower bounds on the leaf size of every formula.
A constant function has formula size zero.
A function of no inputs has formula size zero.
A restriction of a formula computing f computes the restriction of f, with only the leaves
of the free inputs.
Restricting a Boolean function by a partial assignment does not increase its formula size.
A formula of least leaf size for a function depending only on the inputs in S has all its
leaves in S.
Every function has a formula of least leaf size that is a constant or has at most 3 L - 2
operation nodes for L leaves.