For those not familiar with preferences in logic programming, it might already be instructive to compare the results obtained on a simple example with and without preferences:
penguin(tweety).
bird(tweety).
flies(tweety) :- not neg flies(tweety), bird(tweety).
neg flies(tweety) :- not flies(tweety), penguin(tweety).
Compiling the file, named
penguin.lp,
and piping the
result
into dlv yields two answer sets:
dlv [build BEN/Nov 24 1999 gcc egcs-2.91.66 19990314 (egcs-1.1.2 release)]
Reading "Examples/penguin.dlv"
{true, penguin(tweety), bird(tweety), flies(tweety)}
{true, penguin(tweety), bird(tweety), neg_flies(tweety)}
For this, we name the two last rules:
This program is expressed in our syntax as follows:
penguin(tweety).
bird(tweety).
flies(tweety) :- name(1), not neg flies(tweety), bird(tweety).
neg flies(tweety) :- name(2), not flies(tweety), penguin(tweety).
1 < 2.
Compiling the file
penguin.lp
and piping the
result
into dlv yields now only one answer set:
dlv [build BEN/Nov 24 1999 gcc egcs-2.91.66 19990314 (egcs-1.1.2 release)]
Reading "Examples/penguin.dlv"
{true, name(1), name(2), penguin(tweety), bird(tweety), ok(2), oko(1,1),
oko(2,1), oko(2,2), prec(1,2), neg_prec(2,1), ap(2), neg_flies(tweety),
oko(1,2), ok(1), bl(1)}
Here we obtain a single answer set that corresponds to the second answer set
above;
it includes further atoms that stem from the additional preference-handling rules.