Documentation

LeanPool.CircuitComplexity.NF.Defs

Normal Forms — Core Definitions #

This module defines Conjunctive Normal Form (CNF) and Disjunctive Normal Form (DNF) Boolean formulas over N variables, together with their evaluation semantics, complexity measures, and De Morgan negation duality.

Main definitions #

A literal: a Boolean variable (by index) together with a polarity flag.

polarity = true represents the positive literal xᵢ; polarity = false represents the negative literal ¬xᵢ.

  • var : Fin N

    The index of the variable this literal refers to.

  • polarity : Bool

    true = positive literal (xᵢ); false = negative literal (¬xᵢ).

Instances For
    def CircuitComplexity.instDecidableEqLiteral.decEq {N✝ : } (x✝ x✝¹ : Literal N✝) :
    Decidable (x✝ = x✝¹)
    Equations
    Instances For

      Evaluate a literal on a bit assignment.

      Equations
      Instances For

        Negate a literal by flipping its polarity.

        Equations
        Instances For
          theorem CircuitComplexity.Literal.eval_neg {N : } (l : Literal N) (x : BitString N) :
          l.neg.eval x = !l.eval x

          Negating a literal negates its evaluation.

          CNF #

          structure CircuitComplexity.CNF (N : ) :

          A CNF (Conjunctive Normal Form) formula over N Boolean variables.

          A CNF is a conjunction of clauses, where each clause is a disjunction of literals.

          • clauses : List (List (Literal N))

            The clauses of the formula. Each clause is a list of literals.

          Instances For
            def CircuitComplexity.CNF.eval {N : } (φ : CNF N) (x : BitString N) :

            A CNF formula evaluates to true iff every clause contains at least one satisfied literal.

            Equations
            Instances For

              The complexity of a CNF formula is its number of clauses.

              Equations
              Instances For

                DNF #

                structure CircuitComplexity.DNF (N : ) :

                A DNF (Disjunctive Normal Form) formula over N Boolean variables.

                A DNF is a disjunction of terms, where each term is a conjunction of literals.

                • terms : List (List (Literal N))

                  The terms of the formula. Each term is a list of literals.

                Instances For
                  def CircuitComplexity.DNF.eval {N : } (φ : DNF N) (x : BitString N) :

                  A DNF formula evaluates to true iff at least one term has all its literals satisfied.

                  Equations
                  Instances For

                    The complexity of a DNF formula is its number of terms.

                    Equations
                    Instances For

                      De Morgan Negation Duality #

                      def CircuitComplexity.CNF.neg {N : } (φ : CNF N) :
                      DNF N

                      Negate a CNF formula by flipping all literal polarities, producing a DNF. By De Morgan's laws, ¬(∧ᵢ ∨ⱼ lᵢⱼ) = ∨ᵢ ∧ⱼ ¬lᵢⱼ.

                      Equations
                      Instances For
                        def CircuitComplexity.DNF.neg {N : } (φ : DNF N) :
                        CNF N

                        Negate a DNF formula by flipping all literal polarities, producing a CNF. By De Morgan's laws, ¬(∨ᵢ ∧ⱼ lᵢⱼ) = ∧ᵢ ∨ⱼ ¬lᵢⱼ.

                        Equations
                        Instances For
                          theorem CircuitComplexity.CNF.eval_neg {N : } (φ : CNF N) (x : BitString N) :
                          φ.neg.eval x = !φ.eval x

                          Negating a CNF formula negates its evaluation (De Morgan duality).

                          theorem CircuitComplexity.DNF.eval_neg {N : } (φ : DNF N) (x : BitString N) :
                          φ.neg.eval x = !φ.eval x

                          Negating a DNF formula negates its evaluation (De Morgan duality).

                          Negating a CNF preserves complexity.