potassco / clingo

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

AST Order in the python API #393

Closed jorgefandinno closed 1 year ago

jorgefandinno commented 1 year ago

It seems that the < operator does not define an order among AST objects. This can be checked with the following python code.

from clingox.testing.ast import parse_statement

rule1 = parse_statement(":- b.")
rule2 = parse_statement(":- not a.")

print(f"rule1: {rule1}")
print(f"rule2: {rule2}")
print("="*40)
print(f"rule1 < rule2: {rule1 < rule2}")
print(f"rule2 < rule1: {rule2 < rule1}")

which produces the following result.

clingo.__version__='5.6.0'
========================================
rule1: #false :- b.
rule2: #false :- not a.
========================================
rule1 < rule2: True
rule2 < rule1: True

The expected result is that either rule1 < rule2 or rule2 < rule1, but not both.

We checked with version 5.5.2 and we got the same result.