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

pgcl2heyvl annotation support update #66

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
204 changes: 5 additions & 199 deletions pgcl/examples-heyvl/2drwalk.heyvl
Original file line number Diff line number Diff line change
@@ -1,196 +1,7 @@
// Auto-generated by pgcl2heyvl from 2drwalk.pgcl
//
// HeyVL file to show
// 2 * ((n + 1) - d) >= ert[C](0)
// using k-induction with k = 1 and invariant = 2 * ((n + 1) - d)
// for the pGCL program C:
//
// nat x;
// nat y;
// nat d;
// nat n;
// while (d < n) {
// if (0 < x) {
// if (0 < y) {
// {
// x := x + 2;
// d := d + 2;
// } [1/4] {
// {
// y := y + 2;
// d := d + 2;
// } [1/3] {
// {
// x := x - 1;
// d := d - 1;
// } [1/2] {
// y := y - 1;
// d := d - 1;
// }
// }
// }
// } else {
// if (y < 0) {
// {
// x := x + 2;
// d := d + 2;
// } [1/4] {
// {
// y := y + 1;
// d := d - 1;
// } [1/3] {
// {
// x := x - 1;
// d := d - 1;
// } [1/2] {
// y := y - 2;
// d := d + 2;
// }
// }
// }
// } else {
// {
// x := x + 2;
// d := d + 2;
// } [1/4] {
// {
// y := y + 1;
// d := d + 1;
// } [1/3] {
// {
// x := x - 1;
// d := d - 1;
// } [1/2] {
// y := y - 1;
// d := d + 1;
// }
// }
// }
// }
// }
// } else {
// if (x < 0) {
// if (0 < y) {
// {
// x := x + 1;
// d := d - 1;
// } [1/4] {
// {
// y := y + 2;
// d := d + 2;
// } [1/3] {
// {
// x := x - 2;
// d := d + 2;
// } [1/2] {
// y := y - 1;
// d := d - 1;
// }
// }
// }
// } else {
// if (y < 0) {
// {
// x := x + 1;
// d := d - 1;
// } [1/4] {
// {
// y := y + 1;
// d := d - 1;
// } [1/3] {
// {
// x := x - 2;
// d := d + 2;
// } [1/2] {
// y := y - 2;
// d := d + 2;
// }
// }
// }
// } else {
// {
// x := x + 1;
// d := d - 1;
// } [1/4] {
// {
// y := y + 1;
// d := d + 1;
// } [1/3] {
// {
// x := x - 2;
// d := d + 2;
// } [1/2] {
// y := y - 1;
// d := d + 1;
// }
// }
// }
// }
// }
// } else {
// if (0 < y) {
// {
// x := x + 1;
// d := d + 1;
// } [1/4] {
// {
// y := y + 2;
// d := d + 2;
// } [1/3] {
// {
// x := x - 1;
// d := d + 1;
// } [1/2] {
// y := y - 1;
// d := d - 1;
// }
// }
// }
// } else {
// if (y < 0) {
// {
// x := x + 1;
// d := d + 1;
// } [1/4] {
// {
// y := y + 1;
// d := d - 1;
// } [1/3] {
// {
// x := x - 1;
// d := d + 1;
// } [1/2] {
// y := y - 2;
// d := d + 2;
// }
// }
// }
// } else {
// {
// x := x + 1;
// d := d + 1;
// } [1/4] {
// {
// y := y + 1;
// d := d + 1;
// } [1/3] {
// {
// x := x - 1;
// d := d + 1;
// } [1/2] {
// y := y - 1;
// d := d + 1;
// }
// }
// }
// }
// }
// }
// }
// tick(1);
// }

coproc k_induction(init_x: UInt, init_y: UInt, init_d: UInt, init_n: UInt) -> (x: UInt, y: UInt, d: UInt, n: UInt)
@ert
coproc main(init_x: UInt, init_y: UInt, init_d: UInt, init_n: UInt) -> (x: UInt, y: UInt, d: UInt, n: UInt)
pre 2 * ((init_n + 1) - init_d)
post 0
{
Expand All @@ -199,11 +10,8 @@ coproc k_induction(init_x: UInt, init_y: UInt, init_d: UInt, init_n: UInt) -> (x
y = init_y
d = init_d
n = init_n
coassert 2 * ((n + 1) - d)
cohavoc d, x, y
covalidate
coassume 2 * ((n + 1) - d)
if d < n {
@invariant(2 * ((n + 1) - d))
while d < n {
if 0 < x {
if 0 < y {
prob_choice = flip((1/4))
Expand Down Expand Up @@ -409,7 +217,5 @@ coproc k_induction(init_x: UInt, init_y: UInt, init_d: UInt, init_n: UInt) -> (x
}
}
tick 1
assert 2 * ((n + 1) - d)
assume 0
} else {}
}
}
78 changes: 5 additions & 73 deletions pgcl/examples-heyvl/C4B_t303.heyvl
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
// Auto-generated by pgcl2heyvl from C4B_t303.pgcl
//
// HeyVL file to show
// (0.5 * (x + 2)) + (0.5 * (y + 2)) >= ert[C](0)
// using k-induction with k = 3 and invariant = (0.5 * (x + 2)) + (0.5 * (y + 2))
// for the pGCL program C:
//
// nat x;
// nat y;
// nat t;
// nat r;
// while (0 < x) {
// {
// r := 1;
// } [1/3] {
// {
// r := 2;
// } [1/2] {
// r := 3;
// }
// }
// x := x - r;
// t := x;
// x := y;
// y := t;
// tick(1);
// }

coproc k_induction(init_x: UInt, init_y: UInt, init_t: UInt, init_r: UInt) -> (x: UInt, y: UInt, t: UInt, r: UInt)
@ert
coproc main(init_x: UInt, init_y: UInt, init_t: UInt, init_r: UInt) -> (x: UInt, y: UInt, t: UInt, r: UInt)
pre (0.5 * (init_x + 2)) + (0.5 * (init_y + 2))
post 0
{
Expand All @@ -35,11 +10,8 @@ coproc k_induction(init_x: UInt, init_y: UInt, init_t: UInt, init_r: UInt) -> (x
y = init_y
t = init_t
r = init_r
coassert (0.5 * (x + 2)) + (0.5 * (y + 2))
cohavoc r, t, x, y
covalidate
coassume (0.5 * (x + 2)) + (0.5 * (y + 2))
if 0 < x {
@k_induction(3, (0.5 * (x + 2)) + (0.5 * (y + 2)))
while 0 < x {
prob_choice = flip((1/3))
if prob_choice {
r = 1
Expand All @@ -56,45 +28,5 @@ coproc k_induction(init_x: UInt, init_y: UInt, init_t: UInt, init_r: UInt) -> (x
x = y
y = t
tick 1
assert (0.5 * (x + 2)) + (0.5 * (y + 2))
if 0 < x {
prob_choice = flip((1/3))
if prob_choice {
r = 1
} else {
prob_choice = flip((1/2))
if prob_choice {
r = 2
} else {
r = 3
}
}
x = x - r
t = x
x = y
y = t
tick 1
assert (0.5 * (x + 2)) + (0.5 * (y + 2))
if 0 < x {
prob_choice = flip((1/3))
if prob_choice {
r = 1
} else {
prob_choice = flip((1/2))
if prob_choice {
r = 2
} else {
r = 3
}
}
x = x - r
t = x
x = y
y = t
tick 1
assert (0.5 * (x + 2)) + (0.5 * (y + 2))
assume 0
} else {}
} else {}
} else {}
}
}
Loading