Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ _invariant: TRUE
} while ((r1 % 2) != 0)
```

### Declassificaton

To specify the declassification of a predicate it is necessary to specify both the expression being declassified and under what conditions this can happen. For example,

```
out = d(sum/cnt, cnt > min)
```

specifies that at this particular line the expression `sum/cnt` can be declassified if `cnt > min`.

### Supported operations
* `=` assignment
* `==` equal to
Expand All @@ -124,8 +134,22 @@ _invariant: TRUE
## TODOs
### Unsupported language features
Below is an inconclusive list of unsupported language features.
* Pointers
* Dynamic thread creation
* Objects

### Improve Type System
* Nested arrays
* Arrays/Pointers to Bools
* Arrays of pointers

### Weak memory model
The logic for the weak memory model is currently not implemented

## Optimisations
### Passification

### General Improvemens
* Implement a standard interface for identifiers and remove specific logic where possible
* Objects are implemented, but implementation appears to be incorrect. Treiber stack put does not pass


16 changes: 16 additions & 0 deletions tests/declassify/avg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
global var sum:
_L: FALSE

global var cnt:
_L: TRUE

global var out:
_L: TRUE

_Gamma_0: sum -> HIGH
_Rely: TRUE
_Guar: TRUE

if (cnt > 5) {
out = d(sum/cnt, cnt > 5);
}
16 changes: 16 additions & 0 deletions tests/declassify/if1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local var pass:

local var ans:

global var out:
_L: TRUE

_Gamma_0: pass -> HIGH
_Rely: TRUE
_Guar: TRUE

if (d(pass == ans, TRUE)) {
out = 1;
} else {
out = 0;
}
16 changes: 16 additions & 0 deletions tests/declassify/neg/avg1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
global var sum:
_L: FALSE

global var cnt:
_L: TRUE

global var out:
_L: TRUE

_Gamma_0: sum -> HIGH
_Rely: TRUE
_Guar: TRUE

if (cnt > 5) {
out = sum/cnt;
}
16 changes: 16 additions & 0 deletions tests/declassify/neg/avg2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
global var sum:
_L: FALSE

global var cnt:
_L: TRUE

global var out:
_L: TRUE

_Gamma_0: sum -> HIGH
_Rely: TRUE
_Guar: TRUE

if (cnt >= 5) {
out = d(sum/cnt, cnt > 5);
}
16 changes: 16 additions & 0 deletions tests/declassify/neg/if1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local var pass:

local var ans:

global var out:
_L: TRUE

_Gamma_0: pass -> HIGH
_Rely: TRUE
_Guar: TRUE

if (pass == ans) {
out = 1;
} else {
out = 0;
}
51 changes: 51 additions & 0 deletions tests/declassify/put
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
global var z:
_L: TRUE

global var tail:
_L: TRUE

global var head:
_L: TRUE

global var L:
_L: TRUE

global array tasks[1]:
_L: levels[_i] == 1
_Rely: tasks[_i] == tasks'[_i]
_Guar: TRUE

global array levels[1]:
_L: TRUE
_Rely: levels[_i] == levels'[_i]
_Guar: (z % 2 == 0 && z' == z) => (levels[_i] == levels'[_i])

local var t:

global var task:
_L: level == 1

global var level:
_L: TRUE

local var dec:

_Gamma_0: z -> LOW, dec -> LOW
_Rely: z == z' && task == task' && level == level' && L == L'
_Guar: z' >= z

if (z % 2 == 1) {
z = z + 1;
}

t = tail;
z = z + 1;
if (dec == 1) {
levels[t % L] = 1;
tasks[t % L] = d(task, dec == 1);
} else {
levels[t % L] = level;
tasks[t % L] = task;
}
z = z + 1;
tail = t + 1;
File renamed without changes.
6 changes: 2 additions & 4 deletions tests/rg/caslev/steal_0 → tests/rg/caslev/steal_
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ _Guar: levels[_i] == levels'[_i]
local var t:
local var h:
local var r:
local var index:
local var level:
local var task:

Expand All @@ -47,10 +46,9 @@ if (h < t) {
r = z;
} while (r % 2 == 1)

index = h % L;
level = levels[index];
level = levels[h % L];
if (level == 1) {
task = tasks[index];
task = tasks[h % L];
} else {
task = -1; // fail
}
Expand Down
70 changes: 0 additions & 70 deletions tests/rg/caslev/steal_old

This file was deleted.

13 changes: 13 additions & 0 deletions tests/rg/neg/pointers1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
global var a:
_L: FALSE

global var b:
_L: FALSE

_Rely: a == a' && b == b'
_Guar: TRUE

a = 2;
b = &a;
*b = 1;
assert a == 2;
19 changes: 19 additions & 0 deletions tests/rg/neg/pointers2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
global var a:
_L: FALSE

global var b:
_L: FALSE

global var out:
_L: a % 2 == 0

global var secret:
_L: FALSE

_Rely: a == a' && b == b'
_Guar: TRUE

a = 1;
b = &a;
*b = 2;
out = secret;
22 changes: 22 additions & 0 deletions tests/rg/neg/pointers3
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
global var a:
_L: FALSE

global var *b:
_L: FALSE
_PT: a

global var out:
_L: a == 2

global var secret:
_L: FALSE

_Gamma_0: out -> LOW
_Rely: a == a' && b == b'
_Guar: TRUE

a = 2;
b = &a;
*b = 1;
out = secret; // SAFE: a = 1
*b = 2; // UNSAFE: invalid control
21 changes: 21 additions & 0 deletions tests/rg/neg/pointers4
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
global var a:
_L: FALSE
_PT: b

global var b:
_L: FALSE

global var c:
_L: *b == 1

global var secret:
_L: FALSE

_Rely: a == a' && b == b' && c == c'
_Guar: TRUE

a = 1;
b = &a;
a = 1;
c = secret;

21 changes: 21 additions & 0 deletions tests/rg/neg/pointers5
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
global var a:
_L: FALSE
_PT: b

global var b:
_L: FALSE

global var c:
_L: *b == 1

global var secret:
_L: FALSE

_Rely: a == a' && b == b' && c == c'
_Guar: TRUE

b = &a;
a = 0; // SAFE
c = secret;
a = 1; // UNSAFE

15 changes: 15 additions & 0 deletions tests/rg/neg/pointers6
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
global var a:
_L: FALSE
_PT: b

global var b:
_L: FALSE

global var c:
_L: *b == 1

_Rely: a == a' && b == b' && c == c'
_Guar: TRUE

b = &a;

Loading