CNF & Clause Form

Conjunctive Normal Form and Clause Representation

Back to Lecture Overview

Introduction

Conjunctive Normal Form (CNF) and clause representation are fundamental preprocessing steps in automated reasoning and theorem proving. Converting logical formulas to CNF enables efficient application of resolution-based inference algorithms.

Why CNF Matters:
  • Standard form for automated theorem provers
  • Enables efficient resolution-based reasoning
  • Simplifies logical formula manipulation
  • Essential for SAT solving algorithms
Applications:
  • Automated theorem proving
  • Logic programming (Prolog)
  • SAT and SMT solvers
  • Model checking and verification

What is Conjunctive Normal Form (CNF)?

Conjunctive Normal Form (CNF)

A logical formula is in CNF if it is a conjunction of disjunctions of literals.

(L₁₁ ∨ L₁₂ ∨ ... ∨ L₁ₙ) ∧ (L₂₁ ∨ L₂₂ ∨ ... ∨ L₂ₘ) ∧ ... ∧ (Lₖ₁ ∨ Lₖ₂ ∨ ... ∨ Lₖₚ)

Where each Lᵢⱼ is a literal (a propositional variable or its negation)

✅ CNF Examples:
(P ∨ Q) ∧ (¬P ∨ R)
(A ∨ ¬B ∨ C) ∧ (¬A) ∧ (B ∨ ¬C)
P ∧ Q ∧ R
❌ Not CNF Examples:
P ∨ (Q ∧ R)
(P → Q) ∧ R
¬(P ∧ Q)

Understanding Clauses

What is a Clause?

A clause is a disjunction of literals. In CNF, each parenthesized group is a clause.

Example: (P ∨ ¬Q ∨ R) ∧ (¬P ∨ S) ∧ (Q ∨ ¬R ∨ ¬S)
Clause 1: (P ∨ ¬Q ∨ R)
Clause 2: (¬P ∨ S)
Clause 3: (Q ∨ ¬R ∨ ¬S)
Literals in Clause 1:
P ¬Q R
Literals in Clause 2:
¬P S
Literals in Clause 3:
Q ¬R ¬S

Converting to CNF: Step-by-Step Algorithm

CNF Conversion Algorithm

Follow these steps to convert any propositional logic formula to CNF:

1
Eliminate Implications and Biconditionals
  • Replace P → Q with ¬P ∨ Q
  • Replace P ↔ Q with (P → Q) ∧ (Q → P), then apply step 1
2
Move Negations Inward (De Morgan's Laws)
  • Replace ¬(P ∧ Q) with ¬P ∨ ¬Q
  • Replace ¬(P ∨ Q) with ¬P ∧ ¬Q
  • Replace ¬¬P with P
3
Distribute OR over AND
  • Replace P ∨ (Q ∧ R) with (P ∨ Q) ∧ (P ∨ R)
  • Replace (P ∧ Q) ∨ R with (P ∨ R) ∧ (Q ∨ R)
4
Simplify (Optional)
  • Remove duplicate literals in clauses
  • Remove tautological clauses (containing both P and ¬P)
  • Remove subsumed clauses

Detailed Conversion Examples

Example 1: Converting (P → Q) ∧ (Q → R)
Original:
(P → Q) ∧ (Q → R)
Step 1:
(¬P ∨ Q) ∧ (¬Q ∨ R)

Steps:

  1. Eliminate implications: (P → Q) becomes (¬P ∨ Q)
  2. Result: (¬P ∨ Q) ∧ (¬Q ∨ R) ✅ Already in CNF!
Example 2: Converting ¬(P ∧ Q) ∨ R
Original:
¬(P ∧ Q) ∨ R
Final CNF:
(¬P ∨ ¬Q ∨ R)

Steps:

  1. Apply De Morgan's law: ¬(P ∧ Q) becomes (¬P ∨ ¬Q)
  2. Substitute: (¬P ∨ ¬Q) ∨ R
  3. Associativity: (¬P ∨ ¬Q ∨ R) ✅ CNF achieved!
Example 3: Converting (P ∨ Q) ∧ (R ∨ (S ∧ T))
Original:
(P ∨ Q) ∧ (R ∨ (S ∧ T))
Final CNF:
(P ∨ Q) ∧ (R ∨ S) ∧ (R ∨ T)

Steps:

  1. Identify issue: (R ∨ (S ∧ T)) is not in CNF
  2. Distribute OR over AND: R ∨ (S ∧ T) becomes (R ∨ S) ∧ (R ∨ T)
  3. Substitute: (P ∨ Q) ∧ (R ∨ S) ∧ (R ∨ T) ✅ CNF achieved!

Interactive CNF Converter

Try Converting Your Own Formulas!

Enter a propositional logic formula and see the CNF conversion steps:

Enter a formula above and click "Convert to CNF" to see the result...
Supported Operators: Use ∧ (AND), ∨ (OR), → (IMPLIES), ↔ (IFF), ¬ (NOT), and parentheses ( )

Why CNF is Essential

Automated Reasoning
  • Resolution algorithm requires CNF input
  • Uniform clause structure simplifies processing
  • Enables efficient unification and matching
  • Standard format for theorem provers
Computational Efficiency
  • Simplified data structures for clauses
  • Faster formula manipulation algorithms
  • Optimized memory usage patterns
  • Parallel processing opportunities
SAT Solving
  • CNF is the standard input for SAT solvers
  • Enables DPLL and CDCL algorithms
  • Supports efficient unit propagation
  • Facilitates conflict-driven learning
Logic Programming
  • Prolog clauses are essentially CNF
  • Enables SLD resolution
  • Supports backtracking search
  • Facilitates program transformation