Prolog Homework for Practice – Prolog Problems

Prolog Assignment Help, Prolog Homework Help

1) Perform suitable substitutions of variables (by ‘people’) and then use resolution to prove from { ¬ parent(Y,X), child(X,Y) }, { gchild(X,Z), ¬ child(X,Y), ¬ child(Y,Z) }, and selected basic facts from the original program ( { parent(pat, jim) }, etc.) the goal G which says that tom has a gchild [ child(X,Y) means X is a child of Y and gchild(X,Y) means that X is a grandchild of Y ]. Of course, this means that you have to (resolution) refute ¬ G. That is, answer i), do ii) and answer iii).

i) What is G, what is ¬ G?
ii) Prove G, that is, give a resolution refutation (a tree proof of □ ) from ¬G plus selected
clauses (indicate the required substitutions).
iii) Which clauses do you need to get □? Do you have a choice?

Do you need answers of these problems? Contact us on WhatsApp for all kind of Prolog Assignment Help and Prolog Homework Help

2) Abstract resolution with predicates and variables: Construct a resolution tree proof of the empty clause □ from the given set of clauses. Clearly indicate which clauses you used, the literal resolved on, and the substitutions made at each step. Do you need all clauses? Capital letters X,Y,U,V,W indicate variables, but a, b, c are constants (as in Prolog). Hint: This is easier than it looks at first.
1) { P(a, X, f(Y)), P(a, Z, f(h(b))), ¬Q(Y, Z) }
2) { ¬Q(h(b), W), H(W, a) }
3) { ¬P(a, W, f(h(b))), H(X,a) }
4) { P(a, c, f(h(U))), H(U,a), Q(h(b), b) }
5) { ¬H(V,a) }

3) More monkey business… (cf.
a) Write a cangetwn/2 predicate that performs a countdown, thus limiting the number of moves the monkey can make. Here is a suggestion how it might look like (N, the number of moves the monkey may still do, is given by the user):
cangetwn( state( ,,_,has ),N ) :- writeln([‘got it!!’, N]).
cangetwn(S1,N):- /If N is positive, subtract 1 to get M for next move/
move( S1,Move,S2 ),writeln([M,move(S1,Move,S2)]),
cangetwn(/What goes here?/).
b) Can this be used to make Prolog find aerobic paths to the banana with some unclimbing?
c) How many moves are ‘used’ by cangetwn when unclimbs are allowed?
d) How does this compare to the situation when unclimbs are not allowed?
e) Is it (with this cangetwn) possible to allow all three suggested unclimbings at once?

4) Prolog: answer questions about the Queens (see program on moodle).
a) How many solutions are generated by prolog for 8 queens. Use ; and count. Now use findall/3 to find all solutions and count them using Prolog.
b) How do you use writeb to display solutions? In other words what is the input to writeb? Be sure to use a monospace typeface so it looks decent.
c) Modify the program so that the board displayed has lids on top. (This requires only very little programming, but the display looks a lot better.).

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *