Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Replace __VERIFIER_assume() by an implementation #1072

Merged
merged 5 commits into from
Jan 10, 2020

Conversation

skanav
Copy link
Contributor

@skanav skanav commented Jan 10, 2020

This PR is created as an alternate solution for the issue #1035 instead of PR #1040

It does semantically the same thing, but instead of replacing the __VERIFIER_assume call with an if condition we now replace it with a function call: assume_cycle_if_not for the memory cleanup tasks and assume_abort_if_not all the remaining tasks.

As a first step the tasks for valid-memcleanup were identified and these files were updated manually.
As a second step all the remaining files were updated using the following script:

find . -name "*.[hci]" -print0 | \
xargs -0 perl -0777 -pi -e \
's/void __VERIFIER_assume([^;]*);/void abort(void); \nvoid assume_abort_if_not(int cond) { \n  if(!cond) {abort();}\n}/ ; \
 s/__VERIFIER_assume/assume_abort_if_not/g'

Fixes: #1035
Closes #1040

Please have a look at #1035 for more details.

Added by dbeyer 2020-01-09:

@skanav skanav added affects SV-COMP rules C Task in language C labels Jan 10, 2020
@skanav skanav added this to the SV-COMP 2021 milestone Jan 10, 2020
@dbeyer dbeyer changed the title Remove verifier assume Replace __VERIFIER_assume() by an implementation Jan 10, 2020
@dbeyer
Copy link
Member

dbeyer commented Jan 10, 2020

This does not affect the rules of SV-COMP, so I removed that label. But it makes one rule superfluous ;-)

Copy link
Member

@dbeyer dbeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasons for this change:

  • The definition of __VERIFIER_assume(p) in the SV-COMP rules (cycling without termination if p is not satisfied) is different from what many people expect by intuition (assumption or contract), and from what is implemented in many participating verifiers.
  • Avoiding this speciality greatly simplifies the rules and the verification tasks.
  • The special semantics of __VERIFIER_assume(p) is not essential to express interesting and practically relevant verification tasks.
  • Having an assume is practically relevant for verification engineers, thus, we still use a function name that reminds the reader of an assume, but the functions have definitions and no other special meaning.

@dbeyer dbeyer merged commit fbb4a60 into master Jan 10, 2020
@PhilippWendler PhilippWendler deleted the remove__VERIFIER_assume branch January 22, 2020 15:12
lembergerth added a commit to lembergerth/sv-benchmarks that referenced this pull request Jul 11, 2020
…_not

Implementation of assume_abort_if_not as proposed by sosy-lab#1072

Commands used:

1. Python code used to remove definition of ldv_assume:

```
def remove_assume(content):
    in_assume = -1
    for line in content:
        if (line.strip() == "void ldv_assume(int expression )"):
            in_assume = 0
        if in_assume < 0 or in_assume > 13:
            yield line
        else:
            in_assume = in_assume + 1

for f in glob.glob(*.c):
    with open(f) as inp:
        content = inp.readlines()
    new_content = list(remove_assume(content))
    with open(f, w) as outp:
        outp.writelines(new_content)
```

2. Python code used to remove definition of ldv_stop:

```
def remove_stop(content):
    in_assume = -1
    for line in content:
        if (line.strip() == "void ldv_stop(void)"):
            in_assume = 0
        if in_assume < 0 or in_assume > 8:
            yield line
        else:
            in_assume = in_assume + 1
for f in glob.glob(*.c):
    with open(f) as inp:
        content = inp.readlines()
    new_content = list(remove_stop(content))
    with open(f, w) as outp:
        outp.writelines(new_content)
```

Bash command used to replace occurrences of ldv_assume and ldv_stop
and introduce definition of assume_abort_if_not:

```
sed -i *.c \
  -e 's/ldv_assume/assume_abort_if_not/g' \
  -e '/void ldv_stop(void) ;/d' \
  -e 's/ldv_stop()/assume_abort_if_not(0)/g' \
  -e 's/void assume_abort_if_not(int expression.*).*;/extern void abort(void);\nvoid assume_abort_if_not(int cond) {\n  if(!cond) {abort();}\n}/'
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C Task in language C
2 participants