Universal Math Solver powered by Sanskrit Resonance Learning & Pāṇini's Grammar
Project description
GanitSolver: Vedic Resonance Learning Model for Mathematics
GanitSolver is a specialized mathematics reasoning engine that combines Sanskrit grammatical structures (Paninian Grammar) with Resonance Learning Models (RLM) to solve complex math problems. It leverages Vibhakti decomposition and Pratyahara domain classification to resonate towards solutions rather than purely symbolic manipulation.
Core Architecture
The solver operates via a pipeline:
- Vibhakti Decomposition (
ganitsolver.rlm.karak): Parses the problem into aKarakFrame(Agent, Object, Instrument, Action). - Resonance Propagation (
ganitsolver.rlm.reasoner): Computes answers by propagating energy through a Paramtatva phonemic graph. - Pratyahara Dispatch (
ganitsolver.solvers.dispatch): Classifies problems into domains (Game Theory/JhaŚ, Counting/aC, Combinatorics/yaN) for specialized solving. - Beam Search (
ganitsolver.api.solver): Explores candidate solutions using phonemic coherence scoring.
Key Components
- RLM Engine: Pure neural-symbolic hybrid reasoning.
- Ganit Library: Python implementation of fast Vedic math tricks (digit sums, modular arithmetic, etc.).
- Solvers: Domain-specific strategies for AIME/Olympiad style problems.
12 Solver Domains
The system employs 12 specialized solver strategies, routed via the Pratyahara Dispatcher. All reasoning happens in Sanskrit:
A. Specialized Solvers (Tier 1 - Specialized Logic)
- Fingerprint Solver (AIME Comprehensive)
- English: "Find the remainder when $2^{100}$ is divided by $7$."
- Sanskrit:
2^{100} saptabhiḥ vibhajyate cet avaśeṣaḥ kaḥ? - Logic: O(1) pattern matching for recurring competition problems.
- Game Theory Solver (JhaŚ Pratyahara)
- English: "Two players remove stones from piles of 3, 5, 7. Who wins?"
- Sanskrit:
dvau krīḍakau 3, 5, 7 rāśibhyaḥ prastarān apasarataḥ. kaḥ jayati? - Logic: Sprague-Grundy theorem for impartial games.
- Combinatorial Structure Solver (YaN Pratyahara)
- English: "How many distinct ways can you color a hexagon with 3 colors under rotation?"
- Sanskrit:
şaḍbhujaṃ tribhiḥ varṇaiḥ paribhramaṇe kati prakāraiḥ rañjayitum śakyate? - Logic: Burnside's Lemma (symmetry) and Graph Theory.
- Pure RLM Beam Solver
- English: "Find the next term in the sequence: 2, 6, 12, 20..."
- Sanskrit:
2, 6, 12, 20... iti śreṇyāḥ agrimam padaṃ kim? - Logic: Phonemic resonance propagation for pattern completion.
B. Gaṇit Library Modules (Tier 2 - Tool-Integrated Reasoning)
used for arithmetic-heavy tasks via code generation:
- Sankhya (Number Theory)
- English: "Find the number of divisors of $10!$."
- Sanskrit:
$10!$ ityasya kāryakāṇāṃ saṅkhyā kā?
- Beeja (Algebra)
- English: "Find the sum of roots of $x^3 - 4x + 1 = 0$."
- Sanskrit:
$x^3 - 4x + 1 = 0$ samīkaraṇasya mūlānāṃ yogaḥ kaḥ?
- Ganana (Counting)
- English: "How many ways can 5 people sit in a circle?"
- Sanskrit:
pañca janāḥ vṛtte kati prakāraiḥ upaveṣṭuṃ śaknuvanti?
- Jyamiti (Geometry)
- English: "Area of a triangle with side lengths 13, 14, 15."
- Sanskrit:
yatra bhujaḥ 13, 14, 15 santi, tasya trikoṇasya kṣetraphalaṃ kim?
- Sambhavna (Probability)
- English: "Probability of rolling sum 7 with two dice."
- Sanskrit:
dvābhyāṃ pāśakābhyāṃ 7 yogaḥ prāptasya sambhāvanā kā?
- Shreni (Sequences)
- English: "Sum of the first 100 terms of an AP with $a=1, d=3$."
- Sanskrit:
yatra $a=1, d=3$ asti, tasyāḥ samāntara-śreṇyāḥ prathama-śata-padānāṃ yogaḥ kaḥ?
- Anka (Digital Logic)
- English: "Convert $101_2$ to base 10."
- Sanskrit:
$101_2$ daśamika-paddhatau parivartaya.
- Samikaran (Equations)
- English: "Integer solutions for $3x + 5y = 19$."
- Sanskrit:
$3x + 5y = 19$ samīkaraṇasya pūrṇa-samādhānāni kāni?
Sanskrit Translation Mechanism (The Pivot Language)
The system is designed with Sanskrit as the mandatory intermediate reasoning language. All non-Sanskrit inputs must be translated before processing.
Architecture: Any Language → Sanskrit → RLM
-
Input Translation (The "Bridge"):
- Indic Languages: Uses
IndicTrans2(Meta) to translating Hindi, Tamil, Telugu, etc., directly into Sanskrit. - Global Languages: Uses
NLLB-200(No Language Left Behind) to translate English, Chinese, French, etc., into Sanskrit. - Why? Sanskrit's diverse case system (Vibhakti) eliminates ambiguity in mathematical relationships that exists in English (e.g., "divided by" vs "dividing").
- Indic Languages: Uses
-
Karak Decomposition (Grammar Parsing): Once the text is in Sanskrit, the
KarakParserdecomposes the sentence using Target-Action-Object (so-called "Vibhakti") rules:- 2nd Case (Karma): The numbers/objects being operated on.
- 3rd Case (Karana): The operator/instrument ($+$, $\times$, $\div$).
- 1st Case (Karta): The variable to solve for.
-
Universal Mathematical Graph: The RLM processes only the Sanskrit phonemes. It does not understand "remainder" or "integral" — it matches the phonemic signature of
avaśeṣa(remainder) orsamākalana(integral).
Example Pipeline
Input (English): "Find the remainder when 2^100 is divided by 7"
- Translate:
2^{100} saptabhiḥ vibhajyate cet avaśeṣaḥ kaḥ?(Sanskrit) - Decompose:
- Kartā:
avaśeṣaḥ(Remainder) - Karaṇa:
saptabhiḥ(By seven - 3rd case) - Kriyā:
vibhajyate(Is divided)
- Kartā:
- Resonate: RLM solves based on the phonemic path of
vibhajyate+saptabhiḥ.
Installation
-
Navigate to the package directory:
cd GanitSolver
-
Install dependencies:
pip install -r requirements.txt
Usage
from ganitsolver import GanitSolver
# Initialize the solver (beam_width controls search breadth)
solver = GanitSolver(
beam_width=128, # Controls search breadth
max_horizon=3, # Max depth for RLM search
model="rlm-small-v1", # RLM model for classification
llm="deepseek-r1-14b", # LLM for TIR (optional, GPU)
device="auto", # auto-detect GPU/CPU
strict_sanskrit=True, # Enforce Sanskrit-only input (Production Mode)
)
# Solve a problem (Sanskrit Input)
problem_text = "2^{100} saptabhiḥ vibhajyate cet avaśeṣaḥ kaḥ?"
answer, confidence = solver.solve(problem_text)
print(f"Answer: {answer} (Confidence: {confidence:.2f})")
Structure
ganitsolver/api: Main user-facing API.ganitsolver/rlm: Core RLM logic, grammar parsing, and graph models.ganitsolver/solvers: Problem-specific solving strategies.ganitsolver/ganit: Mathematical utility library.
License
[Add License Here]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ganitsolver-0.1.0.tar.gz.
File metadata
- Download URL: ganitsolver-0.1.0.tar.gz
- Upload date:
- Size: 96.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc0fd275fe6bff7181ec882cf2f0ceb72f90d2758b1c24b1de8a536eb040ebc
|
|
| MD5 |
3adf63e118f05e4df005a37c142079c4
|
|
| BLAKE2b-256 |
b044be2e1b61745813d92eb5b24163b1e5eb3c4b429e3a8529402ddf8cc14d8b
|
File details
Details for the file ganitsolver-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ganitsolver-0.1.0-py3-none-any.whl
- Upload date:
- Size: 107.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e433a8ecf83c5a7cbc281d52dd440c273e5c905ee2c56591e4806b481cd46e65
|
|
| MD5 |
0d6a8bd00b8a904eed186daf56200645
|
|
| BLAKE2b-256 |
b084c8caba3c29ecb21aea09e6fbeda13175daa3b28d147bbe0a8b1155f575cf
|