Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes in markup #21

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
12 changes: 4 additions & 8 deletions Bench/007-filter_by_substring.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ def checkSubstring(s : List[int], sub : List[int]) -> bool:
# post-conditions-end

# impl-start
result = False # type : bool
result = False
result : bool = False
if (len(sub)) == (0):
result = True
elif (len(s)) >= (len(sub)):
d_0_i_ = int(0) # type : int
d_0_i_ = 0
d_0_i_ : int = 0
while (d_0_i_) <= ((len(s)) - (len(sub))):
# invariants-start
Invariant(Acc(list_pred(s), 1/2))
Expand Down Expand Up @@ -90,8 +88,7 @@ def filter__by__substring(strings : List[List[int]], substring : List[int]) -> L

# impl-start
res : List[List[int]] = []
d_2_i_ = int(0) # type : int
d_2_i_ = 0
d_2_i_ : int = 0
while (d_2_i_) < (len(strings)):
# invariants-start
Invariant(Acc(list_pred(res)))
Expand All @@ -104,8 +101,7 @@ def filter__by__substring(strings : List[List[int]], substring : List[int]) -> L
Invariant(Forall(int, lambda d_3_i_:
(Implies(0 <= d_3_i_ and d_3_i_ < len(res), InArray(strings, res[d_3_i_])), [[InArray(strings, res[d_3_i_])]])))
# invariants-end
d_4_check_ = False # type : bool
d_4_check_ = checkSubstring((strings)[d_2_i_], substring)
d_4_check_ : bool = checkSubstring((strings)[d_2_i_], substring)
if d_4_check_:
cpy = list((strings)[d_2_i_])
res = (res) + [cpy]
Expand Down
20 changes: 8 additions & 12 deletions Bench/010-is_palindrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ def is__palindrome(start : int, s : List[int]) -> bool:
# post-conditions-end

# impl-start
d_1_i_ = int(0) # type : int
d_1_i_ = start
d_2_j_ = int(0) # type : int
d_2_j_ = (len(s)) - (1)
d_1_i_ : int = start
d_2_j_ : int = (len(s)) - (1)
while (d_1_i_) < (d_2_j_):
# invariants-start
Invariant(Acc(list_pred(s), 1/2))
Expand Down Expand Up @@ -76,12 +74,12 @@ def make__palindrome(s : List[int]) -> List[int]:
# post-conditions-end

# impl-start
result = list([int(0)] * 0) # type : List[int]
result : List[int] = list([int(0)] * 0)
if (len(s)) == (0):
result = []
return result
d_6_beginning__of__suffix_ = int(0) # type : int
d_8_flag_ = is__palindrome(d_6_beginning__of__suffix_, s) # type : bool
d_6_beginning__of__suffix_ : int = int(0)
d_8_flag_ : bool = is__palindrome(d_6_beginning__of__suffix_, s)
while not(d_8_flag_):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand All @@ -91,7 +89,7 @@ def make__palindrome(s : List[int]) -> List[int]:
# invariants-end
d_6_beginning__of__suffix_ = (d_6_beginning__of__suffix_) + (1)
d_8_flag_ = is__palindrome(d_6_beginning__of__suffix_, s)
d_10_reversed_ = reverse(d_6_beginning__of__suffix_, s) # type : List[int]
d_10_reversed_ : List[int] = reverse(d_6_beginning__of__suffix_, s)
result = (s) + (d_10_reversed_)
return result
# impl-end
Expand All @@ -112,10 +110,8 @@ def reverse(end : int, 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_) < (end):
# invariants-start
Invariant(Acc(list_pred(str), 1/2))
Expand Down
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
15 changes: 5 additions & 10 deletions Bench/036-fizz_buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ def fizz__buzz(n : int) -> int:
# post-conditions-end

# impl-start
result = int(0) # type : int
result = 0
d_1_i_ = int(0) # type : int
d_1_i_ = 0
result : int = 0
d_1_i_ : int = 0
while (d_1_i_) < (n):
# invariants-start
Invariant(((0) <= (d_1_i_)) and ((d_1_i_) <= (n)))
Expand All @@ -23,8 +21,7 @@ def fizz__buzz(n : int) -> int:
Invariant(result == fizz_buzz_fun(d_1_i_))
# invariants-end
if (((d_1_i_ % 11)) == (0)) or (((d_1_i_ % 13)) == (0)):
d_4_cnt_ = int(0) # type : int
d_4_cnt_ = count7(d_1_i_)
d_4_cnt_ : int = count7(d_1_i_)
result = (result) + (d_4_cnt_)
d_1_i_ = (d_1_i_) + (1)
return result
Expand Down Expand Up @@ -57,10 +54,8 @@ def count7(x : int) -> int:
# post-conditions-end

# impl-start
count = int(0) # type : int
count = 0
d_6_y_ = int(0) # type : int
d_6_y_ = x
count : int = 0
d_6_y_ : int = x
while (d_6_y_) > (0):
# invariants-start
Invariant(((0) <= (d_6_y_)) and ((d_6_y_) <= (x)))
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
6 changes: 2 additions & 4 deletions Bench/052-below-threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def below__threshold(l : List[int], t : int) -> bool:
# post-conditions-end

# impl-start
b = False # type : bool
b = True
d_1_i_ = int(0) # type : int
d_1_i_ = 0
b : bool = True
d_1_i_ : int = 0
while (d_1_i_) < (len(l)):
# invariants-start
Invariant(Acc(list_pred(l)))
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
12 changes: 4 additions & 8 deletions Bench/072-will_it_fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ def will__it__fly(s : List[int], w : int) -> bool:
# post-conditions-end

# impl-start
result = False # type : bool
result = True
d_0_i_ = int(0) # type : int
d_0_i_ = 0
d_1_j_ = int(0) # type : int
d_1_j_ = (len(s)) - (1)
result : bool = True
d_0_i_ : int = 0
d_1_j_ : int = (len(s)) - (1)
while (d_0_i_) < (d_1_j_):
# invariants-start
Invariant(Acc(list_pred(s)))
Expand All @@ -32,8 +29,7 @@ def will__it__fly(s : List[int], w : int) -> bool:
return result
d_0_i_ = (d_0_i_) + (1)
d_1_j_ = (d_1_j_) - (1)
d_3_total_ = int(0) # type : int
d_3_total_ = 0
d_3_total_ : int = 0
d_0_i_ = 0
while (d_0_i_) < (len(s)):
# invariants-start
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
Loading
Loading