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

An Unknown Instance of Loop Invariant? #178

Open
sjxer723 opened this issue Apr 23, 2024 · 1 comment
Open

An Unknown Instance of Loop Invariant? #178

sjxer723 opened this issue Apr 23, 2024 · 1 comment
Assignees

Comments

@sjxer723
Copy link

sjxer723 commented Apr 23, 2024

Hi, I tried to verify the following example.

void main(int argc, char **argv)
{
    unsigned int sn, i, size;
    __CPROVER_assume(i == 1);
    __CPROVER_assume(sn == 0);

    size = argc;

    while(i<= size)
    {
        i = i + 1;
        sn = sn +1;
    }

  assert(((i <= size) || (sn == size) || (sn == 0)));
}

It should be verified since i = sn+1 is guaranteed during the execution and the difference between i and size should be at most 1. However, when I run cls foo.c (foo.c is the name of the file), it reports UNKNOWN as follows,

** statistics: 
  number of solver instances: 178
  number of solver calls: 148
  number of summaries used: 2
  number of termination arguments computed: 0

[main.assertion.1] assertion i <= size || sn >= size || sn == (unsigned int)0: UNKNOWN

** 1 of 1 unknown
** 0 of 1 failed

May I know if I should enable other options to make it report SUCCESS or FAILURE? Thanks a lot!

@peterschrammel peterschrammel self-assigned this Apr 23, 2024
@sjxer723 sjxer723 changed the title A False Positive of Loop Invariant? An Unknown Instance of Loop Invariant? Apr 23, 2024
@viktormalik
Copy link
Collaborator

Hi, by default, 2LS uses the intervals abstract domain which I believe is not sufficient in this case. Since you need to reason about a relation between two variables, you'll need something stronger, the zones domain (--zones) should do.

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

No branches or pull requests

3 participants