feat: Use aesop to solve for goals

This commit is contained in:
Leni Aniva 2024-06-05 14:02:12 -07:00
parent 9c672562a9
commit 4e678c7b97
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
4 changed files with 20 additions and 33 deletions

View File

@ -10,6 +10,15 @@
"inputRev": "main", "inputRev": "main",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop.git",
"type": "git",
"subDir": null,
"rev": "0a21a48c286c4a4703c0be6ad2045f601f31b1d0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.8.0-rc1",
"inherited": false,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/quote4", {"url": "https://github.com/leanprover-community/quote4",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
@ -19,15 +28,6 @@
"inputRev": "master", "inputRev": "master",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"rev": "0a21a48c286c4a4703c0be6ad2045f601f31b1d0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/ProofWidgets4", {"url": "https://github.com/leanprover-community/ProofWidgets4",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
@ -55,7 +55,7 @@
"inputRev": "main", "inputRev": "main",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/mathlib4.git", {"url": "https://github.com/leanprover-community/mathlib4",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "db651742f2c631e5b8525e9aabcf3d61ed094a4a", "rev": "db651742f2c631e5b8525e9aabcf3d61ed094a4a",

View File

@ -1,8 +1,8 @@
import Lake import Lake
open Lake DSL open Lake DSL
-- require aesop from git require aesop from git
-- "https://github.com/leanprover-community/aesop.git" @ "v4.8.0-rc1" "https://github.com/leanprover-community/aesop.git" @ "v4.8.0-rc1"
require mathlib from git require mathlib from git
"https://github.com/leanprover-community/mathlib4" @ "v4.8.0-rc1" "https://github.com/leanprover-community/mathlib4" @ "v4.8.0-rc1"

View File

@ -73,6 +73,8 @@ class Agent:
if search_state.is_solved: if search_state.is_solved:
# if the state is solved, propagate this solved status # if the state is solved, propagate this solved status
if search_state.is_root: if search_state.is_root:
if verbose:
print("Search complete: Root state solved")
self.reset() self.reset()
return True return True

View File

@ -15,16 +15,11 @@ class LLMAgent(Agent):
sgl.set_default_backend(sgl.OpenAI("gpt-4")) sgl.set_default_backend(sgl.OpenAI("gpt-4"))
self.goal_tactic_id_map = collections.defaultdict(lambda : 0) self.goal_tactic_id_map = collections.defaultdict(lambda : 0)
self.intros = [
"intro",
]
self.tactics = [ self.tactics = [
"simp", "aesop",
"rfl", #"simp",
"decide", #"rfl",
] #"decide",
self.no_space_tactics = [
"assumption",
] ]
def next_tactic(self, state: GoalState, goal_id: int, informal_stmt:str="", informal_proof:str="") -> Optional[Tactic]: def next_tactic(self, state: GoalState, goal_id: int, informal_stmt:str="", informal_proof:str="") -> Optional[Tactic]:
@ -32,13 +27,7 @@ class LLMAgent(Agent):
i = self.goal_tactic_id_map[key] i = self.goal_tactic_id_map[key]
target = state.goals[goal_id].target target = state.goals[goal_id].target
if target.startswith(''): if i >= len(self.tactics):
tactics = self.intros
elif ' ' in target:
tactics = self.tactics
else:
tactics = self.no_space_tactics
if i >= len(tactics):
new_state = None new_state = None
for ii in range(self.n_trials): for ii in range(self.n_trials):
print(f"===============trail {str(ii)}============") print(f"===============trail {str(ii)}============")
@ -51,13 +40,9 @@ class LLMAgent(Agent):
if tactic: if tactic:
return tactic return tactic
return None return None
else: else:
self.goal_tactic_id_map[key] = i + 1 self.goal_tactic_id_map[key] = i + 1
return tactics[i] return self.tactics[i]
class TestSearch(unittest.TestCase): class TestSearch(unittest.TestCase):