Skip to content

Commit

Permalink
smart search
Browse files Browse the repository at this point in the history
  • Loading branch information
alex28sh committed Jan 20, 2025
1 parent 6ca207d commit 11cc906
Show file tree
Hide file tree
Showing 15 changed files with 1,258 additions and 105 deletions.
92 changes: 22 additions & 70 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prompts/humaneval-nagini/ask_for_fixed.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The following errors occurred during verification:
{error}

Please fix the error by adding, removing or modifying the invariants and return the fixed program.
Please fix the error by adding, removing or modifying the invariants and asserts and return the fixed program.
Don't add any additional text comments, your response must contain only program with invariants.
Do not provide ANY explanations. Don't include markdown backticks. Respond only in Python code, nothing else.
31 changes: 0 additions & 31 deletions prompts/humaneval-nagini/rewrite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,6 @@ Don't add any additional text comments, your response must contain only program
Do not provide ANY explanations. Don't include markdown backticks. Respond only in Python code, nothing else.
Also add assertions in necessary places.
Do not change the code, only add invariants and assertions. Don't remove any helper functions, they are there to help you.
You might need to work with accumulating functions, such as sum, so here's an example of how to do that:
```
from typing import cast, List, Dict, Set, Optional, Union
from nagini_contracts.contracts import *

@Pure
def Sum(a : List[int], s : int, t : int) -> int :
Requires(Acc(list_pred(a)))
Requires(((0) <= (s)) and ((s) <= (t)) and ((t) <= (len(a))))

if s == t:
return 0
else:
return (a)[t - 1] + (Sum(a, s, t - 1))

def sum_loop(numbers: List[int]) -> int:
Requires(Acc(list_pred(numbers)))
Ensures(Acc(list_pred(numbers)))
Ensures(Result() == Sum(numbers, 0, len(numbers)))
s = int(0)
i = int(0)
while (i) < (len(numbers)):
Invariant(Acc(list_pred(numbers)))
Invariant(0 <= i and i <= len(numbers))
Invariant(Forall(int, lambda d_1_p_:
(Implies(0 <= d_1_p_ and d_1_p_ < len(numbers), Sum(numbers, 0, d_1_p_ + 1) == Sum(numbers, 0, d_1_p_) + numbers[d_1_p_]), [[Sum(numbers, 0, d_1_p_ + 1)]])))
Invariant(s == Sum(numbers, 0, i))
Assert(Sum(numbers, 0, i + 1) == Sum(numbers, 0, i) + numbers[i])
s = s + (numbers)[i]
i = i + 1
return s
```
The program:
{program}
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ url = "https://packages.jetbrains.team/pypi/p/grazi/jetbrains-ai-platform-public
priority = "supplemental"

[tool.poetry.dependencies]
python = "^3.9"
python = ">=3.10"
grazie-api-gateway-client = "^0.1.3"
appdirs = "^1.4.4"
networkx = "^3.4.2"

[tool.poetry.group.dev.dependencies]
isort = "^5.10.1"
Expand Down
Loading

0 comments on commit 11cc906

Please sign in to comment.