Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

% Run using the command % clingo ex2.txt 0 #const n=6. person(1..n). spot(1..n). % ----------------------------------------------------- % Test problem likes(1, 2). likes(3, 4). likes(X, Y) :-

% Run using the command % clingo ex2.txt 0 #const n=6. person(1..n). spot(1..n). % ----------------------------------------------------- % Test problem likes(1, 2). likes(3, 4). likes(X, Y) :- likes(Y, X). dislikes(3, 1). dislikes(4, 1). dislikes(4, 2). dislikes(5, 1). dislikes(5, 2). dislikes(5, 3). dislikes(6, 2). dislikes(6, 3). dislikes(X, Y) :- dislikes(Y, X). % End of test problem % ----------------------------------------------------- % Instruction: % Use the predicate assigned(P, S) to say that person P is assigned spot S %%% DEFINE % Helper Predicate: % adjacent(S1, S2) - spots S1 and S2 are adjacent, i.e., next to each other adjacent(S, S+1) :- spot(S), spot(S+1). adjacent(n, 1). % TODO by you: say that adjacent is a symmetric relation. % TODO by you: Say that no other spots are adjacent. %%% GENERATE candidate solutions % TODO by you

%%% TEST whether a candidate solution is a real solution or not % TODO by you % ----------------------------------------------------- % For display purposes only % arrangement(P1, P2, P3, P4, P5, P6) says that person P1 sits on spot1, P2 on spot 2, etc. arrangement(P1, P2, P3, P4, P5, P6) :- assigned(P1, 1), assigned(P2, 2), assigned(P3, 3), assigned(P4, 4), assigned(P5, 5), assigned(P6, 6). % You can filter your output as follows (uncomment the line below): #show arrangement/6. %#show assigned/2.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions