Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex28sh committed Nov 4, 2024
1 parent 4c66b05 commit 9e3ba09
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 58 deletions.
16 changes: 5 additions & 11 deletions Bench/055-fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,23 @@ def ComputeFib(n : int) -> int:
# post-conditions-end

# impl-start
result = int(0) # type : int
result : int = int(0)
if (n) == (0):
result = 0
return result
if (n) == (1):
result = 1
return result
d_0_a_ = int(0) # type : int
d_1_b_ = int(0) # type : int
rhs0_ = 0 # type : int
rhs1_ = 1 # type : int
d_0_a_ = rhs0_
d_1_b_ = rhs1_
d_2_i_ = int(0) # type : int
d_2_i_ = 2
d_0_a_ : int = 0
d_1_b_ : int = 1
d_2_i_ : int = 2
while (d_2_i_) <= (n):
# invariants-start
Invariant(((2) <= (d_2_i_)) and ((d_2_i_) <= ((n) + (1))))
Invariant((d_0_a_) == (fib((d_2_i_) - (2))))
Invariant((d_1_b_) == (fib((d_2_i_) - (1))))
# invariants-end
d_3_temp_ = int(0) # type : int
d_3_temp_ = (d_0_a_) + (d_1_b_)
d_3_temp_ : int = (d_0_a_) + (d_1_b_)
d_0_a_ = d_1_b_
d_1_b_ = d_3_temp_
d_2_i_ = (d_2_i_) + (1)
Expand Down
15 changes: 5 additions & 10 deletions Bench/057-monotonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ def monotonic(xs : List[int]) -> bool:
# post-conditions-end

# impl-start
result = False # type : bool
if (len(xs)) == (1):
result = True
return result
d_4_increasing_ = False # type : bool
d_4_increasing_ = True
d_5_decreasing_ = False # type : bool
d_5_decreasing_ = True
d_6_i_ = int(0) # type : int
d_6_i_ = 1
return True
d_4_increasing_ : bool = True
d_5_decreasing_ : bool = True
d_6_i_ : int = 1
while (d_6_i_) < (len(xs)):
# invariants-start
Invariant(Acc(list_pred(xs)))
Expand All @@ -42,6 +37,6 @@ def monotonic(xs : List[int]) -> bool:
if ((xs)[(d_6_i_) - (1)]) <= ((xs)[d_6_i_]):
d_5_decreasing_ = False
d_6_i_ = (d_6_i_) + (1)
result = (d_4_increasing_) or (d_5_decreasing_)
result : bool = (d_4_increasing_) or (d_5_decreasing_)
return result
# impl-end
3 changes: 1 addition & 2 deletions Bench/058-common.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def common(l1 : List[int], l2 : List[int]) -> List[int]:
Invariant(Forall(int, lambda d_0_i_:
(Implies((d_0_i_) >= 0 and d_0_i_ < len(c), ExistsBoth(l1, l2, c[d_0_i_])), [[ExistsBoth(l1, l2, c[d_0_i_])]])))
# invariants-end
d_5_j_ = int(0) # type : int
d_5_j_ = 0
d_5_j_ : int = 0
while (d_5_j_) < (len(l2)):
# invariants-start
Invariant(Acc(list_pred(c)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/064-vowel_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def vowel__count(s : List[int]) -> int:
# post-conditions-end

# impl-start
count = int(0) # type : int
count = 0
d_1_i_ = int(0) # type : int
d_1_i_ = 0
count : int = 0
d_1_i_ : int = 0
while (d_1_i_) < (len(s)):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand Down
1 change: 1 addition & 0 deletions Bench/066-digitSum.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def upper__sum(s : List[int]) -> int:
Invariant(Forall(int, lambda d_0_i_: (Implies(((0) <= (d_0_i_)) and ((d_0_i_) < (len(s))), upper__sum__rec(0, d_0_i_ + 1, s) == upper__sum__rec(0, d_0_i_, s) + s[d_0_i_]), [[upper__sum__rec(0, d_1_i_ + 1, s)]])))
Invariant((res) == (upper__sum__rec(0, d_1_i_, s)))
# invariants-end
Assert(upper__sum__rec(0, d_1_i_ + 1, s) == upper__sum__rec(0, d_1_i_, s) + s[d_1_i_])
res = (res) + (((s)[d_1_i_]))
d_1_i_ = (d_1_i_) + (1)
return res
Expand Down
2 changes: 1 addition & 1 deletion Bench/083-starts_one_ends.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def CountNumbersStartingOrEndingWithOne(n : int) -> int:
# post-conditions-end

# impl-start
count = int(0) # type : int
count : int = int(0)
if (n) == (1):
count = 1
elif True:
Expand Down
4 changes: 1 addition & 3 deletions Bench/092-any_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ def any__int(a : int, b : int, c : int) -> bool:
# post-conditions-end

# impl-start
r = False # type : bool
r = (((a) == ((b) + (c))) or ((b) == ((a) + (c)))) or ((c) == ((a) + (b)))
return r
return (((a) == ((b) + (c))) or ((b) == ((a) + (c)))) or ((c) == ((a) + (b)))
# impl-end
6 changes: 2 additions & 4 deletions Bench/108-count_nums.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ def count__nums(s : List[int]) -> int:
# post-conditions-end

# impl-start
cnt = int(0) # type : int
cnt = 0
d_1_i_ = int(0) # type : int
d_1_i_ = 0
cnt : int = 0
d_1_i_ : int = 0
while (d_1_i_) < (len(s)):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/122-add_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ def SumElementsWithAtMostTwoDigits(lst : List[int], k : int) -> int:
# post-conditions-end

# impl-start
sum = int(0) # type : int
sum = 0
d_3_i_ = int(0) # type : int
d_3_i_ = 0
sum : int = 0
d_3_i_ : int = 0
while d_3_i_ < k:
# invariants-start
Invariant(Acc(list_pred(lst)))
Expand Down
25 changes: 10 additions & 15 deletions Bench/123-get_odd_collatz.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ def next__odd__collatz__iter(n : int) -> int:
# post-conditions-end

# impl-start
next = int(0) # type : int
next = n
next : int = n
if ((next % 2)) == (1):
next = ((3) * (next)) + (1)
d_0_start_ = next # type : int
d_0_start_ : int = next
while ((next % 2)) == (0):
# invariants-start
Invariant((next) > (0))
Expand All @@ -79,9 +78,8 @@ def get__odd__collatz__unsorted(n : int) -> List[int]:
not (((1) <= (d_2_i_)) and ((d_2_i_) < (len(Result())))) or (((Result())[d_2_i_]) == (next__odd__collatz((Result())[(d_2_i_) - (1)])))))
# post-conditions-end
# impl-start
odd__collatz = list([int(0)] * 0) # type : List[int]
d_3_cur_ = int(0) # type : int
d_3_cur_ = n
odd__collatz : List[int] = []
d_3_cur_ : int = n
if ((d_3_cur_ % 2)) == (0):
d_3_cur_ = next__odd__collatz__iter(d_3_cur_)
odd__collatz = [d_3_cur_]
Expand Down Expand Up @@ -128,11 +126,10 @@ def get__odd__collatz(n : int) -> List[int]:
# post-conditions-end

