-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1259 from utwente-fmt/veymont-lightweight-heavywe…
…ight VeyMont: support inline, wrapped, and no stratified permissions, fix some of Wander's issues, update VeyMont pass order.
- Loading branch information
Showing
32 changed files
with
876 additions
and
245 deletions.
There are no files selected for viewing
This file contains 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 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
34 changes: 34 additions & 0 deletions
34
examples/technical/veymont/branchUnanimityStratificationProblem.pvl
This file contains 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,34 @@ | ||
/* | ||
This test shows that, even though one of the parties know that the branch is unanimous, we still cannot show branch unanimity. | ||
This verifies just fine in combination with --veymont-no-branch-unanimity | ||
*/ | ||
|
||
class Storage { | ||
int x; | ||
int temp; | ||
|
||
ensures Perm(x, 1) ** x == 10 ** Perm(temp, 1); | ||
constructor(); | ||
} | ||
|
||
choreography Example() { | ||
endpoint alice = Storage(); | ||
endpoint bob = Storage(); | ||
|
||
requires Perm(alice.x, 1) ** Perm[alice](bob.x, 1\2) ** Perm(alice.temp, 1); | ||
requires Perm(bob.x, 1\2) ** Perm(bob.temp, 1); | ||
requires alice.x == 10 && (\endpoint alice; bob.x == 10); | ||
requires bob.x == 10; | ||
run { | ||
loop_invariant Perm(alice.x, 1) ** Perm[alice](bob.x, 1\2) ** Perm(alice.temp, 1); | ||
loop_invariant (\endpoint alice; alice.x == bob.x); | ||
loop_invariant Perm(bob.x, 1\2) ** Perm(bob.temp, 1); | ||
loop_invariant alice.x >= 0 && bob.x >= 0; | ||
while (alice.x > 0 && bob.x > 0) { | ||
alice.x := alice.x - 1; | ||
channel_invariant Perm(alice.x, 1\2) ** Perm(bob.x, 1\2); | ||
communicate alice.x -> bob.temp; | ||
bob.x := bob.x - 1; | ||
} | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
package vct.col.ast.expr.heap.alloc | ||
|
||
import vct.col.ast.expr.ExprImpl | ||
import vct.col.ast.{NewObject, Type} | ||
import vct.col.print.{Ctx, Doc, Precedence, Text} | ||
import vct.col.ast.ops.NewObjectOps | ||
import vct.col.check.{CheckContext, CheckError, TypeErrorExplanation} | ||
|
||
trait NewObjectImpl[G] extends NewObjectOps[G] { | ||
trait NewObjectImpl[G] extends NewObjectOps[G] with ExprImpl[G] { | ||
this: NewObject[G] => | ||
override def t: Type[G] = cls.decl.classType(Seq()) | ||
|
||
override def precedence: Int = Precedence.POSTFIX | ||
override def layout(implicit ctx: Ctx): Doc = | ||
Text("new") <+> ctx.name(cls) <> "()" | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) ++ | ||
(if (cls.decl.typeArgs.nonEmpty) | ||
Seq(TypeErrorExplanation( | ||
this, | ||
"This expression only supports non-generic classes", | ||
)) | ||
else | ||
Seq()) | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package vct.col.ast.expr.veymont | ||
|
||
import vct.col.ast.expr.ExprImpl | ||
import vct.col.ast.ops.MessageOps | ||
import vct.col.ast.{Message, Type} | ||
import vct.col.check.{CheckContext, CheckError} | ||
import vct.col.print._ | ||
|
||
trait MessageImpl[G] extends MessageOps[G] { | ||
trait MessageImpl[G] extends MessageOps[G] with ExprImpl[G] { | ||
this: Message[G] => | ||
override def layout(implicit ctx: Ctx): Doc = Text("\\msg") | ||
override def precedence: Int = Precedence.ATOMIC | ||
override def t: Type[G] = ref.decl.msg.t | ||
|
||
// We don't check for being in a channel invariant here because the only other place | ||
// where you can use a `\msg` is as the message of a communicate. In that cause, you get | ||
// infinite recursion in the typechecker anyway, so might as well not check for this here. | ||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package vct.col.ast.expr.veymont | ||
|
||
import vct.col.ast.expr.ExprImpl | ||
import vct.col.ast.ops.ReceiverOps | ||
import vct.col.ast.{Receiver, Type} | ||
import vct.col.check.{CheckContext, CheckError, OnlyInChannelInvariant} | ||
import vct.col.print._ | ||
|
||
trait ReceiverImpl[G] extends ReceiverOps[G] { | ||
trait ReceiverImpl[G] extends ReceiverOps[G] with ExprImpl[G] { | ||
this: Receiver[G] => | ||
override def layout(implicit ctx: Ctx): Doc = Text("\\receiver") | ||
override def precedence: Int = Precedence.ATOMIC | ||
override def t: Type[G] = ref.decl.receiver.get.decl.t | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) ++ | ||
(context.inCommunicateInvariant match { | ||
case Some(_) => Seq() | ||
case None => Seq(OnlyInChannelInvariant(this)) | ||
}) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package vct.col.ast.expr.veymont | ||
|
||
import vct.col.ast.expr.ExprImpl | ||
import vct.col.ast.ops.SenderOps | ||
import vct.col.ast.{Sender, Type} | ||
import vct.col.check.{CheckContext, CheckError, OnlyInChannelInvariant} | ||
import vct.col.print._ | ||
|
||
trait SenderImpl[G] extends SenderOps[G] { | ||
trait SenderImpl[G] extends SenderOps[G] with ExprImpl[G] { | ||
this: Sender[G] => | ||
override def layout(implicit ctx: Ctx): Doc = Text("\\sender") | ||
override def precedence: Int = Precedence.ATOMIC | ||
override def t: Type[G] = ref.decl.sender.get.decl.t | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) ++ | ||
(context.inCommunicateInvariant match { | ||
case Some(_) => Seq() | ||
case None => Seq(OnlyInChannelInvariant(this)) | ||
}) | ||
} |
This file contains 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 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 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
Oops, something went wrong.