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

Decidability/computability of lambda equality hinders reasoning abilities #432

Open
romac opened this issue Jan 16, 2019 · 2 comments
Open

Comments

@romac
Copy link
Member

romac commented Jan 16, 2019

Background: #62

In short, because lambda equality is assumed to be decidable within Inox' semantics, the assertion in the following testcase is deemed invalid unknown (with --check-models). That stems from Inox assuming that an implementation of bar could discriminate between k and x => k(x), and return a different result in each case. While that is possible in Scala because of reference equality [1], this is in general not something we want to support within Stainlesss' semantics.

abstract class Foo {
  def bar(f: Int => Int): Int
}

val k = (i: Int) => i

def test(foo: Foo) = {
  assert(foo.bar(k) == foo.bar(x => k(x))) // INVALID
}

We should thus (as discussed with @samarion) add a mode to Inox where lambda equality is deemed undecidable, and enable that mode when used through Stainless. See the corresponding issue in the Inox repository: epfl-lara/inox#87.

We therefore also need to check that user-land code does not rely on such semantics (ie. compare lambdas for equality).

  • [1]

    case class Bar() extends Foo {
      def bar(f: Int => Int): Int = if (f == k) 0 else -1
    }
@romac
Copy link
Member Author

romac commented Jan 16, 2019

@samarion Please feel free to edit/comment on this issue if I misunderstood/misrepresented the issue and potential solution.

@vkuncak
Copy link
Collaborator

vkuncak commented Feb 28, 2019

Assuming lambda equality is actually very useful in reasoning about higher-order functions.
We may be encoding parameter passing through equalities or lets and we need to have at least some use of positive equalities in assumptions to get the expected proofs go through.

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

No branches or pull requests

2 participants