Documentation

Complexitylib.Circuits.NormalForm.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 #

Relation to Complexity.SAT #

Complexity.Literal, Complexity.CNF, and Complexity.DNF are deliberately distinct from Complexity.SAT.Lit and Complexity.SAT.CNF. The types here are Fin-indexed over a fixed variable count N and are used for circuit lower bounds, whereas the SAT versions are Nat-indexed and serve as the language encoding for SAT.

structure Complexity.Literal (N : ) :

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 Boolean variable this literal refers to.

  • polarity : Bool

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

Instances For
    def Complexity.instDecidableEqLiteral.decEq {N✝ : } (x✝ x✝¹ : Literal N✝) :
    Decidable (x✝ = x✝¹)
    Equations
    Instances For
      def Complexity.Literal.eval {N : } (l : Literal N) (x : BitString N) :

      Evaluate a literal on a bit assignment.

      Equations
      Instances For

        Negate a literal by flipping its polarity.

        Equations
        Instances For
          theorem Complexity.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 Complexity.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 Complexity.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
              def Complexity.CNF.complexity {N : } (φ : CNF N) :

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

              Equations
              Instances For

                DNF #

                structure Complexity.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 Complexity.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
                    def Complexity.DNF.complexity {N : } (φ : DNF N) :

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

                    Equations
                    Instances For

                      De Morgan Negation Duality #

                      def Complexity.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 Complexity.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 Complexity.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 Complexity.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.