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 #
Literal— a Boolean variable with a polarity flag (positive or negative)CNF— a conjunction of clauses (each clause is a disjunction of literals)DNF— a disjunction of terms (each term is a conjunction of literals)CNF.complexity— the number of clauses in a CNF formulaDNF.complexity— the number of terms in a DNF formulaCNF.neg/DNF.neg— De Morgan negation (CNF ↔ DNF)
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
Equations
Instances For
CNF #
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.
The clauses of the formula. Each clause is a list of literals.
Instances For
A CNF formula evaluates to true iff every clause contains at least one
satisfied literal.
Equations
- φ.eval x = φ.clauses.all fun (clause : List (CircuitComplexity.Literal N)) => clause.any fun (l : CircuitComplexity.Literal N) => l.eval x
Instances For
The complexity of a CNF formula is its number of clauses.
Equations
- φ.complexity = φ.clauses.length
Instances For
DNF #
A DNF formula evaluates to true iff at least one term has all its
literals satisfied.
Equations
- φ.eval x = φ.terms.any fun (term : List (CircuitComplexity.Literal N)) => term.all fun (l : CircuitComplexity.Literal N) => l.eval x
Instances For
The complexity of a DNF formula is its number of terms.
Equations
- φ.complexity = φ.terms.length
Instances For
De Morgan Negation Duality #
Negate a CNF formula by flipping all literal polarities, producing a DNF.
By De Morgan's laws, ¬(∧ᵢ ∨ⱼ lᵢⱼ) = ∨ᵢ ∧ⱼ ¬lᵢⱼ.
Equations
- φ.neg = { terms := List.map (fun (clause : List (CircuitComplexity.Literal N)) => List.map CircuitComplexity.Literal.neg clause) φ.clauses }
Instances For
Negate a DNF formula by flipping all literal polarities, producing a CNF.
By De Morgan's laws, ¬(∨ᵢ ∧ⱼ lᵢⱼ) = ∧ᵢ ∨ⱼ ¬lᵢⱼ.
Equations
- φ.neg = { clauses := List.map (fun (term : List (CircuitComplexity.Literal N)) => List.map CircuitComplexity.Literal.neg term) φ.terms }
Instances For
Negating a CNF preserves complexity.