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

Hide statements #5562

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a9d1b80
Add Boogie as a submodule
keyboardDrummer Jun 12, 2024
7bded0a
Use Boogie submodule
keyboardDrummer Jun 12, 2024
e7be101
Added reveal test
keyboardDrummer Jun 13, 2024
d34a4fa
Move resolve code for revealStmt to RevealStmt class
keyboardDrummer Jun 13, 2024
b7ae5a5
reveal.dfy test passes
keyboardDrummer Jun 13, 2024
f354052
Update reveal test
keyboardDrummer Jun 13, 2024
23f82c6
Progress towards blind functions
keyboardDrummer Jun 15, 2024
dcc4a89
Simplification
keyboardDrummer Jun 15, 2024
5bbc32e
Reveal.dfy passes
keyboardDrummer Jun 15, 2024
10d4a0f
Refactoring for readability
keyboardDrummer Jun 15, 2024
8f5940a
Add hidden function ensure clause test case to reveal.dfy
keyboardDrummer Jun 16, 2024
37f9462
Refactor TrPredicateStmt
keyboardDrummer Jun 16, 2024
608a6ab
Fix test
keyboardDrummer Jun 16, 2024
fca4526
Reveal now had a passing test for combining blind, opaque and reveal
keyboardDrummer Jun 17, 2024
8c0b90d
Update reveal.dfy test
keyboardDrummer Jun 20, 2024
97c4910
Add scratch test for playing around with
keyboardDrummer Jun 24, 2024
653c776
Make functions in Prelude revealed
keyboardDrummer Jun 24, 2024
3d7e01c
Make more generated function always revealed
keyboardDrummer Jun 24, 2024
5a65cb8
Let axioms decide if they can be hidden
keyboardDrummer Jun 27, 2024
af8b397
Update tests
keyboardDrummer Jun 27, 2024
f8bf900
Update test
keyboardDrummer Jun 27, 2024
84021fb
Update tests
keyboardDrummer Jun 27, 2024
eba67ca
Draft
keyboardDrummer Jul 1, 2024
f4da59c
Replace blind with hide statement
keyboardDrummer Jul 1, 2024
ee98116
Some success on revealFunctions.dfy
keyboardDrummer Jul 1, 2024
64f1c3d
revealFunctions.dfy works except for scoping now
keyboardDrummer Jul 1, 2024
28a2483
Scoping for if now works for revealFunctions.dfy
keyboardDrummer Jul 1, 2024
f4e3658
revealFunctions passes
keyboardDrummer Jul 1, 2024
b755a61
Reveal functions passes
keyboardDrummer Jul 2, 2024
0c2f5a0
Finished draft of revealInBlock test
keyboardDrummer Jul 2, 2024
10db663
Fix printing and cloning of hide reveal statements
keyboardDrummer Jul 2, 2024
18fb8fb
revealInBlock test passes
keyboardDrummer Jul 2, 2024
dd9fd67
Fixed revealInExpression test
keyboardDrummer Jul 2, 2024
f5afce8
Refactoring
keyboardDrummer Jul 2, 2024
a6e65d2
Progress in isolating expression wellformedness checks
keyboardDrummer Jul 3, 2024
c46ff52
revealInExpression test now passes
keyboardDrummer Jul 3, 2024
7861efa
Some cleanup
keyboardDrummer Jul 3, 2024
5664a6f
Adapt to Boogie changes and fix tests
keyboardDrummer Jul 3, 2024
64c5b4c
Refactoring and fixes
keyboardDrummer Jul 3, 2024
b5ad048
Remove comment
keyboardDrummer Jul 4, 2024
eca25fb
Merge commit 'origin/master~1' into alwaysOpaque
keyboardDrummer Jul 4, 2024
c60e66f
Merge remote-tracking branch 'origin/master' into alwaysOpaque
keyboardDrummer Jul 4, 2024
c33ffb1
Refactoring
keyboardDrummer Jul 4, 2024
fbe6356
Update documentation
keyboardDrummer Jul 4, 2024
a8670a9
Add release note
keyboardDrummer Jul 4, 2024
a2a6541
Revert "Use Boogie submodule"
keyboardDrummer Jul 4, 2024
b0b6350
Revert "Add Boogie as a submodule"
keyboardDrummer Jul 4, 2024
915659d
Update Boogie version
keyboardDrummer Jul 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
Prev Previous commit
Next Next commit
Some cleanup
  • Loading branch information
