You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defcheck_lean_compiles_strict(snippet: str, server: Server, require_no_goals: bool=True) ->bool:
""" Checks if a snippet is valid Lean 4 code, *strictly*, by: 1) server.load_sorry(file=snippet) -> returns list[CompilationUnit] 2) For each CompilationUnit: - If it has any `messages` containing "error", or - If it has leftover goals (goal_state != None) and we require full proof => fail If no errors or leftover goals, we declare success. Args: snippet: Lean 4 code snippet server: Pantograph Server require_no_goals: if True, any leftover goals => fail Returns: bool: True if fully compiled with no leftover errors or goals """try:
units=server.load_sorry(snippet)
# If "error" in result => already raises ServerError, so we skip the except blockexceptException:
# Hard parse error or somethingreturnFalse# Now check each CompilationUnit for leftover messages or goalsforcuinunits:
# If there's any "error" or "error:" mention in cu.messages => failformsgincu.messages:
lower_msg=msg.lower()
# A typical check: if "error" is in the string => failif"error"inlower_msg:
returnFalse# If user wants no leftover goals, but .goal_state is not None => we see that as partialifrequire_no_goalsandcu.goal_stateisnotNone:
# Means there's at least one sorry/hole or leftover type error, so failreturnFalse# If we pass all checks => successreturnTrue
which checks if there is any type of compilation bug. I think that should work. Right?
Context: this is for the crucial pass @ k metric for predictable evaluations of LLMs for AutoFormalization. I will add this later.
The text was updated successfully, but these errors were encountered:
I wrote this:
which checks if there is any type of compilation bug. I think that should work. Right?
Context: this is for the crucial pass @ k metric for predictable evaluations of LLMs for AutoFormalization. I will add this later.
The text was updated successfully, but these errors were encountered: