Thursday, April 26, 2018

The Sanskrit word for algorithm: Vṛtti वृत्ति


Red Mandala,  by the Flickr user GarlandCannon. A fine illustration of the swirling nature of Vṛttis, and of how they are recursively composed of each other.


What is the right word to describe an "algorithm"  in Sanskrit or in other Indian languages ?

There was an interesting discussion on Rajeev Malhotra's mailing group on this topic. I suggested the word "Vṛtti" वृत्ति (pronounced roughly as Vritti) as the equivalent word, following the use of Pāṇini in his Ashṭādhyāyi. I am sharing my (slightly edited) argument here in this blog.


On the equivalent word for an "algorithm", Prof. Kannan and Prof.Ramasubramanian suggested "Śaraṇī" सरणि (arrangement) which probably has previously been used by the Sanskrit mathematicians. Some others also  suggested "Kuṭṭaka" कुट्टक (iterative refinement) which was used by Āryabhaṭa.

But these suggestions ignore the historical trajectory of development of ideas in Europe. When Europe discovered the "Sind Hind" of Al-Khwarizmi, which is but a translation and commentary of Brahmagupta's works, it experienced a major transformation in how a rigorous mathematical procedure should be formulated. Instead of relying on "proof" by geometry as the ultimate arbiter, we have a series of precise instructions for "constructively" accomplishing a task. This is a computational method of thinking, instead of a geometric method of thinking. This important turn in scientific thinking is described in the works of Prof. Roddam Narasimha and Prof. C.K. Raju. In western academia, India has not been credited for this important scientific revolution. So why not call "Āryabhaṭam" instead of "Algorithm" ? We can refer to the far earlier original Indian procedures of Āryabhaṭa instead of the secondary ideas of the later scholar Al-Khwarizmi. As a computer scientist, I have seen no single textbook, museum or university discuss Āryabhaṭa. People can visit the computer history museum in Mountain View, CA to see how marginally these Indian ideas are presented. Unless Indian computer scientists demand it, this place in history will not be ceded to India.

However, the computational method in India is even earlier to Āryabhaṭa. We can definitely state that Pāṇini's methods for word derivation in language are precise algorithms. Not only that, Pāṇini's Ashṭādhyāyi anticipated many future developments in computer programming: Lambda calculus, encapsulation in object oriented programming, and even some ideas which may not yet have been implemented in computer programming ! In short, Pāṇini's methods have far more rigor and computational creativity than what reached Europe via Al-Khwarizmi. In India, Vyākaraṇa (grammar) was clearly the queen of the sciences. The scientific texts in every single discipline were shaped by the computational methods of Pāṇini and other grammarians.

