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

Bounded pool for not in #1939

Merged
merged 7 commits into from
Apr 11, 2022

Conversation

RustanLeino
Copy link
Collaborator

Recognize !in operator when looking for compilable comprehensions. For example, each of the quantifications

!exists x :: x in S
forall x :: !(x in S)
forall x :: x in S ==> false

compiled, but the equivalent

forall x :: x !in S

did not. Now, all of them compile.

Also, fix malformed Java code generated for comprehensions that use maps.

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

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

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

Great job adding !in for the list of operators to consider for the heuristics.
Could you add a test for the Java problem you mention?

Test/comp/Comprehensions.dfy Show resolved Hide resolved
@@ -3313,7 +3313,8 @@ public class CheckHasNoAssumes_Visitor : BottomUpVisitor {
} else if (bound is ComprehensionExpr.MapBoundedPool) {
var b = (ComprehensionExpr.MapBoundedPool)bound;
TrParenExpr(su.Substitute(b.Map), collectionWriter, inLetExprBody);
collectionWriter.Write(".Keys{0}.Elements{0}", propertySuffix);
GetSpecialFieldInfo(SpecialField.ID.Keys, null, null, out var keyName, out _, out _);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a test that explain why this change was necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Method PrintCollectionEmptiness in Test/comp/Comprehensions.dfy includes tests that previously failed with Java. Previously, the code on L3316 would output .Keys.Elements (or .Keys().Elements()) for all the compilers. However, in Java, our compiler uses the name .keySet() instead of .Keys. The GetSpecialFieldInfo mechanism returns the appropriate name for each language.

@RustanLeino
Copy link
Collaborator Author

@MikaelMayer The tests in method PrintCollectionEmptiness in Test/comp/Comprehensions.dfy includes tests that previously failed with Java.

@MikaelMayer MikaelMayer self-requested a review March 30, 2022 19:59
MikaelMayer
MikaelMayer previously approved these changes Mar 30, 2022
Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

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

Great job !

# Conflicts:
#	RELEASE_NOTES.md
#	Source/Dafny/Compilers/SinglePassCompiler.cs
@RustanLeino RustanLeino enabled auto-merge (squash) April 11, 2022 17:03
@RustanLeino RustanLeino merged commit 870f6d5 into dafny-lang:master Apr 11, 2022
@RustanLeino RustanLeino deleted the bounded-pool-for-not-in branch April 11, 2022 19:01
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.

2 participants