| Crates.io | oak-lean |
| lib.rs | oak-lean |
| version | 0.0.1 |
| created_at | 2025-10-21 02:30:53.200564+00 |
| updated_at | 2026-01-23 04:36:34.065356+00 |
| description | Lean theorem prover language parser with support for dependent types and formal verification. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893161 |
| size | 98,341 |
High-performance incremental Lean parser for the oak ecosystem with flexible configuration, optimized for theorem proving and formal verification.
Oak Lean is a robust parser for Lean theorem prover, designed to handle complete Lean syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for theorem proving and formal verification.
Basic example:
use oak_lean::{Parser, LeanLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
def factorial : ℕ → ℕ
| 0 := 1
| (n + 1) := (n + 1) * factorial n
theorem factorial_pos (n : ℕ) : factorial n > 0 :=
begin
induction n with n ih,
{ simp [factorial] },
{ simp [factorial, ih, mul_pos] }
end
"#);
let result = parser.parse(&source);
println!("Parsed Lean successfully.");
Ok(())
}
use oak_lean::{Parser, LeanLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
def is_even (n : ℕ) := ∃ k, n = 2 * k
theorem even_plus_even_is_even (m n : ℕ)
(h₁ : is_even m) (h₂ : is_even n) : is_even (m + n) :=
begin
cases h₁ with k hk,
cases h₂ with l hl,
use k + l,
rw [hk, hl],
ring,
end
"#);
let result = parser.parse(&source);
println!("Definition parsed successfully.");
use oak_lean::{Parser, LeanLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
inductive tree (α : Type)
| leaf : tree
| node : α → tree → tree → tree
"#);
let result = parser.parse(&source);
println!("Inductive type parsed successfully.");
use oak_lean::{Parser, LeanLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("def hello := \"world\"");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_lean::{Parser, LeanLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
def broken_function
println("Hello")
// Missing function parameters and return type
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Lean integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.