statement stringlengths 4 290 | proof stringlengths 0 3.01k | type stringclasses 6
values | symbolic_name stringlengths 4 44 | library stringclasses 4
values | filename stringclasses 18
values | imports listlengths 0 7 | deps listlengths 0 11 | docstring stringclasses 16
values | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
Encoder where
| native : NativeEncoder → Encoder
| external : ExternalEncoder → Encoder
| generic : GenericEncoder → Encoder | inductive | LeanCopilot.Encoder | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | ||
ModelRegistry where
generators : Std.HashMap String Generator | Std.HashMap.ofList [(Builtin.generator.name, .native Builtin.generator)]
encoders : Std.HashMap String Encoder :=
Std.HashMap.ofList [(Builtin.encoder.name, .native Builtin.encoder)] | structure | LeanCopilot.ModelRegistry | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
generatorNames (mr : ModelRegistry) : List String | mr.generators.toList.map (·.1) | def | LeanCopilot.ModelRegistry.generatorNames | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
encoderNames (mr : ModelRegistry) : List String | mr.encoders.toList.map (·.1) | def | LeanCopilot.ModelRegistry.encoderNames | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
modelNames (mr : ModelRegistry) : List String | mr.generatorNames ++ mr.encoderNames | def | LeanCopilot.ModelRegistry.modelNames | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getModelRegistry : IO ModelRegistry | modelRegistryRef.get | def | LeanCopilot.getModelRegistry | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getGenerator (name : String) : Lean.CoreM Generator | do
let mr ← getModelRegistry
match mr.generators[name]? with
| some (.native model) =>
if ¬(← isUpToDate model.url) then
Lean.logWarning s!"The local model {model.name} is not up to date. You may want to run `lake exe LeanCopilot/download` to re-download it."
return .native model
| some descr => r... | def | LeanCopilot.getGenerator | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getEncoder (name : String) : IO Encoder | do
let mr ← getModelRegistry
match mr.encoders[name]? with
| some descr => return descr
| none => throw $ IO.userError s!"unknown encoder: {name}" | def | LeanCopilot.getEncoder | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
registerGenerator (name : String) (model : Generator) | do
let mr ← getModelRegistry
modelRegistryRef.modify fun _ =>
{mr with generators := mr.generators.insert name model} | def | LeanCopilot.registerGenerator | Models | LeanCopilot/Models/Registry.lean | [
"Lean",
"Batteries.Data.HashMap",
"LeanCopilot.Models.Native",
"LeanCopilot.Models.External",
"LeanCopilot.Models.Generic",
"LeanCopilot.Models.Builtin",
"LeanCopilot.Models.FFI"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
reprover : NativeGenerator | {
url := Url.parse! "https://huggingface.co/kaiyuy/ct2-leandojo-lean4-tacgen-byt5-small"
tokenizer := ByT5.tokenizer
params := {
numReturnSequences := 1
}
}
#eval generate reprover "n : ℕ\n⊢ gcd n n = n" | def | reprover | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [
"params"
] | ReProver's tactic generator in CT2 format. | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
reprover' : NativeGenerator | {reprover with
device := .cpu
computeType := .float32
params := {numReturnSequences := 4}
}
#eval generate reprover' "n : ℕ\n⊢ gcd n n = n" | def | reprover' | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [
"params",
"reprover"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
byt5 : NativeGenerator | {
url := Url.parse! "https://huggingface.co/kaiyuy/ct2-byt5-small"
tokenizer := ByT5.tokenizer
params := {
numReturnSequences := 1
}
}
#eval generate byt5 "Hello, world!" | def | byt5 | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [
"params"
] | The original ByT5 checkpoint in CT2 format. | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
reproverEncoder : NativeEncoder | {
url := Url.parse! "https://huggingface.co/kaiyuy/ct2-leandojo-lean4-retriever-byt5-small"
tokenizer := ByT5.tokenizer
}
#eval encode reproverEncoder "n : ℕ\n⊢ gcd n n = n" | def | reproverEncoder | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [] | ReProver's retriever encoder in CT2 format. | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
dummyGenerator : GenericGenerator | where
generate _ _ := return #[⟨"Hello, world!", 0.5⟩, ("Hi!", 0.3)]
#eval generate dummyGenerator "n : ℕ\n⊢ gcd n n = n" | def | dummyGenerator | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [] | Arbitrary generator you can define. | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
dummyEncoder : GenericEncoder | where
encode _ := return FloatArray.mk #[1, 2, 3]
#eval encode dummyEncoder "Hi!" | def | dummyEncoder | LeanCopilotTests | LeanCopilotTests/ModelAPIs.lean | [
"LeanCopilot"
] | [] | Arbitrary encoder you can define. | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
params | {Builtin.generator.params with
numReturnSequences := 4
minLength := 100
lengthPenalty := 1.0
temperature := 0.5
} | def | params | LeanCopilotTests | LeanCopilotTests/TacticSuggestion.lean | [
"LeanCopilot"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
updatedModel | {Builtin.generator with params := params}
#eval getModelRegistry
#eval registerGenerator "updatedModel" (.native updatedModel)
#eval getModelRegistry | def | updatedModel | LeanCopilotTests | LeanCopilotTests/TacticSuggestion.lean | [
"LeanCopilot"
] | [
"params"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getOS! : SupportedOS | if System.Platform.isWindows then
.windows
else if System.Platform.isOSX then
.macos
else
.linux | def | LeanCopilot.getOS! | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [
"SupportedOS",
"getOS!"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
ensureDirExists (dir : FilePath) : IO Unit | do
if ¬ (← dir.pathExists) then
IO.FS.createDirAll dir | def | LeanCopilot.ensureDirExists | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [
"ensureDirExists"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getHomeDir : IO FilePath | do
let home := if getOS! == .windows then "USERPROFILE" else "HOME"
let some dir ← IO.getEnv home | throw $ IO.userError s!"Cannot find the ${home} environment variable."
return dir | def | LeanCopilot.getHomeDir | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [
"getOS!"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getDefaultCacheDir : IO FilePath | do
return (← getHomeDir) / ".cache/lean_copilot/models" | def | LeanCopilot.getDefaultCacheDir | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getCacheDir : IO FilePath | do
let defaultCacheDir ← getDefaultCacheDir
let dir := match ← IO.getEnv "LEAN_COPILOT_CACHE_DIR" with
| some dir => (dir : FilePath)
| none => defaultCacheDir
ensureDirExists dir
return dir.normalize | def | LeanCopilot.getCacheDir | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [
"ensureDirExists"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
getModelDir (url : Url) : IO FilePath | do
return (← getCacheDir) / url.hostname / url.path |>.normalize | def | LeanCopilot.getModelDir | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
isUpToDate (url : Url) : IO Bool | do
let dir := ← getModelDir url
if ¬ (← dir.pathExists) then
return false
let _ ← IO.Process.run {
cmd := "git"
args := #["fetch", "--quiet", "--all"]
cwd := dir
}
let branch := (← IO.Process.run {
cmd := "git"
args := #["symbolic-ref", "refs/remotes/origin/HEAD","--short"]
cwd :... | def | LeanCopilot.isUpToDate | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
initGitLFS : IO Unit | do
let proc ← IO.Process.output {
cmd := "git"
args := #["lfs", "install"]
}
if proc.exitCode != 0 then
throw $ IO.userError "Failed to initialize Git LFS. Please install it." | def | LeanCopilot.initGitLFS | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
downloadUnlessUpToDate (url : Url) : IO Unit | do
let dir := ← getModelDir url
if ← isUpToDate url then
println! s!"The model is available at {dir}"
return
println! s!"Downloading the model into {dir}"
if ← dir.pathExists then
IO.FS.removeDirAll dir
let some parentDir := dir.parent | unreachable!
IO.FS.createDirAll parentDir
initGitLFS
... | def | LeanCopilot.downloadUnlessUpToDate | ModelCheckpointManager | ModelCheckpointManager/Download.lean | [
"ModelCheckpointManager.Url"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
builtinModelUrls : List String | [
"https://huggingface.co/kaiyuy/ct2-leandojo-lean4-tacgen-byt5-small",
"https://huggingface.co/kaiyuy/ct2-leandojo-lean4-retriever-byt5-small",
"https://huggingface.co/kaiyuy/premise-embeddings-leandojo-lean4-retriever-byt5-small",
"https://huggingface.co/kaiyuy/ct2-byt5-small"
] | def | builtinModelUrls | ModelCheckpointManager | ModelCheckpointManager/Main.lean | [
"ModelCheckpointManager.Url",
"ModelCheckpointManager.Download"
] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
main (args : List String) : IO Unit | do
let mut tasks := #[]
let urls := Url.parse! <$> (if args.isEmpty then builtinModelUrls else args)
for url in urls do
tasks := tasks.push $ ← IO.asTask $ downloadUnlessUpToDate url
for t in tasks do
match ← IO.wait t with
| Except.error e => throw e
| Except.ok _ => pure ()
println! "Done... | def | main | ModelCheckpointManager | ModelCheckpointManager/Main.lean | [
"ModelCheckpointManager.Url",
"ModelCheckpointManager.Download"
] | [
"builtinModelUrls"
] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
Url where
protocol : String
hostname : String
path : FilePath
deriving Inhabited, Repr | structure | LeanCopilot.Url | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | ||
isValid (url : Url) : Bool | ¬ url.protocol.isEmpty ∧ ¬ url.hostname.isEmpty ∧ ¬ url.path.toString.isEmpty ∧ url.path.isRelative ∧ url.path.fileName.isSome | def | LeanCopilot.Url.isValid | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
toString (url : Url) : String | assert! isValid url
s!"{url.protocol}://{url.hostname}/{url.path}" | def | LeanCopilot.Url.toString | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
parse (s : String) : Option Url | let parts := s.splitOn "://"
if h : parts.length != 2 then
none
else
have : parts.length > 1 := by
by_cases h' : parts.length = 2
· rw [h']
apply Nat.lt_succ_of_le
simp
· simp_all
have : parts.length > 0 := by
apply Nat.lt_of_succ_lt
assumption
let proto... | def | LeanCopilot.Url.parse | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
parse! (s : String) : Url | match parse s with
| some url => url
| none => panic! "Invalid url: {s}" | def | LeanCopilot.Url.parse! | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
name! (url : Url) : String | url.path.fileName.get! | def | LeanCopilot.Url.name! | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
url₁ | parse! "https://huggingface.co/kaiyuy/ct2-leandojo-lean4-tacgen-byt5-small" | def | LeanCopilot.Url.url₁ | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 | |
url₂ | parse! "https://huggingface.co/bert-base-uncased"
#eval url₁
#eval url₂
#eval url₁.name!
#eval url₂.name! | def | LeanCopilot.Url.url₂ | ModelCheckpointManager | ModelCheckpointManager/Url.lean | [] | [] | https://github.com/lean-dojo/LeanCopilot | 4ad50a8d816799241c93f6f46f6926ef16189e39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.