ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
297 stars 34 forks source link

Integer comparison does not behave as expected. #80

Closed EdGaere closed 2 years ago

EdGaere commented 2 years ago

Arithmetic operator "less-than-or-equal-to" (<=) seems to perform a string comparison rather than a numerical comparison.

I am still a beginner at ProLog/ProbLog. Either way, I thinks it's misleading.

%less than or equal to 12
lte_12(X) :- X @=< 12.

query(lte_12(11)) .
query(lte_12(12)) .
query(lte_12(13)) .
query(lte_12(99) ) .
query(lte_12(100)) .

Output:

lte_12(11): 1
lte_12(12): 1
lte_12(13): 0
lte_12(99): 0
lte_12(100):    1    <-- ??
lte_12(1000):   1    <-- ??

Python 3.8.3 problog==2.2.2

EdGaere commented 2 years ago

Solved it. Use intgr(), on both sides, to force a numerical comparison.

lte_12(X) :- intgr(X) @=< intgr(12) .