%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Encoding for semi-stable sets % Input: % arg(y) ... y is an argument % att(x, y)... attack with the name x attacks argument y % mem(x, y)... argument y is part of the attack x % % Output: % in(y) ... argument y is in the extension %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Guess some set in(X) :- arg(X), not out(X). out(X) :- arg(X), not in(X). % See which attacks are blocked, i.e. not possible as some member is out blocked(R) :- mem(R, X), out(X). % Eliminate all sets that do not block every attack that attacks one of its elements :- in(X), att(R, X), not blocked(R). % See which attacks X are defeated by S, i.e. there is a subset of arguments in S that attacks some argument involved in X defeated(R1) :- att(R1, _), mem(R1, X), att(R2, X), not blocked(R2). % Eliminate all sets that contain some argument that is attack by some not-defeated attack :- in(X), att(R, X), not defeated(R). % Calculate S+ sPlus(Y) :- in(Y). sPlus(Y) :- att(R, Y), not blocked(R). notSPlus(Y) :- not sPlus(Y), arg(Y). % Does S+ already cover all arguemnts? notStable :- not sPlus(Y), arg(Y). % Guess some extended Range extendedRange(X) : notSPlus(X) :- notStable. extendedRange(X) :- sPlus(X), notStable. % Every element in the extended range must be justified, either by adding it to the base set or by adding all members of some attack on it to the base set sIn(X) | necAtt(R) : att(R, X) :- extendedRange(X). sIn(X) :- att(R, _), necAtt(R), mem(R, X). % Notice that the following rule only uses conditions over domain predicates, i.e., the condition is resolved during grounding. unBlocked(R) :- att(R,_), sIn(X):mem(R,X). % The base set must be conflict free fail :- sIn(Y), att(R, Y), unBlocked(R). % The base set must be admissible fail | necAtt(R2) : att(R2, Y), mem(R1, Y) :- sIn(X), att(R1, X). %Saturize sIn(X) :- fail, arg(X). extendedRange(X) :- fail, arg(X). necAtt(R) :- fail, att(R, _). :- not fail, notStable.