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

require condition disappear in presence of statements #1343

Closed
mario-bucev opened this issue Nov 23, 2022 · 1 comment · Fixed by #1344
Closed

require condition disappear in presence of statements #1343

mario-bucev opened this issue Nov 23, 2022 · 1 comment · Fixed by #1344
Assignees
Labels

Comments

@mario-bucev
Copy link
Collaborator

@samuelchassot discovered a bug where having statements within require somehow make the required condition go away.
For instance, this should go through, but does not:

object BlindRequire {
  def myLemma(x: BigInt): Unit = {
    ()
  }.ensuring(_ => x + x == 2 * x)

  def blind(x: BigInt): Unit = {
    require {
      myLemma(x)
      x >= 0
    }
    assert(x >= 0) // fails
  }
}
@mario-bucev mario-bucev self-assigned this Nov 23, 2022
@mario-bucev
Copy link
Collaborator Author

Oh no, it's imperative again :(

[ Debug  ] Symbols before ImperativeCodeElimination
[ Debug  ] 
[ Debug  ] -------------Functions-------------
[ Debug  ] def myLemma((x: BigInt) @pure): Unit = {
[ Debug  ]   ()
[ Debug  ] } ensuring {
[ Debug  ]   (_$1: Unit) => x + x == 2 * x
[ Debug  ] }
[ Debug  ] 
[ Debug  ] def blind((x: BigInt) @pure): Unit = {
[ Debug  ]   myLemma(x)
[ Debug  ]   require(x >= 0)
[ Debug  ]   assert(x >= 0)
[ Debug  ]   ()
[ Debug  ] }
[ Debug  ] 
[ Debug  ] 
[ Debug  ] 
[ Debug  ] 
[ Debug  ] Symbols after ImperativeCodeElimination
[ Debug  ] 
[ Debug  ] -------------Functions-------------
[ Debug  ] def myLemma((x: BigInt) @pure): Unit = {
[ Debug  ]   ()
[ Debug  ] } ensuring {
[ Debug  ]   (_$1: Unit) => x + x == 2 * x
[ Debug  ] }
[ Debug  ] 
[ Debug  ] def blind((x: BigInt) @pure): Unit = {
[ Debug  ]   val tmp: Unit = myLemma(x)
[ Debug  ]   assert(x >= 0)
[ Debug  ]   require(x >= 0)
[ Debug  ]   ()
[ Debug  ] }

mario-bucev added a commit to mario-bucev/stainless that referenced this issue Nov 23, 2022
mario-bucev added a commit to mario-bucev/stainless that referenced this issue Nov 23, 2022
@mario-bucev mario-bucev mentioned this issue Nov 23, 2022
vkuncak pushed a commit that referenced this issue Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant