Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help, trying to complete this by tonight to help me study for my exam, bu

ID: 3840633 • Letter: P

Question

Please help, trying to complete this by tonight to help me study for my exam, but I am stuck after trying many times.

3. If we had the following has flu rebecca What would the following return? has flu (janet) has flu (john) has flu (x) kisses (K, Y) has flu (Y kisses (janet ,john 4. If we had a one-way road links 6 towns. (i.e. townl----- -----town2---- ----town3 ----town4--- ----town5---- ---town6) Finish writing the program that can work out if you can travel on that road and can get from A to B. connected (town 1,town 2). connected (town 2,town 3). connected (town 3 ,tomm4). connected (town ,town 5 connected (town 5,totm6) can get (x,Y) connected (x, Y) can get (x,Y) connected (x, z), can get 5- Suppose that we are working with the following es, the names are from the movie Pulp Fiction loves (vincent, mia) loves (marcellus, mia) loves (mia, marcellus) loves (pumpkin huney bunny) loves (huney bunny, pumpkin) jealous B):- loves (A,C) loves (B,C), A V- B. (A,B a. Now we pose we have the query jealous (X,Y). What would we get back ifwe asked for all solutions? Show what would be the output. b. Would it make a difference if we removed the last AN If yes how?

Explanation / Answer

Solution:

3) ?- has_flu(janet).

This returns True.

Explanation:

Rule: has_flu(X) :- kisses(X,Y), has_flu(Y).

kisses(janet,john). à john kisses janet.

has_flu(john). à john has flu.

So, has_flu(janet). à returns True as john kisses janet, janet also has flu.

4) can_get(X,Y) :- connected(X,Z), can_get(Z,Y).

Explanation:

If X needs to be connected to Y, then there should be a connection from X to Z and also should be connection from Z to Y. So that X and Y can be connected.

Example:

can_get(A,C) :- connected(A,B), can_get(B,C) à A and C are thus connected.

5) ?-jealous(X,Y).

a) For the above query, only the combination for vincent and marcellus will return True.

?-jealous(vincent,marcellus) à True

Because, jealous(A,B) :- loves(A,C), loves(B,C), A/=B

jealous(vincent,marcellus):- loves(vincent,mia), loves(marcellus,mia),vincent/=marcellus.

b) If we remove A/=B condition from the above query, then it makes no sense as a person cannot get jealous on himself. And B should be different persons so that the above query makes sense.