keyboardDrummer committed Jul 3, 2024
commit 7861efa3c1962de81174285c3f465190bafa83cb
49 changes: 12 additions & 37 deletions Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,32 +255,7 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
CheckWellformedWithResult(expr, wfOptions, null, null, locals, builder, etran);
}

/// <summary>
/// Adds to "builder" code that checks the well-formedness of "expr". Any local variables introduced
/// in this code are added to "locals".
/// If "result" is non-null, then after checking the well-formedness of "expr", the generated code will
/// assume the equivalent of "result == expr".
/// See class WFOptions for descriptions of the specified options.
/// </summary>
void CheckWellformedWithResult(Expression expr, WFOptions wfOptions, Bpl.Expr result, Type resultType,
List<Bpl.Variable> locals, BoogieStmtListBuilder builder, ExpressionTranslator etran,
string resultDescription = null) {
Contract.Requires(expr != null);
Contract.Requires(wfOptions != null);
Contract.Requires((result == null) == (resultType == null));
Contract.Requires(locals != null);
Contract.Requires(builder != null);
Contract.Requires(etran != null);
Contract.Requires(predef != null);

var proofBuilder = new BoogieStmtListBuilder(this, options, builder.Context);
CheckWellFormedInner(expr, wfOptions, result, resultType, locals, proofBuilder, etran, resultDescription);
if (!proofBuilder.Empty) {
PathAsideBlock(expr.Tok, proofBuilder, builder);
}
}

