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

Higher-order functions problem #3411

Closed
MikaelMayer opened this issue Jan 26, 2023 Discussed in #3405 · 0 comments · Fixed by #3412
Closed

Higher-order functions problem #3411

MikaelMayer opened this issue Jan 26, 2023 Discussed in #3405 · 0 comments · Fixed by #3412

Comments

@MikaelMayer
Copy link
Member

Discussed in #3405

Originally posted by Nangos January 26, 2023
Hi All,

I recently met a problem when verifying with higher-order functions. It boils down to the following minimal example:

var f: int -> int;
assert seq(1, x => f(x))[0] == f(0);  // No problem
assert seq(1, f)[0] == f(0);  // Error: assertion might not hold

In the general case (especially when writing class methods), one would have to write x reads f.reads(x) requires f.requires(x) => f(x) in the place of f. This will be quite a boilerplate.

After some random attempts, I found an acceptable workaround:

// Seems like a mere identity function. What's going on here?
function magic<S, T>(f: S ~> T): (S ~> T) {
  x reads f.reads(x) requires f.requires(x) => f(x)
}

assert seq(1, magic(f))[0] == f(0);  // No problem now

I am still curious about what exactly is happening under the hood and whether there are more elegant ways to deal with this. Any suggestion is welcome.

MikaelMayer added a commit that referenced this issue Jan 26, 2023
This PR is an attempt at detecting if an axiom was wrongly instantiated. If all the CI test pass, then it's likely a typo fix and I'll follow up with a test to ensure #3411 is fixed
MikaelMayer added a commit that referenced this issue Jan 26, 2023
This PR fixes #3411 
Seems like one of Boogie's axiom was wrong, but it was unnoticed because
another application axiom was ignoring the wrong argument.
I added the test case of the issue.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
atomb pushed a commit to atomb/dafny that referenced this issue Feb 1, 2023
This PR fixes dafny-lang#3411 
Seems like one of Boogie's axiom was wrong, but it was unnoticed because
another application axiom was ignoring the wrong argument.
I added the test case of the issue.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
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

Successfully merging a pull request may close this issue.

1 participant