How to convert First-Order Logic into Conjunctive Normal Form (CNF) and use Resolution graphs to prove theorems.
To perform automated theorem proving, AI systems convert logical sentences into a standardized format called Conjunctive Normal Form (CNF). A sentence in CNF is a conjunction (∧) of clauses, where each clause is a disjunction (∨) of literals (a literal is a predicate or its negation).
Every sentence in First-Order Logic (FOL) can be converted into an inferentially equivalent CNF sentence using a systematic six-step procedure.
We will illustrate the conversion process using the sentence: "Everyone who loves all animals is loved by someone."
∀x[∀y(Animal(y)⇒Loves(x,y))⇒∃yLoves(y,x)]
Replace all implications (A⇒B) and biconditionals (A⇔B) using their equivalent disjunctions:
- A⇒B≡¬A∨B
- A⇔B≡(¬A∨B)∧(¬B∨A)
Applying this to our sentence:
∀x[¬∀y(¬Animal(y)∨Loves(x,y))∨∃yLoves(y,x)]
Move negation symbols (¬) inwards until they apply only to individual predicates. Use De Morgan's laws and quantifier negation rules:
- ¬(A∨B)≡¬A∧¬B
- ¬(A∧B)≡¬A∨¬B
- ¬∀xP≡∃x¬P
- ¬∃xP≡∀x¬P
- ¬(¬A)≡A
Pushing the negation inwards:
∀x[∃y¬(¬Animal(y)∨Loves(x,y))∨∃yLoves(y,x)]
∀x[∃y(Animal(y)∧¬Loves(x,y))∨∃yLoves(y,x)]
Ensure each quantifier binds a unique variable name to prevent naming conflicts:
- Rename the second variable y in the existential quantifier to z:
∀x[∃y(Animal(y)∧¬Loves(x,y))∨∃zLoves(z,x)]
Skolemization is the process of removing existential quantifiers (∃) by replacing existential variables with constants or functions:
- Skolem Constants: If the existential quantifier is not inside the scope of a universal quantifier, replace the variable with a brand-new constant. (e.g., ∃x Rich(x)→Rich(G1)).
- Skolem Functions: If the existential quantifier is within the scope of a universal quantifier, the existential variable depends on the universal variable. Replace it with a new function of that universal variable.
In our sentence:
- The existential variable y is within the scope of universal quantifier x. Replace y with Skolem function F(x).
- The existential variable z is within the scope of universal quantifier x. Replace z with Skolem function G(x).
∀x[(Animal(F(x))∧¬Loves(x,F(x)))∨Loves(G(x),x)]
Since all remaining variables are universally quantified, we omit the universal quantifier symbols (∀). The variables are implicitly assumed to be universally quantified:
(Animal(F(x))∧¬Loves(x,F(x)))∨Loves(G(x),x)
Rearrange the formula using the distributive law: (A∧B)∨C≡(A∨C)∧(B∨C).
(Animal(F(x))∨Loves(G(x),x))∧(¬Loves(x,F(x))∨Loves(G(x),x))
This yields two distinct CNF clauses:
- Clause 1a: Animal(F(x))∨Loves(G(x),x)
- Clause 1b: ¬Loves(x,F(x))∨Loves(G(x),x)
To prove a goal using the resolution rule, we use Proof by Contradiction:
- Express all knowledge-base facts and rules in FOL.
- Negate the goal statement.
- Convert all statements into CNF.
- Apply resolution steps, replacing complementary literals using Unification (substituting variables), until the empty clause (⊥) is derived.
Let's solve the famous logical puzzle:
Facts:
- Everyone who loves all animals is loved by someone.
- Anyone who kills an animal is loved by no one.
- Jack loves all animals.
- Either Jack or Curiosity killed the cat, who is named Tuna.
- Tuna is a cat.
- Cats are animals.
Goal: Prove that Curiosity killed the cat (Kills(Curiosity,Tuna)).
¬Kills(Curiosity,Tuna)
- Clause A1: Animal(F(x))∨Loves(G(x),x)
- Clause A2: ¬Loves(x,F(x))∨Loves(G(x),x)
- Clause B: ¬Loves(y,x)∨¬Animal(z)∨¬Kills(x,z)
- Clause C: ¬Animal(w)∨Loves(Jack,w) (Variable renamed to w)
- Clause D: Kills(Jack,Tuna)∨Kills(Curiosity,Tuna)
- Clause E: Cat(Tuna)
- Clause F: ¬Cat(u)∨Animal(u) (Variable renamed to u)
- Clause G (Negated Goal): ¬Kills(Curiosity,Tuna)
- Resolve E and F using substitution {u/Tuna}:
- Parent 1: Cat(Tuna)
- Parent 2: ¬Cat(u)∨Animal(u)
- Resolvent R1: Animal(Tuna)
- Resolve D and G (resolves Kills(Curiosity,Tuna)):
- Parent 1: Kills(Jack,Tuna)∨Kills(Curiosity,Tuna)
- Parent 2: ¬Kills(Curiosity,Tuna)
- Resolvent R2: Kills(Jack,Tuna)
- Resolve B and R2 using substitution {x/Jack,z/Tuna}:
- Parent 1: ¬Loves(y,x)∨¬Animal(z)∨¬Kills(x,z)
- Parent 2: Kills(Jack,Tuna)
- Resolvent R3: ¬Loves(y,Jack)∨¬Animal(Tuna)
- Resolve R3 and R1 (resolves Animal(Tuna)):
- Parent 1: ¬Loves(y,Jack)∨¬Animal(Tuna)
- Parent 2: Animal(Tuna)
- Resolvent R4: ¬Loves(y,Jack)
- Resolve A2 and C using substitution {x/Jack,w/F(Jack)}:
- Parent 1: ¬Loves(x,F(x))∨Loves(G(x),x)
- Parent 2: ¬Animal(w)∨Loves(Jack,w)
- Resolvent R5: ¬Animal(F(Jack))∨Loves(G(Jack),Jack)
- Resolve R5 and A1 using substitution {x/Jack}:
- Parent 1: ¬Animal(F(Jack))∨Loves(G(Jack),Jack)
- Parent 2: Animal(F(x))∨Loves(G(x),x)
- Resolvent R6: Loves(G(Jack),Jack)
- Resolve R6 and R4 using substitution {y/G(Jack)}:
- Parent 1: Loves(G(Jack),Jack)
- Parent 2: ¬Loves(y,Jack)
- Resolvent R7: ⊥ (Contradiction!)
Since resolution leads directly to the empty clause (⊥), the negated goal is false, and it is proven that Curiosity killed the cat.