Docsity

Logic Programming and Artificial Intelligence Problem Sheet, Study notes of Computer Numerical Control

Toggle sidebar
bg1
Logic Programming and Artificial Intelligence
14 February 2010
LPA Problem Sheet 6
Due: 13:15 on 1 March
1. [4 marks] In each box in the following table enter the result of applying the substitution
corresponding to the row to the expression corresponding to the column.
f(a, b)f(g(x), x)f(x, f (y, z)) y
{ }
{x7→ y, y 7→ z, z 7→ x}
{x7→ g(y), y 7→ g(x)}
{x7→ f(y, y), z 7→ a}
2. [5 marks] In each box of the following table enter the most general unifier of the ex-
pression for the row and the expression for the column, or enter “none” to indicate that
they have no unifiers.
f(x, x)f(y, g(y)) f(a, y )f(a, b)f(y, g(x))
f(x0, x0)
f(y0, g(y0)) XXXXX
f(a, y0) XXXXX XXXXX
f(a, b) XXXXX XXXXX XXXXX
f(y, g(x0)) XXXXX XXXXX XXXXX XXXXX
3. (a) [8 marks] Using the leftmost selection function, draw the entire SLD search space
for the following Horn clause argument. Label each arc in the tree with the premise
that gets used in the inference.
1) above(y, x)→below(x, y)
2) on(z, y)→abov e(z, y )
3) below(a, b)
4) on(w, y)∧above(y, z)→abov e(w, z )
5) on(c, d)
6) on(d, e)
7) on(c, b)
8) on(f, c)
—————————
below(x, d)
(b) [8 marks] Use the PROLOG trace facility to print out the entire search space
confronted by PROLOG when operating on this Horn clause argument. Annotate
your listing to show how it corresponds to the nodes of the previous search space.
You can do this by uniquely labelling the nodes in your search space and using
these labels to indicate corresponding points in your listing.
4. Let Pbe the following set of definite clauses:
1. P(x, f (x)) (Your father is one of your parents.)
2. P(x, m(x)) (Your mother is one of your parents.)
3. P(x, y)→A(x, y) (Your parents’ are ancestors of yours.)
4. P(x, y)∧A(y, z )→A(x, z) (Your parents ancestors are ancestors of yours.)
(a) [8 marks] Using the leftmost selection function, give the SLD search space to depth
3 for the argument whose premises are Pand whose conclusion is A(x, j). Explain
what the rest of the search space looks like. Does it contain any answers? If
you gave this problem to PROLOG, what do you expect its behaviour would be?
(Note: A tree with a single node has depth 0.)
(b) [2 marks] Repeat the previous question, except this time replace premise 4 with
40.P(y, z)∧A(x, y )→A(x, z) (Your ancestors’ parents are ancestors of yours.)
1
pf2

Partial preview of the text

Download Logic Programming and Artificial Intelligence Problem Sheet and more Study notes Computer Numerical Control in PDF only on Docsity!

Logic Programming and Artificial Intelligence 14 February 2010 LPA Problem Sheet 6 Due: 13:15 on 1 March

  1. [4 marks] In each box in the following table enter the result of applying the substitution corresponding to the row to the expression corresponding to the column. f (a, b) f (g(x), x) f (x, f (y, z)) y { } {x 7 → y, y 7 → z, z 7 → x} {x 7 → g(y), y 7 → g(x)} {x 7 → f (y, y), z 7 → a}
  2. [5 marks] In each box of the following table enter the most general unifier of the ex- pression for the row and the expression for the column, or enter “none” to indicate that they have no unifiers.

f (x, x) f (y, g(y)) f (a, y) f (a, b) f (y, g(x)) f (x′, x′) f (y′, g(y′)) XXXXX f (a, y′) XXXXX XXXXX f (a, b) XXXXX XXXXX XXXXX f (y, g(x′)) XXXXX XXXXX XXXXX XXXXX

  1. (a) [8 marks] Using the leftmost selection function, draw the entire SLD search space for the following Horn clause argument. Label each arc in the tree with the premise that gets used in the inference. 1) above(y, x) → below(x, y) 2) on(z, y) → above(z, y) 3) below(a, b) 4) on(w, y) ∧ above(y, z) → above(w, z) 5) on(c, d) 6) on(d, e) 7) on(c, b) 8) on(f, c) ————————— below(x, d) (b) [8 marks] Use the PROLOG trace facility to print out the entire search space confronted by PROLOG when operating on this Horn clause argument. Annotate your listing to show how it corresponds to the nodes of the previous search space. You can do this by uniquely labelling the nodes in your search space and using these labels to indicate corresponding points in your listing.
  2. Let P be the following set of definite clauses:
    1. P (x, f (x)) (Your father is one of your parents.)
    2. P (x, m(x)) (Your mother is one of your parents.)
    3. P (x, y) → A(x, y) (Your parents’ are ancestors of yours.)
    4. P (x, y) ∧ A(y, z) → A(x, z) (Your parents ancestors are ancestors of yours.)

(a) [8 marks] Using the leftmost selection function, give the SLD search space to depth 3 for the argument whose premises are P and whose conclusion is A(x, j). Explain what the rest of the search space looks like. Does it contain any answers? If you gave this problem to PROLOG, what do you expect its behaviour would be? (Note: A tree with a single node has depth 0.) (b) [2 marks] Repeat the previous question, except this time replace premise 4 with 4 ′. P (y, z) ∧ A(x, y) → A(x, z) (Your ancestors’ parents are ancestors of yours.)

(c) [8 marks] Using the leftmost selection function, give the SLD search space to depth 4 for the argument whose premises are P and whose conclusion is A(j, x). Show an answer box for all nodes in the search space. Explain what the rest of the search space looks like. Does it contain any answers? (d) [4 marks] Suppose you gave the last problem to PROLOG. What answer do you expect it would give first? Explain what this answer means. What if you asked for another answer? What if you continued asking for more and more answers? (e) [4 marks] Suppose we gave PROLOG the premises P and the goal clause A(x, y). Draw the part of the SLD search space (including an answer box for all nodes) that PROLOG would grow up to the point when it finds the second answer. Explain what these two answers mean. (f) [4 marks] Using the leftmost selection function, give the SLD search space for the argument whose premises are P and whose conclusion is P (x, x). What would happen if you gave this problem to PROLOG. (Think carefully!)

  1. [2 marks] What is the full name (not just initials!) of the person who is credited with inventing unification and the unification algorithm.

[challenge problem]

  1. Prove that the SLD inference rule for first-order logic is sound. (Hint: Remember that this is a backwards proof rule.)