Thursday 18 April 2013

Bits and Bytes

In the Spring of the year 1985, a NASA scientist by the name of Rick Briggs, working at Roacs-NASA Ames Research Center(California), composed and presented an article by the name of "Sanskrit and Artificial Intelligence" for AI Magazine, published by NASA. Needless to say, C++ was still in its naive form by then, JAVA still hadn't arrived, and programmers were having a real tough time trying to deal with the machine-like computer languages in mnemonic codes.

In simpler terms, Mnemonic codes are part of Assembly Language, which comprise of operations like ADD(to add), SUB(to subtract), etc, which a computing machine can understand. Even to perform simplest of calculations in series, people were still feeding in scores of mnemonic codes, which they could neither comprehend nor understand properly. The Mnemonic codes formed a part of low level language and were completely different from the natural languages which humans speak or understand.
The search for a comprehensive programming language which would be compatible with natural languages was still on. C/C++ had provided glimpses of hope, albeit after years of research and money being pumped into it. Mr Briggs commented that the scientists have got beaten heavily by some 2,600 years in  being able to develop semantics for such a programming language, when a certain Indian sage, by the name of Panini, belonging to 7 BC, had all the answers to the problems the scientists were facing. Now why would Rick Briggs, a NASA scientist, claim such a thing? Had he found certain elements in Panini's work which compelled him ascertain such a notion?

Namaste and welcome to the eighth post of this blog. This post, like all the previous ones is indeed very special, but more so, because I personally found it the toughest to compose till now. I really hope you guys like it much more than all of the previous posts.

Panini was the man who designed the entire grammar for Sanskrit. The semantics, which comprise of some 4000 rules in total, are so scientific and logical in nature, that it could very well be the baseline of structures used by various computer scientists. Panini composed a book by the name of Ashtadhyayi which comprise of exhaustive set of rules for Sanskrit Grammar. The grammar is based purely on mathematical and algebraic algorithms, and is powerful enough to be used to model a generator, which could churn out the rules for languages like Chinese or Thai.


Alright enough of the theory, time for some practicals. Lets take up certain concepts of modern day computer programming and see how well they match up with the rules of Panini's Sanskrit.

Database and Metadata: In layman terms, Database is a collection of data. Raw data is meaningless. Metadata, in programming terms, means data about data. In other words, raw data, which is meaningless as such, assumes meaningful patterns and collection when metadata is applied to it. Panini's Sanskrit, in the form of 4000 rules, form four compact databases. Aksharasam Amanaya, Sutrapatha, Datupatha and Ganpatha are the databases of Sanskrit, and the metadata are the rules contained within these databases.

Recursion: Those who are not aware, recursion is a process of repeating items in a self-similar way. In computer programming, whenever a method call is made from within the method itself, it is called recursion
The picture below would explain recursion better
It is interesting to note that Panini has extensively used recursion in Sanskrit grammar. Each of the 4000 rules are called Sutras, and each complete word to define those rules was called Pada. Panini did not use all the Padas in a Sutra to fully explain the Sutra. He, at times refers to previous Sutras where the Pada has already been defined or used (method invocation). There are instances when Panini has called a Sutra from within itself to refer to the Pada.

मार्जारः श्रावितृ मूषकम् अपश्यत् (The cat, who hears, saw the rat)

Here there is a recursion of मार्ज(The Cat). May sound easy now, but think of it as a semantic being composed 2600 years ago

Arrays and null values: Panini has defined a term called Lop, which would be equivalent to Null. A null can be assigned to a variable, or a pada in Sanskrit, and then used for simple Array operations in Sanskrit like Join(Sandhi in Sanskrit). A number of array joins can result in a complex term, which again can be broken down(disjoint). The below example shows A simple Sanskrit word as three distinct String arrays with Null
नमःस्तुते = न             मः           लोपः           स्                तु             लोपः         ते
             S1[0]     S1[1]         Null            S2[0]          S2[1]       Null           S3[0]

Polymorphism: Literally, polymorphism simply means one word having more than one meanings. My software industry friends would understand better, but the below image can be of help for the others.

If "cut" is called, it maybe for a surgeon, hair stylist or an actor. A single action can mean different to different audience.
लम्बोदर: could mean A person with big Stomach, and could also mean Lord Ganesha. The user of the word has the freedom to define the meaning of the word in his context(run time polymorphism)

Distributive Law(Inheritance and Sets):  Panini used Brevity extensively in his Sanskrit Grammar rules. Consider this:
सुरेश: विपणिं गच्छति : Suresh went to the market(Suresh(s)Market(b))
सुरेश: त्रिचक्रिका क्रयक्रीत Suresh bought a cycle(Suresh(s)Cycle(b))
Suresh went to the market, brought a cycle(s(a+b))


Conditional Prgramming(If-Then-Else): Panini had made strict rules when two words were being joint or disjoint. At times, it would happen, that these rules may conflict. He again had a set of conditional statements, as per which every time there was a conflict, some rules can "block" other rules based on certain conditions

If X then Y(माथरा कौनदिन्य: न्याय: )
If X then Y else Z(तक्र कौनदिन्य: न्याय: )
If(not X) then Y(निसेधा)
If X then(Y and Z) (विभास: )

And the similarities, rather derivations dont end there. Sanskrit grammar has full support of multiple inheritance, function overloading, data abstraction, transformations...the list is endless. If certain scientists at NASA, and in India are to be believed, Sanskrit could very well be the language for all future communications, including interstellar communication. With hopes that one day this may be true, I would like to bring my post to an end. At some later time, I would wish to pick up the remaining of the software programming paradigms and their Sanskrit origins. But, as of now, I would love to know what you felt about this post.

