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

Inline lets before trigger selection #130

Merged
merged 10 commits into from
Jul 28, 2017

Conversation

wilcoxjay
Copy link
Collaborator

Fixes #128.

When TriggerAnnotation.Annotate encounters a LetExpr, it now inlines the let using Translator.Substitute (which is now static to make it easy to call from outside the translator).

This improves trigger selection when there are lets inside a quantifier. There was even an (admittedly synthetic) existing test case in the test suite that ran into this problem!

Note that the inlined expression is only considered for the purposes of trigger selection. The rest of the pipeline continues to see the un-inlined expression.

I considered factoring Translator.Substitute out of the translator and into its own file (or into Cloner), but in the end I felt that it made sense to leave it there because of the scary comment about dropping parts of expressions that are only for well-formedness checks.

@RustanLeino
Copy link
Collaborator

Great feature. :) I'm also happy to see that Substitute could be made static.

I have one suggestion: Why not also support let expressions with multiple LHSs? I think this would come at almost no extra work, by simply calling the overloaded Substitute method (the one that takes a substMap).

@cpitclaudel
Copy link
Member

Indeed, very nice. This should help with loop detection, too; as in this comment:

  // WISH: It might also be good to zeta-reduce before loop detection.
  assert forall x :: true || Q(x) || (var xx := x+1; Q(xx));

There was even an (admittedly synthetic) existing test case in the test suite that ran into this problem!
Well, it did have a WISH annotation, didn't it? :)

@wilcoxjay
Copy link
Collaborator Author

I added support for lets with multiple LHSs, as you suggested.

@cpitclaudel In that example, is the intention that after integrating let-inlining into loop detection, that a loop will be detected where it is not now?

@cpitclaudel
Copy link
Member

Exactly.

@wilcoxjay
Copy link
Collaborator Author

I just added let inlining to loop detection as well, and it works on the tests. (The loop even gets rewritten correctly!)

@cpitclaudel
Copy link
Member

Super! Very nice.

@wilcoxjay wilcoxjay merged commit b971c88 into master Jul 28, 2017
@wilcoxjay wilcoxjay deleted the inline-lets-before-trigger-selection branch July 28, 2017 20:46
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.

None yet

4 participants