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

Unsoundness of no-inc:z3 involving class invariants #1432

Open
mario-bucev opened this issue Jul 11, 2023 · 0 comments
Open

Unsoundness of no-inc:z3 involving class invariants #1432

mario-bucev opened this issue Jul 11, 2023 · 0 comments

Comments

@mario-bucev
Copy link
Collaborator

The following odd-looking snippet sometimes goes through with --solvers="no-inc:smt-z3:z3 tactic.default_tactic=smt sat.euf=true" (a solver we sometimes use, see e.g. SortedArray) even though it should not:

import stainless.*
import stainless.lang.*
import stainless.proof.*
import stainless.collection.*

object Min {

  case class Wrapper(dummy: BigInt, data: Data)

  case class Data(dummy: BigInt, values: ListMap[Int, Int]) {
    require(values.contains(3) && values.contains(4))
  }

  def test(w: Wrapper, x: BigInt): Unit = {
    require(x >= 0)
    decreases(x)
    if (x == 0) {
      w match {
        case w@Wrapper(_, _) => check(w.data.values.contains(3))
      }
      ()
    } else {
      test(w, x - 1)
    }
  }.ensuring(_ => false)
}

I would have thought this bug was introduced by 9fbc579 but I've tested it against an older commit and it went through as well.

Note that smt-cvc4 and smt-z3 provide a correct counter-example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant