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

Wrong result is given for the unreach-call property #209

Closed
leventeBajczi opened this issue Sep 20, 2023 · 3 comments
Closed

Wrong result is given for the unreach-call property #209

leventeBajczi opened this issue Sep 20, 2023 · 3 comments
Assignees

Comments

@leventeBajczi
Copy link
Contributor

Config 1: --strategy DIRECT --maxenum 1 --loglevel RESULT --refinement SEQ_ITP --lbe LBE_SEQ --search ERR --prunestrategy FULL --predsplit ATOMS --cex-monitor DISABLE --domain EXPL
Problem17_label11.yml

Config 2: --strategy DIRECT --maxenum 1 --loglevel RESULT --refinement SEQ_ITP --lbe LBE_SEQ --search ERR --prunestrategy FULL --predsplit ATOMS --cex-monitor DISABLE --domain PRED_CART
Problem10_label30.yml, Problem11_label40.yml, Problem15_label49.yml

@s0mark
Copy link
Contributor

s0mark commented Oct 20, 2023

The reason behind the wrong answers appears to be that the semantics of integer division (/) and modulo (%) for negative numbers are different in C and in Z3, as well as in Theta which follows the Z3 semantics in its core (e.g. IntLitExpr):

expression C / Z3 div
5 / 3 1 1
5 / -3 -1 -1
-5 / 3 -1 -2
-5 / -3 1 2
expression C % Z3 mod Z3 rem
5 % 3 2 2 2
5 % -3 2 2 -2
-5 % 3 -2 1 1
-5 % -3 -2 1 -1

@s0mark
Copy link
Contributor

s0mark commented Oct 23, 2023

I fixed the integer division and modulo problems in #230. I ran Theta with the configurations and the tasks mentioned in the issue, it no longer gives wrong answers to them.

This issue brings up the possibility of further discrepancies between the semantics of C, Theta and the solvers: the sdiv/srem and udiv/urem operators for bitvectors might also be effected.

s0mark added a commit that referenced this issue Oct 23, 2023
Fix the discrepancies between the semantics of integer division and modulo in C, Z3 and Theta (see issue #209 and PR #230).
@leventeBajczi
Copy link
Contributor Author

Thanks! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants