-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal MeTTa interpreter fixes and optimizations #429
Conversation
This implementation calls interpret() function inside directly which is not a minimal MeTTa way. The proper way is to implement it in MeTTa using pure interpret() and collapse() function. Less proper way is to return `(interpret $atom %Undefined% <space>)` from grounded Assert...Op operation. But current implementation is added to quickly migrate to the minimal MeTTa interpreter.
Add standard atoms collection into C API and use it in Python API to check the equality with predefined atom.
In case of function call empty result means the function is not defined on the passed arguments. Thus the whole branch is removed from the plan. In case of tuple call empty result means there is no function which matches this tuple. Thus original tuple is returned as a result.
This corresponds to the core functionality implemented in a previous version of the interpreter. When function definition cannot be found the atom is returned as is. Two major use-cases are type constructors (which are usually have no definition only type declaration) and partially defined functions (which return results on some arguments and stay non-reducible on others).
Use if-equal to check equality of atoms instead of matching as matching doesn't work for variable types. Add return type checking step into interpret-args function.
Now empty vector returned from GroundedAtom means value of the unit type Void. Thus returning empty collection should be interpreted as Empty.
Remove unnecessary cloning, bindings merge, bindings application. Add separate branch without cloning for the typical case with single result.
This is to make tests for the old interpreter green again.
Added Unfortunately I see the result of execution from old Python repl and new Rust repl are different. For instance the Nil's example:
returns |
Ok, I have found the root cause: in Python interpreter |
06abf9a
to
5f96b07
Compare
Test fails because stdlib is not loaded. In minimal MeTTa case it is critical because stdlib contains interpreter's implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks convenient to start playing with Minimal MeTTa
Merging it after confirming with @Necr0x0Der and @luketpeterson |
Next batch of minimal MeTTa related fixes and changes:
minimal
feature is added to switch core library to the minimal MeTTa interpreter at compile time, one can run Rust unit tests usingcargo test --features minimal
match
is renamed tounify
because previousmatch
definition has different order of arguments and thus incompatible with new one, oldmatch
is added into minimal MeTTa standard libraryassert...
,collapse
,superpose
,let
andlet*
,case
,match
andpragma!
are added into minimal MeTTa standard library, some of them are added as grounded atoms because they require the working atomspace to evaluate arguments which is not implemented yetVoid
is added as a result ofassert...
operation, this is to handle Chaining of functions with side effects with guaranteed order #390 in minimal MeTTaNotReducible
is returned instead ofEmpty
by minimal MeTTa interpreter when function definition is not found. This corresponds to the previous interpreter's behavior. Two major use-cases are type constructors (which are usually have no definition only type declaration) and partially defined functions (which return results on some arguments and stay non-reducible on others).chain
operation is added andchain
implementation is optimizedBetter to review commit by commit.