-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
8,780 additions
and
751 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
| Pramod Subramanyan | [email protected] | | ||
| Sanjit Seshia | [email protected] | | ||
| Rohit Sinha | [email protected] | | ||
| Kevin Cheang | [email protected] | | ||
| Cameron Rasmussen | [email protected] | | ||
|
||
## Other Contributors | ||
|
||
|
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,18 +1,19 @@ | ||
name := "uclid" | ||
version := "0.9.5" | ||
scalaVersion := "2.12.6" | ||
maintainer := "[email protected]" | ||
scalaVersion := "2.12.7" | ||
|
||
scalacOptions += "-feature" | ||
scalacOptions += "-unchecked" | ||
scalacOptions += "-deprecation" | ||
|
||
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases" | ||
|
||
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.8.0" | ||
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0" | ||
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" | ||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.6" withSources() | ||
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.1" | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test" | ||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.1" withSources() | ||
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5" | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test" | ||
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.0" | ||
|
||
enablePlugins(JavaAppPackaging) |
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,115 @@ | ||
module main { | ||
|
||
var fork_taken : [bv2]boolean; | ||
var num_forks : [bv2]bv2; | ||
var eaten : [bv2]boolean; | ||
|
||
|
||
var got_forks_left : [bv2]boolean; | ||
var got_forks_right : [bv2]boolean; | ||
|
||
|
||
init { | ||
fork_taken = const(false, [bv2]boolean); | ||
num_forks = const(0bv2, [bv2]bv2); | ||
eaten = const(false, [bv2]boolean); | ||
got_forks_left = const(false, [bv2]boolean); | ||
got_forks_right = const(false, [bv2]boolean); | ||
} | ||
|
||
|
||
procedure acquire_left(i: bv2) | ||
returns (success: boolean) | ||
modifies fork_taken; | ||
{ | ||
success = false; | ||
if (fork_taken[i - 1bv2] == false) { | ||
fork_taken[i - 1bv2] = true; | ||
success = true; | ||
} | ||
} | ||
|
||
|
||
procedure acquire_right(i: bv2) | ||
returns (success: boolean) | ||
modifies fork_taken; | ||
{ | ||
success = false; | ||
if (fork_taken[i] == false) { | ||
fork_taken[i] = true; | ||
success = true; | ||
} | ||
} | ||
|
||
input i: bv2; | ||
input tryLeft : boolean; | ||
input tryRight: boolean; | ||
|
||
procedure get_forks(i: bv2) | ||
modifies fork_taken, num_forks, got_forks_left, got_forks_right; | ||
{ | ||
var got_fork : boolean; | ||
|
||
// each philosopher tries to acquire left fork first and then right fork | ||
|
||
if (tryLeft && !got_forks_left[i]) { | ||
call (got_fork) = acquire_left(i); | ||
if (got_fork) { | ||
num_forks[i] = num_forks[i] + 1bv2; | ||
got_forks_left[i] = true; | ||
} | ||
} | ||
|
||
if (tryRight && got_forks_left[i] && !got_forks_right[i]) { | ||
call (got_fork) = acquire_right(i); | ||
if (got_fork) { | ||
num_forks[i] = num_forks[i] + 1bv2; | ||
got_forks_right[i] = true; | ||
} | ||
} | ||
} | ||
|
||
procedure release_forks(i: bv2) | ||
modifies num_forks, fork_taken, got_forks_left, got_forks_right; | ||
{ | ||
// releases the forks after philosopher has eaten once | ||
// and again competes to acquire the forks | ||
num_forks[i] = 0bv2; | ||
fork_taken[i] = false; | ||
fork_taken[i - 1bv2] = false; | ||
got_forks_right[i] = false; | ||
got_forks_left[i] = false; | ||
} | ||
|
||
next { | ||
|
||
if (eaten[i] == false) { | ||
// try acquiring two forks | ||
call get_forks(i); | ||
if (num_forks[i] == 2bv2) { eaten' = eaten[i -> true]; } | ||
} | ||
else { | ||
call release_forks(i); | ||
eaten' = eaten[i -> false]; | ||
} | ||
} | ||
|
||
// Given all resource has been consumed and all users have tried, | ||
// then atleast one philosopher has succeed | ||
// (i.e. no deadlock, however starvation is possible) | ||
property[LTL] someone_eats: | ||
|
||
G ( F(i == 0bv2) && F ((i == 1bv2)) && F(i == 2bv2) && F(i == 3bv2) && | ||
F(fork_taken[0bv2] == true) && F(fork_taken[1bv2] == true) && | ||
F(fork_taken[2bv2] == true) && F(fork_taken[3bv2] == true)) | ||
==> F(eaten[0bv2] || eaten[1bv2] || eaten[2bv2] || eaten[3bv2]); | ||
|
||
|
||
|
||
control { | ||
v = bmc(8); | ||
check; | ||
print_results; | ||
v.print_cex(i, tryLeft, tryRight, got_forks_left, got_forks_right, fork_taken, num_forks, eaten); | ||
} | ||
} |
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,105 @@ | ||
module main { | ||
|
||
var fork_taken : [bv2]boolean; | ||
var num_forks : [bv2]bv2; | ||
var eaten : [bv2]boolean; | ||
|
||
|
||
var got_forks_left : [bv2]boolean; | ||
var got_forks_right : [bv2]boolean; | ||
|
||
|
||
init { | ||
fork_taken = const(false, [bv2]boolean); | ||
num_forks = const(0bv2, [bv2]bv2); | ||
eaten = const(false, [bv2]boolean); | ||
got_forks_left = const(false, [bv2]boolean); | ||
got_forks_right = const(false, [bv2]boolean); | ||
} | ||
|
||
|
||
procedure acquire_left(i: bv2) | ||
returns (success: boolean) | ||
modifies fork_taken; | ||
{ | ||
success = false; | ||
if (fork_taken[i - 1bv2] == false) { | ||
fork_taken[i - 1bv2] = true; | ||
success = true; | ||
} | ||
} | ||
|
||
|
||
procedure acquire_right(i: bv2) | ||
returns (success: boolean) | ||
modifies fork_taken; | ||
{ | ||
success = false; | ||
if (fork_taken[i] == false) { | ||
fork_taken[i] = true; | ||
success = true; | ||
} | ||
} | ||
|
||
input i: bv2; | ||
input tryLeft : boolean; | ||
input tryRight: boolean; | ||
|
||
procedure get_forks(i: bv2) | ||
modifies fork_taken, num_forks, got_forks_left, got_forks_right; | ||
{ | ||
var got_fork : boolean; | ||
|
||
// Philosophers either gets both forks or none | ||
|
||
if (tryLeft && tryRight && !fork_taken[i-1bv2] && !fork_taken[i]) { | ||
num_forks[i] = num_forks[i] + 2bv2; | ||
got_forks_left[i] = true; | ||
got_forks_right[i] = true; | ||
} | ||
} | ||
|
||
procedure release_forks(i: bv2) | ||
modifies num_forks, fork_taken, got_forks_left, got_forks_right; | ||
{ | ||
// releases the forks after philosopher has eaten once | ||
// and again competes to acquire the forks | ||
num_forks[i] = 0bv2; | ||
fork_taken[i] = false; | ||
fork_taken[i - 1bv2] = false; | ||
got_forks_right[i] = false; | ||
got_forks_left[i] = false; | ||
} | ||
|
||
next { | ||
|
||
if (eaten[i] == false) { | ||
// try acquiring two forks | ||
call get_forks(i); | ||
|
||
if (num_forks[i] == 2bv2) { eaten' = eaten[i -> true]; } | ||
} else { | ||
call release_forks(i); | ||
eaten' = eaten[i -> false]; | ||
} | ||
} | ||
|
||
// Given all resource has been consumed and all users have tried, | ||
// then atleast one philosopher has succeed | ||
// (i.e. no deadlock, however starvation is possible) | ||
property[LTL] someone_eats: | ||
|
||
G ( F(i == 0bv2) && F ((i == 1bv2)) && F(i == 2bv2) && F(i == 3bv2) && | ||
F(fork_taken[0bv2] == true) && F(fork_taken[1bv2] == true) && | ||
F(fork_taken[2bv2] == true) && F(fork_taken[3bv2] == true)) | ||
==> F(eaten[0bv2] || eaten[1bv2] || eaten[2bv2] || eaten[3bv2]); | ||
|
||
|
||
|
||
control { | ||
v = bmc(12); | ||
check; | ||
print_results; | ||
v.print_cex(i, tryLeft, tryRight, fork_taken, num_forks, eaten); | ||
} | ||
} |
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,44 @@ | ||
module fib | ||
{ | ||
var a, b : integer; | ||
|
||
init { | ||
assume (a >= 0); | ||
assume (b > 0); | ||
assume (a <= b); | ||
} | ||
|
||
next { | ||
a' = b; | ||
b' = a + b; | ||
} | ||
} | ||
|
||
module main | ||
{ | ||
instance fib1 : fib(); | ||
instance fib2 : fib(); | ||
|
||
init { | ||
assume (fib1.a == fib2.a && fib1.b == fib2.b); | ||
} | ||
|
||
next { | ||
next (fib1); | ||
next (fib2); | ||
} | ||
|
||
property b_are_eq : fib1.b == fib2.b; | ||
property a_are_eq : fib1.a == fib2.a; | ||
property b_gt_0 : fib1.b > 0 && fib2.b > 0; | ||
property a_ge_0 : fib1.a >= 0 && fib2.a >= 0; | ||
property a_le_b : fib1.a <= fib1.b && fib2.a <= fib2.b; | ||
|
||
control { | ||
v = unroll(5); | ||
// v = induction; | ||
check; | ||
print_results; | ||
v.print_cex(fib1.a, fib1.b, fib2.a, fib2.b); | ||
} | ||
} |
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,54 @@ | ||
module main | ||
{ | ||
function hash(d1 : integer, h1 : integer) : integer; | ||
|
||
axiom forall (d1 : integer, d2 : integer, h1 : integer, h2 : integer) | ||
pattern[hash(d1, h1), hash(d2, h2)] | ||
:: (d1 == d2 && h1 == h2) <==> hash(d1, h1) == hash(d2, h2); | ||
|
||
var dcopy : [integer]integer; | ||
var data : [integer]integer; | ||
var dhash : integer; | ||
|
||
procedure compute_hash(d : [integer]integer) | ||
returns (h : integer) | ||
{ | ||
var h1, h2 : integer; | ||
h1 = hash(d[1], d[2]); | ||
h2 = hash(d[3], d[4]); | ||
h = hash(h1, h2); | ||
} | ||
|
||
init { | ||
dcopy = data; | ||
call (dhash) = compute_hash(data); | ||
data[0] = dhash; | ||
} | ||
|
||
next { | ||
var idx : integer; | ||
var dat : integer; | ||
var arr1 : [integer]integer; | ||
var arrh : integer; | ||
|
||
// havoc the index idx with dat. | ||
arr1 = data[idx -> dat]; | ||
// update the hash | ||
call (arrh) = compute_hash(arr1); | ||
// store the hash. | ||
data' = arr1[0 -> arrh]; | ||
} | ||
|
||
invariant init_hash: | ||
dhash == hash(hash(dcopy[1], dcopy[2]), hash(dcopy[3], dcopy[4])); | ||
invariant eq_data : | ||
(data[0] == dhash) ==> (data[1] == dcopy[1] && data[2] == dcopy[2] && | ||
data[3] == dcopy[3] && data[4] == dcopy[4]); | ||
|
||
control { | ||
set_solver_option(":mbqi", false); | ||
v = induction(1); | ||
check; | ||
print_results; | ||
} | ||
} |
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,5 +1,5 @@ | ||
// this adds the native packager. | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.1") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.14") | ||
// this helps create eclipse projects. | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.3") | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") | ||
|
Oops, something went wrong.