The word that Pāṇini used to describe a precise computational instruction is "Vṛtti" वृत्ति. I suggest this nice paper by Paul Kiparsky for understanding how these computational instructions are given. (https://web.stanford.edu/class/linguist289/encyclopaedia001.pdf ) The objective of Pāṇini's Ashṭādhyāyi is greater than giving a series of instructions (algorithm) for one specific task. It is to produce a complete "generative model" for all the variations in language. In other words, he gives a set of algorithms for all possible tasks. This is known as a generative grammar, and it is only until Noam Chomsky's work that this is understood to be a precise equivalent to a Turing Machine. So in India, we started our computational thinking with a full Turing Machine, and not a half-baked idea like an "algorithm". 

The operational rules of "vṛtti" are of the form: A -> B (C_D). A is transformed into B, when it is enclosed between C and D. One such rule can encode a full algorithm. This is because the variables A, C and D can all be recursively defined using rules of the exact same form. It is an automaton or a state-transducing machine. As such, in my opinion, the word "vṛtti" वृत्ति has the full descriptive power of an algorithm. It is a short word and can be used to derive longer Sanskrit words to describe algorithms of different types and for different domains. Sanskrit is a very fecund language and many new words can be created for algorithm (e.g, Kalana-vidhi is perfectly fine), but we often forget (a) brevity and (b) importance of projecting the historical trajectory of ideas.

The understanding of "vṛtti" as a procedure for transformation is deployed in many other contexts. Patanjali uses this famously to describe the transformations of mental states : "Yōgas chitta vṛtti nirōdhaḥ". By using the word "vṛtti" he ties this understanding of human cognition to the computational methods of Pāṇini. Symbolism in Itihāsas like the ten heads of Rāvaṇa (more accurately, "daśa Kanṭha" or ten necks) is discussed by later philosophers as "daśēndriya vṛtti" (the transformations of mind owing to being bound by the sense-objects of the ten senses: 5 Jñānēndriya+5 Karmēndriya). Thus, we have a history of Indian scientists in psychology referring to the computational method of "vṛtti". It is only recently that such computational thinking has penetrated the cognitive sciences in "modern science". In India, we had it from the very beginning, owing to the importance of Vyākaraṇa and its computational methods.

The word "vṛtti" inherently refers to the cyclical understanding of time (vṛtta वृत्त = circle, or a metrical pattern of repetition). A transformative rule to a cyclical motion is obtained to setting up of secondary cycles e.g, through a gear mechanism. This is precisely how the mind is transformed by getting entangled in secondary motions owing to the sense objects. This understanding of Yōga is very ancient, even earlier to Pāṇini, going back to the Vēdas. Another word Pāṇini used is Pratyāhāra प्रत्याहार, as an equivalent for compacting of information, to refer to a larger group of variables on which the same computational transformation (vṛtti) can be applied. In Yōga, Pratyāhāra refers to withdrawing the mind away from the sensory objects i.e, moving towards the "Bindu" बिन्दु which is at the centre of the circle (vṛtta). These are very precise notions for encoding human-computer interaction (HCI), on which aspects of a computational system the user has to pay attention to. These ideas provide an alternative to the dominant discourse on artificial intelligence (AI, exactly equivalent to Vṛtti) and its relationship with HCI.

These ideas have germinated from the ancient philosophical bed of Sāmkhya साङ्ख्य.  In Sāmkhya, the objective reality of the universe is termed Prakṛti प्रकृति  and the experiencing self is termed Puruṣa पुरुष.  Of these two, Vṛttis belong exclusively to Prakṛti, resulting in all the manifold variation in space, as well as change in time. The evolution of Prakṛti according to these Vṛttis is termed Karma कर्म. However, Puruṣa is considered completely distinct from space and time, and thus independent of Vṛttis or Karma.  Thus, withdrawing into the Puruṣa, away from Vṛttis, is termed Pratyāhāra. The accumulation of Vṛttis raise the entropy of Prakṛti (which is referred to as Rajas रजस्  or dust), whereas Pratyāhāra results in lowering the entropy (or raising negative entropy, which is referred to as Sattva सत्त्व).  The inertia of not doing any action is termed Tamas तमस् (darkness or illusion). These three Guṇa गुण  (attributes/qualities) of Sattva, Rajas and Tamas provide the vocabulary for describing all the variation of objects in the universe (Prakṛti).

It will be unfortunate if we don't refer to this native tradition of computational thinking in India, when we coin new Sanskrit words for computer science.

Some related terms: 

Greedy algorithm: Lubdha vṛtti लुब्धवृत्ति
Branch & bound algorithm: Śākhā samyamita vṛtti शाखासंयमितवृत्ति
Recursive algorithm: Pratyāvarta vṛtti प्रत्यावर्तवृत्ति
Backtracking algorithm: Pratyāgaccha vṛtii प्रत्यागच्छवृत्ति
Algorithm for shortest path on graph: Alpiṣṭa jālamārga vṛtti अल्पिष्ठजालमार्गवृत्ति
Classification algorithm: Vargīkaraṇa vṛtti वर्गीकरणवृत्ति
Regression algorithm: Kramīkaraṇa vṛtti क्रमीकरणवृत्ति
Neural network: Mastishka Jāla मस्तिष्कजाल Majjāla मज्जाल
Neural net learning algorithm: Majjāla grahaṇa vṛtti मज्जालग्रहणवृत्ति
Path planning algorithm: Mārga yōjanā vṛtti मार्गयोजनावृत्ति

Further Reading: 

I wrote an essay in my blog on the Computational Sciences of the Sanskrit tradition, discussing the need to develop an authentic Indic perspective for computational thinking.

I am writing some essays for the website Pragyata, where I provide greater context for these ideas in the philosophy, symbolism and art of India.

The cosmic wheel  describes the nature of Ṛta ऋत (cosmic order).

The infinite lotus describes the nature of Ananta अनन्त  (infinity).

I am also writing some essays for the website IndiaFacts. Please follow me there for my essays on Indic knowledge.

* Some people have complained to me about the word "red pill". This word has recently acquired some annoying "manosphere" connotations, although my personal blog far predates all of this. It was just a silly reference to the then newly-released Matrix movies. I will keep this blog alive, but hopefully will move the important content to a personal website.