1

I have a question regarding Answer Set Programming on how to make an existing fact invalid, when there is already (also) a default statement present in the Knowledge Base.

For example, there are two persons seby and andy, one of them is able to drive at once. The scenario can be that seby can drive as seen in Line 3 but let's say, after his license is cancelled he cannot drive anymore, hence we now have Lines 4 to 7 and meanwhile andy learnt driving, as seen in Line 7. Line 6 shows only one person can drive at a time, besides showing seby and andy are not the same.

1 person(seby).
2 person(andy).
3 drives(seby).
4 drives(seby) :- person(seby), not ab(d(drives(seby))), not -drives(seby).
5 ab(d(drives(seby))).
6 -drives(P) :- drives(P0), person(P), P0 != P.
7 drives(andy).

In the above program, Lines 3 and 7 contradict with Line 6, and the Clingo solver (which I use) obviously outputs UNSATISFIABLE.

Having said all this, please don't say to delete Line 3 and the problem is solved. The intention behind asking this question is to know whether it is possible now to make Line 3 somehow invalid to let Line 4 do its duty.

However, Line 4 can also be written as:

4 drives(P) :- person(P), not ab(d(drives(P))), not -drives(P).

Thanks a lot in advance.

theRam
  • 15
  • 7

2 Answers2

0

I do not fully understand the problem. Line 3 and line 4 are separate rules, even if line 4's antecedent is false line 3 would still be true. In other words, line 4 seems redundant.

It seems like you want a choice. I assume ab(d(drives(seby))) denotes that seby has lost their license. So, below line four is your constraint on only people with a license driving. Line five is the choice, so by default andy or seby can drive but not both. Notice in the ground program how line five is equivalent to drives(seby) :- not drives(andy). and drives(andy) :- not drives(seby). You can also have seby as being the preferred driver using optimization statements (the choice rule below is like an optimization statement).

person(seby).
person(andy).
ab(d(drives(seby))).
:- person(P), ab(d(drives(P))), drives(P).
1{drives(P) : person(P)}1.
Dr. Thomas C. King
  • 993
  • 2
  • 15
  • 28
0

If something is true, it must always be true. Therefore the line:

drives(seby).

will always be true.

However, we can get around this by putting the fact into a choice rule.

0{drives(seby)}1.

This line says that an answer will have 0 to 1 drives(seby).. This means we can have rules that contradict drives(seby). and the answer will still be satisfiable, but we can also have drives(seby). be true.

Both this program:

0{drives(seby)}1.
drives(seby).

And this program:

0{drives(seby)}1.
:- drives(seby).

Are satisfiable.

Most likely you will want drives(seby). to be true if it can be, and false if it can't be. To accomplish this, we need to force Clingo into making drives(seby). true if it can. We can do this by using an optimization.

A naive way to do this is to count how many drives(seby). exist (either 0 or 1) and maximize the count.

We can count the number of drives(seby). with this line:

sebyCount(N) :- N = #count {drives(seby) : drives(seby)}.

N is equal to the number of drives(seby). in the domain drives(seby).. This will either be 0 or 1.

And then we can maximize the value of N with this statement:

#maximize {N@1 : sebyCount(N)}.

This maximizes the value of N with the priority 1 (the lower the number, the lower the priority) in the domain of sebyCount(N).