Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enable isolating all return statements #5917

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/DafnyCore/AST/Tokens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Token(int linenum, int colnum) {
this.val = "";
}

public bool IsSourceToken => this != NoToken;
public int kind { get; set; } // Used by coco, so we can't rename it to Kind

public string ActualFilename => Filepath;
Expand Down Expand Up @@ -160,6 +161,8 @@ public bool IsValid {
get { return WrappedToken.IsValid; }
}

public virtual bool IsSourceToken => false;

public int kind {
get { return WrappedToken.kind; }
set { WrappedToken.kind = value; }
Expand Down Expand Up @@ -305,6 +308,8 @@ public override IToken WithVal(string newVal) {
throw new NotImplementedException();
}

public override bool IsSourceToken => this != NoToken;

public BoogieRangeToken ToToken() {
return new BoogieRangeToken(StartToken, EndToken, null);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/DafnyCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Runtime.Numerics" Version="4.3.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<PackageReference Include="Boogie.ExecutionEngine" Version="3.4.1" />
<PackageReference Include="Boogie.ExecutionEngine" Version="3.4.2" />
<PackageReference Include="Tomlyn" Version="0.16.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyDriver/CliCompilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ string OriginDescription(IImplementationPartOrigin origin, bool outer) {
var result = origin switch {
PathOrigin pathOrigin => $"{OriginDescription(pathOrigin.Inner, false)}" +
$"after executing lines {string.Join(", ", pathOrigin.BranchTokens.Select(b => b.line))}",
RemainingAssertionsOrigin remainingAssertions => $"{OriginDescription(remainingAssertions.Origin, false)}remaining assertions",
RemainingAssertionsOrigin remainingAssertions => OriginDescription(remainingAssertions.Origin, false) + (outer ? "remaining assertions" : ""),
IsolatedAssertionOrigin isolateOrigin => $"{OriginDescription(isolateOrigin.Origin, false)}assertion at line {isolateOrigin.line}",
JumpOrigin returnOrigin => $"{OriginDescription(returnOrigin.Origin, false)}{JumpOriginKind(returnOrigin)} at line {returnOrigin.line}",
AfterSplitOrigin splitOrigin => $"{OriginDescription(splitOrigin.Inner, false)}assertions after split_here at line {splitOrigin.line}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: ! %verify --isolate-assertions --cores=1 --progress VerificationJobs "%s" &> %t.raw
// RUN: %sed 's#\(time.*\)#<redacted>#g' %t.raw > %t
// RUN: %diff "%s.expect" "%t"

ghost function f(i:nat, j:nat):int {if i == 0 then 0 else f(i - 1, i * j + 1) + f(i - 1, 2 * i * j)}

ghost function f(i:nat, j:nat):int {
if i == 0 then 0 else f(i - 1, i * j + 1) + f(i - 1, 2 * i * j)
}
lemma{:resource_limit 10000000} L()
{
assert true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// RUN: %verify --progress VerificationJobs --cores=1 %s &> %t.raw
// RUN: ! %verify --progress VerificationJobs --cores=1 %s &> %t.raw
// RUN: %sed 's#\(time.*\)#<redacted>#g' %t.raw > %t
// RUN: %diff "%s.expect" "%t"




method {:isolate_assertions} Foo() {
method {:isolate_assertions} Foo(x: int) returns (r: int)
ensures r > 3
ensures r < 10
{
assert true;
assert true;
if (x == 3) {
return 7;
} else {
return 12;
}
}

method Bar() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Verified 0/2 symbols. Waiting for Foo to verify.
Verified 1/2 of Foo: assertion at line 9 - verified successfully <redacted>
Verified 2/2 of Foo: assertion at line 10 - verified successfully <redacted>
Verified 1/6 of Foo: assertion at line 10 - verified successfully <redacted>
Verified 2/6 of Foo: assertion at line 11 - verified successfully <redacted>
Verified 3/6 of Foo: return at line 15, assertion at line 7 - verified successfully <redacted>
Copy link
Member

Choose a reason for hiding this comment

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

Nice clarity on what's being verified!

Verified 4/6 of Foo: return at line 15, assertion at line 8 - could not be verified <redacted>
Verified 5/6 of Foo: return at line 13, assertion at line 7 - verified successfully <redacted>
Verified 6/6 of Foo: return at line 13, assertion at line 8 - verified successfully <redacted>
isolateAllAssertions.dfy(15,4): Error: a postcondition could not be proved on this return path
isolateAllAssertions.dfy(8,12): Related location: this is the postcondition that could not be proved
Verified 1/2 symbols. Waiting for Bar to verify.
Verified 1/1 of Bar: entire body - verified successfully <redacted>

Dafny program verifier finished with 3 verified, 0 errors
Dafny program verifier finished with 6 verified, 1 error
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

Dafny program verifier finished with 142 verified, 0 errors
Dafny program verifier finished with 148 verified, 0 errors
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

Dafny program verifier finished with 55 verified, 0 errors
Dafny program verifier finished with 67 verified, 0 errors
2 changes: 1 addition & 1 deletion customBoogie.patch
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ index 4a8b2f89b..a308be9bf 100644
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Runtime.Numerics" Version="4.3.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
- <PackageReference Include="Boogie.ExecutionEngine" Version="3.4.1" />
- <PackageReference Include="Boogie.ExecutionEngine" Version="3.4.2" />
+ <ProjectReference Include="..\..\boogie\Source\ExecutionEngine\ExecutionEngine.csproj" />
+ <ProjectReference Include="..\..\boogie\Source\BaseTypes\BaseTypes.csproj" />
+ <ProjectReference Include="..\..\boogie\Source\Core\Core.csproj" />
Expand Down
1 change: 1 addition & 0 deletions docs/dev/news/5917.feat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When using `--isolate-assertions` or `{:isolate_assertions}`, a separate assertion batch will be generated per pair of return statement and ensures clause.