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

Implement scaling of instance predicates #1003

Merged
merged 1 commit into from
Apr 5, 2023
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
2 changes: 1 addition & 1 deletion src/main/vct/main/stages/Transformation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ case class SilverTransformation
ResolveExpressionSideEffects,
EncodeTryThrowSignals,

ResolveScale,
// No more classes
ClassToRef,

Expand Down Expand Up @@ -274,7 +275,6 @@ case class SilverTransformation

// Silver compat (basically no new nodes)
FinalizeArguments,
ResolveScale,
ExplicitADTTypeArgs,
ForLoopToWhileLoop,
BranchToIfElse,
Expand Down
1 change: 1 addition & 0 deletions src/rewrite/vct/rewrite/ResolveScale.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ case class ResolveScale[Pre <: Generation]() extends Rewriter[Pre] {
case Value(loc) =>
(amount > NoPerm()) ==> Value(dispatch(loc))
case apply: PredicateApply[Pre] => apply.rewrite(perm = amount * dispatch(apply.perm))
case apply: InstancePredicateApply[Pre] => apply.rewrite(perm = amount * dispatch(apply.perm))

case Star(left, right) => scale(left, amount) &* scale(right, amount)
case Implies(cond, cons) => Implies(dispatch(cond), scale(cons, amount))
Expand Down
12 changes: 12 additions & 0 deletions test/main/vct/test/integration/examples/TechnicalSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,17 @@ vercors should verify using silicon in "example using string primitive" pvl
@*/
void test();
"""

vercors should verify using silicon in "unfold scaled instance predicate" pvl
"""
class C {
resource P (int x) = true;

requires [1\2]P(0);
void m (int x) {
unfold [1\3]P(0);
}
}
"""
}