Skip to content

Instantly share code, notes, and snippets.

@okram
Last active May 8, 2020 11:10
Show Gist options
  • Save okram/1c45a65490dab55efa1d71fb3620d857 to your computer and use it in GitHub Desktop.
Save okram/1c45a65490dab55efa1d71fb3620d857 to your computer and use it in GitHub Desktop.
mm-ADT [http://mm-adt.org]
This is a demo of the [trace] instruction which exposes
the core data structure of the mm-ADT VM (obj trace graph).
Unfortunately, it will be difficult to understand without knowing how polys and types work in mm-ADT.
However, for those competent with Gremlin/TinkerPop (TP3),
the examples below are like path().by(), but for both types and values.
///////////////////////////////////////////////////////////////////////////////////////////////////////
mmlang> int[plus,2][mult,3] // standard type
==>int[plus,2][mult,3]
mmlang> int[plus,2][mult,3][tracer] // the type's trace back to the int ctype
==>[int/[plus,2]/int/[mult,3]/int/[tracer,[/]]]<=int[plus,2][mult,3][tracer,[/]]
mmlang> int[plus,2][mult,3][tracer,[_|_]] // provide a poly to trace and it process segments accordingly
==>[int//int//int/]<=int[plus,2][mult,3][tracer,[|]]
mmlang> int[plus,2][mult,3][tracer,[[is,false]|_]] // only the instructions/edges of the trace
==>[/[plus,2]//[mult,3]//[tracer,[[is,false]|]]]
mmlang> 1,2,3[plus,2][mult,3] // int values being processed
==>9
==>12
==>15
mmlang> 1,2,3[plus,2][mult,3][tracer] // the value trace back to root
==>[1/[plus,2]/3/[mult,3]/9/[tracer,[/]]]
==>[2/[plus,2]/4/[mult,3]/12/[tracer,[/]]]
==>[3/[plus,2]/5/[mult,3]/15/[tracer,[/]]]
mmlang> 1,2,3[plus,2][mult,3][tracer,[_|_]] // only the vertices of the trace
==>[1//3//9/]
==>[2//4//12/]
==>[3//5//15/]
mmlang> 1,2,3[plus,2][mult,3][tracer,[-<[[is>10]-->0|int-->1]|_]] // a more complicated trace poly for processing the vertices (branching the trace)
==>[[|1]//[|1]//[|1]/]
==>[[|1]//[|1]//[0|]/]{2}
mmlang>
@okram
Copy link
Author

okram commented May 8, 2020

slarko 4:52 AM

Okay, this is why polys are rad.
They will play the role of TP3 by() step modulators.
They will play the role of TP3 branch() , choose(), optional(), etc.
They are the means by which all pattern matching is done (match case).
They are how composite data structures will be encoded.
They are a direct mapping of the underlying stream ring algebra. (+ = / , * = \ , +[head] = |)

What is awesome is that both the obj trace graph (which includes both type and value traces) is a category (ObjTrace) and it commutes! That means, every path through the “diagram” (the trace graph) that lands on the same vertex yield the same result. This data structure/category will lay the foundation for all our compiler rewrites and optimizations. Furthermore, because it’s a category, you can “flip the arrows” (ObjTrace_Op). Guess what that is — reversible computing. You can go from input to output and output to input. Both ways commute. The mm-ADT VM will be responsible for dropping trace data that will not be used later in the program. This is our garbage collection story and it's very much like TP3's PathRetractionStrategy.

Finally poly is all about allowing developers to “lift” the type graph into mm-ADT so it can be computed on directly. And because polys map directly to the stream ring algebra, you can write mm-ADT in poly and compute with it — this is going to lead to very natural software reflection (more on this in the coming weeks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment