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

Penetrating by blocks #5779

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d6f3951
Add proof by statement
keyboardDrummer Sep 16, 2024
84c7073
Merge remote-tracking branch 'origin/master' into penetratingByBlocks
keyboardDrummer Sep 16, 2024
a2f6b5c
Pass AssertMode to all Assert calls
keyboardDrummer Sep 16, 2024
313ad7e
Use free calls inside by blocks
keyboardDrummer Sep 20, 2024
174abf8
Move code from BoogieGenerator.TrStatement into separate files
keyboardDrummer Sep 20, 2024
5a2f37c
Use namespace directive
keyboardDrummer Sep 20, 2024
ae6f060
Start with removing pre and post call stuff
keyboardDrummer Sep 20, 2024
3cdae72
Finish pre/post call cleanup
keyboardDrummer Sep 20, 2024
9e7a558
Remove the proof field everywhere but in BlockByProof
keyboardDrummer Sep 20, 2024
2b17edc
Update parser
keyboardDrummer Sep 20, 2024
0774dc4
Fix a few bugs
keyboardDrummer Sep 20, 2024
1049866
More use of BodyTranslationContext.AssertMode
keyboardDrummer Sep 20, 2024
a8b2312
Improve printing
keyboardDrummer Sep 20, 2024
0391450
Rename of UpdateStmt
keyboardDrummer Sep 20, 2024
6b985cf
Add comments
keyboardDrummer Sep 20, 2024
fe456d3
Definite assignment tracking issue
keyboardDrummer Sep 21, 2024
5af6b22
Definite assignment tracker changed so it's never cleaned up
keyboardDrummer Sep 21, 2024
6e6d73d
Add substituter implementation
keyboardDrummer Sep 21, 2024
212cfbe
Prepare for using ordered dictionary for locals
keyboardDrummer Sep 23, 2024
da8787e
Introduce Variables class to track Boogie variables using an ordered …
keyboardDrummer Sep 23, 2024
185834a
CallBy.dfy works now
keyboardDrummer Sep 23, 2024
6f2dbf3
CallByHide.dfy passes
keyboardDrummer Sep 23, 2024
16f8ef7
Convert giant if to switch statement
keyboardDrummer Sep 23, 2024
5415a97
Fix
keyboardDrummer Sep 23, 2024
00e11e8
Merge remote-tracking branch 'origin/master' into penetratingByBlocks
keyboardDrummer Sep 23, 2024
10ee669
Ran formatter and def assignment improvement
keyboardDrummer Sep 23, 2024
2eea9e3
Move to symbols for mapping to tracking variables
keyboardDrummer Sep 24, 2024
6560fc2
Fixes
keyboardDrummer Sep 24, 2024
e9db4b9
More fixes
keyboardDrummer Sep 24, 2024
0830162
Fix formatter
keyboardDrummer Sep 24, 2024
35442d9
Merge commit 'ef13a72f3a9d3f' into penetratingByBlocks
keyboardDrummer Sep 24, 2024
d4ca466
Fix
keyboardDrummer Sep 24, 2024
4dfbd8b
Fix expect file
keyboardDrummer Sep 24, 2024
e8c409f
Undo Def as tracking changes
keyboardDrummer Sep 24, 2024
a078831
Fixes
keyboardDrummer Sep 24, 2024
e86fed8
Update expect file
keyboardDrummer Sep 24, 2024
67cdf7b
Update tests
keyboardDrummer Sep 24, 2024
054140b
Update tests
keyboardDrummer Sep 24, 2024
ae8d333
Use an immediately dictionary instead of adding and removing
keyboardDrummer Sep 24, 2024
a4796d2
Fix test generation
keyboardDrummer Sep 24, 2024
8ab5cb7
Refactoring
keyboardDrummer Sep 24, 2024
bdb02ae
Update test
keyboardDrummer Sep 24, 2024
2f189bb
Add test-case for assign such that
keyboardDrummer Sep 24, 2024
880fa30
Add tests
keyboardDrummer Sep 24, 2024
95a09a2
Add another test
keyboardDrummer Sep 24, 2024
13a25b3
Updates
keyboardDrummer Sep 25, 2024
46dc302
Fix SubsetTypes
keyboardDrummer Sep 25, 2024
946bdd6
Merge branch 'master' into penetratingByBlocks
keyboardDrummer Sep 25, 2024
f45a1a3
Remove todos
keyboardDrummer Oct 6, 2024
7cce358
Regenerated makefiles
keyboardDrummer Oct 6, 2024
d132f87
Merge remote-tracking branch 'origin/master' into penetratingByBlocks
keyboardDrummer Oct 6, 2024
f9c2fa3
Update doos
keyboardDrummer Oct 6, 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 @@ -829,7 +829,7 @@ void CheckWellformedWithResult(Expression expr, WFOptions wfOptions,
// use the given assert attribute only
builder.Add(Assert(tok, ss.E, desc, builder.Context, wfOptions.AssertKv));
} else {
builder.Add(AssertAndForget(tok, ss.E, desc));
builder.Add(AssertAndForget(builder.Context, tok, ss.E, desc));
}
}
}
Expand Down Expand Up @@ -1665,7 +1665,7 @@ private void CheckElementInit(IToken tok, bool forArray, List<Expression> dims,
var pre = FunctionCall(tok, Requires(dims.Count), Bpl.Type.Bool, args);
var q = new Bpl.ForallExpr(tok, bvs, BplImp(ante, pre));
var indicesDesc = new PODesc.IndicesInDomain(forArray ? "array" : "sequence", dims, init);
builder.Add(AssertAndForget(tok, q, indicesDesc));
builder.Add(AssertAndForget(builder.Context, tok, q, indicesDesc));
if (!forArray && options.DoReadsChecks) {
// unwrap renamed local lambdas
var unwrappedFunc = init;
Expand Down Expand Up @@ -1716,7 +1716,7 @@ private void CheckElementInit(IToken tok, bool forArray, List<Expression> dims,
// assert (forall i0,i1,i2,... ::
// 0 <= i0 < ... && ... ==> init.requires(i0,i1,i2,...) is Subtype);
q = new Bpl.ForallExpr(tok, bvs, BplImp(ante, cre));
builder.Add(AssertAndForget(init.tok, q, subrangeDesc));
builder.Add(AssertAndForget(builder.Context, init.tok, q, subrangeDesc));
}

if (forArray) {
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/Verifier/BoogieGenerator.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ private void SplitAndAssertExpression(BoogieStmtListBuilder witnessCheckBuilder,
foreach (var split in ss) {
if (split.IsChecked) {
var tok = witnessExpr.tok is { } t ? new NestedToken(t, split.Tok) : witnessExpr.tok;
witnessCheckBuilder.Add(AssertAndForget(tok, split.E, desc));
witnessCheckBuilder.Add(AssertAndForget(witnessCheckBuilder.Context, tok, split.E, desc));
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions Source/DafnyCore/Verifier/BoogieGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3362,18 +3362,19 @@ private PredicateCmd Assert(IToken tok, Expr condition, PODesc.ProofObligationDe
return cmd;
}

Bpl.PredicateCmd AssertAndForget(IToken tok, Bpl.Expr condition, PODesc.ProofObligationDescription desc) {
return AssertAndForget(tok, condition, desc, tok, null);
PredicateCmd AssertAndForget(BodyTranslationContext context, IToken tok, Bpl.Expr condition, PODesc.ProofObligationDescription desc) {
return AssertAndForget(context, tok, condition, desc, tok, null);
}

Bpl.PredicateCmd AssertAndForget(IToken tok, Bpl.Expr condition, PODesc.ProofObligationDescription desc, IToken refinesTok, Bpl.QKeyValue kv) {
PredicateCmd AssertAndForget(BodyTranslationContext context, IToken tok, Bpl.Expr condition, PODesc.ProofObligationDescription desc, IToken refinesTok, Bpl.QKeyValue kv) {
Contract.Requires(tok != null);
Contract.Requires(desc != null);
Contract.Requires(condition != null);
Contract.Ensures(Contract.Result<Bpl.PredicateCmd>() != null);

Bpl.PredicateCmd cmd;
if ((assertionOnlyFilter != null && !assertionOnlyFilter(tok)) ||
PredicateCmd cmd;
if (context.AssertMode == AssertMode.Assume ||
(assertionOnlyFilter != null && !assertionOnlyFilter(tok)) ||
(RefinementToken.IsInherited(refinesTok, currentModule) && (codeContext == null || !codeContext.MustReverify))) {
// produce a "skip" instead
cmd = TrAssumeCmd(tok, Bpl.Expr.True, kv);
Expand Down Expand Up @@ -3502,7 +3503,8 @@ Bpl.AssertCmd TrAssertCmd(IToken tok, Bpl.Expr expr, Bpl.QKeyValue attributes =
return attributes == null ? new Bpl.AssertCmd(tok, expr) : new Bpl.AssertCmd(tok, expr, attributes);
}

Bpl.AssertCmd TrAssertCmdDesc(IToken tok, Bpl.Expr expr, PODesc.ProofObligationDescription description, Bpl.QKeyValue attributes = null) {
Bpl.AssertCmd TrAssertCmdDesc(IToken tok, Bpl.Expr expr,
PODesc.ProofObligationDescription description, Bpl.QKeyValue attributes = null) {
ReportAssertion(tok, description);
return new Bpl.AssertCmd(tok, expr, description, attributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public static void EmitBoogie(BoogieGenerator generator, BlockByProofStmt block,
List<Variable> locals, BoogieGenerator.ExpressionTranslator etran, ICodeContext codeContext) {
var proofBuilder = new BoogieStmtListBuilder(generator, builder.Options, builder.Context);

//generator.CurrentIdGenerator.Push();
generator.CurrentIdGenerator.Push();
generator.TrStmtList(block.Proof.Body, proofBuilder, locals, etran);
//generator.CurrentIdGenerator.Pop();
generator.CurrentIdGenerator.Pop();

generator.TrStmt(block.Body, proofBuilder, locals, etran);
generator.PathAsideBlock(block.Tok, proofBuilder, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ void ProcessCallStmt(CallStmt cs, Dictionary<TypeParameter, Type> tySubst, Bpl.E
}

AddReferencedMember(callee);
var call = Call(builder.Context, tok, MethodName(callee, isCoCall ? MethodTranslationKind.CoCall : MethodTranslationKind.Call), ins, new List<Bpl.IdentifierExpr>());
var calleeName = MethodName(callee, isCoCall ? MethodTranslationKind.CoCall : MethodTranslationKind.Call);
var call = Call(builder.Context, tok, calleeName, ins, outs);
proofDependencies?.AddProofDependencyId(call, tok, new CallDependency(cs));
if (
(assertionOnlyFilter != null && !assertionOnlyFilter(tok)) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private bool TrAssertCondition(PredicateStmt stmt,
if (split.IsChecked) {
var tok = enclosingToken == null ? split.E.tok : new NestedToken(enclosingToken, split.Tok);
var desc = new PODesc.AssertStatementDescription(stmt, errorMessage, successMessage);
proofBuilder.Add(AssertAndForget(ToDafnyToken(flags.ReportRanges, tok), split.E, desc, stmt.Tok,
proofBuilder.Add(AssertAndForget(proofBuilder.Context, ToDafnyToken(flags.ReportRanges, tok), split.E, desc, stmt.Tok,
etran.TrAttributes(stmt.Attributes, null))); // attributes go on every split
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void TrStmt(Statement stmt, BoogieStmtListBuilder builder,
} else if (split.IsChecked) {
var yieldToken = new NestedToken(s.Tok, split.Tok);
var desc = new PODesc.YieldEnsures(fieldSub.Substitute(p.E));
builder.Add(AssertAndForget(yieldToken, split.E, desc, stmt.Tok, null));
builder.Add(AssertAndForget(builder.Context, yieldToken, split.E, desc, stmt.Tok, null));
}
}
builder.Add(TrAssumeCmdWithDependencies(yeEtran, stmt.Tok, p.E, "yield ensures clause"));
Expand Down Expand Up @@ -585,19 +585,19 @@ private void TrCalcStmt(CalcStmt stmt, BoogieStmtListBuilder builder, List<Varia
TrStmt_CheckWellformed(index, b, locals, etran, false);
if (index.Type.IsNumericBased(Type.NumericPersuasion.Int)) {
var desc = new PODesc.PrefixEqualityLimit(index);
b.Add(AssertAndForget(index.tok, Bpl.Expr.Le(Bpl.Expr.Literal(0), etran.TrExpr(index)), desc));
b.Add(AssertAndForget(b.Context, index.tok, Bpl.Expr.Le(Bpl.Expr.Literal(0), etran.TrExpr(index)), desc));
}
}
TrStmt_CheckWellformed(CalcStmt.Rhs(stmt.Steps[i]), b, locals, etran, false);
var ss = TrSplitExpr(builder.Context, stmt.Steps[i], etran, true, out var splitHappened);
// assert step:
AddComment(b, stmt, "assert line" + i.ToString() + " " + (stmt.StepOps[i] ?? stmt.Op).ToString() + " line" + (i + 1).ToString());
if (!splitHappened) {
b.Add(AssertAndForget(stmt.Lines[i + 1].tok, etran.TrExpr(stmt.Steps[i]), new PODesc.CalculationStep(stmt.Steps[i], stmt.Hints[i])));
b.Add(AssertAndForget(b.Context, stmt.Lines[i + 1].tok, etran.TrExpr(stmt.Steps[i]), new PODesc.CalculationStep(stmt.Steps[i], stmt.Hints[i])));
} else {
foreach (var split in ss) {
if (split.IsChecked) {
b.Add(AssertAndForget(stmt.Lines[i + 1].tok, split.E, new PODesc.CalculationStep(stmt.Steps[i], stmt.Hints[i])));
b.Add(AssertAndForget(b.Context, stmt.Lines[i + 1].tok, split.E, new PODesc.CalculationStep(stmt.Steps[i], stmt.Hints[i])));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %testDafnyForEachResolver "%s"
// RUN: %testDafnyForEachResolver "%s" -- --bprint=/Users/rwillems/SourceCode/dafny/b4.bpl
keyboardDrummer marked this conversation as resolved.
Show resolved Hide resolved


// Note: We are using the built-in equality to compare keys.
Expand Down