Hello everybody!
I wanted to share with you the
project I have been working on over the last 2 years.
When I first got interested in NARS I started by experimenting with OpenNARS and ONA, trying to understand how they function. I eventually got the book by Dr. Wang and began reading it to try and get a deeper understanding. A year and a half ago at a NARS workshop in San Francisco I saw Christian Hahm present his experiment with MNIST using his Python implementation. And he probably doesn’t remember this but at one point during the presentation he asked a question: “why make another NARS implementation?” And then proceeded to answer it himself — because this is the best way to learn. It is funny how an off-hand comment like that can have an impact beyond the original intention. I decided then that to really learn about NARS, I needed to try and build it myself.
They say the best tool is the one you know how to use, and when it comes to programming languages, Swift is the one I know best and that’s what I chose. It isn’t to say that it is better than other languages, but it does have some nice features that I’ve grown to appreciate. One of the things it allows you to do is define custom operators and in the context of Narsese it seemed natural to define copulas and compound connectors as operators to make expressing Narsese terms more natural in the code. So for example, `bird -> animal` is not only valid in Narsese but can also be a valid Swift expression at compile time. It is similar to, and was partially inspired by, the work Patrick Hammer did in ONA with his rule language. In NARS-Swift the idea is taken even further.
The other inspiration came from the original NARS implementation in Prolog. Rule based languages are a natural fit for the logic of NARS but if my Java and C skills are so-so, when it comes to logic programming, I am completely lost. Thankfully, a friend told me about miniKanren which is similar to Prolog in some ways (and different in others) but most importantly it is not designed as a standalone language, but as a DSL to be embedded in other host languages. And now that I had Narsese embedded in Swift it seemed natural to continue this nesting further and use another embedded language to do the logic processing. So similar to NARS Prolog, rule application is handled by a specialized language and the thing I had to figure out is how to translate between them.
I learned a lot while building the system, through many iterations and testing. I want to say thank you to everyone who helped answer my questions on this mailing list and helped me in my learning journey.
As it stands, the system is not complete, b
ut I am happy with its current state. There is still work to be done with temporal reasoning as well as goals and operations. If you like to check it out, I recently added an online demo which is made possible by compiling the code to WebAssembly and running it entirely inside the browser.
It was a long time coming and I hope you find this useful in some way, I know I did! Let me know your thoughts and comments and have a great day!
Maxim