potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
606 stars 81 forks source link

I am confused with the OR logic. #466

Closed jyt13 closed 10 months ago

jyt13 commented 10 months ago

Below is the conditions I defined known(a) :- known(b), known(c). known(b) :- known(d); known(e). If b and c is known then a is known; If d or e is known then b is known. I hope like if I give two facts, d is known and c is known, the platform can deduce that a is known. However it does not work, and as I test, the OR logic here seems not working as expected.

And the following codes work: known(a) :- known(b), known(c). known(b) :- {known(d); known(e)}>=1. I used a more direct approach, and that's right. with 2 facts known(c). known(d). It can be solved that finally a,b,c and d are known.

I am using clingo 4.5.4

Thank you in advance

rkaminsk commented 10 months ago

The ; separator is not a disjunction but can alternatively be used to separate body elements. To express disjunction with normal rules, you can use

known(b) :- known(d).
known(b) :- known(e).

For the example above, you could also use

known(b) :- known(d;e).

Have a look at https://arxiv.org/abs/1507.06576 for a precise semantics.

jyt13 commented 10 months ago

The ; separator is not a disjunction but can alternatively be used to separate body elements. To express disjunction with normal rules, you can use

known(b) :- known(d).
known(b) :- known(e).

For the example above, you could also use

known(b) :- known(d;e).

Have a look at https://arxiv.org/abs/1507.06576 for a precise semantics.

Thank you so much.