generated from potassco/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The meta-encoding for the derivation sequence is applied several times to assign atoms in stage (as there is no clear way to have the order of derivation) and the answer set is also filtered (just in case the same atom is derived with multiple reasons on the same iteration). The meta-encoding for the graph is aligned with the definition of "reason" in the article. Disjunctive heads are supported.
- Loading branch information
Mario Alviano
committed
Feb 13, 2024
1 parent
c7a5f5b
commit 736a2cb
Showing
5 changed files
with
178 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,52 @@ | ||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (support, Rule), _); | ||
assign(Atom, _, (support, Rule)); | ||
pos_body(Rule, BodyAtom). | ||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (support, Rule), _); | ||
assign(Atom, _, (support, Rule)); | ||
neg_body(Rule, BodyAtom). | ||
link(Atom, HeadAtom) :- | ||
assign(Atom, _, (support, Rule), _); | ||
head(Rule, HeadAtom), assign(HeadAtom, false, _, _). | ||
link(Atom, FalseHeadAtom) :- | ||
assign(Atom, _, (support, Rule)); | ||
head(Rule, FalseHeadAtom), assign(FalseHeadAtom, false, _). | ||
|
||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (choice, Rule), _); | ||
assign(Atom, _, (head_upper_bound, Rule)); | ||
pos_body(Rule, BodyAtom). | ||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (choice, Rule), _); | ||
assign(Atom, _, (head_upper_bound, Rule)); | ||
neg_body(Rule, BodyAtom). | ||
link(Atom, HeadAtom) :- | ||
assign(Atom, _, (choice, Rule), Index); | ||
head(Rule, HeadAtom), assign(HeadAtom, true, _, Index'), Index' < Index. | ||
|
||
{link(Atom, Atom'): false_body(Rule, Atom', Index'), Index' < Index} = 1 :- | ||
assign(Atom, _, (lack_of_support,), Index); | ||
head(Rule, Atom). | ||
% disj rule? | ||
|
||
%link(HeadAtom, Atom) :- | ||
% assign(Atom, _, (last_support, Rule, Atom), Index); | ||
% head(Rule, HeadAtom), assign(HeadAtom, _, _, Index'), Index' < Index. | ||
% handle disjunctive rules? | ||
link(BodyAtom, Atom) :- | ||
assign(BodyAtom, _, (last_support, Rule, Atom), _). | ||
{link(BodyAtom, Atom'): false_body(Rule', Atom', Index'), Index' < Index} = 1 :- | ||
assign(BodyAtom, _, (last_support, Rule, Atom), Index); | ||
head(Rule', Atom), false_body(Rule, Atom, _). | ||
|
||
link(Atom, HeadAtom) :- | ||
assign(Atom, _, (constraint, Rule), Index); | ||
head(Rule, HeadAtom), assign(HeadAtom, _, _, Index'), Index' < Index. | ||
link(Atom, TrueHeadAtom) :- | ||
assign(Atom, _, (head_upper_bound, Rule)); | ||
head(Rule, TrueHeadAtom), assign(TrueHeadAtom, true, _). | ||
|
||
link(Atom, BecauseOfAtom) :- | ||
assign(Atom, _, (lack_of_support,)); | ||
head(Rule, Atom), cannot_support(Rule, Atom, BecauseOfAtom). | ||
|
||
link(Atom, AtomToSupport) :- | ||
assign(Atom, _, (last_support, Rule, AtomToSupport)). | ||
link(Atom, BecauseOfAtom) :- | ||
assign(Atom, _, (last_support, Rule, AtomToSupport)); | ||
cannot_support(Rule, AtomToSupport, BecauseOfAtom). | ||
|
||
link(Atom, TrueHeadAtom) :- | ||
assign(Atom, _, (constraint, Rule, upper_bound)); | ||
head(Rule, TrueHeadAtom), assign(TrueHeadAtom, true, _). | ||
link(Atom, FalseHeadAtom) :- | ||
assign(Atom, _, (constraint, Rule, lower_bound)); | ||
head(Rule, FalseHeadAtom), assign(FalseHeadAtom, false, _). | ||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (constraint, Rule), _); | ||
assign(Atom, _, (constraint, Rule, _)); | ||
pos_body(Rule, BodyAtom), BodyAtom != Atom. | ||
link(Atom, BodyAtom) :- | ||
assign(Atom, _, (constraint, Rule), _); | ||
assign(Atom, _, (constraint, Rule, _)); | ||
neg_body(Rule, BodyAtom), BodyAtom != Atom. | ||
|
||
|
||
reach(Atom) :- query(Atom). | ||
reach(Atom') :- reach(Atom), link(Atom, Atom'), not hide(Atom'). | ||
|
||
hide(Atom) :- head(Rule, Atom); not pos_body(Rule,_); not neg_body(Rule,_). | ||
|
||
%#show. | ||
%#show node(X,V,R) : assign(X,V,R,_), reach(X). | ||
%#show link(X,Y) : link(X,Y), reach(X), reach(Y). | ||
node(X,V,R) :- assign(X,V,R,_), reach(X). | ||
link'(X,Y) :- link(X,Y), reach(X), reach(Y). | ||
#show. | ||
#show node(X,V,R) : assign(X,V,R), reach(X). | ||
#show link(X,Y) : link(X,Y), reach(X), reach(Y). |
Oops, something went wrong.