forked from kcyras/ABAplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ground.dl
executable file
·31 lines (25 loc) · 1.09 KB
/
ground.dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Encoding for grounded extensions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% an argument x defeats an argument y if x attacks y
defeat(X,Y) :- att(X,Y).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For the remaining part we need to put an order on the domain.
% Therefore, we define a successor-relation with infinum and supremum
% as follows
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lt(X,Y) :- arg(X),arg(Y), X<Y, not input_error.
nsucc(X,Z) :- lt(X,Y), lt(Y,Z).
succ(X,Y) :- lt(X,Y), not nsucc(X,Y).
ninf(X) :- lt(Y,X).
nsup(X) :- lt(X,Y).
inf(X) :- not ninf(X), arg(X).
sup(X) :- not nsup(X), arg(X).
%% we now fill up the predicate in(.) with arguments which are defended
defended_upto(X,Y) :- inf(Y), arg(X), not defeat(Y,X).
defended_upto(X,Y) :- inf(Y), in(Z), defeat(Z,Y), defeat(Y,X).
defended_upto(X,Y) :- succ(Z,Y), defended_upto(X,Z), not defeat(Y,X).
defended_upto(X,Y) :- succ(Z,Y), defended_upto(X,Z), in(V), defeat(V,Y), defeat(Y,X).
defended(X) :- sup(Y), defended_upto(X,Y).
in(X) :- defended(X).