Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex28sh committed Dec 3, 2024
1 parent c89f39e commit 005124f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Bench/027-flip_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def flip__case(s : List[int]) -> List[int] :
Invariant(Acc(list_pred(res)))
Invariant(((0) <= (i)) and ((i) <= (len(s))))
Invariant((len(res)) == (len(s)))
Invariant(Forall(int, lambda i: (Implies(((0) <= (i)) and ((i) < (i)), lower((s)[i]) == upper((res)[i])))))
Invariant(Forall(int, lambda i: (Implies(((0) <= (i)) and ((i) < (i)), upper((s)[i]) == lower((res)[i])))))
Invariant(Forall(int, lambda j: (Implies(((0) <= (j)) and ((j) < (i)), lower((s)[j]) == upper((res)[j])))))
Invariant(Forall(int, lambda j: (Implies(((0) <= (j)) and ((j) < (i)), upper((s)[j]) == lower((res)[j])))))
# invariants-end
res[i] = flip__char(s[i])
i = i + 1
Expand Down
4 changes: 2 additions & 2 deletions Bench/043-pairs-sum-to-zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def pairs__sum__to__zero(l : List[int]) -> bool:
Invariant(((i) >= (0)) and ((i) < (len(l))))
Invariant(((j) >= (0)) and ((j) <= (len(l))))
Invariant(Implies(not(result), Forall(int, lambda i1:
Forall(int, lambda j:
(Implies((((((0) <= (i1)) and ((i1) < (i))) and (((0) <= (j)) and ((j) < (len(l))))) or (i1 == i and ((0) <= (j)) and ((j) < (j)))) and ((i1) != (j)), (((l)[i1]) + ((l)[j])) != (0)), [[((l)[i1]) + ((l)[j])]])))))
Forall(int, lambda j1:
(Implies((((((0) <= (i1)) and ((i1) < (i))) and (((0) <= (j1)) and ((j1) < (len(l))))) or (i1 == i and ((0) <= (j1)) and ((j1) < (j)))) and ((i1) != (j1)), (((l)[i1]) + ((l)[j1])) != (0)), [[((l)[i1]) + ((l)[j1])]])))))
Invariant(not (result) or ((Exists(int, lambda i1:
Exists(int, lambda j1:
(((((0) <= (i1)) and ((i1) < (i))) and (((0) <= (j1)) and ((j1) < (len(l))))) and ((i1) != (j1))) and ((((l)[i1]) + ((l)[j1])) == (0)))))
Expand Down
2 changes: 1 addition & 1 deletion Bench/056-correct_bracketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def correct_bracketing(s : List[int]) -> bool:
# impl-start
i : int = 0
depth : int = 0
result : int = True
result : bool = True
while i < len(s):
# invariants-start
Invariant(Acc(list_pred(s), 1/2))
Expand Down
3 changes: 1 addition & 2 deletions Bench/104-unique_digits.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def UniqueDigits(x : List[int]) -> List[int]:

# impl-start
result : List[int] = []
i = 0
i : int = 0

while i < len(x):
# invariants-start
Expand All @@ -74,7 +74,6 @@ def UniqueDigits(x : List[int]) -> List[int]:
if HasNoEvenDigit((x)[i]):
result = (result) + [(x)[i]]
i = (i) + (1)
i : int = 0
while (i) < (len(result)):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down
16 changes: 8 additions & 8 deletions Bench/106-f.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,23 @@ def f(n : int) -> List[int]:
j = (j) + (1)
result = (result) + [x]
else:
x : int = 0
j : int = 0
while (j) < (i):
x1 : int = 0
j1 : int = 0
while (j1) < (i):
# invariants-start
Invariant(Acc(list_pred(result)))
Invariant(((i) >= (0)) and ((i) <= (n)))
Invariant((len(result)) == (i))
Invariant(((j) >= (0)) and ((j) <= (i)))
Invariant((x) == (sum__spec(j - 1)))
Invariant(((j1) >= (0)) and ((j1) <= (i)))
Invariant((x1) == (sum__spec(j1 - 1)))
Invariant(Forall(int, lambda i:
(Implies((((i) >= (0)) and ((i) < (len(result)))) and (((i % 2)) == (0)), ((result)[i]) == (factorial__spec(i - 1))), [[factorial__spec(i - 1)]])))
Invariant(Forall(int, lambda i:
(Implies((((i) >= (0)) and ((i) < (len(result)))) and (((i % 2)) != (0)), ((result)[i]) == (sum__spec(i - 1))), [[sum__spec(i - 1)]])))
# invariants-end
x = (x) + (j + 1)
j = (j) + (1)
result = (result) + [x]
x1 = (x1) + (j1 + 1)
j1 = (j1) + (1)
result = (result) + [x1]
i = (i) + (1)
return result
# impl-end
12 changes: 6 additions & 6 deletions Bench/109-move_one_ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def move__one__ball(a : List[int]) -> bool:
Ensures(Implies(Result(), Exists(int, lambda i:
(((0) <= (i)) and ((i) < (len(a)))) and (is__sorted(a, 0, i) and is__sorted(a, i, len(a)) and (Forall(int, lambda j:
Implies(0 <= j and j < i,
Forall(int, lambda j:
Implies(i <= j and j < len(a), a[j] > a[j])))))))))
Forall(int, lambda j1:
Implies(i <= j1 and j1 < len(a), a[j] > a[j1])))))))))
Ensures(Implies(Exists(int, lambda i:
(((0) <= (i)) and ((i) < (len(a)))) and (is__sorted(a, 0, i) and is__sorted(a, i, len(a)) and (Forall(int, lambda j:
Implies(0 <= j and j < i,
Forall(int, lambda j:
Implies(i <= j and j < len(a), a[j] > a[j]))))))), Result()))
Forall(int, lambda j1:
Implies(i <= j1 and j1 < len(a), a[j] > a[j1]))))))), Result()))
# post-conditions-end

# impl-start
Expand Down Expand Up @@ -71,8 +71,8 @@ def move__one__ball(a : List[int]) -> bool:
Assert(Implies(is__sorted(a, 0, min__index) and is__sorted(a, min__index, len(a)) and min__index != 0 and a[len(a) - 1] < a[0],
(Forall(int, lambda j:
Implies(0 <= j and j < min__index,
Forall(int, lambda j:
Implies(min__index <= j and j < len(a), a[j] > a[j])))))))
Forall(int, lambda j1:
Implies(min__index <= j1 and j1 < len(a), a[j] > a[j1])))))))
# assert-end
can : bool = is__sorted(a, 0, min__index) and is__sorted(a, min__index, len(a)) and (min__index == 0 or a[len(a) - 1] < a[0])
return can
Expand Down
4 changes: 2 additions & 2 deletions Bench/163-generate_integers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def generate__integers(a : int, b : int) -> List[int]:
Invariant(i >= 2)
Invariant(Implies((i) <= (upper), i <= 8))
Invariant(upper <= 8)
Invariant(Forall(int, lambda i:
not (((i) >= (0)) and ((i) < (len(result)))) or ((((result)[i] % 2)) == (0))))
Invariant(Forall(int, lambda j:
(not (((j) >= (0)) and ((j) < (len(result)))) or ((((result)[j] % 2)) == (0)))))
Invariant(Forall(int, lambda j:
(not (((j) >= (0)) and ((j) < (len(result)))) or (((result)[j]) > 0 and ((result)[j]) < 10), [[result[j]]])))
# invariants-end
Expand Down

0 comments on commit 005124f

Please sign in to comment.