Coming up with a book based on Indian history/mythology.
Please join the Facebook page and invite others as well to do the same.
Please help me promote the book and the page and make it a huge success.

Please click here and like the page which comes up - Finders, Keepers

If you are on Facebook and are interested in such topics, please click on the link below and like the page which comes up.
Rediscovering India

Goodbye and Namaste!!

References:
1.) R. Briggs, 1985, “Knowledge representation in Sanskrit and artificial intelligence", AI Magazine, vol.6,pp. 22-38.
2.) The methods used inside the ashtadyayi is similar to today's arrays, inheritance (including multiple inheritance), polymorphism, etc. used in OOPS - Reference: Recent Research in Science and Technology, 2011, 3(7): 109-111,  ISSN: 2076-5061, www.scholarjournals.org
3.) Ashtadyayi Reference: http://avagraha.wordpress.com/
4.) Panini's Ashtadhyayi A Computer Scientist's viewpoint by Amba Kulkarni, 3096420, http://www.academia.edu/
5.) Maharshi Panini : The Father of Computer Programming !!! http://asciencecalledhinduism.blogspot.in/2013/03/blog-post.html

29 comments:

  1. Replies
    1. Namaste Prabal!!
      Thanks a lot for the reply

      Delete
  2. Interesting indeed. Eagerly waiting for another post on similar lines (As suggested towards the end of post)

    ReplyDelete
    Replies
    1. Thanks a lot Rohit!!!
      I will try to bring up the further programming concepts in subsequent posts

      Delete
  3. Read entire article breathlessly. In the times prior to C or OOPS, there used to be lot of excitement about this. Many of us were proud of declarations by many scientists and engineers alike about sanskrit being most suitable language for interacting with the otherwise dumb machine called computer. However, the voice and excitement thereof not only dampened gradually, it died all of a sudden. Thanks for reminding and thanks for trying to bring back the focus on the subject. Great work ! But I suggest you to continue the work and if possible try to give it shape of a Book.

    ReplyDelete
    Replies
    1. Namaste Sandeep!!!
      Thanks a lot for liking it this much!!!
      I really hope people take a cue out of it, and start taking these concepts seriously enough.

      THanks a lot sir, for your appreciations!!

      Delete
  4. Read entire article breathlessly. In the times prior to C or OOPS, there used to be lot of excitement about this. Many of us were proud of declarations by many scientists and engineers alike about sanskrit being most suitable language for interacting with the otherwise dumb machine called computer. However, the voice and excitement thereof not only dampened gradually, it died all of a sudden. Thanks for reminding and thanks for trying to bring back the focus on the subject. Great work ! But I suggest you to continue the work and if possible try to give it shape of a Book.

    ReplyDelete
    Replies
    1. Seems to be multiple similar comments, these

      Delete
  5. nice article...the research and the explanation are great..
    keep penning

    ReplyDelete
    Replies
    1. Namaste mk!!
      Thanks a lot for appreciating the post!!!!

      Delete
  6. Veryyyyy good blog... Good effort... Truly useful one for developers and students! :)

    ReplyDelete
    Replies
    1. Namaste and Thanks a lot for liking this post

      Delete
  7. This is so pointless. I'm a mechanical engineering student currently and I've taken quite a few programming courses, and this seems retarded. Sorry.

    ReplyDelete
    Replies
    1. Namaste!!
      Though I would have loved had this post not being made anonymous. But, I am sure a lot of mechanical engineering students who have taken up programming courses would not find it retarted. Thanks

      Delete
  8. Dear Saxena,

    A very good insight and study by you.

    ReplyDelete
  9. Dear Saxena,

    A keen study and analysis by you.

    ReplyDelete
    Replies
    1. Namaste!
      Thanks a lot for reading through the entry and liking the post

      Delete
  10. First off.. Good article.

    with reference to the book itself, ashtadyayi itself is ashtanam adhyayaanam samaharaha: as in the joining of 8 chapters, dealing with the 4 padarthas.. a complete trestise on a language to be adapted as need be!

    ReplyDelete
    Replies
    1. Namaste Varun!!
      Ashtadhyayi, the first ever book on Grammar itself surely deserves more recognition than it has got till now. I hope with more international focus, the treatise will earn the respect it deserved

      Delete
  11. Great article Sapan :)

    i am more interested in sanskrit now

    ReplyDelete
  12. You changed my understanding of sanskrit as a language.. looking forward for more insights :)
    Thanks for this

    ReplyDelete
  13. I didn't understand how there is a recursion in "मार्जारः श्रावितृ मूषकम् अपश्यत्"

    Could you please explain?

    ReplyDelete
    Replies
    1. The sentence starts with Marj, the cat, and while we are forming it up, it refers back again to the start of the sentence when it encounters "who hears", to get the reference.
      Again it goes back to the start of the sentence to get the reference of the cat.

      Delete
  14. I was wondering what was it that made Sanskrit different from other languages..realized that while most languages started off in rudimentary form and over generations evolved in a haphazard manner, Sanskrit was the product of brilliance of one single man called panini..thanks for such a wonderful post!
    -Deepti

    ReplyDelete
  15. Amazing post !!
    I was skocked to know that sanskrit is the suitable language for computer programming .
    Manner you analyze the facts was fantabulous . Good Going Great Job !!

    ReplyDelete
  16. Totally Shocked!!!!
    The way Sanskrit is analysed with respect to the logics and concepts of programming is just adorable...!!
    Thank you SAPAN SAXENA

    ReplyDelete