Documentation

Complexity.Computability.Circuit.Boolean.Formula.Restriction

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 #

Main results #

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.

          @[simp]
          @[simp]

          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
            @[simp]

            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.

            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.

                @[simp]
                theorem Cslib.Circuits.Boolean.formulaSize_const {n : ℕ} (b : Bool) :
                (formulaSize fun (x : BitString n) => b) = 0

                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.