Documentation

Complexity.Computability.Circuit.Boolean.ReadOnce

Positive and read-once Boolean formulas from tight binary-cost circuits #

A one-output De Morgan circuit c : Circuit Boolean.signature n 1 on n ≥ 1 variables that depends on all n inputs must use at least n - 1 binary (AND/OR) gates (Circuit.card_inputSupport_le_cost_binaryCost). When n ≥ 1 and this bound is tight (c.program.cost binaryCost ≤ n - 1, i.e. c.program.cost binaryCost + 1 ≤ n), no gate in the backward cone of the output can share wires or use a Boolean constant, so the circuit unfolds without duplication into a constant-free negation-normal-form formula (LitFormula) of leaf size n in which each of the n variables appears at a single leaf (Circuit.exists_litFormula_of_cost_binaryCost_le).

If moreover every coordinate i : Fin n is positively essential—meaning some pair of inputs differing only at i flips the output from false to true when coordinate i is flipped from false to true—then every leaf must have positive polarity, yielding a positive (monotone) read-once formula F : PosFormula n of leaf size n and gate size n - 1 computing the same function (Circuit.exists_posFormula_of_cost_binaryCost_le) [Ilango2020FOCS, Section III.B; ECCC TR20-183, Section 3, Claim 13, p. 24].

Main definitions #

Main results #

References #

Constant-free positive (monotone) Boolean formulas #

A constant-free positive Boolean formula on n variables, built from input variables var i using binary conjunction (and) and disjunction (or).

