Integer comparison does not behave as expected.
EdGaere opened this issue · comments
Edward Gaere commented
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
Edward Gaere commented
Solved it. Use intgr(), on both sides, to force a numerical comparison.
lte_12(X) :- intgr(X) @=< intgr(12) .