hazlenuts? tomsredcar? 2ideas? prolog? · facts? •hazlenuts? no •tomsredcar? yes •2ideas? no...
TRANSCRIPT
![Page 1: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/1.jpg)
Facts?
• Hazlenuts?
• tomsRedCar?
• 2Ideas?
• Prolog?
![Page 2: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/2.jpg)
Facts?
• Hazlenuts? No
• tomsRedCar? Yes
• 2Ideas? No
• Prolog? No
Cannot start of capital letter or a number
![Page 3: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/3.jpg)
Given the database below…
blue_box. red_box. green_circle. blue_circle. orange_triangle
• green_circle?
• circle_green?
• red_triangle?
• red_box?
• orange_triangle?
![Page 4: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/4.jpg)
Given the database below…
blue_box. red_box. green_circle. blue_circle. orange_triangle
• green_circle? Yes
• circle_green? No
• red_triangle? No
• red_box? Yes
• orange_triangle? No
![Page 5: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/5.jpg)
Unification
• eats(fred,tomatoes).
• eats(Whom,What).
• eats(fred,Food).
• eats(Person,jim).
• cd(29,beatles,sgt_pepper).
• cd(A,B,help).
• f(X,a)
• f(a,X)
![Page 6: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/6.jpg)
Unification
• eats(fred,tomatoes).
• eats(Whom,What).
• eats(fred,Food).
• eats(Person,jim).
• cd(29,beatles,sgt_pepper).
• cd(A,B,help).
• f(X,a)
• f(a,X)
• Whom = fred
• What = tomatoes
![Page 7: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/7.jpg)
Unification
• eats(fred,tomatoes).
• eats(Whom,What).
• eats(fred,Food).
• eats(Person,jim).
• cd(29,beatles,sgt_pepper).
• cd(A,B,help).
• f(X,a)
• f(a,X)
• Whom = fred
• What = tomatoes
• Person=fred
• Food=jim
![Page 8: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/8.jpg)
Unification
• eats(fred,tomatoes).
• eats(Whom,What).
• eats(fred,Food).
• eats(Person,jim).
• cd(29,beatles,sgt_pepper).
• cd(A,B,help).
• f(X,a)
• f(a,X)
• Whom = fred
• What = tomatoes
• Person=fred
• Food=jim
• sgt_pepper and help do not unify
![Page 9: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/9.jpg)
Unification
• eats(fred,tomatoes).
• eats(Whom,What).
• eats(fred,Food).
• eats(Person,jim).
• cd(29,beatles,sgt_pepper).
• cd(A,B,help).
• f(X,a)
• f(a,X)
• Whom = fred
• What = tomatoes
• Person=fred
• Food=jim
• sgt_pepper and help do not unify
• X = a
![Page 10: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/10.jpg)
Unification
• likes(jane,X)
• likes(X,jim)
• f(X,Y)
• f(P,P)
• f(foo,L)
• f(A1,A1)
![Page 11: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/11.jpg)
Unification
• likes(jane,X)
• likes(X,jim)
• f(X,Y)
• f(P,P)
• f(foo,L)
• f(A1,A1)
• X cannot bound to both jane and jim
![Page 12: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/12.jpg)
Unification
• likes(jane,X)
• likes(X,jim)
• f(X,Y)
• f(P,P)
• f(foo,L)
• f(A1,A1)
• X cannot bound to both jane and jim
• X = P and Y = P
• X = Y
![Page 13: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/13.jpg)
Unification
• likes(jane,X)
• likes(X,jim)
• f(X,Y)
• f(P,P)
• f(foo,L)
• f(A1,A1)
• X cannot bound to both jane and jim
• X = P and Y = P
• X = Y
• A1 = foo and A1 = L
• Hence, L = foo
![Page 14: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/14.jpg)
Rules?
• a :- b, c, d:- e f.
• happy(X):- a , b.
• happy(X):- hasmoney(X) & has_friends(X).
• fun(fish):- blue(betty), bike(yamaha).
![Page 15: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/15.jpg)
Rules?
• a :- b, c, d:- e, f. No
• happy(X):- a , b. Yes
• happy(X):- hasmoney(X) & has_friends(X). No
• fun(fish):- blue(betty), bike(yamaha). Yes
![Page 16: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/16.jpg)
Queries
likes(john,mary). likes(john,trains). likes(peter,fast_cars). likes(Person1,Person2):-
hobby(Person1,Hobby), hobby(Person2,Hobby).
hobby(john,trainspotting). hobby(tim,sailing). hobby(helen,trainspotting). hobby(simon,sailing)
• likes(john,trains). • likes(helen,john). • likes(tim,helen). • likes(john,helen).
![Page 17: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/17.jpg)
Queries
likes(john,mary). likes(john,trains). likes(peter,fast_cars). likes(Person1,Person2):-
hobby(Person1,Hobby), hobby(Person2,Hobby).
hobby(john,trainspotting). hobby(tim,sailing). hobby(helen,trainspotting). hobby(simon,sailing)
• likes(john,trains). Yes • likes(helen,john). Yes • likes(tim,helen). No • likes(john,helen). Yes
![Page 18: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/18.jpg)
Recursion
a(X):- b(X,Y), a(X). go_home(no_12). go_home(X):- get_next_house(X,Y),
home(Y). foo(X):- bar(X). lonely(X):- no_friends(X). no_friends(X):- totally_barmy(X).
has_flu(rebecca). has_flu(john). has_flu(X):- kisses(X,Y),has_flu(Y). kisses(janet,john). search(end). search(X):- path(X,Y), search(Y).
![Page 19: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/19.jpg)
Recursion
a(X):- b(X,Y), a(X). go_home(no_12). go_home(X):- get_next_house(X,Y),
home(Y). foo(X):- bar(X). lonely(X):- no_friends(X). no_friends(X):- totally_barmy(X).
has_flu(rebecca). has_flu(john). has_flu(X):-
kisses(X,Y),has_flu(Y). kisses(janet,john). search(end). search(X):- path(X,Y), search(Y).
![Page 20: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/20.jpg)
Lists
• [a,d,z,c] and [H|T]
• [apple,pear,grape] and [A,pear|Rest]
• [a|Rest] and [a,b,c]
• [a,[]] and [A,B|Rest]
![Page 21: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/21.jpg)
Lists
• [a,d,z,c] and [H|T]
H = a and T = [d,z,c]
• [apple,pear,grape] and [A,pear|Rest]
A = apple and Rest = [grape]
• [a|Rest] and [a,b,c]
Rest = [b,c]
• [a,[]] and [A,B|Rest]
A = a, B = [] and Rest = []
![Page 22: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/22.jpg)
Lists
• [One] and [two|[]]
• [one] and [Two]
• [a,b,X] and [a,b,c,d]
![Page 23: Hazlenuts? tomsRedCar? 2Ideas? Prolog? · Facts? •Hazlenuts? No •tomsRedCar? Yes •2Ideas? No •Prolog? No Cannot start of capital letter or a number](https://reader034.vdocuments.net/reader034/viewer/2022051604/60035ac82abc3c591860ffd4/html5/thumbnails/23.jpg)
Lists
• [One] and [two|[]]
One = two
• [one] and [Two]
Two = one
• [a,b,X] and [a,b,c,d]
No X can not represent the two atoms c,d