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

Introduce {:isolate} and {:isolate "paths"} attributes for assert and return commands #952

Merged
merged 62 commits into from
Oct 7, 2024

Conversation

keyboardDrummer
Copy link
Collaborator

@keyboardDrummer keyboardDrummer commented Sep 24, 2024

Changes

  • Introduce the {:isolate} attribute on AssertCmd and ReturnCmd
  • Introduce the {:isolate "paths"} attribute on AssertCmd and ReturnCmd
  • Introduce new tokens that allow precisely describing where a particular Split comes from.
  • Fix a bug that caused too many VCs to be created when using /vcsSplitOnEveryAssert together with focus
  • Fix incorrect token bug for VCs originating from focus.

Testing

  • Created a folder Test/implementationDivision that has tests for {:isolate}, {:isolate "paths"}, {:focus} and {:split_here}

@keyboardDrummer keyboardDrummer changed the title Introduce /isolatePaths option and {:isolate_paths} attribute Improvements to {:focus} Sep 27, 2024
@keyboardDrummer keyboardDrummer marked this pull request as draft September 27, 2024 21:54
@keyboardDrummer keyboardDrummer marked this pull request as ready for review October 3, 2024 10:09
keyboardDrummer added a commit that referenced this pull request Oct 3, 2024
@keyboardDrummer keyboardDrummer force-pushed the isolatePaths branch 2 times, most recently from 0eb1327 to e3a6d66 Compare October 4, 2024 14:52
Copy link
Collaborator

@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.

Here are my initial comments. It's nice to see isolate assertions, it's going to be useful.

@@ -882,7 +882,7 @@ protected override Cmd ComputeDesugaring(PrintOptions options)

// Do this after copying the attributes so it doesn't get overwritten
if (callId is not null) {
a.CopyIdWithModificationsFrom(tok, req,
(a as ICarriesAttributes).CopyIdWithModificationsFrom(tok, req,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this coercion necessary? I seems that AssertCmd always implement this interface, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactoring from a previous PR that through a git error was reverted in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That issue happened to me in the past as well 😖

Source/Core/VariableDependenceAnalyser.cs Outdated Show resolved Hide resolved
Source/Directory.Build.props Outdated Show resolved Hide resolved
Source/ExecutionEngine/VerificationTask.cs Show resolved Hide resolved
Source/Graph/Graph.cs Show resolved Hide resolved

namespace VCGeneration;

class SplitAttributeHandler {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this file only refactored from somewhere else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's part of the old ManualSplitFinder.cs, but it's changed quite a bit.

Source/VCGeneration/VerificationConditionGenerator.cs Outdated Show resolved Hide resolved
@@ -1445,7 +1430,7 @@ public static Counterexample AssertCmdToCloneCounterexample(VCGenOptions options
{
Contract.Assert(block != null);
Contract.Assume(block.TransferCmd != null);
returnCmd = gotoCmdOrigins.GetValueOrDefault(block.TransferCmd);
returnCmd = block.TransferCmd.tok is GotoFromReturn gotoFromReturn ? gotoFromReturn.Origin : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I now see how you encode meta-data in tokens.
I had launched a discussion about the design of having different tokens vs. flattened tokens here:
dafny-lang/dafny#3354
It all boils down to deciding if you want to encode multiple information using wrapped tokens, where each token provides more information. If that is the case, then a flat token containing everything is more maintainable.
If the cases are truly disjoint, then a hierarchy of tokens is the way to go.
In the light of that, are your new tokens wrapper nestable or not?

Copy link
Collaborator Author

@keyboardDrummer keyboardDrummer Oct 4, 2024

Choose a reason for hiding this comment

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

IMO the name Token should be reserved for lexical tokens, so data that only describes a source location and a word. However, I think for error reporting purposes, it is useful to track what the origin of nodes in the AST is, that origin might be ParsedFromSource(IToken token) : IOrigin, but it can also be something related to a program transformation. In this case, the origin of the goto jump is the desugaring transformation of a return jump.

I think in the future I would prefer to rename IToken to IOrigin.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed that IToken can be renamed to IOrigin, so that the token part is a sub-part of it, concerns only the lexical token, and not every metadata we don't know otherwise where to store.

In the meantime, if there is a token wrapper, I suggest there is at most one such wrapper that will contain any possible information about the origin. Is it what you did? Or are there at least two token wrapper classes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it what you did? Or are there at least two token wrapper classes?

I think so, if I understand you correctly. Every AST node only has a single origin related field, whether that is a Token or a TokenWrapper.

Source/VCGeneration/VerificationRunResult.cs Show resolved Hide resolved
@@ -2,10 +2,8 @@ non-interference-2.bpl(25,1): Error: Non-interference check failed
Execution trace:
non-interference-2.bpl(7,3): anon0
non-interference-2.bpl(12,5): inline$AtomicIncr$0$anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_PC$0$L
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get that (0, 0) is not useful, but what about the label on the right? It looked useful.

Copy link
Collaborator Author

@keyboardDrummer keyboardDrummer Oct 4, 2024

Choose a reason for hiding this comment

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

Yeah.. that name is still in the codebase, but someone needs to assign a proper token to the generated node that has that name before it will show up in the execution trace. I can't really judge what the civl code is doing and what tokens should be where.

I can pass in a variant of Token.NoToken, and then it would show this exact message again. I'm not sure it's an improvement though. I'd rather leave this as is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is the message stored? If it's not in the token, we should display it without token information. If it was in the token, and is lost because of the new encoding, I'd recommend to revert that change.
I worry about breaking Civi users who relied on the last line being printed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I've made it so that nothing changes in the civl tests.

@keyboardDrummer keyboardDrummer enabled auto-merge (squash) October 4, 2024 16:45
@keyboardDrummer keyboardDrummer merged commit 25160fa into boogie-org:master Oct 7, 2024
5 checks passed
@keyboardDrummer keyboardDrummer deleted the isolatePaths branch October 7, 2024 11:00
@keyboardDrummer keyboardDrummer restored the isolatePaths branch October 8, 2024 09:29
fabiomadge added a commit to fabiomadge/boogie that referenced this pull request Oct 15, 2024
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