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

Trait postcondition ignored #5840

Open
jaylorch opened this issue Oct 17, 2024 · 0 comments
Open

Trait postcondition ignored #5840

jaylorch opened this issue Oct 17, 2024 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@jaylorch
Copy link
Collaborator

Dafny version

4.8.1

Code to produce this issue

module Testing {

  trait V {
    ghost function Repr() : set<object>
      reads this

    ghost predicate Valid()
      reads this
      reads Repr()

    method Update()
      requires this.Valid()
      modifies Repr()
      ensures  this.Valid()
  }

  class C<T extends V>
  {
    var t: T

    ghost function Repr() : set<object>
        reads this
        reads t as V
    {
      { this, t as V } + (t as V).Repr()
    }

    ghost predicate Valid()
      reads Repr()
    {
      (t as V).Valid()
    }

    constructor Create(x: T)
    {
      t := x;
    }

    method HUpdate()
      requires Valid()
      modifies Repr()
      ensures  Valid()
    {
      (t as V).Update();
      assert((t as V).Valid()); // Why doesn't this follow from the postcondition of `V.Update`?
    }
  }

}

Command to run and resulting output

C:\Apps\TestDafny>C:\Bin\dafny-4.8.1-win\Dafny.exe verify --type-system-refresh test.dfy
test.dfy(45,12): Error: assertion might not hold
   |
45 |       assert((t as V).Valid()); // Why doesn't this follow from the postcondition of `V.Update`?
   |             ^^^^^^^^^^^^^^^^^^


Dafny program verifier finished with 4 verified, 1 error

What happened?

I expected the assert to hold, since it follows directly from the postcondition of V.Update.

What type of operating system are you experiencing the problem on?

Windows

@jaylorch jaylorch added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Oct 17, 2024
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
Projects
None yet
Development

No branches or pull requests

1 participant