Pāṇinian Grammar: Part 8 - The Programming Genius of Pāṇini
Let us now see an example of the multiple inheritance case. Consider the three sets of Sandhi rules below.
- इ/उ/ऋ/ऌ + vowel = य्/व् /र् /ल् + vowel (Part 1 - इकः यण् अचि)
- अ + vowel = guna (medium grade of the vowel)
- Vowel + Vowel (same pair) = Long Vowel
I give various examples of the three rules:
- प्रति + उषा = प्रत्युषा, सु + आगतम् = स्वागतम्, मातृ + अंशः = मात्रांशः
- राज + इन्द्रः = राजेद्रः, मह + उत्सवः = महोत्सवः, सप्त + ऋषिः = सप्तर्षिः
- ब्रह्म + अस्त्रम् = ब्रह्मास्त्रम्, योगि + इन्द्रः = योगीन्दरः, गुरु + उत्तमः = गुरूत्तमः
We see that rule 3 conflicts with rules 1 and 2. In the examples of rule 3, ब्रह्म + अस्त्रम् where in sandhi, an अ+अ is encountered, I can also apply rule 2 because it falls under the domain of अ+ any vowel . In the same rule 3 example of योगि + इन्द्रः where in sandhi, an इ+इ is encountered, I can also apply Rule 1 because it falls under the domain of इ + any vowel. So, how does Pāṇini ensure that it is only Rule 3 that applies in all those examples and not rules 1 and 2. The concept of overriding for the case of multiple inheritance comes into play. Consider the possible pairs of vowels visualized below. The like vowel combinations come at the diagonal of the table.
| अ | इ | उ | ऋ | |
| अ | अ+अ | अ+इ | अ+उ | अ+ऋ |
| इ | इ+अ | इ+इ | इ+उ | इ+ऋ |
| उ | उ+अ | उ+इ | उ+उ | उ+ऋ |
| ऋ | ऋ+अ | ऋ+इ | ऋ+उ | ऋ+ऋ |
Now, the information of whether the combination is under the applicability of rule 1 (इ,उ,ऋ+vowel) or rule 2 (अ+vowel) or rule 3 (like vowels) is also given.
| अ | इ | उ | ऋ | |
| अ | Rule 2,3 | Rule 2 | Rule 2 | Rule 2 |
| इ | Rule 1 | Rule 1,3 | Rule 1 | Rule 1 |
| उ | Rule 1 | Rule 1 | Rule 1,3 | Rule 1 |
| ऋ | Rule 1 | Rule 1 | Rule 1 | Rule 1,3 |
One sees that the domain of Rule 3 is contained in the combinations of the domains of rules 1 and 2.
So, Pāṇini does not have to qualify anything more - the overriding principle automatically overrides applications of rules 1 and 2 whenever rule 3 also can be applied. So, rules 1 and 2 will be applied only when rule 3 cannot be applied. This is because the rules 1 and 2 are more general than rule 3 which is more specific and always an instruction for a specific class is followed whenever it clashes with an instruction from a generic case.
Recursion and Production of More Objects
We saw that classes are templates for objects which contain information about data and instructions (functions). And we saw that functions like evenoddcheck act on data and give out new data (take two numbers and return remainder). But wait, can a function throw out new objects, thus adding to a database? This is possible in object oriented programming - one can have functions inside classes (that act inside all the objects of those classes) and one can arrange these functions to return new objects of the existing classes with its own new functions. I do not want to write a code again for this but the idea should be clear.
Pāṇini does this too - he utillises important aspects of Saṃskṛta language. Let us take one simple application - the desideratives or सनाद्यन्तः. Consider the following two sentences in English:
- I read books.
- I want to read books.
In the first sentence, the verb is factual - the reading is a matter of fact. Whereas in the second sentence, the verbal part “want to read” is not factual - it merely conveys desire or intention. English conveys this desire by using the verb “want” and then putting a “to” in front of the verb that is desired. But Saṃskṛta modifies the verb itself to achieve this meaning. This mood of desire or intention is called the desiderative mood in grammar. See in Saṃskṛta.
- सः पुस्तकानि पठति (He reads books)
- सः पुस्तकानि पिपठिषति (He wants to read books)
So, we see that the verb transforms internally from पठति to पिपठिषति. What is happening are two crucial steps.
- Reduplication of the first consonant of the initial consonant part of the root with some vowel - i.e. पठ् => (the initial consonant प् in पठ् reduplicates with इ) पि + पठ् = पिपठ्
- Then, an additional स् /इष् is added to the reduplicated root - पिपठ् + इष् = पिपठिष्
Then, as usual we add the usual thematic vowel अ and the personal ending ति to get the final verb.
- पिपठिष् + अ + ति = पिपठिषति
How Pāṇini thinks of this process is that to convey desire, one manufactures a new root पिपठिष् from the ordinary verb पठ् through reduplication and addition of इष्. These roots are called secondary roots that convey desiderative grade.
Pāṇini uses a special function that acts on all roots to create new roots. If we consider roots as objects like he did, then what he is doing is coming up with a function that takes in a root and gives out another root. The technical name that he gives for this function in his grammar is सन्. When the suffix सन् is added to a root, it triggers appropriate reduplication and additions to give up another root related to it and conveying the meaning of desire.
To translate from the language of object oriented programming to Pāṇinian grammatical terms,
| Pāṇini | Programming |
| Optimal Ordering of the data of roots, suffixes and sounds | Database management |
| Definitions संज्ञा of technical terms (eg. the terms गुण ,वृद्धि in vowel grades) | Reserved keywords (eg. int, float) |
| Roots, Suffixes, and various groupings and subgroupings within them like तद्धित suffixes or class 1 (भ्वादि) roots | Classes and inherited subclasses |
| The actual data of the roots and suffixes | Objects |
| विधि - rules | Standard Function like % |
| Instructions for combinations and transformations of data | Functions defined inside the appropriate class that rewrite and give back a new object |
| A rule with a smaller domain overriding a rule or rules with a larger domain containing the smaller domain | Function overriding via inheritance |
Thus, we have seen how Pāṇini anticipates modern object oriented programming techniques through his masterpiece. This is just a scratch on the surface but I hope I have whetted your appetite enough to explore more.
Authored by Rama Seshan Chandra Sekaran. Published by Brhat.