Skip to content

Commit

Permalink
fixes in 3,16,33,42,48,49,68,73,78,80,88,104,121,151,152,154,159
Browse files Browse the repository at this point in the history
  • Loading branch information
alex28sh committed Nov 4, 2024
1 parent bb30d05 commit 1ad64c4
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 105 deletions.
15 changes: 5 additions & 10 deletions Bench/003-below-zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ def below__zero(ops : List[int]) -> bool:
# post-conditions-end

# impl-start
res = False # type : bool
d_3_balance_ = int(0) # type : int
d_3_balance_ = 0
d_4_i_ = int(0) # type : int
d_4_i_ = 0
d_3_balance_ : int = 0
d_4_i_ : int = 0

while (d_4_i_) < (len(ops)):
# invariants-start
Expand All @@ -50,10 +47,8 @@ def below__zero(ops : List[int]) -> bool:

d_3_balance_ = (d_3_balance_) + ((ops)[d_4_i_])
if (d_3_balance_) < (0):
res = False
return res
return False
d_4_i_ = (d_4_i_) + (1)

res = True
return res

return True
# impl-end
4 changes: 2 additions & 2 deletions Bench/016-count_distinct_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def count_distinct_characters(s : List[int]) -> int:
# post-conditions-end

# impl-start
c = int(0) # type : int
d_2_i_ = int(97) # type : int
c : int = int(0)
d_2_i_ : int = int(97)
while (d_2_i_) <= (122):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand Down
22 changes: 8 additions & 14 deletions Bench/033-sort_third.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ def sort__third(a : List[int]) -> List[int]:
# post-conditions-end

# impl-start
sorted__even = list([int(0)] * 0) # type : List[int]
d_3_p_ = list([False] * 0) # type : List[bool]
d_3_p_ = list([])
d_4_i_ = int(0) # type : int
d_4_i_ = 0
sorted__even : List[int] = []
d_3_p_ : List[bool] = list([])
d_4_i_ : int = 0
while (d_4_i_) < (len(a)):
# invariants-start
Invariant(Acc(list_pred(d_3_p_)))
Expand Down Expand Up @@ -59,10 +57,8 @@ def SortSeqPred(s : List[int], p : List[bool]) -> List[int]:
# post-conditions-end

# impl-start
sorted = list([int(0)] * 0) # type : List[int]
sorted = list(s)
d_9_i_ = int(0) # type : int
d_9_i_ = 0
sorted : List[int] = list(s)
d_9_i_ : int = 0
while (d_9_i_) < (len(sorted)):
# invariants-start
Invariant(Acc(list_pred(sorted)))
Expand All @@ -84,10 +80,8 @@ def SortSeqPred(s : List[int], p : List[bool]) -> List[int]:
(((sorted)[d_12_j_]) <= ((sorted)[d_13_k_])), [[sorted[d_13_k_]]]))), [[(sorted)[d_12_j_]]])))
# invariants-end
if (p)[d_9_i_]:
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 Down Expand Up @@ -121,7 +115,7 @@ def SortSeqPred(s : List[int], p : List[bool]) -> List[int]:
Assert((p)[d_15_minIndex_])
Assert(p[d_9_i_])
# assert-end
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/042-incr-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ def incr__list(l : List[int]) -> List[int]:
# post-conditions-end

# impl-start
result = list([int(0)] * 0) # type : List[int]
result = list([])
d_1_i_ = int(0) # type : int
d_1_i_ = 0
result : List[int] = list([])
d_1_i_ : int = 0
while (d_1_i_) < (len(l)):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/048-is-palindrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def is__palindrome(text : List[int]) -> bool:
# post-conditions-end

# impl-start
result = False # type : bool
result = True
d_1_i_ = int(0) # type : int
d_1_i_ = 0
result : bool = True
d_1_i_ : int = 0
while (d_1_i_) < ((len(text) // 2)):
# invariants-start
Invariant(Acc(list_pred(text)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/049-modp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ def modp(n : int, p : int) -> int:
# post-conditions-end

# impl-start
r = int(0) # type : int
r = (1 % p)
d_0_i_ = int(0) # type : int
d_0_i_ = 0
r : int = (1 % p)
d_0_i_ : int = 0
while (d_0_i_) < (n):
# invariants-start
Invariant(((0) <= (d_0_i_)) and ((d_0_i_) <= (n)))
Expand Down
10 changes: 4 additions & 6 deletions Bench/068-pluck.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ def PluckSmallestEven(nodes : List[int]) -> List[int]:
# post-conditions-end

# impl-start
result = list([int(0)] * 0) # type : List[int]
d_4_smallestEven_ = int(0) # type : int
d_4_smallestEven_ = -1
d_5_smallestIndex_ = int(0) # type : int
d_5_smallestIndex_ = -1
d_6_i_ = int(0) # type : int
result : List[int] = []
d_4_smallestEven_ : int = -1
d_5_smallestIndex_ : int = -1
d_6_i_ : int = int(0)
while d_6_i_ < len(nodes):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/073-smallest_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ def smallest__change(s : List[int]) -> int:
# post-conditions-end

# impl-start
c = int(0) # type : int
c = 0
d_1_i_ = int(0) # type : int
d_1_i_ = 0
c : int = 0
d_1_i_ : int = 0
while (d_1_i_) < ((len(s) // 2)):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/078-hex_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ def count__prime__hex__digits(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
13 changes: 4 additions & 9 deletions Bench/080-is_happy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ def IsHappy(s : List[int]) -> bool:
# post-conditions-end

# impl-start
happy = False # type : bool
if (len(s)) < (3):
happy = False
return happy
d_1_i_ = int(0) # type : int
d_1_i_ = 1
return False
d_1_i_ : int = 1
while (d_1_i_) < ((len(s)) - (1)):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand All @@ -48,9 +45,7 @@ def IsHappy(s : List[int]) -> bool:
Implies(((0) < (d_2_j_)) and ((d_2_j_) < (d_1_i_)), ThreeDistinct(s, d_2_j_))))
# invariants-end
if not(ThreeDistinct(s, d_1_i_)):
happy = False
return happy
return False
d_1_i_ = (d_1_i_) + (1)
happy = True
return happy
return True
# impl-end
21 changes: 8 additions & 13 deletions Bench/088-sort_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ def sort__array(s : List[int]) -> List[int]:
# post-conditions-end

# impl-start
sorted = list([int(0)] * 0) # type : List[int]
sorted : List[int] = []
if (len(s)) == (0):
sorted = list([])
return sorted
elif (((((s)[0]) + ((s)[(len(s)) - (1)])) % 2)) == (0):
# assert-start
Assert(len(s) > 0)
# assert-end
d_4_t_ = list([int(0)] * 0) # type : List[int]
d_4_t_ = BubbleSort(s)
d_4_t_ : List[int] = BubbleSort(s)
# assert-start
Assert(Forall(int, lambda d_0_i_:
Forall(int, lambda d_1_j_:
Expand Down Expand Up @@ -71,10 +70,8 @@ def reverse(str : List[int]) -> List[int]:
# post-conditions-end

# impl-start
rev = list([int(0)] * 0) # type : List[int]
rev = []
d_12_i_ = int(0) # type : int
d_12_i_ = 0
rev : List[int] = []
d_12_i_ : int = 0
while (d_12_i_) < (len(str)):
# invariants-start
Invariant(Acc(list_pred(str), 1/2))
Expand Down Expand Up @@ -106,9 +103,8 @@ def BubbleSort(a1 : List[int]) -> List[int]:
# post-conditions-end

# impl-start
a = list(a1) # type : List[int]
d_2_i_ = int(0) # type : int
d_2_i_ = (len((a))) - (1)
a : List[int] = list(a1)
d_2_i_ : int = (len((a))) - (1)
while (d_2_i_) > (0):
# invariants-start
Invariant(Acc(list_pred(a)))
Expand All @@ -127,8 +123,7 @@ def BubbleSort(a1 : List[int]) -> List[int]:
[[(a)[d_6_k_k_]]])),
[[(a)[d_5_k_]]])))
# invariants-end
d_7_j_ = int(0) # type : int
d_7_j_ = 0
d_7_j_ : int = 0
while (d_7_j_) < (d_2_i_):
# invariants-start
Invariant(Acc(list_pred(a)))
Expand All @@ -150,7 +145,7 @@ def BubbleSort(a1 : List[int]) -> List[int]:
[[(a)[d_12_k_]]])))
# invariants-end
if ((a)[d_7_j_]) > ((a)[(d_7_j_) + (1)]):
rhs0_ = (a)[(d_7_j_) + (1)] # type : int
rhs0_ : int = (a)[(d_7_j_) + (1)]
(a)[(d_7_j_) + (1)] = (a)[d_7_j_]
(a)[d_7_j_] = rhs0_
d_7_j_ = (d_7_j_) + (1)
Expand Down
15 changes: 5 additions & 10 deletions Bench/104-unique_digits.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def UniqueDigits(x : List[int]) -> List[int]:
# post-conditions-end

# impl-start
result = list([int(0)] * 0) # type : List[int]
result = list([])
result : List[int] = []
d_5_i_ = 0

while d_5_i_ < len(x):
Expand All @@ -75,8 +74,7 @@ def UniqueDigits(x : List[int]) -> List[int]:
if HasNoEvenDigit((x)[d_5_i_]):
result = (result) + [(x)[d_5_i_]]
d_5_i_ = (d_5_i_) + (1)
d_9_i_ = int(0) # type : int
d_9_i_ = 0
d_9_i_ : int = 0
while (d_9_i_) < (len(result)):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down Expand Up @@ -111,10 +109,8 @@ def UniqueDigits(x : List[int]) -> List[int]:
[[result[d_13_k_]]]))),
[[(result)[d_12_j_]]])))
# invariants-end
d_17_minIndex_ = int(0) # type : int
d_17_minIndex_ = d_9_i_
d_18_j_ = int(0) # type : int
d_18_j_ = (d_9_i_) + (1)
d_17_minIndex_ : int = d_9_i_
d_18_j_ : int = (d_9_i_) + (1)
while (d_18_j_) < (len(result)):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down Expand Up @@ -157,8 +153,7 @@ def UniqueDigits(x : List[int]) -> List[int]:
d_17_minIndex_ = d_18_j_
d_18_j_ = (d_18_j_) + (1)
if (d_17_minIndex_) != (d_9_i_):
d_20_temp_ = int(0) # type : int
d_20_temp_ = (result)[d_9_i_]
d_20_temp_ : int = (result)[d_9_i_]
# assert-start
Assert(HasNoEvenDigit((result)[d_17_minIndex_]))
# assert-end
Expand Down
6 changes: 2 additions & 4 deletions Bench/121-solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ def add(v : 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(v)):
# invariants-start
Invariant(Acc(list_pred(v)))
Expand Down
6 changes: 2 additions & 4 deletions Bench/151-double_the_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def double__the__difference(lst : List[int]) -> int:
# post-conditions-end

# impl-start
r = int(0) # type : int
r = 0
d_3_k_ = int(0) # type : int
d_3_k_ = 0
r : int = 0
d_3_k_ : int = 0
while (d_3_k_) < (len(lst)):
# invariants-start
Invariant(Acc(list_pred(lst)))
Expand Down
7 changes: 2 additions & 5 deletions Bench/152-compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ def Compare(scores : List[int], guesses : List[int]) -> List[int]:
# post-conditions-end

# impl-start
result = [int(0)] * 0 # type : List[int]
nw0_ = [int(0)] * len((scores)) # type : List[int]
result = nw0_
d_1_i_ = int(0) # type : int
d_1_i_ = 0
result : List[int] = [int(0)] * len((scores))
d_1_i_ : int = 0
while (d_1_i_) < (len((scores))):
# invariants-start
Invariant(Acc(list_pred(result)))
Expand Down
10 changes: 3 additions & 7 deletions Bench/154-cycpattern_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def CycpatternCheck(word : List[int], pattern : List[int]) -> bool:
# post-conditions-end

# impl-start
result = False # type : bool
d_3_i_ = int(0) # type : int
d_3_i_ = 0
d_3_i_ : int = 0
while (d_3_i_) <= (len(pattern)):
# invariants-start
Invariant(Acc(list_pred(word)))
Expand All @@ -41,9 +39,7 @@ def CycpatternCheck(word : List[int], pattern : List[int]) -> bool:
(Implies(((0) <= (d_4_j_)) and ((d_4_j_) < (d_3_i_)), not(IsSubstring(word, pattern, d_4_j_))), [[IsSubstring(word, pattern, d_4_j_)]])))
# invariants-end
if IsSubstring(word, pattern, d_3_i_):
result = True
return result
return True
d_3_i_ = (d_3_i_) + (1)
result = False
return result
return False
# impl-end
2 changes: 1 addition & 1 deletion Bench/159-eat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def eat(number : int, need : int, remaining : int) -> List[int]:
# post-conditions-end

# impl-start
result = list([int(0)] * 2) # type : List[int]
result : List[int] = list([int(0)] * 2)
if (remaining) < (need):
result[0] = (number) + (remaining)
else:
Expand Down

0 comments on commit 1ad64c4

Please sign in to comment.