Presentation is loading. Please wait.

Presentation is loading. Please wait.

Converting arbitrary wffs to CNF A wff is in prenex form iff it consists of a string of quantifiers (called a prefix) followed by a quantifier free formula.

Similar presentations


Presentation on theme: "Converting arbitrary wffs to CNF A wff is in prenex form iff it consists of a string of quantifiers (called a prefix) followed by a quantifier free formula."— Presentation transcript:

1 Converting arbitrary wffs to CNF A wff is in prenex form iff it consists of a string of quantifiers (called a prefix) followed by a quantifier free formula called a matrix. 5. Convert to Prenex Form At this stage there is no remaining existential quantifiers and each universal quantifier has its own variable symbol. We may now move all of the universal quantifiers to the front of the wff and let the scope of each quantifier include the entirety of the wff following it. The resulting wff is in prenex form. From (1*)  X(  P(X) v  Y((  P(Y) v P(f(X, Y)))  Q(X, h(X))   P(h(X))))  X  Y(  P(X) v ((  P(Y) v P(f(X, Y)))  Q(X, h(X))   P(h(X))))

2 Converting arbitrary wffs to CNF 6. Eliminate universal quantifiers Since all the variables in the wff we use must be within the scope of a quantifier, we are assured that all the variables remaining at this step are universally quantified. Furthermore, the order of universal quantification is unimportant, so we may eliminate the explicit occurrence of universal quantifiers and assume, by convention, that all variables in the matrix are universally quantified.

3 Converting arbitrary wffs to CNF 7. Put the Matrix in CNF Distribute  over v : (A  B) v C becomes (A v C)  (B v C) Flatten nested conjunctions and disjunctions : (A v B) v C becomes (A v B v C) (A  B)  C becomes (A  B  C) At this point we have a conjunction of clauses ; We must have a set of clauses ! separate the conjuncts

4 Substitution A substitution  is a set of ordered pairs:  = {X 1 / t 1,...., X n / t n } where X i is a variable and t i is a term such that all X i are distinct. A simple expression is either an atom or a term. Example: E 1 = P(X, X, Y),  = {X / bill, Y / Z} E 1  = P(bill, bill, Z) Means that for each pair x i / t i, the term t i is substituted simultaneoulsy for every occurrence of the variable x i throughout the scope of the substitution (E 1 )

5 Composition Let  = {X 1 / s 1,...., X m / s m } and α = {Y 1 / t 1,...., Y n / t n } be substitutions. The composition of  and α, denoted by  α, is the substitution consisting of the bindings in the resulting sequence: a) consider the sequence of bindings (apply α to the terms of  and concatenate the result with α) X 1 / (s 1 α),...., X m / (s m α), Y 1 / t 1,...., Y n / t n b)delete from this sequence: any binding X i / (s i α) for which X i = (s i α) and any binding Y j / t j for which Y j є {X 1,...., X m }.

6 Composition Examples: 1) Let  = { X / f(Y), Z / U} and α = {Y / b, U / Z}, then  α = {X / f(b), Y / b, U / Z} 2) Let  = { X / Y } and α = {X / a, Y / a}, then  α = {X / a, Y /a}

7 Unification Let Σ be a finite set of simple expressions. A unifier for the set Σ = {E 1, E 2 } is a substitution  such that Σ  is a singleton: E 1  = E 2  Σ is said to be unifiable iff there exists such . If  is a unifier for Σ, and if for any unifier α for Σ there exists a substitution φ such that α =  φ, then  is called a most general unifier (mgu). A mgu is unique except for variables renaming (alphabetic variants).

8 Unification Example: Let Σ = {R(X, f(Y), B), R(Z, f(B), B)}. Then  = {X /Z, Y / B} is a mgu for Σ. Although {X / A, Z / A, Y / B} is a unifier for Σ it is not a mgu (the simplest) since there does not exist a substitution φ such that {X /Z, Y / B} = {X / A, Z / A, Y / B} φ Notice that {X / A, Z / A, Y / B} = {X /Z, Y / B}{Z / A}

9 Unification Let Σ be a finite set of simple expressions. The Disagreement set of Σ is defined as follows. Locate the leftmost symbol position at which not all members of Σ have the same symbol, and extract from each expression in Σ the subexpression begining at that symbol position. The set of all these subexpressions is the disagreement set. Example: let Σ be the set {P(x, y), P (x, f(g(a)))} then D = {y, f(g(a))}

10 Unification Algorithm Input: a finite set Σ of simple expressions Output: a mgu for Σ (if Σ is unifiable) 1. Set k = 0 and  0 = . 2. If Σ  k is a singleton, then stop:  k is an mgu for Σ. Else find the disagreement set D k of Σ  k. 3. If there exists X and t in D k such that X is a variable not occurring in t, then set  k+ 1 =  k {x / t}, increment k by 1 and go to step 2. Else report that Σ is not unifiable, and stop.


Download ppt "Converting arbitrary wffs to CNF A wff is in prenex form iff it consists of a string of quantifiers (called a prefix) followed by a quantifier free formula."

Similar presentations


Ads by Google