Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
21a9246
Add tests
keyboardDrummer Jul 15, 2024
0ec4c02
Fix test
keyboardDrummer Jul 15, 2024
a0d6c9d
Update test
keyboardDrummer Jul 25, 2024
42faeca
Put function wellformedness check in a separate file, and extract som…
keyboardDrummer Jul 26, 2024
eae6238
Refactoring
keyboardDrummer Jul 26, 2024
3e142d9
Add test
keyboardDrummer Jul 26, 2024
2c93cf4
Move function ensures clause check from procedure ensures clause to i…
keyboardDrummer Jul 26, 2024
c6c2bc3
Prepare for injecting the function postcondition into the StmtExpr Pa…
keyboardDrummer Jul 26, 2024
1ecd423
Change with bugs
keyboardDrummer Jul 27, 2024
6d757b4
Slightly better behavior
keyboardDrummer Jul 27, 2024
cbb8b9b
Update test
keyboardDrummer Jul 27, 2024
0726bc5
One more passing test
keyboardDrummer Jul 27, 2024
ae13091
Ran formatter
keyboardDrummer Jul 29, 2024
18f38f8
Merge remote-tracking branch 'origin/master' into isolatedWellformedness
keyboardDrummer Jul 30, 2024
fb1ab6e
Remove unused code
keyboardDrummer Jul 30, 2024
837f587
Add test-case
keyboardDrummer Jul 31, 2024
b460fb6
Fixes
keyboardDrummer Jul 31, 2024
4a5bc5c
Fix
keyboardDrummer Jul 31, 2024
d8fa9c5
Fixes
keyboardDrummer Aug 8, 2024
b65ec85
Merge remote-tracking branch 'origin/master' into isolatedWellformedness
keyboardDrummer Aug 8, 2024
bbe156c
Add testcase for ensures clause on function reporting
keyboardDrummer Aug 9, 2024
fffe0ee
Fixes
keyboardDrummer Aug 9, 2024
e2514f5
Fix witness expression proofs
keyboardDrummer Aug 9, 2024
813a5fe
Fix expect file
keyboardDrummer Aug 9, 2024
50319de
Fix subset type check
keyboardDrummer Aug 9, 2024
597000c
Cleanup WF check for StmtExpr, to reduce nesting
keyboardDrummer Aug 9, 2024
243c547
Refactoring
keyboardDrummer Aug 9, 2024
aa43a4f
Fix bug
keyboardDrummer Aug 9, 2024
0d08aef
Fixes
keyboardDrummer Aug 9, 2024
1374af2
Fix for default parameters
keyboardDrummer Aug 9, 2024
d92ebf7
Fix some expect files
keyboardDrummer Aug 9, 2024
75f8b72
Fixed reads bug
keyboardDrummer Aug 10, 2024
3823092
Remove unused method
keyboardDrummer Aug 12, 2024
c2859db
Removed PathAside for StmtExpr, and remove statementExpressionScope.d…
keyboardDrummer Aug 12, 2024
5ab40e8
Remove some messy code to see what it breaks
keyboardDrummer Aug 12, 2024
1a536cd
Fix IDE test
keyboardDrummer Aug 12, 2024
7caa143
Update expect files
keyboardDrummer Aug 12, 2024
f077794
Change signature
keyboardDrummer Aug 12, 2024
fb3401a
Undo extract method
keyboardDrummer Aug 12, 2024
8974e7f
Merge branch 'master' into testRemovingAdaptBoxAndResultDescription
keyboardDrummer Aug 12, 2024
bdbfa6e
Undo formatting changes
keyboardDrummer Aug 12, 2024
2f0e6c9
Merge branch 'testRemovingAdaptBoxAndResultDescription' of github.com…
keyboardDrummer Aug 12, 2024
c11f667
Cleanup and improve error reporting for witness
keyboardDrummer Aug 12, 2024
9887a5b
Add test case for reporting off function call expr
keyboardDrummer Aug 12, 2024
e7e7917
Reduce changes
keyboardDrummer Aug 12, 2024
e5d4b67
Undo a fix
keyboardDrummer Aug 12, 2024
f42b915
Ran formatter
keyboardDrummer Aug 12, 2024
91597f2
Add extra test and fix
keyboardDrummer Aug 12, 2024
bb8e2e3
Update measure-complexity expect file
keyboardDrummer Aug 12, 2024
51b4ff0
Fix expect files
keyboardDrummer Aug 12, 2024
241d7d7
Merge branch 'master' into testRemovingAdaptBoxAndResultDescription
stefan-aws Aug 13, 2024
b6a9d8a
Merge branch 'testRemovingAdaptBoxAndResultDescription' of github.com…
keyboardDrummer Aug 13, 2024
288d151
Fix ProofDependencyLogging test
keyboardDrummer Aug 13, 2024
aa185cb
Add --performance-stats option and use this on the SchorrWaite test
keyboardDrummer Aug 14, 2024
f78fb93
Add two more tests
keyboardDrummer Aug 14, 2024
8598094
Merge branch 'verificationPerformanceStats' into testRemovingAdaptBox…
keyboardDrummer Aug 14, 2024
e5bcd0e
Add exception for different resolver
keyboardDrummer Aug 14, 2024
c3e2143
Update subset test resource count
keyboardDrummer Aug 14, 2024
581ab43
Enable rounding
keyboardDrummer Aug 14, 2024
8d9b434
Update test
keyboardDrummer Aug 14, 2024
6657f01
Merge branch 'verificationPerformanceStats' into testRemovingAdaptBox…
keyboardDrummer Aug 14, 2024
829ff78
Merge remote-tracking branch 'origin/master' into testRemovingAdaptBo…
keyboardDrummer Aug 23, 2024
c567e1d
Fixes
keyboardDrummer Aug 23, 2024
a2fe6c5
Merge remote-tracking branch 'origin/master' into testRemovingAdaptBo…
keyboardDrummer Aug 23, 2024
c7ee87e
Fix tests and token
keyboardDrummer Aug 23, 2024
f08c17a
Change --find-project option
keyboardDrummer Aug 26, 2024
3f0b621
Update proof for LemmaSeqLswModEquivalence
keyboardDrummer Aug 26, 2024
4b61176
Update doo files and remove obsolete code
keyboardDrummer Aug 26, 2024
8d816a9
Review comments
keyboardDrummer Aug 26, 2024
e07a4e0
Remove outdated comment
keyboardDrummer Aug 26, 2024
0a270b2
Trigger CI
keyboardDrummer Aug 27, 2024
f5a7b0e
Merge remote-tracking branch 'origin/master' into testRemovingAdaptBo…
keyboardDrummer Sep 4, 2024
7ecfdbe
Ran formatter
keyboardDrummer Sep 4, 2024
0d7402c
Fixes
keyboardDrummer Sep 4, 2024
ea83f6d
Merge branch 'master' into testRemovingAdaptBoxAndResultDescription
keyboardDrummer Sep 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1560,10 +1560,10 @@ void CheckPostconditionForRhs(BoogieStmtListBuilder innerBuilder, Expression bod
var letBody = Substitute(e.Body, null, substMap);
CheckWellformed(letBody, wfOptions, locals, builder, etran);
if (e.Constraint_Bounds != null) {
var substMapPrime = SetupBoundVarsAsLocals(lhsVars, builder, locals, etran);
var substMap2 = SetupBoundVarsAsLocals(lhsVars, builder, locals, etran);
var nonGhostMapPrime = new Dictionary<IVariable, Expression>();
foreach (BoundVar bv in lhsVars) {
nonGhostMapPrime.Add(bv, bv.IsGhost ? substMap[bv] : substMapPrime[bv]);
nonGhostMapPrime.Add(bv, bv.IsGhost ? substMap[bv] : substMap2[bv]);
}
var rhsPrime = Substitute(e.RHSs[0], null, nonGhostMapPrime);
var letBodyPrime = Substitute(e.Body, null, nonGhostMapPrime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void Check(Function f) {
// assume each one of them. After all that (in particular, after assuming all
// of them), do the postponed reads checks.
delayer.DoWithDelayedReadsChecks(false, wfo => {
builder.Add(new CommentCmd("Check Wfness of preconditions, and then assume them"));
builder.Add(new CommentCmd("Check well-formedness of preconditions, and then assume them"));
foreach (AttributedExpression require in f.Req) {
if (require.Label != null) {
require.Label.E = (f is TwoStateFunction ? ordinaryEtran : etran.Old).TrExpr(require.E);
Expand All @@ -135,14 +135,14 @@ public void Check(Function f) {
// the preconditions. In other words, the well-formedness of the reads clause is
// allowed to assume the precondition (yet, the requires clause is checked to
// read only those things indicated in the reads clause).
builder.Add(new CommentCmd("Check Wfness of the reads clause"));
builder.Add(new CommentCmd("Check well-formedness of the reads clause"));
delayer.DoWithDelayedReadsChecks(false,
wfo => { generator.CheckFrameWellFormed(wfo, f.Reads.Expressions, locals, builder, etran); });

ConcurrentAttributeCheck(f, etran, builder);

// check well-formedness of the decreases clauses (including termination, but no reads checks)
builder.Add(new CommentCmd("Check Wfness of the decreases clause"));
builder.Add(new CommentCmd("Check well-formedness of the decreases clause"));
foreach (Expression p in f.Decreases.Expressions) {
generator.CheckWellformed(p, new WFOptions(null, false), locals, builder, etran);
}
Expand Down Expand Up @@ -172,7 +172,6 @@ public void Check(Function f) {
generator.Reset();
}

// TODO should be moved so its injected
private void ConcurrentAttributeCheck(Function f, ExpressionTranslator etran, BoogieStmtListBuilder builder) {
// If the function is marked as {:concurrent}, check that the reads clause is empty.
if (Attributes.Contains(f.Attributes, Attributes.ConcurrentAttributeName)) {
Expand Down Expand Up @@ -208,7 +207,7 @@ private BoogieStmtListBuilder GetBodyCheckBuilder(Function f, ExpressionTranslat
var selfCall = GetSelfCall(f, etran, parameters);
var context = new BodyTranslationContext(f.ContainsHide);
var bodyCheckBuilder = new BoogieStmtListBuilder(generator, generator.options, context);
bodyCheckBuilder.Add(new CommentCmd("Check Wfness of body and result subset type constraint"));
bodyCheckBuilder.Add(new CommentCmd("Check well-formedness of body and result subset type constraint"));
if (f.Body != null && generator.RevealedInScope(f)) {
var doReadsChecks = etran.readsFrame != null;
var wfo = new WFOptions(null, doReadsChecks, doReadsChecks, false);
Expand Down Expand Up @@ -278,7 +277,7 @@ private Expr GetSelfCall(Function f, ExpressionTranslator etran, List<Variable>
private BoogieStmtListBuilder GetPostCheckBuilder(Function f, ExpressionTranslator etran, List<Variable> locals) {
var context = new BodyTranslationContext(f.ContainsHide);
var postCheckBuilder = new BoogieStmtListBuilder(generator, generator.options, context);
postCheckBuilder.Add(new CommentCmd("Check Wfness of postcondition and assume false"));
postCheckBuilder.Add(new CommentCmd("Check well-formedness of postcondition and assume false"));

// Assume the type returned by the call itself respects its type (this matters if the type is "nat", for example)
var args = new List<Expr>();
Expand Down
41 changes: 27 additions & 14 deletions Source/DafnyCore/Verifier/BoogieGenerator.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,16 +1431,16 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
// parameters of the procedure
var inParams = MkTyParamFormals(decl.TypeArgs, true);
Type baseType;
Bpl.Expr wh;
Bpl.Expr whereClause;
Copy link
Member

Choose a reason for hiding this comment

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

Useful renaming.

if (decl.Var != null) {
baseType = decl.Var.Type;
Bpl.Type varType = TrType(baseType);
wh = GetWhereClause(decl.Var.tok, new Bpl.IdentifierExpr(decl.Var.tok, decl.Var.AssignUniqueName(decl.IdGenerator), varType), baseType, etran, NOALLOC);
whereClause = GetWhereClause(decl.Var.tok, new Bpl.IdentifierExpr(decl.Var.tok, decl.Var.AssignUniqueName(decl.IdGenerator), varType), baseType, etran, NOALLOC);
// Do NOT use a where-clause in this declaration, because that would spoil the witness checking.
inParams.Add(new Bpl.Formal(decl.Var.tok, new Bpl.TypedIdent(decl.Var.tok, decl.Var.AssignUniqueName(decl.IdGenerator), varType), true));
} else {
baseType = ((NewtypeDecl)decl).BaseType;
wh = null;
whereClause = null;
}

// the procedure itself
Expand Down Expand Up @@ -1487,7 +1487,7 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
// }

// check well-formedness of the constraint (including termination, and delayed reads checks)
var builderInitializationArea = CheckConstraintWellformedness(decl, context, etran, locals, builder);
var builderInitializationArea = CheckConstraintWellformedness(decl, context, whereClause, etran, locals, builder);

// Check that the type is inhabited.
// Note, the possible witness in this check should be coordinated with the compiler, so the compiler knows how to do the initialization
Expand All @@ -1507,15 +1507,16 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
CheckResultToBeInType(result.Tok, result, decl.Var.Type, locals, returnBuilder, etran);
}

// check that the witness is assignable to the type of the given bound variable
CheckResultToBeInType(decl.Witness.tok, decl.Witness, baseType, locals, witnessCheckBuilder, etran);
// check that the witness expression checks out
witnessExpr = Substitute(decl.Constraint, decl.Var, result);
witnessExpr = decl.Constraint != null ? Substitute(decl.Constraint, decl.Var, decl.Witness) : null;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
witnessExpr = decl.Constraint != null ? Substitute(decl.Constraint, decl.Var, decl.Witness) : null;
witnessExpr = decl.Constraint != null ? Substitute(decl.Constraint, decl.Var, decl.Witness) : decl.Witness;

?

witnessExpr.tok = result.Tok;
var desc = new PODesc.WitnessCheck(witnessString, witnessExpr);

SplitAndAssertExpression(returnBuilder, witnessExpr, etran, context, desc);
});
codeContext = ghostCodeContext;

} else if (decl.WitnessKind == SubsetTypeDecl.WKind.CompiledZero) {
var witness = Zero(decl.tok, baseType);
if (witness == null) {
Expand All @@ -1524,8 +1525,8 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
} else {
// before trying 0 as a witness, check that 0 can be assigned to baseType
witnessString = Printer.ExprToString(options, witness);
CheckResultToBeInType(decl.tok, witness, decl.Var.Type, locals, witnessCheckBuilder, etran, $"trying witness {witnessString}: ");
witnessExpr = Substitute(decl.Constraint, decl.Var, witness);
CheckResultToBeInType(decl.tok, witness, baseType, locals, witnessCheckBuilder, etran, $"trying witness {witnessString}: ");
witnessExpr = decl.Constraint != null ? Substitute(decl.Constraint, decl.Var, witness) : null;
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above. I'm surprised that witnessExpr can be null even if there is a witness given.

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied these changes from #5547. I'm afraid I don't understand them myself. @ssomayyajula do you?


witnessExpr.tok = decl.tok;
var desc = new PODesc.WitnessCheck(witnessString, witnessExpr);
Expand Down Expand Up @@ -1556,7 +1557,6 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
private void SplitAndAssertExpression(BoogieStmtListBuilder witnessCheckBuilder, Expression witnessExpr,
ExpressionTranslator etran, BodyTranslationContext context, PODesc.WitnessCheck desc) {
witnessCheckBuilder.Add(new Bpl.AssumeCmd(witnessExpr.tok, etran.CanCallAssumption(witnessExpr)));
var witnessCheck = etran.TrExpr(witnessExpr);

var ss = TrSplitExpr(context, witnessExpr, etran, true, out var splitHappened);
if (!splitHappened) {
Expand All @@ -1572,13 +1572,26 @@ private void SplitAndAssertExpression(BoogieStmtListBuilder witnessCheckBuilder,
}

private BoogieStmtListBuilder CheckConstraintWellformedness(RedirectingTypeDecl decl, BodyTranslationContext context,
ExpressionTranslator etran, List<Variable> locals, BoogieStmtListBuilder builder) {
Bpl.Expr whereClause, ExpressionTranslator etran, List<Variable> locals, BoogieStmtListBuilder builder) {
var constraintCheckBuilder = new BoogieStmtListBuilder(this, options, context);
var builderInitializationArea = new BoogieStmtListBuilder(this, options, context);
var delayer = new ReadsCheckDelayer(etran, null, locals, builderInitializationArea, constraintCheckBuilder);
delayer.DoWithDelayedReadsChecks(false, wfo => {
CheckWellformedAndAssume(decl.Constraint, wfo, locals, constraintCheckBuilder, etran, "predicate subtype constraint");
});
if (decl.Constraint == null) {
constraintCheckBuilder.Add(new Bpl.CommentCmd($"well-formedness of {decl.WhatKind} constraint is trivial"));
} else {
constraintCheckBuilder.Add(new Bpl.CommentCmd($"check well-formedness of {decl.WhatKind} constraint"));
if (whereClause != null) {
constraintCheckBuilder.Add(new Bpl.AssumeCmd(decl.tok, whereClause));
}
var delayer = new ReadsCheckDelayer(etran, null, locals, builderInitializationArea, constraintCheckBuilder);
delayer.DoWithDelayedReadsChecks(false, wfo => {
CheckWellformedAndAssume(decl.Constraint, wfo, locals, constraintCheckBuilder, etran, "predicate subtype constraint");
});
}

// var delayer = new ReadsCheckDelayer(etran, null, locals, builderInitializationArea, constraintCheckBuilder);
// delayer.DoWithDelayedReadsChecks(false, wfo => {
// CheckWellformedAndAssume(decl.Constraint, wfo, locals, constraintCheckBuilder, etran, "predicate subtype constraint");
// });
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// var delayer = new ReadsCheckDelayer(etran, null, locals, builderInitializationArea, constraintCheckBuilder);
// delayer.DoWithDelayedReadsChecks(false, wfo => {
// CheckWellformedAndAssume(decl.Constraint, wfo, locals, constraintCheckBuilder, etran, "predicate subtype constraint");
// });

PathAsideBlock(decl.Tok, constraintCheckBuilder, builder);
return builderInitializationArea;
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Dafny program verifier finished with 15 verified, 0 errors
Total resources used is 26054889
Max resources used by VC is 15592113
Dafny program verifier finished with 272 verified, 0 errors
Total resources used is 30533115
Max resources used by VC is 2074326
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Dafny program verifier finished with 15 verified, 0 errors
Total resources used is 28044434
Max resources used by VC is 16505967
Dafny program verifier finished with 276 verified, 0 errors
Total resources used is 28989931
Max resources used by VC is 1092418
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ function Test(x: bool): int
assert P(2) by { reveal p21; } // p21 can be revealed and this assertion is visible outside.
2
};
assert P(x); // No longer verifies since we scoped expression proofs
assert P(x);
x
}