Hello everyone!
I would like to share with you a project related to NARS that I have completed over the past two months - the Rust implementation/reproduction of OpenNARS 1.5.8, also called NARust 158.
This announcement will include three sections: background, overview, and experience. If you want to "install and play" directly, you can jump to the Overview section.
In 2022, I began reading Dr. Wang's GTI and found OpenNARS, ONA, NARS-Python, and PyNARS through opennars.org. While playing with the demos of OpenNARS and ONA, I became interested in NARS as an open, real-time, autonomous, and most importantly, 'playable' intelligent system. Using my Python programming skills, I made my first contribution to the NARS project by writing an enhanced terminal ConsolePlus for PyNARS.
(ONA demos, which I've played before)
Then I began to wonder: What would happen if different versions of NARS could communicate with each other? If the same demo can easily switch between multiple NARS versions, what interesting differences Following this issue, I noticed the inconsistency in the format among different NARS versions, so I thought about standardizing the input and output between NARS versions and creating a universal interface that is independent of specific NARS versions. Combining my familiarity with Julia and TypeScript, I developed JuNarsese, NAVM.jl, and BabelNAR.jl, and finally utilized a Flash game I wrote in junior high school to create the simulation environment Matriangle.
(Matriangle and OpenNARS)
(Matriangle and ONA)
After that, when the progress on Matriangle stagnated and did not produce interesting results for a long time, I realized that studying NARS only on the surface is far from enough for research, experimentation, and application of NARS. Only by delving deeper into the internal mechanisms of NARS (especially the core) can one truly understand the system's mechanism. Coincidentally, I had the honor of obtaining the latest version of "NAL" from Dr. Wang and was inspired by Changxin Sun's work on OpenJunars, so I naturally turned to the study of NARS on the logic and control levels.
Considering that Julia lacks support for static AOT (Ahead of Time) compilation (generating standalone executables like ONA), I turned to the relatively 'modern' system-level language Rust, which I found to be very suitable for me in terms of programming features and development ecosystem. I started learning Rust in February this year and rewrote JuNarsese (Narsese.rs), NAVM, and BabelNAR from March to April.
At first, I hoped to write a version of NARS entirely based on my own understanding, but I found this to be unrealistic: compared to the description in NAL and the source code of OpenNARS and PyNARS, my understanding of the internal mechanisms of NARS was far from enough; the program writing also stagnated at a certain step, and I couldn't figure out the overall structure and direction of effort. After consulting more materials, I stopped the initial programming and planned to reimplement an existing version of NARS first.
After soliciting opinions from various parties, I chose the relatively stable version - OpenNARS 1.5.8 - with simpler code, and completed the annotations with notes for this "Declarative Core" from May to July. At the same time, I named the Rust version I wrote NARust 158, representing the NARS implementation it is based on.
Now, NARust 158 has basically completed the basic replication of OpenNARS 1.5.8, and while incorporating some of the better designs from OpenNARS 3.x (such as derivation contexts), it has also added some of my unique understandings of NARS (such as the summary of the control mechanism "Direct Inference, Transform Inference, Matching Inference, and Concept Inference" four major processes).
At present, this Rust implementation has passed all the tests that the original version of OpenNARS 1.5.8 can pass on the OpenNARS test suite, and even surpassed the original in some tests - which is enough to prove that this NARS implementation has achieved the goal of "reimplementing OpenNARS 1.5.8" in terms of reasoner functionality.
Dedicated to all NARS researchers.
If you want to directly experience the complete system, you can directly visit this online demo
(the surrounding functions of the website are not yet complete and are still under development).
At the same time, the project has been open-sourced on GitHub, and detailed English documentation can be found here.
(The documentation includes project introduction, comparative testing, and more!)
With apologies, the source code comments and documentation are mostly written in my native language. Speakers of other languages may need some translation tools.
In the process of writing this Rust version of NARS, I have also gained a lot of knowledge about NAL and control mechanisms.
In terms of NAL, compared to before writing this system, my understanding has increased from "deductions, abductions, and inductions" to "weak inferences, backward inferences", as well as "syllogistic rules, structural inferences, and compositional rules". I have learned about the whole picture of "Eternal Knowledge Processing" related to NAL 1~6, which will also prepare me for the next advanced NAL 7~9 layers.
In terms of control mechanisms, compared to before writing this system, I have a deeper understanding of "semantic relevance principle", "constant time in 1 cycle principle" and other content, and I also understand the design principles of "Term-link", "Task-link", "Bag", "Concept" and other structures. With this knowledge, I am confident that I can provide a complete version of NARS.
To go further, this new version of NARS is also a reorganization of the existing OpenNARS 1.5.8. The logic that was not very clear or slightly cumbersome in the original OpenNARS 1.5.8 (for example, pattern matching based on link types) can become more readable and understandable with Rust's pattern matching, tuple types, sum types, etc. I also hope that I have done a valuable job in this regard.
Finally, I would like to thank all the researchers of the NARS team. Without their foundation and guidance, I could not have made such valuable work. I hope that this project can play its unique role and make its own contribution to the NARS project and the OpenNARS community.
Comments and discussion are welcome!