feat: Add handling for errors in compilation

This commit is contained in:
Leni Aniva 2024-10-05 15:38:35 -07:00
parent 568b81235c
commit 48f2f2cb5a
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 15 additions and 2 deletions

View File

@ -183,7 +183,20 @@ def prove(
# If this throws index out of bound errors it means the source doesn't contain walled off Lean sections. # If this throws index out of bound errors it means the source doesn't contain walled off Lean sections.
print(colored("Sketch:", "yellow"), fl_sketch) print(colored("Sketch:", "yellow"), fl_sketch)
lean_code, = [extract_lean_code(sketch)[0] for sketch in fl_sketch] lean_code, = [extract_lean_code(sketch)[0] for sketch in fl_sketch]
state, = server.load_sorry(lean_code) print(colored("Lean code:", "light_grey"), lean_code)
states = server.load_sorry(lean_code)
if len(states) != 1:
print(colored("Model must output one compilation unit", "red"))
raise NotImplemented
state = states[0]
if isinstance(state, list) and len(state) > 0:
print(colored("Sketch failed:", "red"), "\n".join(state))
# what should we do?
raise NotImplemented
agent = HammerAgent() agent = HammerAgent()
result = agent.search(server, state) result = agent.search(server, state)
print(colored(f"Result: {result}", "blue")) print(colored(f"Result: {result}", "blue"))

View File

@ -100,7 +100,7 @@ SYSTEM_PROMPT_SKETCH_V0 = 'You are an expert mathematician and an expert in the
STOP_TOKENS_SKETCH_V0: list[str] = ['Informal:', '(*### Problem', '###Solution', 'Formal:'] STOP_TOKENS_SKETCH_V0: list[str] = ['Informal:', '(*### Problem', '###Solution', 'Formal:']
prompt_sketch_template_lean4_v0 = ("Translate the informal solution into a sketch in the " prompt_sketch_template_lean4_v0 = ("Translate the informal solution into a sketch in the "
f"formal Lean 4 proof. Add {TOKEN_PLACEHOLDER} in the formal sketch whenever possible. " f"formal Lean 4 proof. Add {TOKEN_PLACEHOLDER} in the formal sketch whenever possible. "
f"{TOKEN_PLACEHOLDER} will be used to call a automated theorem prover or tactic in Lean 4. " f"{TOKEN_PLACEHOLDER} will be used to call a automated theorem prover or tactic in Lean 4. Do not use any lemmas."
"Here are some examples:\n" "Here are some examples:\n"
) )
def get_prompt_sketch_template_4_lean_v0( def get_prompt_sketch_template_4_lean_v0(