Logical Engine for Multi-domain Mathematical Analysis
A research prototype exploring neural-guided symbolic mathematics in Rust. Inspired by AlphaProof and AlphaZero.
- A research prototype exploring hybrid neural-symbolic reasoning
- A proof of concept for AlphaProof-style mathematical search
- 550+ verified transformation rules for IMO-level mathematics
- An MCTS engine guided by a neural policy network
- A learning project for anyone interested in symbolic AI
- Not a Wolfram Alpha replacement - we handle basic calculus, not arbitrary math
- Not production-ready - this is research code
- Not a complete CAS - missing integration, limits, ODEs, and advanced features
- Not magic - it applies explicit rules, nothing more
| Category | Examples | Status |
|---|---|---|
| Arithmetic | (2+3)*(4+5) -> 45 |
Working |
| Identities | ((x+0)*1)+0 -> x |
Working |
| Power Rules | x^2 * x^3 * x^4 -> x^9 |
Working |
| Basic Derivatives | d/dx(x^3) -> 3x^2 |
Working |
| Sum Rule | d/dx(x^2 + x^3) -> 2x + 3x^2 |
Working |
| Trig Derivatives | d/dx(sin x) -> cos x |
Working |
| Linear Equations | 3x + 5 = 17 -> x = 4 |
Working |
| Pythagorean | sin^2(x) + cos^2(x) -> 1 |
Working |
| Like Terms | 2(x+y) + 3(x+y) -> 5(x+y) |
Working |
| Category | Count | Examples |
|---|---|---|
| Integration | 9 | ∫x^n dx → x^(n+1)/(n+1) |
| Number Theory | 80+ | Divisibility, GCD, modular arithmetic |
| Inequalities | 40+ | AM-GM, Cauchy-Schwarz, Triangle |
| Combinatorics | 50+ | Binomial, Pascal, Catalan, generating functions |
| Polynomials | 40+ | Vieta's, symmetric polys, factoring |
+------------------------------------------------------------------+
| Neural Policy Network |
| (Transformer, suggests which rule to try) |
+------------------------------+-----------------------------------+
|
v
+-----------+ +-----------------------------+ +-----------+
| Problem |---->| MCTS Search Engine |---->| Solution |
| Expr | | (AlphaZero-style UCB) | | + Proof |
+-----------+ +--------------+--------------+ +-----------+
|
v
+-----------------------------+
| Rule Library |
| (550+ verified transforms) |
+--------------+--------------+
|
v
+-----------------------------+
| Verifier |
| (Numerical + Symbolic) |
+-----------------------------+
Unlike LLMs that predict text statistically, LEMMA:
- Only applies verified mathematical rules - no hallucination
- Provides complete proof traces - every step is justified
- Uses neural guidance for search - learns which rules to try first
| Crate | Purpose | Lines of Code |
|---|---|---|
mm-core |
Expression AST, parsing, evaluation | ~3,700 |
mm-rules |
550+ transformation rules | ~22,700 |
mm-verifier |
Numerical and symbolic verification | ~600 |
mm-search |
Beam search, Neural MCTS | ~1,800 |
mm-brain |
Transformer network (Candle) | ~2,400 |
mm-solver |
Unified API | ~1,400 |
- Rust 1.75+
- ~500MB disk space for dependencies
git clone https://github.com/Pushp-Kharat1/LEMMA.git
cd LEMMA
# Build everything
cargo build --release
# Run the benchmark suite
cargo run --release --example benchmark_advanced
# Run stress tests
cargo run --release --example stress_test# Generates ~17k synthetic examples, trains for 50 epochs
cargo run --release --example train_networkuse mm_core::{Expr, SymbolTable};
use mm_rules::rule::standard_rules;
use mm_search::{MCTSConfig, NeuralMCTS};
use mm_verifier::Verifier;
fn main() {
let mut symbols = SymbolTable::new();
let x = symbols.intern("x");
// Setup the solver
let rules = standard_rules();
let verifier = Verifier::new();
let mcts = NeuralMCTS::new(rules, verifier);
// Solve: 3x + 5 = 17
let equation = Expr::Equation {
lhs: Box::new(Expr::Add(
Box::new(Expr::Mul(Box::new(Expr::int(3)), Box::new(Expr::Var(x)))),
Box::new(Expr::int(5)),
)),
rhs: Box::new(Expr::int(17)),
};
let solution = mcts.simplify(equation);
// Result: x = 4
// Steps: ["isolate_variable", "cancel_multiplication"]
// Verified: true
}An internal audit identified issues in earlier evaluation scripts and neural-rule integration that invalidated previous competitive benchmark claims. Those historical results are deprecated. Current verified performance is documented in the Benchmark section below. See Issue #8 for technical details and remediation work.
Algebraic Identities: 5/6
Constant Folding: 5/5
Trigonometry: 3/3
Derivatives: 5/5
Multi-Variable: 2/2
--------------------------
TOTAL: 20/21 (95.2%)
Multi-Step Algebra: 3/3
Calculus Multi-Step: 3/3
Equation Solving: 2/2
Trig Multi-Step: 2/2
--------------------------
TOTAL: 10/10 (100%)
All 10 passing
LLMs are amazing at many tasks, but they can:
- Produce plausible-looking but incorrect derivations
- Skip steps or make sign errors
- Not explain why a transformation is valid
LEMMA trades generality for reliability:
- Every step is a provable transformation
- The verifier catches errors
- Complete proof traces for debugging
- Performance - MCTS explores thousands of nodes; speed matters
- Memory Safety - No GC pauses during search
- Type System - Expression trees are naturally typed
- Ecosystem - Candle for neural networks, excellent tooling
See CONTRIBUTING.md for detailed guidelines.
Quick version:
- Fork the repo
- Add a rule to
mm-rules/src/algebra.rs - Add a test case
- Submit a PR
We especially welcome:
- New mathematical rules
- Bug reports with reproducible examples
- Documentation improvements
- Benchmark problems that fail
Mozilla Public License 2.0 - see LICENSE
- AlphaZero - MCTS + Neural guidance
- AlphaProof - Inspiration for math reasoning
- Candle - Rust ML framework
- SimSIMD / USearch - Ash Vardanian's ecosystem
- rule-based symbolic transformation
- domain-aware rule gating
- credit-constrained search control
- reinforcement-style meta-reward feedback
- hybrid symbolic + learned policy guidance
It is NOT:
- a CAS
- an LLM
- a IMO/JEE/MATH paper solver
- a theorem prover
- a Magic Box .... yet
It’s a research platform/Prototype for studying/Understanding how symbolic systems can be guided, constrained, and optimized Through Neural Guidance.
- Author: Pushp Kharat
- Email: kharatpushp16@outlook.com
- GitHub: @Pushp-Kharat1
LEMMA is a research project. Use it to learn, experiment, and contribute - not as your only source of mathematical truth.
bUY ME A COFFEE : https://buymeacoffee.com/kharatpushg