Instances For
    def Cslib.Circuits.Boolean.instDecidableEqPosFormula.decEq {n✝ : ℕ} (x✝ x✝¹ : PosFormula n✝) :
    Decidable (x✝ = x✝¹)
    Instances For

      Evaluate a positive formula on an n-bit input.

      Instances For
        @[simp]
        theorem Cslib.Circuits.Boolean.PosFormula.eval_var {n : ℕ} (i : Fin n) (x : BitString n) :
        (var i).eval x = x i
        @[simp]
        theorem Cslib.Circuits.Boolean.PosFormula.eval_and {n : ℕ} (L R : PosFormula n) (x : BitString n) :
        (L.and R).eval x = (L.eval x && R.eval x)
        @[simp]
        theorem Cslib.Circuits.Boolean.PosFormula.eval_or {n : ℕ} (L R : PosFormula n) (x : BitString n) :
        (L.or R).eval x = (L.eval x || R.eval x)

        Number of variable leaves in a positive formula.

        Instances For

          Number of binary gates (and and or) in a positive formula.

          Instances For
            @[simp]
            @[simp]

            Number of and gates in a positive formula.

            Instances For

              Number of or gates in a positive formula.

              Instances For

                The set of input variables appearing at the leaves of a positive formula.

                Instances For

                  A positive formula is read-once when no input variable appears at more than one leaf.

                  Instances For

                    A positive formula is read-once if and only if its leaf support has cardinality equal to its leaf size.

                    theorem Cslib.Circuits.Boolean.PosFormula.eval_eq_of_eq_on_leafSupport {n : ℕ} (F : PosFormula n) {x y : BitString n} (h : ∀ i ∈ F.leafSupport, x i = y i) :
                    F.eval x = F.eval y

                    Evaluation of a positive formula depends only on the variables in F.leafSupport.

                    Positive formulas compute monotone Boolean functions.

                    A positive formula with no and gates evaluates to the disjunction of the variables in its leaf support.

                    Embedding into De Morgan and monotone formulas and circuits #

                    View a PosFormula as a De Morgan Formula.

                    Instances For

                      Compile a PosFormula to a one-output De Morgan circuit.

                      Instances For

                        Subformulas and context invariance in read-once formulas #

                        IsSubformula T F holds when T occurs as a syntactic subformula of F.

                        Instances For
                          theorem Cslib.Circuits.Boolean.PosFormula.eval_eq_of_isSubformula_of_eval_eq {n : ℕ} {T F : PosFormula n} (hsub : T.IsSubformula F) (hro : F.IsReadOnce) {w₁ w₂ : BitString n} (hout : ∀ v ∉ T.leafSupport, w₁ v = w₂ v) (heval : T.eval w₁ = T.eval w₂) :
                          F.eval w₁ = F.eval w₂

                          In a read-once positive formula F, if T is a subformula of F and two inputs w₁, w₂ agree on all coordinates outside T.leafSupport and give T the same Boolean value, then F evaluates to the same value on w₁ and w₂.

                          Flip-sensitivity bound on numOr #

                          The coordinates in F.leafSupport whose flip from w₀ to true changes F.eval from false to true.

                          Instances For

                            Gate-elimination bound on OR gates [Ilango2020FOCS, Section III.B; ECCC TR20-183, Section 3, Claim 14, p. 25]: in any read-once positive formula F, for any baseline input w₀, at most F.numOr + 1 coordinates in F.leafSupport flip F.eval from false to true.

                            Indexed disjunction of positive formulas #

                            def Cslib.Circuits.Boolean.PosFormula.orFin {N : ℕ} (m : ℕ) :
                            0 < m → (Fin m → PosFormula N) → PosFormula N

                            Right-nested disjunction of m positive formulas (m > 0).

                            Instances For
                              theorem Cslib.Circuits.Boolean.PosFormula.eval_orFin {N : ℕ} (m : ℕ) (hm : 0 < m) (f : Fin m → PosFormula N) (w : BitString N) :
                              (orFin m hm f).eval w = decide (∃ (i : Fin m), (f i).eval w = true)
                              theorem Cslib.Circuits.Boolean.PosFormula.leafSize_orFin_of_eq {N : ℕ} (m : ℕ) (hm : 0 < m) (f : Fin m → PosFormula N) (k : ℕ) :
                              (∀ (i : Fin m), (f i).leafSize = k) → (orFin m hm f).leafSize = m * k
                              theorem Cslib.Circuits.Boolean.PosFormula.mem_leafSupport_orFin {N : ℕ} (m : ℕ) (hm : 0 < m) (f : Fin m → PosFormula N) (v : Fin N) :
                              v ∈ (orFin m hm f).leafSupport ↔ ∃ (i : Fin m), v ∈ (f i).leafSupport

                              Constant-free negation-normal-form Boolean formulas #

                              A constant-free negation-normal-form Boolean formula on n variables, built from literals lit i pol (x i when pol = true, !x i when pol = false) using binary and and or.

                              Instances For
                                def Cslib.Circuits.Boolean.instDecidableEqLitFormula.decEq {n✝ : ℕ} (x✝ x✝¹ : LitFormula n✝) :
                                Decidable (x✝ = x✝¹)
                                Instances For

                                  Evaluate a literal formula on an n-bit input.

                                  Instances For

                                    Negate a literal formula by De Morgan's laws, flipping the polarity of each literal and swapping and and or.

                                    Instances For

                                      Number of literal leaves in a literal formula.

                                      Instances For

                                        Number of positive literal leaves (lit i true) in a literal formula.

                                        Instances For

                                          The set of input variables occurring positively (lit i true) at a leaf.

                                          Instances For

                                            Project a literal formula to a positive formula by dropping literal polarities. When all leaves have positive polarity (posLeafCount = leafSize), this preserves evaluation.

                                            Instances For
                                              theorem Cslib.Circuits.Boolean.LitFormula.eval_le_of_not_mem_posSupport {n : ℕ} {F : LitFormula n} {i : Fin n} (hi : i ∉ F.posSupport) {y₀ y₁ : BitString n} (hdiff : ∀ (k : Fin n), k ≠ i → y₀ k = y₁ k) (hy₀ : y₀ i = false) (hy₁ : y₁ i = true) :
                                              F.eval y₁ ≤ F.eval y₀

                                              If variable i does not occur positively in F, flipping i from false to true can only decrease F.eval.

                                              Unfolding tight binary-cost De Morgan programs into formulas #

                                              theorem Cslib.Circuits.Program.exists_litFormula_of_card_biUnion_wireSupport_ge {n g : ℕ} (hn : 0 < n) (p : Program Boolean.signature n g) (frontier : Finset (Wire n g)) (h : frontier.card + p.cost Boolean.binaryCost ≤ (frontier.biUnion p.wireSupport).card) :
                                              ∃ (F : Wire n g → Boolean.LitFormula n), (∀ w ∈ frontier, ∀ (x : BitString n), (F w).eval x = p.trace Boolean.interpretation x w) ∧ ∑ w ∈ frontier, (F w).leafSize = frontier.card + p.cost Boolean.binaryCost

                                              When a frontier of wires in a De Morgan program achieves the binary-cost support bound frontier.card + p.cost binaryCost ≤ (frontier.biUnion p.wireSupport).card, every wire in the frontier unfolds into a constant-free NNF formula (LitFormula) such that the leaf sizes across the frontier sum to frontier.card + p.cost binaryCost.

                                              A one-output De Morgan circuit with 1 ≤ n, full input support n ≤ c.inputSupport.card, and c.program.cost binaryCost + 1 ≤ n unfolds into a constant-free NNF formula F : LitFormula n of leaf size n computing c.

                                              theorem Cslib.Circuits.Circuit.exists_posFormula_of_cost_binaryCost_le {n : ℕ} (hn : 0 < n) (c : Circuit Boolean.signature n 1) (hcost : c.program.cost Boolean.binaryCost + 1 ≤ n) (hpos : ∀ (i : Fin n), ∃ (y₀ : BitString n) (y₁ : BitString n), (∀ (k : Fin n), k ≠ i → y₀ k = y₁ k) ∧ y₀ i = false ∧ y₁ i = true ∧ c.eval Boolean.interpretation y₀ 0 = false ∧ c.eval Boolean.interpretation y₁ 0 = true) :

                                              Unfolding a tight binary-cost circuit into a positive read-once formula [Ilango2020FOCS, Section III.B; ECCC TR20-183, Section 3, Claim 13, p. 24]: if c is a one-output De Morgan circuit on n ≥ 1 inputs with c.program.cost binaryCost + 1 ≤ n such that every input coordinate i : Fin n is positively essential for fun x => c.eval interpretation x 0, then there exists a read-once positive formula F : PosFormula n with F.leafSize = n, F.size = n - 1, and F.leafSupport = Finset.univ that computes c.