19_CNF_and_Unification
CNF Conversion & Unification Algorithm
1. Converting to Clause Form (CNF)
Clause Form (or Conjunctive Normal Form) is a simplified representation of WFFs that is necessary for the resolution algorithm.
Steps to Convert:
- Eliminate Implications: Replace
P → Qwith¬P ∨ QandP ↔ Qwith(¬P ∨ Q) ∧ (¬Q ∨ P). - Move Negations Inward: Use De Morgan's laws and quantifier negation rules:
- ¬∀x P(x) ≡ ∃x ¬P(x)
- ¬∃x P(x) ≡ ∀x ¬P(x)
- Standardize Variables: Rename variables so that no two quantifiers use the same name.
- Skolemize: Replace existential variables (
∃) with Skolem functions or constants.
- If no universal quantifier (∀) precedes it: Use Skolem constant (e.g., a).
- If inside the scope of ∀y: Use Skolem function (e.g., g(y)).
- Drop Universal Quantifiers: Move all
∀to the left and drop them as implicit. - Distribute Disjunction: Use
A ∨ (B ∧ C) ≡ (A ∨ B) ∧ (A ∨ C)to put the matrix into CNF. - Write as Clauses: Each conjunct (part connected by
∧) becomes a separate clause.
CNF Conversion Worked Example:
Formula: ∃n∀y (∀z P(f(n), y, z) → (∃u Q(y, u) ∧ ∃v R(y, v)))
- Step 1 (Eliminate Implication):
∃n∀y (¬∀z P(f(n), y, z) ∨ (∃u Q(y, u) ∧ ∃v R(y, v))) - Step 2 (Negations Inward):
∃n∀y (∃z ¬P(f(n), y, z) ∨ (∃u Q(y, u) ∧ ∃v R(y, v))) - Step 4 (Skolemize):
- n → Skolem constant a
- z → Skolem function g(y)
- u → Skolem function h(y)
- v → Skolem function k(y)
Result: ∀y (¬P(f(a), y, g(y)) ∨ (Q(y, h(y)) ∧ R(y, k(y))))
- Step 5/6 (Distribute/Clauses):
1. ¬P(f(a), y, g(y)) ∨ Q(y, h(y))
2. ¬P(f(a), y, g(y)) ∨ R(y, k(y))
2. Unification Algorithm
Unification is the process of making two expressions identical by finding a substitution for their variables.
Key Definitions:
- Substitution: A set of pairs
{t/v}where termtreplaces variablev. - Unifier: A substitution that makes expressions identical.
- Most General Unifier (MGU): The simplest possible unifier, from which all others can be derived.
- Occur Check: A critical test during unification where we ensure that the variable
vwe are substituting for does not occur within the termtbeing substituted (e.g., cannot unifyxwithf(x)). Failure to perform this check leads to infinite loops and incorrect proofs.
Algorithm Steps:
- Set k=0, σ₀ = empty.
- If all expressions are already identical, STOP. σₖ is the MGU.
- Find the disagreement set (first position where expressions differ).
- If there's a variable
vand termtin the disagreement set such thatvdoes not occur int(the occur check):
- Apply substitution {t/v}.
- Increment k and repeat.
- Otherwise, STOP — not unifiable.
Worked Example 1 (Failure):
Unifying: S = { P(f(a), g(x)), P(f(a), f(a)) }
- Disagreement Set:
{ g(x), f(a) } - Conclusion: Neither is a variable. Functions
gandfare different. - Result: Not unifiable.
Worked Example 2 (Success):
Unifying: S = { P(x, f(y)), P(a, f(b)) }
- Disagreement Set:
{ x, a }.xis a variable,ais a term.
- Substitution: {a/x}
- Apply to S:
{ P(a, f(y)), P(a, f(b)) } - New Disagreement Set:
{ y, b }.yis a variable,bis a term.
- Substitution: {b/y}
- Final MGU:
{a/x, b/y}