20-DatalogResolution

# Parentbobjay parentbobkay rules auntxy sisterxz

• Notes
• 11

This preview shows page 9 - 11 out of 11 pages.

parent('bob','jay'). parent('bob','kay'). Rules: aunt(x,y) :- sister(x,z), parent(z,y). Queries: aunt('ann',x)?

Subscribe to view the full document.

Discussion #20 Chapter 4, Sections 4.1 & 4.4.1-3 10/11 Tree View Facts: sister('ann','bob'). parent('bob','jay'). parent('bob','kay'). Rules: aunt(x,y) :- sister(x,z), parent(z,y). Queries: aunt('ann',x)? aunt('ann',x) sister( 'ann' ,z),parent(z, 'ann' ). sister( 'ann' ,z),parent(z, 'jay' ). sister( 'ann' , 'ann' ) sister( 'ann' , 'ann' ) sister( 'ann' , 'bob' ),parent( 'bob‘, 'jay' ). x = 'ann' z = 'ann' x = 'bob' x = 'jay' x = 'kay' z = 'bob' z = 'ann' fail fail succeed succeed Note that we only need to keep track of one path from root to leaf at a time.
Discussion #20 Chapter 4, Sections 4.1 & 4.4.1-3 11/11 Potential Infinite Recursion 1. f(1,1). 2. f(1,2). 3. f(2,3). 4. b(x,y):-f(x,y). 5. b(x,y):-f(x,z),b(z,y). b(1,3)? b(1,3) f(1,3) fail rule 4 f(1,z),b(z,3) rule 5 f(1,1),b(1,3) succeed z=1 f(1,3),b(3,3) fail z=3 f(1,2),b(2,3) succeed z=2 f(2,3) succeed rule 4 Infinite Recursion! fail Infinite recursion! Keep current path stack if recursive call already in path, fail! Domain = {1,2,3}
You've reached the end of this preview.
• Winter '12
• MichaelGoodrich
• Recursion, Backtracking, Lower case, Query language, Datalog

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern