ar for horn clause logic introducing: unification

27
AR for Horn clause logic AR for Horn clause logic Introducing: Introducing: Unification Unification

Upload: estrella-digman

Post on 14-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1

AR for Horn clause logic Introducing: Unification Slide 2 2 How to deal with variables? Example: p lot_maint(house(p)) big(house(p)) p lot_maint(house(p)) big(house(p)) false lot_maint(house(Bos)) We would like to conclude: by means of generalized modus ponens. false big(house(Bos)) Principle: use instantiations of the 2 Horn clauses, such that these DO match. Slide 3 3 More examples: We drop the universal quantification, since all variables are universally quantified anyway. Some examples using standard modus ponens: related(x,y) parent(x,y) parent(John,Mary) parent(John,Mary) related(John,Mary) loves(John,x) related(John,x) related(y,father(y)) related(y,father(y)) loves(John,father(John)) Unification !! Slide 4 4 Substitutions: Examples: ={ x / h(g(A)), y / g(A), z / w} = { x / g(z), y / B} A substitution is a finite set of pairs of the form variable / term, such that all variables at the left- hand sides of the pairs are distinct. In our substitutions we will NOT allow that some variable that occurs left also occurs in some term at the right. Slide 5 5 Applying substitutions: Substitutions can be applied to simple expressions (atoms or terms), by replacing all occurrences of the left-side variables in the expression by the corresponding terms. = { x / g(z), y / B} p(x, f(y, z)) = p(g(z), f(B, z)) ={ x / h(g(A)), y / g(A), z / w} p(x, f(y, z)) =p(h(g(A)), f(g(A), w)) p(x, f(y, z)) = p(h(g(A)), f(g(A), w)) Examples: Slide 6 6 Remember the motivation: We want substitutions that make atoms equal. lot_maint(house(p)) big(house(p)) lot_maint(house(p)) big(house(p)) false lot_maint(house(Bos)) The two atoms in the clauses: must be made equal. Slide 7 7 Unifiers Example: S = {related(John,x), related(y, father(y))} = {y / John, x / father(John)} is a unifier for S S = {related(John,father(John))} Given a set of simple expressions S, we call a substitution a unifier for S if: S is a singleton Slide 20 Unification A basic algorithm in Automated Reasoning Slide 21 21 A unification algorithm :={ s = t }; mgu:= { s = t }; Stop:= false; Case: t is a variable, s is not a variable: Case: t is a variable, s is not a variable: replace s = t by t = s in mgu; replace s = t by t = s in mgu; Case: s is a variable, t is the SAME variable: Case: s is a variable, t is the SAME variable: delete s = t from mgu; delete s = t from mgu; Case: s is a variable, t is not a variable and Case: s is a variable, t is not a variable and contains s : contains s : Stop:= true; Stop:= true;...... While not(Stop) and mgu still contains s = t of Slide 22 22 Unification algorithm (2) If Stop = false : Report mgu ! Case: s is a variable, t is not identical to nor Case: s is a variable, t is not identical to nor contains s and s occurs elsewhere in mgu: contains s and s occurs elsewhere in mgu: replace all other occurrences of s in mgu by t ; replace all other occurrences of s in mgu by t ;... Case: s is of the form f(s1,,sn), t of g(t1,,tm): if f g or n m : Stop := true; if f g or n m : Stop := true; else replace s = t in mgu by else replace s = t in mgu by s1 = t1, s2 = t2, , sn = tn ; s1 = t1, s2 = t2, , sn = tn ;End_while Slide 23 23 Example 1: Unify: p(B,y) and p(x,f(x)) : Init: mgu:= { p(B,y) = p(x,f(x))} Case 5: mgu:= {B = x, y = f(x) } Case 1: mgu:= {x = B, y = f(x) } Case 4: mgu:= {x = B, y = f(B) } No more cases applicable ! p(B,y) and p(x,f(x)) are unifiable mgu = { x/B, y/f(B) } result: p(B, f(B))