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

fix: Substitute for receiver in automatically generated induction hypothesis #2002

Merged
merged 11 commits into from
Apr 12, 2022

Conversation

RustanLeino
Copy link
Collaborator

A lemma like

class C {
  lemma MyLemma(x: X)
    requires Pre(x)
    ensures Post(x)
    decreases D(x)
  {
  }
}

should give rise to an induction hypothesis (which is provided by the verifier as an assumption on entry to the lemma's body) of the form

forall this': C, x': X | this'.Pre(x') && this'.D(x') < this.D(x) :: this'.Post(x')

Previously, this was generated incorrectly. In particular, the formula this'.Post(x') was previously generated as this.P(x'). This PR corrects the generated formula.

Fixes #2001

The example given in issue #2001 is included in Test/dafny1/Induction.dfy.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Test/dafny1/Induction.dfy Outdated Show resolved Hide resolved
@@ -594,7 +594,7 @@ public partial class Translator {
// Generate a CallStmt for the recursive call
Expression recursiveCallReceiver;
List<Expression> recursiveCallArgs;
RecursiveCallParameters(m.tok, m, m.TypeArgs, m.Ins, substMap, out recursiveCallReceiver, out recursiveCallArgs);
RecursiveCallParameters(m.tok, m, m.TypeArgs, m.Ins, receiverSubst, substMap, out recursiveCallReceiver, out recursiveCallArgs);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment in L555 still up-to-date?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I improved it.

@RustanLeino RustanLeino enabled auto-merge (squash) April 12, 2022 15:23
@RustanLeino RustanLeino merged commit 3c951f2 into dafny-lang:master Apr 12, 2022
@RustanLeino RustanLeino deleted the issue-2001 branch April 13, 2022 01:17
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 this pull request may close these issues.

Automatic induction does not substitute receiver parameter
2 participants