fix: Lean source project for DSP

This commit is contained in:
Leni Aniva 2024-10-04 18:53:00 -07:00
parent 02167afa30
commit d94e3086c1
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
6 changed files with 59 additions and 42 deletions

View File

@ -4,8 +4,16 @@ based on Sean Welleck's DSP for Isabelle: https://github.com/wellecks/ntptutoria
## Execution ## Execution
First of all, build the experiment repo.
``` sh ``` sh
python3 experiments/dsp/main.py eval # experiments/dsp
cd lean_src_proj
lake build
```
Then run `main.py`
``` sh
python3 experiments/dsp/main.py -h
``` ```
## Related work ## Related work

View File

@ -1,68 +1,75 @@
{"version": 7, {"version": "1.1.0",
"packagesDir": ".lake/packages", "packagesDir": ".lake/packages",
"packages": "packages":
[{"url": "https://github.com/leanprover/std4", [{"url": "https://github.com/leanprover-community/batteries",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "cbc437aed076ea3aeb83f318d572f8b6de38265d", "scope": "",
"name": "std", "rev": "2ead90d24b4fac3a05c9c4294daa39bd8686fb98",
"name": "batteries",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"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,
"scope": "",
"rev": "a64fe24aa94e21404940e9217363a9a1ed9a33a6",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.10.0-rc1",
"inherited": false,
"configFile": "lakefile.toml"},
{"url": "https://github.com/leanprover-community/quote4", {"url": "https://github.com/leanprover-community/quote4",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "fd760831487e6835944e7eeed505522c9dd47563", "scope": "leanprover-community",
"rev": "a7bfa63f5dddbcab2d4e0569c4cac74b2585e2c6",
"name": "Qq", "name": "Qq",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"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": "82ac8cce559c3da0ade17cee3e275111fb7f1920",
"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,
"rev": "f5b2b6ff817890d85ffd8ed47637e36fcac544a6", "scope": "leanprover-community",
"rev": "d1b33202c3a29a079f292de65ea438648123b635",
"name": "proofwidgets", "name": "proofwidgets",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"inputRev": "v0.0.28", "inputRev": "v0.0.39",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover/lean4-cli", {"url": "https://github.com/leanprover/lean4-cli",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "a751d21d4b68c999accb6fc5d960538af26ad5ec", "scope": "",
"rev": "a11566029bd9ec4f68a65394e8c3ff1af74c1a29",
"name": "Cli", "name": "Cli",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"inputRev": "main", "inputRev": "main",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/import-graph.git", {"url": "https://github.com/leanprover-community/import-graph",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "64d082eeaad1a8e6bbb7c23b7a16b85a1715a02f", "scope": "leanprover-community",
"rev": "d366a602cc4a325a6f9db3a3991dfa6d6cf409c5",
"name": "importGraph", "name": "importGraph",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"inputRev": "main", "inputRev": "main",
"inherited": true, "inherited": true,
"configFile": "lakefile.lean"}, "configFile": "lakefile.toml"},
{"url": "https://github.com/leanprover-community/mathlib4.git", {"url": "https://github.com/leanprover-community/mathlib4.git",
"type": "git", "type": "git",
"subDir": null, "subDir": null,
"rev": "a6f770740f4c07b236c336115f4de99c28cd8910", "scope": "",
"rev": "f5c3f06aa7f6d6c221786d2890c345a00e6341f8",
"name": "mathlib", "name": "mathlib",
"manifestFile": "lake-manifest.json", "manifestFile": "lake-manifest.json",
"inputRev": null, "inputRev": "v4.10.0-rc1",
"inherited": false, "inherited": false,
"configFile": "lakefile.lean"}], "configFile": "lakefile.lean"}],
"name": "lean_src_proj", "name": "LeanSrcProj",
"lakeDir": ".lake"} "lakeDir": ".lake"}

View File

@ -1,20 +1,12 @@
import Lake import Lake
open Lake DSL open Lake DSL
package «lean_src_proj» {
-- add any package configuration options here
}
require mathlib from git
"https://github.com/leanprover-community/mathlib4.git"
-- ref: https://github.com/leanprover-community/aesop?tab=readme-ov-file#building
-- ref2: https://chatgpt.com/c/fbb6dde3-46e7-4117-9c02-78e5df1e0df5
-- add aesop pkg as a depedency
require aesop from git require aesop from git
"https://github.com/JLimperg/aesop" "https://github.com/leanprover-community/aesop.git" @ "v4.10.0-rc1"
require mathlib from git
"https://github.com/leanprover-community/mathlib4.git" @ "v4.10.0-rc1"
package LeanSrcProj
@[default_target] @[default_target]
lean_lib «LeanSrcProj» { lean_lib «LeanSrcProj»
-- add any library configuration options here
}

View File

@ -1 +0,0 @@
leanprover/lean4:v4.6.0-rc1

View File

@ -0,0 +1 @@
../../../src/lean-toolchain

View File

@ -1,4 +1,4 @@
import sys, os, json import sys, os, json, subprocess
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import Union, Any, Tuple from typing import Union, Any, Tuple
@ -221,8 +221,14 @@ def full_proof_search_dsp_lean(
server.gc() server.gc()
return return
experiment_dir = Path(__file__).resolve().parent experiment_dir = Path(__file__).resolve().parent
def get_project_and_lean_path():
cwd = experiment_dir / 'lean_src_proj'
p = subprocess.check_output(['lake', 'env', 'printenv', 'LEAN_PATH'], cwd=cwd)
return cwd, p
# -- Main # -- Main
def main(args): def main(args):
@ -231,7 +237,12 @@ def main(args):
path_2_eval_dataset = Path(args.eval_dataset).expanduser() path_2_eval_dataset = Path(args.eval_dataset).expanduser()
print(f'{path_2_eval_dataset=}') print(f'{path_2_eval_dataset=}')
server = Server() project_path, lean_path = get_project_and_lean_path()
server = Server(
imports=["Mathlib", "Aesop"],
project_path=project_path,
lean_path=lean_path,
)
# - Start wandb run # - Start wandb run
# print(f'\n\n-- Setup params') # print(f'\n\n-- Setup params')

View File

@ -17,8 +17,7 @@ class HammerAgent(Agent):
self, self,
state: GoalState, state: GoalState,
goal_id: int, goal_id: int,
informal_stmt: str, ) -> Optional[Tactic]:
informal_proof: str) -> Optional[Tactic]:
key = (state.state_id, goal_id) key = (state.state_id, goal_id)
i = self.goal_tactic_id_map[key] i = self.goal_tactic_id_map[key]