CS计算机代考程序代写 prolog School of Computer Science

School of Computer Science

COMPSCI 761 Assignment 3 due Friday 22 October 2021

Due: by 11:59pm on the due date. Late assignments will not be marked.

Total mark: 10.

Worth: This assignment counts towards 10% of your final mark.

1. [3 marks] Solve the following crossword puzzle using Prolog:

The following knowledge base represents a lexicon containing these words:

• word(apastosaurus,a,p,a,t,o,s,a,u,r,u,s)
• word(bones,b,o,n,e,s)
• word(eggs,e,g,g,s)
• word(extinct,e,x,t,i,n,c,t)
• word(claws,c,l,a,w,s)
• word(fossil,f,o,s,s,i,l)
• word(raptor,r,a,p,t,o,r)
• word(teeth,t,e,e,t,h)
• word(triassic,t,r,i,a,s,s,i,c)
• word(triceratops,t,r,i,c,e,r,a,t,o,p,s)

Implement a Prolog predicate crossword(A,B,C,D,E,F,G,H,I,J) where the variable X should
be the corresponding word as indicated in the diagram. Submit your answer as crossword.pl
file.

COMPSCI 761 Assignment 3 Page 1 of 2

2. [3 marks] Define predicates and(X,Y) (for conjunction), or(X,Y) (for disjunction), impl(X,Y)
(for implication), and equ(X,Y) (for equivalence) which succeed or fail according to the result
of their respective operations. E.g. and(A,B) will succeed, if and only if both A and B succeed.
Note that A and B can be Prolog goals (not only the constants true and false).

A logical expression in three variables can then be written in prefix notation, as in the following
example: equ(or(not(A),B),impl(A,not(C))).

Now, write a predicate table(X,Y,Z,Expression) which prints the truth table of a given
logical expression Expression in two variables.

Example:

?- table(A,B,C,and(A,or(not(B),C))).

t t t t

t t f f

t f t t

t f f t

f t t f

f t f f

f f t f

f f f f

Write your answer in file truthtable.pl and submit this file.

3. [4 marks] The monkey-and-bananas problem is faced by a monkey in a laboratory with
some bananas hanging out of reach from the ceiling. A box is available that will enable the
monkey to reach the bananas if he climbs on it. There are three locations: A,B,C. Initially,
the monkey is at A, the bananas at B, and the box at C. The monkey and box have Low
height, but if the monkey climbs onto the box he will have High height. The bananas initially
have High height. The actions available to the monkey include Go from one place to another,
Push an object from one place to another, ClimbUp onto or ClimbDown from an object, and
Grasp or Ungrasp an object. The result of a Grasp is that the monkey holds the object if the
monkey and object are in the same place at the same height. The goal of the monkey is to hold
the banana and return to location A.

(a) Write a PDDL domain file monkey domain.pddl that specifies the six action schemas: Go,
Push, ClimbUp, ClimbDown, Grasp, and Ungrasp.

(b) Write a PDDL problem file monkey task.pddl that specifies the initial state and the goal.

Submit the two files monkey domain.pddl and monkey task.pddl.

COMPSCI 761 Assignment 3 Page 2 of 2