udexon / SAIGON

SAIGON: Stack Machine Artificial Intelligence Graph Object Notation
5 stars 1 forks source link

RPN is not good data representation #1

Open ponyatov opened 5 years ago

ponyatov commented 5 years ago

FORTH-like languages and RPN are the best and most simple to implement command and DDL/DML language model, but not good data representation. Did you see on using object graphs as a more human-friendly and rich data model?

Humans think in schemes, and computer reasonable good in graph processing, so it looks more suitable to use objects graphs, for example, Marvin Minsky frames model is very very close to modern programming languages and can be implemented natively.

ponyatov commented 5 years ago

As a sample of frame model used for FORTH-like system I can show this source: https://github.com/ponyatov/metaL/blob/master/metaL.py

The base Frame class works as a universal data container and virtual machine (any data can have arbitrary attributes, and can act as an executable data structure). I took Minsky's model and extended it with the ability to store data in order to be able to use it as a universal knowledge representation stricture. For example, source code in any programming language can be parsed into attribute grammar and represented in a unified object graph.

I use this frame model as a base engine for Forth-like language (Android port in slow progress) but there is no limit on adding more classes for graph node types, for example, N-ary relations from Prolog.

udexon commented 5 years ago

Do you have screenshot and examples?

Interesting ideas.

On Mon, Sep 16, 2019, 14:51 Dmitry Ponyatov notifications@github.com wrote:

As a sample of frame model used for FORTH-like system I can show this source: https://github.com/ponyatov/metaL/blob/master/metaL.py

The base Frame class works as a universal data container and virtual machine (any data can have arbitrary attributes, and can act as an executable data structure).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/udexon/SAIGON/issues/1?email_source=notifications&email_token=ABYMUTH64KA65EUPNQHZ2SDQJ4UIDA5CNFSM4IW6MD4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6YH36I#issuecomment-531660281, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYMUTDQAQNR3TRK4YNFXELQJ4UIDANCNFSM4IW6MD4A .

ponyatov commented 5 years ago

You can test the Android app on play: https://play.google.com/store/apps/details?id=io.github.ponyatov.mlforth and view some sources in Java: https://github.com/ponyatov/mlFORTH/tree/master/app/src/main/java/io/github/ponyatov The last update with calculator functions is still in checking before publication, it will be ready a few hours later.

I did some very primitive visualization in Python version but found some unpredicted errors. I'll fix it in a few days if I will have time to do it, but there is nothing special more then directed graph with every slot/attribute name on every edge. You can implement it yourself with a preferred plotting library, looking into Frame class sources and wiki:

ponyatov commented 5 years ago

In Google Play you can see the screenshot which shows a state of a single VM instance -- it has almost no difference from the base Frame class. So, any Frame factically a FORTH stack machine which combines data stack in nest[] and vocabulary in slot{}. The parser uses PLY library in Python version and a simple Ragel-based parser in Android/Java.

Now I'm focused on making on-device scripting app for use on my mobile phone I have in a pocket all the way. In the current stage, it is stack calculator uses objects (frames) as a primitive data element, now it is able to do simple math and radix conversions (which I need every day 8-).

Next step is making control structures definitions in a form of nested frames tree, and visualization mode to view parts of a knowledge database as a directed graph. I still has no idea what library can I use in place of graphviz 8-\

ponyatov commented 5 years ago

While I have no viz module, every frame can be dumped in a tree form, the main screen shows the current VM which interacts with the user as a FORTH shell. I do not figured yet how to make it scrollable, so in the current release, I enabled only nest/stack dump. A few time later I'm going to split VM dump onto two slidable activities -- stack only, and full dump. Or the app menu can be used to trigger the mode it works.

With this unified frame dump I can't discard of using frame model/engine in any software I'm writing. It is very comfortable to get VM state/stack dump after any command execution in console REPL. I just see what I have in a stack, and run next few words -- I already voted on your RPN use, but specifically as a shell/command language. The system also can be dumped/initiated from some .ini file in FORTH-like syntax -- it still stays human-readable, and parser very simple and works faster than any JSON/Python/etc data languages (recursive infix syntax eats computing resources and memory to store parser stacks, FORTH works in a straight line single pass without any caching structures).

udexon commented 5 years ago

Do you have sample code for testing?

What are the results?

Screenshots?

I keyed in some code but there was no results nor errors.

On Mon, Sep 16, 2019, 20:43 Dmitry Ponyatov notifications@github.com wrote:

While I have no viz module, every frame can be dumped in a tree form, the main screen shows the current VM which interacts with the user as a FORTH shell. I do not figured yet how to make it scrollable, so in the current release, I enabled only nest/stack dump. A few time later I'm going to split VM dump onto two slidable activities -- stack only, and full dump. Or the app menu can be used to trigger the mode it works.

With this unified frame dump I can't discard of using frame model/engine in any software I'm writing. It is very comfortable to get VM state/stack dump after any command execution in console REPL. I just see what I have in a stack, and run next few words -- I already voted on your RPN use, but specifically as a shell/command language. The system also can be dumped/initiated from some .ini file in FORTH-like syntax -- it still stays human-readable, and parser very simple and works faster than any JSON/Python/etc data languages (recursive infix syntax eats computing resources and memory to store parser stacks, FORTH works in a straight line single pass without any caching structures).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/udexon/SAIGON/issues/1?email_source=notifications&email_token=ABYMUTAUF4HBOAMX5R6MZR3QJ55QPA5CNFSM4IW6MD4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ZAKWI#issuecomment-531760473, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYMUTESZ6MSNQJRC5DQOGLQJ55QPANCNFSM4IW6MD4A .

ponyatov commented 5 years ago

I'll inform you when I'll get noticeable results in knowledge representation or other AI-related stuff. Now it is a very simple scripting engine can't be treated seriously especially in comparing with mainstream programming technologies. I just wanted to share the data model good for homoiconic systems design.

ponyatov commented 5 years ago

As an example, this code is written in RPN notation (not FORTH but something close) which produces homoiconic graph data structure which represents a minimalistic system -- a single VM with few constants, few executable commands (implemented in Python as a carrier language/runtime) and a Web server node.

https://github.com/ponyatov/cpds/wiki/module-spec

udexon commented 5 years ago

Interesting.

What is next?

On Tue, Sep 24, 2019, 17:18 Dmitry Ponyatov notifications@github.com wrote:

As an example, this code is written in RPN notation (not FORTH but something close) which produces homoiconic graph data structure which represents a minimalistic system -- a single VM with few constants, few executable commands (implemented in Python as a carrier language/runtime) and a Web server node.

https://github.com/ponyatov/cpds/wiki/module-spec

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/udexon/SAIGON/issues/1?email_source=notifications&email_token=ABYMUTGBVVHLNVTOWKTCT3DQLHLO3A5CNFSM4IW6MD4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7NWETA#issuecomment-534471244, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYMUTEJDMR5C6RJQXRQPNTQLHLO3ANCNFSM4IW6MD4A .