# impl-start
sorted = list([int(0)] * 0) # type : List[int]
sorted : List[int] = []
sorted = get__odd__collatz__unsorted(n)
d_12_unsorted_ = list(sorted) # type : List[int]
d_9_i_ = int(0) # type : int
d_9_i_ = 0
d_12_unsorted_ : List[int] = list(sorted)
d_9_i_ : int = 0
while (d_9_i_) < (len(sorted)):
# invariants-start
Invariant(Acc(list_pred(sorted)))
Expand All @@ -152,10 +149,8 @@ def get__odd__collatz(n : int) -> List[int]:
(not ((((d_9_i_) <= (d_13_k_)) and ((d_13_k_) < (len(sorted))))) or
(((sorted)[d_12_j_]) <= ((sorted)[d_13_k_])), [[sorted[d_13_k_]]]))), [[(sorted)[d_12_j_]]])))
# invariants-end
d_15_minIndex_ = int(0) # type : int
d_15_minIndex_ = d_9_i_
d_16_j_ = int(0) # type : int
d_16_j_ = (d_9_i_) + (1)
d_15_minIndex_ : int = d_9_i_
d_16_j_ : int = (d_9_i_) + (1)
while (d_16_j_) < (len(sorted)):
# invariants-start
Invariant(Acc(list_pred(sorted)))
Expand All @@ -182,7 +177,7 @@ def get__odd__collatz(n : int) -> List[int]:
d_15_minIndex_ = d_16_j_
d_16_j_ = (d_16_j_) + (1)
if (d_15_minIndex_) != (d_9_i_):
rhs0_ = (sorted)[d_9_i_] # type : int
rhs0_ : int = (sorted)[d_9_i_]
(sorted)[d_9_i_] = (sorted)[d_15_minIndex_]
(sorted)[d_15_minIndex_] = rhs0_
d_9_i_ = (d_9_i_) + (1)
Expand Down
6 changes: 2 additions & 4 deletions Bench/142-sum_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ def sum__squares(lst : List[int]) -> int:
# post-conditions-end

# impl-start
r = int(0) # type : int
r = 0
d_2_k_ = int(0) # type : int
d_2_k_ = 0
r : int = 0
d_2_k_ : int = 0
while (d_2_k_) < (len(lst)):
# invariants-start
Invariant(Acc(list_pred(lst)))
Expand Down

0 comments on commit 9e3ba09

Please sign in to comment.