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

Opaque functions cause failing override checks #422

Open
RustanLeino opened this issue Nov 12, 2019 · 0 comments
Open

Opaque functions cause failing override checks #422

RustanLeino opened this issue Nov 12, 2019 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator)

Comments

@RustanLeino
Copy link
Collaborator

If a method in a trait mentions an opaque function and the overriding method in a class does the same, then the override check still fails:

$ dafny trait-opaque-bug.dfy
Dafny 2.3.0.10506
trait-opaque-bug.dfy(13,9): Error: the method must provide an equal or more permissive precondition than in its parent trait
Execution trace:
    (0,0): anon0

Dafny program verifier finished with 2 verified, 1 error

Method M in the following program gives a repro. A workaround is to wrap the opaque function into another (Workaround below) and mentioning it instead of the original function

predicate {:opaque} P(x: int) {
  x < 5
}

trait Tr {
  method M(x: int)
    requires P(x)
  method N(x: int)
    requires Workaround(x)
}

class C extends Tr {
  method M(x: int)
    requires P(x)
  {
  }
  method N(x: int)
    requires Workaround(x)
  {
  }
}

predicate Workaround(x: int) {
  P(x)
}

The problem comes down to a mismatch of fuel constants, as the following two lines in the generated Boogie code show:

    assume _module.__default.P(StartFuel__module._default.P, x#0);
    assert _module.__default.P(StartFuelAssert__module._default.P, x#0);
@robin-aws robin-aws added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator) labels Jun 23, 2020
@acioc acioc added this to the Dafny 3.0 milestone Aug 12, 2020
@atomb atomb removed this from the Dafny 3.0 milestone Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator)
Projects
None yet
Development

No branches or pull requests

4 participants