| Crates.io | oak-coq |
| lib.rs | oak-coq |
| version | 0.0.1 |
| created_at | 2025-10-20 12:20:31.800012+00 |
| updated_at | 2026-01-23 04:18:24.864491+00 |
| description | Coq 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 | 1891839 |
| size | 118,447 |
High-performance incremental Coq parser for the oak ecosystem with flexible configuration, optimized for theorem proving and formal verification.
Oak Coq is a robust parser for Coq, designed to handle complete Coq syntax including modern features like tactics, definitions, and proofs. 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_coq::{Parser, CoqLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
Theorem plus_comm : forall n m : nat, n + m = m + n.
Proof.
intros n m.
induction n as [| n' IHn'].
- simpl. reflexivity.
- simpl. rewrite IHn'. reflexivity.
Qed.
"#);
let result = parser.parse(&source);
println!("Parsed Coq theorem successfully.");
Ok(())
}
use oak_coq::{Parser, CoqLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
Theorem plus_assoc : forall n m p : nat,
n + (m + p) = (n + m) + p.
Proof.
intros n m p.
induction n as [| n' IHn'].
- simpl. reflexivity.
- simpl. rewrite IHn'. reflexivity.
Qed.
"#);
let result = parser.parse(&source);
println!("Parsed Coq theorem successfully.");
use oak_coq::{Parser, CoqLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
Definition double (n : nat) : nat :=
n + n.
Fixpoint factorial (n : nat) : nat :=
match n with
| 0 => 1
| S n' => n * factorial n'
end.
"#);
let result = parser.parse(&source);
println!("Parsed Coq definitions successfully.");
use oak_coq::{Parser, CoqLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("Theorem plus_comm : forall n m : nat, n + m = m + n.");
let result = parser.parse(&source);
// Token information is available in the parse result
use oak_coq::{Parser, CoqLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
Theorem invalid : forall n : nat,
n = n.
Proof.
intros n.
(* Missing Qed *)
"#);
let result = parser.parse(&source);
if let Err(e) = result.result {
println!("Parse error: {:?}", e);
}
The parser generates a comprehensive AST with the following main structures:
Oak Coq 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.