Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent result for evaluate()/solve() when changing order of variables and constants in (+) operands #2

Open
michaelmera opened this issue Aug 27, 2022 · 1 comment
Assignees
Labels
bug Something isn't working medium Bugs/issues of medium importance SMT-LIB Bugs related to ISLa's handling of SMT-LIB formulas.

Comments

@michaelmera
Copy link

Here is a file reproducing the problem. It does two times the same computation, just inverting the order of the operands of (+):

# isla_add_order.py
from isla.type_defs import Grammar
from isla.solver import ISLaSolver

GRAMMAR: Grammar = {
    "<start>": ["<isbn10>"],
    "<isbn10>": [
        "<digit><digit><digit><digit><digit><digit><digit><digit><digit><checkdigit>"
    ],
    "<digit>": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
    "<checkdigit>": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X"],
}

valid="097522980X"

if __name__ == "__main__":
    solver = ISLaSolver(GRAMMAR, "(= (+ 254 10 (* 2 str.to.int(<isbn10>.<digit>[9]))) 264)")
    print(solver.evaluate(valid))
    solver = ISLaSolver(GRAMMAR, "(= (+ 254 (* 2 str.to.int(<isbn10>.<digit>[9])) 10) 264)")
    print(solver.evaluate(valid))

The output is:

$ python isla_add_order.py
TRUE
FALSE
@michaelmera michaelmera changed the title iconsistent result for evaluate()/solve() when changing order of variables and constants in (+) operands inconsistent result for evaluate()/solve() when changing order of variables and constants in (+) operands Aug 28, 2022
@rindPHI
Copy link
Owner

rindPHI commented Aug 29, 2022

Hi Michael,

ISLa can unfortunately only handle the binary version of "+" it seems. I added a test case and a TODO for the issue. In the meantime, you could just write

solver = ISLaSolver(GRAMMAR, "(= (+ 254 (+ 10 (* 2 str.to.int(<isbn10>.<digit>[9])))) 264)")

This version of + should be commutative.

Best,
Dominic

@rindPHI rindPHI self-assigned this Aug 29, 2022
@rindPHI rindPHI added bug Something isn't working SMT-LIB Bugs related to ISLa's handling of SMT-LIB formulas. medium Bugs/issues of medium importance labels Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working medium Bugs/issues of medium importance SMT-LIB Bugs related to ISLa's handling of SMT-LIB formulas.
Projects
None yet
Development

No branches or pull requests

2 participants