private void CheckWellFormedInner(Expression expr, WFOptions wfOptions, Expr result, Type resultType, List<Variable> locals,
void CheckWellformedWithResult(Expression expr, WFOptions wfOptions, Expr result, Type resultType, List<Variable> locals,
BoogieStmtListBuilder builder, ExpressionTranslator etran, string resultDescription = null) {
var origOptions = wfOptions;
if (wfOptions.LValueContext) {
Expand All @@ -293,7 +268,7 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
switch (expr) {
case StaticReceiverExpr stexpr: {
if (stexpr.ObjectToDiscard != null) {
CheckWellFormedInner(stexpr.ObjectToDiscard, wfOptions, null, null, locals, builder, etran);
CheckWellformedWithResult(stexpr.ObjectToDiscard, wfOptions, null, null, locals, builder, etran);
}

break;
Expand Down Expand Up @@ -1221,7 +1196,7 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
resultIe = new Bpl.IdentifierExpr(body.tok, resultVar);
rangeType = lam.Type.AsArrowType.Result;
}
CheckWellFormedInner(body, newOptions, resultIe, rangeType, locals, b, comprehensionEtran, "lambda expression");
CheckWellformedWithResult(body, newOptions, resultIe, rangeType, locals, b, comprehensionEtran, "lambda expression");
});

if (mc != null) {
Expand Down Expand Up @@ -1291,9 +1266,9 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
Contract.Assert(letExpr != null);
CheckWellformedLetExprWithResult(letExpr, wfOptions, result, resultType, locals, bThen, etran, false);
} else {
CheckWellFormedInner(e.Thn, wfOptions, result, resultType, locals, bThen, etran, "if expression then branch");
CheckWellformedWithResult(e.Thn, wfOptions, result, resultType, locals, bThen, etran, "if expression then branch");
}
CheckWellFormedInner(e.Els, wfOptions, result, resultType, locals, bElse, etran, "if expression else branch");
CheckWellformedWithResult(e.Els, wfOptions, result, resultType, locals, bElse, etran, "if expression else branch");
builder.Add(new Bpl.IfCmd(iteExpr.tok, etran.TrExpr(e.Test), bThen.Collect(iteExpr.tok), null, bElse.Collect(iteExpr.tok)));
result = null;
break;
Expand All @@ -1317,18 +1292,18 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
CheckNotGhostVariant(e.InCompiledContext, updateExpr, e.Root, "update of", e.Members,
e.LegalSourceConstructors, builder, etran);

CheckWellFormedInner(e.ResolvedExpression, wfOptions, result, resultType, locals, builder, etran, resultDescription);
CheckWellformedWithResult(e.ResolvedExpression, wfOptions, result, resultType, locals, builder, etran, resultDescription);
result = null;
break;
}
case ConcreteSyntaxExpression expression: {
var e = expression;
CheckWellFormedInner(e.ResolvedExpression, wfOptions, result, resultType, locals, builder, etran, resultDescription);
CheckWellformedWithResult(e.ResolvedExpression, wfOptions, result, resultType, locals, builder, etran, resultDescription);
result = null;
break;
}
case NestedMatchExpr nestedMatchExpr:
CheckWellFormedInner(nestedMatchExpr.Flattened, wfOptions, result, resultType, locals, builder, etran, resultDescription);
CheckWellformedWithResult(nestedMatchExpr.Flattened, wfOptions, result, resultType, locals, builder, etran, resultDescription);
result = null;
break;
case BoogieFunctionCall call: {
Expand Down Expand Up @@ -1401,7 +1376,7 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
var b = new BoogieStmtListBuilder(this, options, builder.Context);
Bpl.Expr ct = CtorInvocation(mc, me.Source.Type, etran, locals, b, NOALLOC, false);
// generate: if (src == ctor(args)) { assume args-is-well-typed; mc.Body is well-formed; assume Result == TrExpr(case); } else ...
CheckWellFormedInner(mc.Body, wfOptions, result, resultType, locals, b, etran, "match expression branch result");
CheckWellformedWithResult(mc.Body, wfOptions, result, resultType, locals, b, etran, "match expression branch result");
ifCmd = new Bpl.IfCmd(mc.tok, Bpl.Expr.Eq(src, ct), b.Collect(mc.tok), ifCmd, els);
els = null;
}
Expand All @@ -1424,7 +1399,7 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
TrStmt(stmtExpr.S, builder, locals, etran);
}

CheckWellFormedInner(stmtExpr.E, options, result, resultType, locals, builder, etran, "statement expression result");
CheckWellformedWithResult(stmtExpr.E, options, result, resultType, locals, builder, etran, "statement expression result");
}

/// <summary>
Expand Down Expand Up @@ -1508,12 +1483,12 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
var r = new Bpl.LocalVariable(pat.tok, new Bpl.TypedIdent(pat.tok, nm, TrType(pat.Expr.Type)));
locals.Add(r);
var rIe = new Bpl.IdentifierExpr(rhs.tok, r);
CheckWellFormedInner(e.RHSs[i], wfOptions, rIe, pat.Expr.Type, locals, builder, etran, "let expression binding RHS well-formed");
CheckWellformedWithResult(e.RHSs[i], wfOptions, rIe, pat.Expr.Type, locals, builder, etran, "let expression binding RHS well-formed");
CheckCasePatternShape(pat, rhs, rIe, rhs.tok, pat.Expr.Type, builder);
var substExpr = Substitute(pat.Expr, null, substMap);
builder.Add(TrAssumeCmdWithDependenciesAndExtend(etran, e.tok, substExpr, e => Bpl.Expr.Eq(e, rIe), "let expression binding"));
}
CheckWellFormedInner(Substitute(e.Body, null, substMap), wfOptions, result, resultType, locals, builder, etran, "let expression result");
CheckWellformedWithResult(Substitute(e.Body, null, substMap), wfOptions, result, resultType, locals, builder, etran, "let expression result");

} else {
// CheckWellformed(var b :| RHS(b); Body(b)) =
Expand Down
Loading