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

                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) :

                  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.