Documentation

Complexity.Computability.Circuit.Boolean.Formula

De Morgan formulas #

A De Morgan formula is a formula over the De Morgan signature, Formula Boolean.signature n, evaluated under Boolean.interpretation. Negations may appear anywhere. Pushing them to the leaves by De Morgan's laws does not change the leaf size, so lower bounds on the leaf size of these formulas are at least as strong as for formulas whose negations sit at the leaves Jukna, Chapter 6.

Main definitions #

Main results #

References #

The constant De Morgan formula.

Instances For

    The negation of a De Morgan formula.

    Instances For

      The conjunction of two De Morgan formulas.

      Instances For

        The disjunction of two De Morgan formulas.

        Instances For

          The exclusive or of two De Morgan formulas, (F ∧ ¬G) ∨ (¬F ∧ G).

          Instances For
            @[simp]

            Evaluating const c returns c.

            @[simp]

            Evaluating F.not negates the value of F.

            @[simp]

            Evaluating F.and G takes the conjunction of the values of F and G.

            @[simp]

            Evaluating F.or G takes the disjunction of the values of F and G.

            @[simp]

            Evaluating F.xor G takes the exclusive or of the values of F and G.

            @[simp]

            Negation preserves the leaf size of a formula.

            @[simp]

            The leaf size of a conjunction is the sum of the leaf sizes of its conjuncts.

            @[simp]

            The leaf size of a disjunction is the sum of the leaf sizes of its disjuncts.

            @[simp]

            The leaf size of F.xor G is twice the sum of the leaf sizes of F and G.

            @[simp]

            A constant formula has no input leaves.

            @[simp]

            A constant formula has no leaves in Y.

            @[simp]

            Negation preserves the number of leaves in Y.

            @[simp]

            The number of leaves in Y of a conjunction is the sum of those of its conjuncts.

            @[simp]

            The number of leaves in Y of a disjunction is the sum of those of its disjuncts.

            @[simp]

            A constant is one operation node.

            @[simp]

            A negation adds one operation node.

            @[simp]

            A conjunction adds one operation node.

            @[simp]

            A disjunction adds one operation node.

            @[simp]
            theorem Cslib.Circuits.Formula.size_xor {n : ℕ} (F G : Formula Boolean.signature n) :
            (F.xor G).size = 2 * F.size + 2 * G.size + 5

            Exclusive or uses two copies of each argument and five operation nodes.

            @[simp]

            A constant has depth one.

            @[simp]

            A negation is one deeper than its argument.

            @[simp]

            A conjunction is one deeper than the deeper conjunct.

            @[simp]

            A disjunction is one deeper than the deeper disjunct.

            Exclusive or adds at most three levels beyond its deeper argument.

            @[simp]
            theorem Cslib.Circuits.Formula.depthWith_const {n : ℕ} (cost : Boolean.Op → ℕ) (c : Bool) :
            depthWith cost (const c) = cost (Boolean.Op.const c)

            The weighted depth of const c is cost (.const c).

            @[simp]

            The weighted depth of F.not adds cost .not to the weighted depth of F.

            @[simp]
            theorem Cslib.Circuits.Formula.depthWith_and {n : ℕ} (F G : Formula Boolean.signature n) (cost : Boolean.Op → ℕ) :
            depthWith cost (F.and G) = max (depthWith cost F) (depthWith cost G) + cost Boolean.Op.and

            The weighted depth of F.and G adds cost .and to the maximum weighted depth of F and G.

            @[simp]
            theorem Cslib.Circuits.Formula.depthWith_or {n : ℕ} (F G : Formula Boolean.signature n) (cost : Boolean.Op → ℕ) :
            depthWith cost (F.or G) = max (depthWith cost F) (depthWith cost G) + cost Boolean.Op.or

            The weighted depth of F.or G adds cost .or to the maximum weighted depth of F and G.

            @[simp]

            A conjunction is the binary node of .and.

            @[simp]

            A disjunction is the binary node of .or.

            The disjunction of a list of De Morgan formulas, as a balanced tree (Formula.balanced); the constant false for no formulas.

            Instances For

              The conjunction of a list of De Morgan formulas, as a balanced tree (Formula.balanced); the constant true for no formulas.

              Instances For
                @[simp]

                Evaluating orList l tests whether any formula in l evaluates to true.

                @[simp]

                Evaluating andList l tests whether every formula in l evaluates to true.

                @[simp]

                The disjunction of no formulas is the constant false.

                @[simp]

                The disjunction of one formula is that formula.

                @[simp]

                The conjunction of no formulas is the constant true.

                @[simp]

                The conjunction of one formula is that formula.

                A balanced disjunction of k ≥ 1 formulas has k - 1 operation nodes besides theirs.

                A balanced conjunction of k ≥ 1 formulas has k - 1 operation nodes besides theirs.

                theorem Cslib.Circuits.Formula.depthWith_orList_le {n : ℕ} {cost : Boolean.Op → ℕ} {l : List (Formula Boolean.signature n)} {d : ℕ} (hl : ∀ F ∈ l, depthWith cost F ≤ d) (hnil : l = [] → cost (Boolean.Op.const false) ≤ d) :

                A balanced disjunction is deeper than its disjuncts by ⌈log₂⌉ of their number times the cost of a disjunction; the disjunction of no formulas is a constant.

                theorem Cslib.Circuits.Formula.depthWith_andList_le {n : ℕ} {cost : Boolean.Op → ℕ} {l : List (Formula Boolean.signature n)} {d : ℕ} (hl : ∀ F ∈ l, depthWith cost F ≤ d) (hnil : l = [] → cost (Boolean.Op.const true) ≤ d) :

                A balanced conjunction is deeper than its conjuncts by ⌈log₂⌉ of their number times the cost of a conjunction; the conjunction of no formulas is a constant.

                With negations and constants free, a balanced disjunction is deeper than its disjuncts by ⌈log₂⌉ of their number.

                With negations and constants free, a balanced conjunction is deeper than its conjuncts by ⌈log₂⌉ of their number.

                The literal of bit i that is true at z.

                Instances For
                  @[simp]
                  theorem Cslib.Circuits.Formula.eval_literal {n : ℕ} (x z : BitString n) (i : Fin n) :

                  Evaluating literal z i at x tests whether x i equals z i.

                  @[simp]

                  A literal has binary-gate depth zero.

                  Every Boolean function has a De Morgan formula: its disjunctive normal form.

                  The De Morgan basis has fan-in at most two.

                  The least depth of a De Morgan formula computing f, with negations and constants free: the least depth with costs binaryCost (Formula.minDepthWith), which is finite because every function has a formula (Formula.exists_computes).

                  Instances For
                    @[simp]

                    The formula depth is the least depth with costs binaryCost.

                    The formula depth is at most the depth of every formula computing the function.