-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JetBrains-Research/HumanEval-Nagini
HumanEval Nagini
- Loading branch information
Showing
18 changed files
with
147 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ run_nagini.py | |
/tmp | ||
results | ||
results/* | ||
/log_tries/ | ||
/log_tries/* | ||
.direnv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule HumanEval-Nagini
added at
35d720
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Given the following Python program, and a set of Nagini invariants, output the program with invariants inserted into the correct place. | ||
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. | ||
The program: | ||
{program} | ||
– | ||
The invariants: | ||
{checks} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
There are still some errors: | ||
{error} | ||
|
||
Could you please fix them? | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Given the following Python program, output Nagini invariants that should go into the `while` loop. | ||
Ensure that the invariants are as comprehensive as they can be. | ||
Even if you think some invariant is not totally necessary, better add it than not. | ||
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. | ||
The program: | ||
{program} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Rewrite the following Python program, adding correct Nagini invariants into `while` loops. | ||
Do not change the code, only add the invariants. | ||
Ensure that the invariants are as comprehensive as they can be. | ||
Even if you think some invariant is not totally necessary, better add it than not. | ||
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. | ||
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
You are an expert in a Python verification framework Nagini. | ||
You will be given tasks dealing with Python programs including precise docstrings and specifications. | ||
Do not provide ANY explanations. Don't include markdown backticks. Respond only in Python code, nothing else. | ||
Take into account that arrays inside the invariants are indexed by type `int`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The verifier timed out during the verification. | ||
This usually means that the provided invariants were too broad or were difficult to check. | ||
Could you please try to improve the invariants and try again? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ def __init__(self): # type: ignore | |
r" *// invariants-start.*?// invariants-end\n", | ||
], | ||
"// assert-line", | ||
"//", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters