Deterministic Natural Language to Algorithm Generation Framework
MathForge AI is a deterministic framework that transforms natural language mathematical problem statements into structured algorithmic representations, executable Python code, and computational complexity analysis. Inspired by compiler design principles, the framework emphasizes reproducibility, interpretability, and transparent decision-making through a rule-based processing pipeline.
Natural language mathematical problems are often easy for humans to understand but difficult for computers to interpret directly. MathForge AI addresses this challenge by systematically converting problem descriptions into formal algorithmic representations, generating executable Python implementations, and estimating computational complexity through a deterministic pipeline.
Unlike probabilistic large language models, MathForge AI follows predefined rules and algorithm templates, ensuring consistent, explainable, and reproducible outputs for the same input.
- End-to-end transformation from natural language to executable code
- Deterministic pipeline ensuring reproducibility and consistency
- Intermediate Representation (IR) for structured abstraction
- Automated pseudocode and Python code generation
- Time and space complexity estimation
- Confidence scoring for output reliability
Mathematical problems are typically expressed in natural language, while computational systems require formal syntax. This mismatch introduces complexity in translating human reasoning into executable solutions.
MathForge addresses this challenge by automating the complete pipeline:
- Problem interpretation
- Algorithm identification
- Code generation
- Complexity analysis
The system follows a compiler-inspired deterministic pipeline:
- Text Preprocessing
- Semantic Analysis (rule-based NLP)
- Intermediate Representation (IR) generation
- Pseudocode generation
- Code synthesis (Python)
- Complexity analysis (time & space)
- Output generation with confidence score
This architecture ensures transparency, traceability, and reproducibility across all stages.
- Tokenization and normalization
- Keyword-based pattern matching
- Parameter extraction
- Deterministic semantic classification
A structured abstraction layer encoding:
- Algorithm type
- Control structures (loops, recursion)
- Data structures
- Computational properties
- Predefined algorithm templates
- Deterministic template selection
- Ensures correctness and avoids hallucination
Supported algorithms:
- Sorting (Bubble, Selection, Merge Sort)
- Searching (Binary Search)
- Recursive patterns (Factorial)
- Numerical methods (Newton-Raphson)
- Template-based Python code generation
- Ensures syntactic correctness
- Produces executable implementations
- Rule-based inference of time and space complexity
- Based on structural properties of algorithms
Examples:
- Nested loops → O(n²)
- Divide & conquer → O(n log n)
-
Quantifies reliability of interpretation
-
Based on:
- Keyword matching
- Parameter extraction
- Validation consistency
- Python
- FastAPI (Backend API)
- HTML, CSS, JavaScript (Frontend)
- Rule-based NLP techniques
mathforge/ │── backend/ # API and processing pipeline │── frontend/ # User interface │── data/ # Sample inputs / datasets │── evaluation/ # Testing and evaluation scripts │── README.md
git clone https://github.com/your-username/mathforge.git cd mathforge
cd backend pip install -r requirements.txt uvicorn main:app --reload
Open frontend/index.html in browser (or run via local server)
-
Input: Natural language mathematical problem
-
System extracts algorithm pattern
-
Generates:
- Intermediate Representation
- Pseudocode
- Python implementation
- Complexity analysis
- Confidence score
Input: "Find factorial of a number"
Output:
- Algorithm: Recursion
Pseudocode:
function factorial(n):
if n == 0:
return 1
return n * factorial(n-1)
Python Code:
def factorial(n):
if n == 0:
return 1
return n * factorial(n-1)
Time Complexity: O(n) Space Complexity: O(n)
Experimental evaluation (50 test cases):
- Algorithm detection accuracy: ~92%
- Code generation accuracy: ~90%
- Complexity estimation accuracy: ~95%
- Average confidence score: 0.88
- Deterministic and reproducible outputs
- No reliance on probabilistic LLMs
- High interpretability and transparency
- Suitable for educational and research applications
- Limited to predefined algorithm templates
- No symbolic algebra support
- Rule-based NLP may struggle with ambiguous inputs
- Integration of transformer-based NLP models
- Expansion of algorithm template library
- Support for advanced mathematical domains
- Visualization of algorithm execution
- Multi-language input support
- Educational tools for learning algorithms
- Automated code generation systems
- AI-assisted programming environments
- Computational mathematics platforms
Unlike LLM-based systems, MathForge uses a deterministic pipeline, ensuring reproducibility, interpretability, and reliability in algorithm generation.
This makes it particularly valuable for:
- Education
- Research
- Verified and trustworthy code generation
This project is developed for academic and research purposes and demonstrates deterministic AI system design.
Thrishika B.Tech in Computer Science and Engineering (AI)