%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Encodings for BAFs
% to compute: d-admissible,
% c-admissible,
% s-admissible,
% d-preferred,
% c-preferred and
% s-preferred extensions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
adm :- d_adm, baf, not input_error. % d-admissible extensions for BAF's
% are the same as the standard admissible extensions
adm :- prefex, not baf, not input_error.
comp :- ground, not input_error. % every grounded ext. is also a complete ext.
prefex :- d_prefex, baf, not input_error. % d-preferred ext. for BAF's are the same as
% standard pref. ext.
d_adm :- d_prefex, baf, not input_error.
closed :- c_adm, baf, not input_error. % c-adm. ext. for BAF's need to be closed
safe :- s_adm, not input_error. % s-adm. ext. for BAF's need to be safe
s_adm :- s_prefex, baf, not input_error.
c_adm :- c_prefex, baf, not input_error.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% support and defeat for BAF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% argument x is supported by argument y
support(X,Z) :- support(X,Y), support(Y,Z).
%% set-supports: argument x is supported by the set S
supported(X) :- support(Y,X), in(Y).
%% defeats (BAF)
defeat(X,Y) :- att(Z,Y), support(X,Z), baf. %supported defeat
defeat(X,Y) :- att(X,Y), baf. %supported defeat
defeat(X,Y) :- att(X,Z), support(Z,Y), baf. %indirekt defeat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% an argument x defeats an argument y if x attacks y
defeat(X,Y) :- att(X,Y).
%% Guess a set S \subseteq A
in(X) :- not out(X), arg(X).
out(X) :- not in(X), arg(X).
%% S has to be conflict-free
:- in(X), in(Y), defeat(X,Y).
%% The argument x is defeated by the set S
defeated(X) :- in(Y), defeat(Y,X).
%% The argument x is not defended by S
not_defended(X) :- defeat(Y,X), not defeated(Y).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% speciall semantics for BAF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% safe
:- supported(B), defeated(B), safe.
:- defeated(B), in(B), safe.
%% s-admissible
:- in(X), not_defended(X), s_adm.
%% closed
:- support(X,Y), out(Y),in(X), closed.
:- support(X,Y), in(Y), out(X), closed.
%% c_admissible
:- in(X), not_defended(X), c_adm.
%% d_admissible
:- in(X), not_defended(X), d_adm.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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