MORK spaces - trueagi-io/PeTTa GitHub Wiki

MORK spaces can be manipulated the same way as other atom spaces in MeTTa code, however are more scalable and provide additional machinery for efficient space-wide operations invoked via MM2 expressions.

Installation

First install and compile MORK main branch: https://github.com/trueagi-io/MORK/wiki/Getting-started

Install it in the same parent folder as where PeTTa is installed, e.g.

myprojectfolder/PeTTa
myprojectfolder/MORK

Then in PeTTa execute: (only tested on Linux thus far)

sh build.sh

Now one can try an example with MORK spaces via:

sh run.sh ./examples/zmorkspaceexec.metta

Usage

;Adding to MORK space that sam is friend of tim:
!(add-atom &mork (friend sam tim))

;Adding MM2 code to MORK space to transform friend to enemy relations:
!(add-atom &mork (exec 0 (, (friend sam $x))
                         (O (- (friend sam $x))
                            (+ (enemy sam $x)))))

;Execute one MM2 exec step:
!(mm2-exec &mork 1)

;Query who sam is freund with:
!(match &mork (enemy sam $x) $x)
;tim

From Python

./PeTTa/python/myexample.py:

from petta import PeTTa

runner = PeTTa()
runner.process_metta_string("""
!(add-atom &mork (friend sam tim))

!(add-atom &mork (exec 0 (, (friend sam $x))
                         (O (- (friend sam $x))
                            (+ (enemy sam $x)))))

!(call (mm2-exec &mork 1))

!(match &mork (enemy sam $x) $x)
""")

print(runner.process_metta_string("!(match &mork (enemy sam $x) $x)"))

Run example from ./PeTTa/python/ folder with:

LD_PRELOAD=../mork_ffi/target/release/libmork_ffi.so python3 myexample.py