III. Logical variables and unification A. logical variables B. substitutions and instances 1. substitution ---------------- s: {X, Y} -> {algol, father(me,dad)} such that s[[X]] = algol, s[[Y]] = father(me,dad). empty: {} -> {} counterexample: bad: {X} -> {X} ---------------- 2. instance of a term ------------------ father(me,dad) is an instance of father(X,dad). ------------------ C. comparing terms -------------- foo(X,3,Y). ?- foo(0,X,X). X = 3 % this is the X of the question, one in fact bound to 0 ---------------- 1. common instance of two terms: term which is instance of both ------------------ plus(0,3,3) is common instance of plus(0,3,Y) and plus(0,X,X) ---------------- 2. generality 3. unifier: a subsitution that makes two terms identical. -------------------- star(algol). ?- star(X). X = algol % star(X) unifies with star(algol) % by substituion s(X)=algol g(X,3). ?- g(4,Y). Y = 3 % and (X = 4) not shown h(X,X). ?- h(Y,Z). Y = _0 % i.e., X's internal name Z = _0 ---------------------- D. exercises ------- For each of the following pairs, compute the mgu, if any member(3,[3]) member(X,[X]) member(Y,[3]) member(X,[X]) member(3,[4]) member(X,[X|L]) length([3],N) member(X,[X|L]) member(X,[X |L]) member(Y,[tree(Y,[],[])|M]) ------- IV. Resolution (logical basis for Prolog) ---------------- imokay :- youreokay, hesokay. % C1 youreokay :- theyreokay. % C2 hesokay. % C3 theyreokay. % C4 ?- imokay. ---------------- ---------------- hesnotokay :- imnotokay. % C5 shesokay :- hesnotokay. % C6 shesokay :- theyreokay. % C7 ?- shesokay. ---------------- ---------------- hesnotokay :- shesokay. % C8 hesnotokay :- imokay. % C9 ?- shesokay. ---------------- A. Example ------------- %facts scientist(sue). %1 scientist(ron). %2 spanish(sue). %3 american(ron). %4 %rule logician(X) :- scientist(X). %5 %goal ?- logician(Y), american(Y). % (is there) some Y is both a logician and an american? --------------- B. resolution theorem proving 1. rule of inference -------------------------------------- (resolution) R or P, (not P or Q) ____________________ R or Q --------------------------------------- ------------------ A\B true false true t f false t t ------------------ 2. the resolution rule (mechanical) ------------------------ suppose clause A contains some term s, clause B contains negation of term t, s and t are unifiable by some subst sigma, then resolvent of A and B is generated by 1. combining the clauses to form A or B 2. removing s and t (from the resulting term) 3. applying substitution sigma to result ------------------------ 3. to ask a question Q, resolve (not Q) against set of clauses, 4. practical questions in using resolution 5. SL resolution C. Why Horn clauses? D. Top-down vs. bottom up control 1. top-down control (backward chaining) as in Prolog 2. bottom up control (forward chaining) as in OPS5 E. Depth-first search vs breadth-first search. ---------------------- p :- p, q. p. q. ----------------------