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

Can someone help me with this ASP program? I totally have no idea how to start i

ID: 3748251 • Letter: C

Question

Can someone help me with this ASP program? I totally have no idea how to start it.i'm so confused about it.

Write an ASP program to be run with the DLV solver that solves the following problems using the generate-and-test methodology:

Given a round table with six chairs and a group of six people, some of whom are married and some of whom do not like each other, find a seating assignment for members of this group such that husbands and wives are seated next to each other and no neighbors dislike each other. Marriage is a symmetric relationship, but disliking is not necessarily symmetric(e.g., person A dislikes B, but B may like A).

Make sure to define the relation:seated(P, C)–person Pis sitting on chair number C

Use and extend the starter code provided in the file problem3.txt.

the txt file:

% Run using the command%

dlv problem3.txt -filter=seating#const

n=6.person(1..n).chair(1..n).

% -----------------------------------------------------%

Test problemmarried(1, 2).married(3, 4).dislikes(1, 3).dislikes(1, 4).dislikes(1, 5).dislikes(2, 4).dislikes(2, 5).dislikes(2, 6).dislikes(3, 5).dislikes(3, 6).

% End of test problem% -----------------------------------------------------%

Instruction:%

Use the predicate seated(P, C) to say that person P is seating on chair number C

%%% GENERATE candidate solutions%

TODO by you%%%

TEST whether a candidate solution is a real solution or not

% TODO by you% -----------------------------------------------------%

For easy display%

seating(P1, P2, P3, P4, P5, P6) says that person P1 sits on chair 1, P2 on chair 2, etc.seating(P1, P2, P3, P4, P5, P6) :- seated(P1, 1), seated(P2, 2), seated(P3, 3), seated(P4, 4), seated(P5, 5), seated(P6, 6).

Explanation / Answer

%---------------------------------------------------------------------------------------% Given n=6.Such that there are 6 persons and 6 chairs.married persons can be sitted next to each other but disliked persons cannot be sitted.Also marriage is Symmetric relationship whereas dislike is not Symmetric.   

%----------------------------------------------------------------------------------------%

%GENERATE Solutions

%First we place the person 1 in chair 1

seated(P1,1).

%P1 married to P2 and P1 dislikes P3,P4,P5,so the left one is P6.P6 can be sitted next to P1

%i.e.P1 is sitted between P2 nd P6

seated(P6,6),seated(P2,2).

%Now we will place a person next to P2 but P2 dislikes P4,P5 and P6 and also P2 is seated next to P1 % so the remaining person to be seated next to P2 is P3,therefore

seated(P3,3)

%hence P3 is married to P4,the next position will be of P4

seated(P4,4)

%as of now seated persons are (6,6),(1,1),(2,2),(3,3) and (4,4) in a round table consisting of 6 chairs %but there is one left chair between P6 and P4 and the left person is P5.

%P5 dislikes P1,P2 and P3 but he can be seated between P4 and P6.

seated(P5,5)

%So the arrangement is

seating(P1,P2,P3,P4,P5,P6):-seated(P1,1),seated(P2,2),seated(P3,3),seated(P4,4),seated(P5,5),seated(P6,6).

% persons can be seated in any chair without disturbing their sequence

%----------------------------------------------------------------------------------------%

TEST

test for person1:- P1 is between P2 andP6,P2 is married to P1 and P1,P6 not dislikes each other.

test for person2:- P2 is between P1 andP3,P2 is married to P1 and P2,P3 not dislikes each other.

test for person3:- P3 is between P2 andP4,P3 is married to P4 and P2,P3 not dislikes each other.

test for person4:- P4 is between P3 andP5,P3 is married to P4 and P4,P5 not dislikes each other.

test for person5:- P5 is between P4 andP6,P4 and P5 not dislikes each other and P5,P6 not dislikes each other.

test for person6:- P6 is between P1 andP5,P6 and P5 not dislikes each other and P1,P6 not dislikes each other

%----------------------------------------------------------------------------------------%

%So seating(P1,P2,P3,P4,P5,P6):-seated(P1,1),seated(P2,2),seated(P3,3),seated(P4,4),seated    (P5,5),seated(P6,6) is tested and is a real solution.%