-
Notifications
You must be signed in to change notification settings - Fork 119
Add /warnVacuousProofs option
#1016
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bac4ccd
Add `/warnVacuousProofs` option
atomb 6e6670a
Fix a few bugs
atomb 4340d15
Actually run the updated test
atomb 75876d2
Make test more robust to Boogie modes
atomb b3eb293
Remove errant comment
atomb daaa9a6
Not being able to run `lit` locally is tedious...
atomb 227fab0
Bump version
atomb 37b2299
Better autogenerated IDs
atomb 5aee94f
Update IDs in expected test output
atomb eef75d5
Address comments from @fabiomadge
atomb 757534d
Fix indexing in expected test output
atomb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
|
|
||
| namespace Microsoft.Boogie; | ||
|
|
||
| /// <summary> | ||
| /// Add `{:id ...}` attributes to all assertions, assumptions, requires | ||
| /// clauses, ensures clauses, and call statements so that verification | ||
| /// coverage tracking is possible. This exists primarily to support the | ||
| /// automatic detection of vacuous proofs in the case where no front | ||
| /// end has added these already. | ||
| /// </summary> | ||
| public class CoverageAnnotator : StandardVisitor | ||
| { | ||
| private int idCount = 0; | ||
| private string currentImplementation; | ||
| private Dictionary<string, ISet<string>> implementationGoalIds = new(); | ||
| private Dictionary<string, Absy> idMap = new(); | ||
|
|
||
| private void AddImplementationGoalId(string id) | ||
| { | ||
| implementationGoalIds[currentImplementation].Add(id); | ||
| } | ||
|
|
||
| private void AddIdIfMissing(ICarriesAttributes node, bool isGoal) | ||
| { | ||
| Absy absy = node as Absy; | ||
| if (absy == null) { | ||
| return; | ||
| } | ||
| var idStr = node.FindStringAttribute("id"); | ||
| if (idStr == null) { | ||
| idStr = $"id_l{absy.tok.line}_c{absy.tok.col}_{NodeType(node)}_{idCount}"; | ||
| idCount++; | ||
| } | ||
| idMap.Add(idStr, absy); | ||
| if (isGoal) { | ||
| AddImplementationGoalId(idStr); | ||
| } | ||
| node.AddStringAttribute(absy.tok, "id", idStr); | ||
| } | ||
|
|
||
| private string NodeType(ICarriesAttributes node) | ||
| { | ||
| return node switch | ||
| { | ||
| Requires _ => "requires", | ||
| Ensures _ => "ensures", | ||
| AssertCmd _ => "assert", | ||
| AssumeCmd _ => "assume", | ||
| CallCmd _ => "call", | ||
| _ => "other" | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get the set of IDs that correspond to goals within the named | ||
| /// implementation. | ||
| /// </summary> | ||
| /// <param name="implName">The name of the implementation.</param> | ||
| /// <returns>The IDs for all goal elements within the implementation.</returns> | ||
| public ISet<string> GetImplementationGoalIds(string implName) => implementationGoalIds[implName]; | ||
|
|
||
| /// <summary> | ||
| /// Get the AST node corresponding to the given ID. | ||
| /// </summary> | ||
| /// <param name="idStr">The `id` attribute placed on an AST node.</param> | ||
| /// <returns>The node where that `id` occurs.</returns> | ||
| public Absy GetIdNode(string idStr) => idMap[idStr]; | ||
|
|
||
| public override Implementation VisitImplementation(Implementation node) | ||
| { | ||
| currentImplementation = node.Name; | ||
| implementationGoalIds.TryAdd(currentImplementation, new HashSet<string>()); | ||
| return base.VisitImplementation(node); | ||
| } | ||
|
|
||
| public override Cmd VisitAssertCmd(AssertCmd node) | ||
| { | ||
| if (node.Expr is LiteralExpr {IsTrue: true}) { | ||
| return node; | ||
| } | ||
|
|
||
| AddIdIfMissing(node, true); | ||
| return base.VisitAssertCmd(node); | ||
| } | ||
|
|
||
| public override Cmd VisitAssumeCmd(AssumeCmd node) | ||
| { | ||
| AddIdIfMissing(node, false); | ||
| return base.VisitAssumeCmd(node); | ||
| } | ||
|
|
||
| public override Cmd VisitCallCmd(CallCmd node) | ||
| { | ||
| AddIdIfMissing(node, false); | ||
| return base.VisitCallCmd(node); | ||
| } | ||
|
|
||
| public override Requires VisitRequires(Requires requires) | ||
| { | ||
| AddIdIfMissing(requires, false); | ||
| return base.VisitRequires(requires); | ||
| } | ||
|
|
||
| public override Ensures VisitEnsures(Ensures ensures) | ||
| { | ||
| if (ensures.Free) { | ||
| return ensures; | ||
| } | ||
|
|
||
| AddIdIfMissing(ensures, true); | ||
| return base.VisitEnsures(ensures); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| Parsing verificationCoverage.bpl | ||
| Coalescing blocks... | ||
| Inlining... | ||
|
|
||
| Verifying testRequiresAssign ... | ||
| [TRACE] Using prover: z3 | ||
| Proof dependencies: | ||
| a0 | ||
| assert_a0 | ||
| assert_r0 | ||
| r0 | ||
|
|
||
| Verifying sum ... | ||
| Proof dependencies: | ||
| id_l127_c3_assume_0 | ||
| id_l127_c3_assume_1 | ||
| invariant sinv_not_1 established | ||
| invariant sinv_not_1 maintained | ||
| invariant sinv1 assumed in body | ||
| invariant sinv1 established | ||
| invariant sinv1 maintained | ||
| invariant sinv2 assumed in body | ||
| invariant sinv2 established | ||
| invariant sinv2 maintained | ||
| spost | ||
| spre1 | ||
|
|
||
| Verifying contradictoryAssume ... | ||
| Proof dependencies: | ||
| cont_assume_1 | ||
| cont_assume_2 | ||
| verificationCoverage.bpl(143,4): Warning: Proved vacuously | ||
|
|
||
| Verifying falseRequires ... | ||
| Proof dependencies: | ||
| false_req | ||
| verificationCoverage.bpl(150,4): Warning: Proved vacuously | ||
|
|
||
| Verifying contradictoryRequires ... | ||
| Proof dependencies: | ||
| cont_req_1 | ||
| cont_req_2 | ||
| verificationCoverage.bpl(158,4): Warning: Proved vacuously | ||
|
|
||
| Verifying assumeFalse ... | ||
| Proof dependencies: | ||
| assumeFalse | ||
| verificationCoverage.bpl(163,2): Warning: Proved vacuously | ||
|
|
||
| Verifying testEnsuresCallee ... | ||
| Proof dependencies: | ||
| tee0 | ||
| tee1 | ||
| ter0 | ||
|
|
||
| Verifying testEnsuresCaller ... | ||
| Proof dependencies: | ||
| call2_tee1 | ||
| ensures clause tee0 from call call1 | ||
| ensures clause tee0 from call call2 | ||
| ensures clause tee1 from call call2 | ||
| requires clause ter0 proved for call call1 | ||
| requires clause ter0 proved for call call2 | ||
| tee_not_1 | ||
| ter1 | ||
| xy_sum | ||
|
|
||
| Verifying obviouslyUnconstrainedCode ... | ||
| Proof dependencies: | ||
| a_gt_10 | ||
| constrained | ||
| x_gt_10 | ||
|
|
||
| Verifying callContradictoryFunction ... | ||
| Proof dependencies: | ||
| ensures clause cont_ens_abs from call call_cont | ||
| requires clause xpos_abs proved for call call_cont | ||
| xpos_caller | ||
| verificationCoverage.bpl(203,2): Warning: Proved vacuously | ||
|
|
||
| Verifying usesSomeInteger ... | ||
| Proof dependencies: | ||
| id_l216_c3_ensures_2 | ||
| someInteger_value_axiom | ||
| Proof dependencies of whole program: | ||
| a_gt_10 | ||
| a0 | ||
| assert_a0 | ||
| assert_r0 | ||
| assumeFalse | ||
| call2_tee1 | ||
| constrained | ||
| cont_assume_1 | ||
| cont_assume_2 | ||
| cont_req_1 | ||
| cont_req_2 | ||
| ensures clause cont_ens_abs from call call_cont | ||
| ensures clause tee0 from call call1 | ||
| ensures clause tee0 from call call2 | ||
| ensures clause tee1 from call call2 | ||
| false_req | ||
| id_l127_c3_assume_0 | ||
| id_l127_c3_assume_1 | ||
| id_l216_c3_ensures_2 | ||
| invariant sinv_not_1 established | ||
| invariant sinv_not_1 maintained | ||
| invariant sinv1 assumed in body | ||
| invariant sinv1 established | ||
| invariant sinv1 maintained | ||
| invariant sinv2 assumed in body | ||
| invariant sinv2 established | ||
| invariant sinv2 maintained | ||
| r0 | ||
| requires clause ter0 proved for call call1 | ||
| requires clause ter0 proved for call call2 | ||
| requires clause xpos_abs proved for call call_cont | ||
| someInteger_value_axiom | ||
| spost | ||
| spre1 | ||
| tee_not_1 | ||
| tee0 | ||
| tee1 | ||
| ter0 | ||
| ter1 | ||
| x_gt_10 | ||
| xpos_caller | ||
| xy_sum | ||
|
|
||
| Boogie program verifier finished with 11 verified, 0 errors |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.