Skip to content

Commit e25f93d

Browse files
author
Alex Lungu
committed
minor fixes
1 parent 0accd52 commit e25f93d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1903
-1082
lines changed

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/alk.jar

-207 KB
Binary file not shown.

input/symb/set0/choose.alk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@havoc A : array<int>;
2+
@assume A.size() == 10;
3+
@assume forall x : int :: 0 <= x && x < 10 ==> A[x] == 2;
4+
5+
choose x from A;
6+
7+
@assert x == 2;

input/symb/set0/choose2.alk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@havoc A : set<int>;
2+
@assume forall x : int :: x in A ==> x == 2;
3+
4+
choose x from A;
5+
6+
@assert x == 2;

input/symb/set0/do.alk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@havoc n : int;
2+
@assume n > 1;
3+
4+
sum = 0;
5+
i = 1;
6+
7+
do
8+
{
9+
sum += i;
10+
i++;
11+
} while (i <= n)
12+
@invariant sum == i * (i - 1) / 2;
13+
@invariant i <= n + 1;
14+
15+
@assert sum == n * (n + 1) / 2;

input/symb/set0/for.alk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@havoc n : int;
2+
@assume n > 1;
3+
sum = 0;
4+
for (i = 1; i <= n; i++)
5+
@invariant sum == i * (i - 1) / 2
6+
@invariant i <= n + 1
7+
{
8+
sum += i;
9+
}
10+
11+
@assert sum == n * (n + 1) / 2;

input/symb/set0/foreach.alk

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@havoc A : array<int>;
2+
@assume A.size() == 3;
3+
@assume forall x : int :: 0 <= x && x < A.size() ==> A[x] == x;
4+
5+
sum = 0;
6+
foreach x from A
7+
{
8+
sum += x;
9+
}
10+
11+
// A |-> $a
12+
while (A.size() > 0)
13+
// (size (set-difference $a (store emptySet x true))) > 0
14+
{
15+
choose x from A;
16+
A.remove(x); // A = A \ { x }
17+
// A |-> (set-difference $a (store emptySet x true))
18+
...
19+
}
20+
21+
A = A \ { x } ---> (set-difference $a (store emptySet x true))
22+
A.remove(x) ---> (store $a x false)
23+
24+
(size (store $a x false)) == (size $a) - 1 daca (store $a x true)
25+
(size $a) altfel
26+
27+
A = A \ {x, y, z}
28+
==================
29+
30+
A.remove(x).remove(y).remove(z)
31+
32+
A = A ^ {x, y, z}
33+
34+
(store $a x true) ==> (size (store $a x false)) == (size $a) - 1
35+
(store $a x false) ==> (size (store $a x false)) == (size $a)
36+
37+
38+
// x in A
39+
// $a.size() > (size (set-difference $a (store emptySet x true))) >= 0
40+
41+
42+
(size (set-difference $a (store emptySet x true))) :=
43+
forall x, y, a :: (size (set-difference x (store y a true)) ==
44+
(size (set-difference x y)) daca (store x a) == false sau (size (set-difference x y)) - 1 altfel

input/symb/set0/foreach2.alk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@havoc A : array<int>;
2+
@assume A.size() == 10;
3+
@assume forall x : int :: 0 <= x && x < 10 ==> A[x] == 2;
4+
5+
6+
sum = 0;
7+
foreach x from A
8+
{
9+
sum += x;
10+
}
11+
@assert A.size() * 2 == sum;
12+

input/symb/set0/repeat.alk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@havoc n : int;
2+
@assume n > 1;
3+
4+
sum = 0;
5+
i = 1;
6+
7+
repeat
8+
{
9+
sum += i;
10+
i++;
11+
} until (i > n)
12+
@invariant sum == i * (i - 1) / 2;
13+
@invariant i <= n + 1;
14+
15+
@assert sum == n * (n + 1) / 2;

0 commit comments

Comments
 (0)