Giri retweetledi

Two Sanskrit texts composed over 2,000 years ago are formal computational systems in everything but name. Pāṇini wrote a compiler. Bharata specified a state machine. Both have been taught as literature for two millennia. They should be taught for what they are to get today's generation to take an interest in learning these texts.
1. The AṢṬĀDHYĀYĪ as COMPILER
Pāṇini's meta-rules (paribhāṣā) govern rule application. His conflict-resolution principle vipratiṣedhe paraṁ kāryam (the later rule wins) is precedence ordering. Anuvṛtti operates as variable scoping and inheritance. The pratyāhāra system is a compression algorithm.
The śivasūtras are a hashing scheme. Fourteen sūtras list all phonemes, terminated by anubandhas (markers). Any contiguous subset is named by [first phoneme + terminating anubandha]. "aC" is all vowels. "haL" is all consonants. "yaṆ" is semivowels. This is pointer arithmetic over a sorted array. Kiparsky and later Wiebke Petersen showed the encoding is optimal for the natural classes Pāṇini's grammar requires.
The tripādī (the last three pādas of book 8) is asiddha. Rules in this section are treated as not having applied with respect to earlier rules. This is two-pass compilation. Transformations are deferred until a later phase, and earlier rules cannot see their output. Pāṇini needed this to handle sandhi without circular dependencies.
The lakāra system (laṭ, liṭ, luṭ, and the rest) is abstract syntax. The ten lakāras are placeholders substituted by actual personal endings via later rules. Deriving bhavati runs through ordered passes: bhū + laṭ, then laṭ substitutes to tip (3rd person singular), tip substitutes to ti, guṇa and subsequent ava-ādeśa yield bhav-, sandhi closes to bhavati. An AST lowered to surface form through ordered transformation passes.
The utsarga-apavāda relationship, with the principle that the specific rule blocks the general, is method dispatch with specificity ordering. CSS works the same way. So does Prolog.
The ekasaṁjñādhikāra (one designation at a time, governed by 1.4.1-2) is a type system with disambiguation rules. Sthānivad-bhāva (1.1.56) states that a substitute behaves like the original for subsequent rules except where excluded. This is inheritance with override semantics.
These observations build on work by Frits Staal, Paul Kiparsky, Wiebke Petersen, and most recently Rishi Rajpopat (2022).
English


















