Tag Archives: gui

New pages of demos and dynamic visualizations of chemlambda moves

The following are artificial chemistry visualizations, made in d3.js. There are two main pages: the first is with demos for #chemlambda   reductions, the second is with dynamic visualizations of the graph rewrites.
Bookmark these pages if you are interested, because there you shall find new stuff on a day-by-day basis.

______________________________________________________

Living computations

What’s better than a movie? A live performance.

I just started new pages where you can see the last living computations with chemlambda:

  • a 20 nodes creature which I qualified previously as a quine, but is not, struggles to survive in a random environment (random reduction method) here
  • the reduction of the predecessor function from lambda calculus turned into a chemlambda reduction (random too) here
  • the self multplication of the S combinator in random conditions here
  • the reduction of Ackermann(2,2) in the  random model here (this is the one used for the video from the last post).
  • a complex reduction in chemlamdba. Here is the recipe:
    – you can write the Y combinator as an expression in the S,K,I, combinators: Y = S (K (S I I)) (S (S (K S) K) (K (S I I)))
    – so take this expression and apply it to the identity I. In combinatory logic this should reduce to something equivalent to YI, which then reduces forever, because it does not have a normal form
    -but we do something more funny, namely all this long string of combinators is transformed into a chemlambda molecule, and we add on top of it a node FO which makes all this big thing to self-reproduce.
    So, we have a bunch of reductions (from the long expression to YI) in parallel with the self-reproduction of the whole thing.
    Now, what you see is this, in a model of computation which uses a random reduction strategy!
    See it live here.

The sources are in this github repository.

_______________________________________________________________________

 

Mol language and chemlambda gui instead of html and web browsers gives new Net service?

The WWW is an Internet system, based on the following ingredients:

  • web pages (written in html)
  • a (web) browser
  •  a web server (because of the choice of client-server architecture)

Tim Berners-Lee wrote those programs. Then the WWW appeared and exploded.

The force behind this explosion comes from the separation of the system into independent parts. Anybody can write a web page, anybody who has the browser program can navigate the web, anybody who wants to make a web server needs basically nothing more than the program for that (and the  previously existing  infrastructure).

In principle it works because of the lack of control over the structure and functioning.

It works because of the separation of form from content, among other clever separations.

It is so successful, it is under our noses, but apparently very few people think about the applications of the WWW ideas in other parts of the culture.

Separation of form from content means that you have to acknowledge that meaning is not what rules the world. Semantics has only only a local, very fragile  existence, you can’t go too far if you build on semantics.

Leave the meaning to the user, let the web client build his meaning from the web pages he can access via his browser. He can access and get the info because the meaning has been separated from the form.

How about another Net service, like the WWW, but which does something different, which goes to the roots of computation?

It would need:

  • artificial molecules instead of web pages; these are files written in a fictional language called “Mol”
  • a gui for the chemlambda artificial chemistry, instead of a web browser;  one should think about it as a Mol compiler & gui,
  • a chemical server which makes chemical soups, or broths, leaving the reduction algorithm to the users;

This Mol language  is an idea which holds some potential, but which needs a lot of pondering. Because the “language” idea has bad effects on computation.

________________________________________________________

 

Walker eating bits and a comment on the social side of research

This post has two parts: the first part presents an experiment and the second part is a comment on the social side of research today.

Part 1: walker eating bits.  In this post I introduced the walker, which has been also mentioned in the previous post.

I made several experiments with the walker, I shall start by describing the most recent one, and then I shall recall (i.e. links to posts and vids) the ones before.

I use the chemlambda gui which is available for download from here.

What I did: first I took the walker and made it walk on a trail which is generated on the fly by a pair A-FOE of nodes. I knew previously that such a pair A-FOE generates a trail of A and FO nodes, because this is the basic behaviour of the Y combinator in chemlambda. See the illustration of this (but in an older version, which uses only one type of fanout nodes, the FO) here.  Part of it was described in the pen-and-paper version in the ALIFE14 article with Louis Kauffman.

OK, if you want to see how the walker walks on the trail then you have to download first the gui and then use the gui with the file walker.mol.

Then I modified the experiment in order to feed the walker with a bit.

A bit is a pair of A-FO nodes, which has the property that it is a propagator. See here the illustration of this fact.

For this I had to modify the mol file, which I did. The new mol file is walker_eating_bit.mol .

The purpose of the experiment is to see what happens when the walker is fed with a bit. Will it preserve its shape and spill out a residue on the trail? Or will it change and degenerate to a molecule which is no longer able to walk?

The answer is shown in the following two screenshots. The first one presents the initial molecule described by the walker_eating_bit.mol.

walker_eating_bit_step0
At the extreme right you see the pair A-FOE which is generating the trail (A is the green big node with two smaller yellow ones and a small blue one and the FOE is the big yellow node with two smaller blue ones and a small yellow one). If you feel lost in the notation, then look a bit at the description in the visual tutorial.

In the middle you see the walker molecule. At the right there is the end of the trail. The walker walks from left to right, but because the trail is generated from right to left, this is seen as if the walker stays in place and the trail at its left gets longer and longer.

OK. Now, I added the bit, I said. The bit is that other pair of two green nodes, at the right of the figure, immediately at the left of the A-FOE pair from the extreme right.

The walker is going to eat this pair. What happens?

I spare you the details and I show you the result of 8 reduction steps in the next figure.

walker_eating_bit_step8

You see that the walker already passed over the bit, processed it and spat it as a pair A-FOE. Then the walker continued to walk some more steps, keeping its initial shape.

GREAT! The walker has a metabolism.

Previous experiments.  If you take the walker on the trail and you glue the ends of the trail then you get a walker tchoo-tchoo going on a circular trail. But wait, due to symmetries, this looks as a molecule which stays the same after each reduction step. Meaning this is a chemlambda quine. I called such a quine an ouroboros. In the post Quines in chemlambda you see such an ouroboros obtained from a walker which walk on a circular train track  made of only one pair.

I previously fed the walker with a node L and a termination node T, see this post for pen and paper description and this video for a more visual description, where the train track is made circular as described previously.

That’s it with the first part.

Part 2: the telling silence of the expert. The expert is no lamb in academia. He or she fiercely protect the small field of expertise where is king or queen. As you know if you read this open notebook, I have the habit of changing the research fields from time to time. This time, I entered into the the radar of artificial chemistry and graph rewriting systems, with an interest in computation. Naturally I tried to consult as many as possible experts in these fields. Here is the one and only contribution from the category theory church.  Yes, simply having a better theory does not trump racism and turf protection.  But fortunately not everything can be solved by good PR only. As it becomes more and more clear, the effect of promotion of mediocrity in academia, which was consistently followed  since the ’70, has devastating effects on the academia itself. Now we have become producers of standardised units of research, and the rest is just the monkey business about who’s on top. Gone is the the trust in science, gone are the funds, but hey, for some the establishment will still provide a good retirement.

The positive side of this big story, where I only offer concrete, punctual examples, is that the avalanche which was facilitated by the open science movement (due to the existence of the net) will change forever the academia in particular. Not into a perfect realm, because there are no such items in the real world catalogue. But the production of scientific research in the old ways of churches and you scratch my back and I’ll scratch yours is now exposed to more eyes than before and soon enough we shall witness a phenomenon similar to the one happened more than 100 years ago in art, where ossified academic art sunk into oblivion and an explosion of creativity ensued, simply because of the exposure of academic painting along with alternative (and, mixed with garbage, much more creative artists) works in the historical impressionist revolution.

______________________________________________

 

Chemlambda quines and DNA pairs, speculation

I’m staring at this space view of the walking machine described first in this post:

walker_space_step0

The picture is a screenshot of the chemlambda gui available for download from this page.

The .mol file of the walker is available at this link.

What is this: is a walker as described in the ouroboros predecessor post, which walks on a train track generated by a y combinator pair A-FOE.

But the strange thing which makes me stare at the picture is that I see a hexagonal structure connected to a quadrilateral one, or I recall that I have seen such structures, see for example the following crop from this source.

nitro_basesSo it’s like the thymine-adenine pair (well, there is no pure adenine side, is only half of it).

Then, I recall seeing all these structures before with the space view, including the one representing the connection between guanine and cytosine, but I have to look at the files to recover them (I have plenty of mol files already, hundreds, I need to classify all the interesting stuff I learned).

Is this a coincidence or not? I don’t know, it is tempting to make the connection between quines in chemlambda, as it is the ouroboros, and self-mantaining molecules like DNA.

______________________________________________

 

The new look of the chemlambda gui, new downloads and a video demo of the space view

Here is a short video with a demo of the space view of chemlambda molecules and their interaction.

http://www.youtube.com/watch?v=ZPzsSpkl8Fw

 

At this link you can download the tar archive which contains the gui I play with. 

I would be grateful if as many as possible download it and spread it in as many places, not only google or other clouds.

Please send me a mail, or post a comment here if you did it, thank you! (mind that if it is your first comment then it is moderated, so don’t worry if it does not appear immediately, maybe I sleep or something like that)

It works surely with firefox, I have been told that it does not work with safari or chromium, because, I learned, those browsers don’t allow to open local files.

 

The Ackermann function in the chemlambda gui

UPDATE: in the collection of animations there are posts about the Ackermann function, like this one.

UPDATE: The Ackermann function, the video:

_______________________

I put this stuff on G+  some days ago and now I can find it only if I look for it on purpose. Older and newer posts, those I can see. I can see colored lobsters, funny nerd jokes, propaganda pro and con legacy publishing, propaganda hidden behind granpa’s way of communicating science, half baked philosophical ideas,  but not my post which I made only two days ago. On my page, I mean, not elsewhere.

Thank you G+ for this, once again. (Note not for humans: this was ironic.)  Don’t forget to draw another box next time when you think about a new algorithm.

A non-ironic thanks though for the very rare occasions when I did met very interesting people and very interesting ideas there.

OK, to the matter, now. But really, G+, what kind of algorithm you use which keeps a lobster on my page but deletes a post about the Ackermann function?

UPDATE: The post is back in sight now. Whew!
The post follows, slightly edited (by adding stuff).
The Ackermann function is an example of a total computable function which is not primitive recursive. It is therefore amusing to try to compute it.
The matter is not what is the value of Ack(m,n), because it grows so fast that very soon the problem of computing it is shadowed by the more trivial problem of storing its values. Instead,  more interesting is to see how your computing device handles the computation itself, things like stacks of calls, etc, because here it is manifest the fact that Ack is not primitive recursive.
To simplify it, the funny thing is to see how you can compute Ack(m,n) without any cheat.
I tried to do this with #chemlambda . I know since a long time that it can be done, as explained (very summary, true) in this old post
https://chorasimilarity.wordpress.com/2013/10/19/a-machine-for-computing-the-ackermann-function-in-graphic-lambda-calculus/
for GLC, not chemlambda (but since chemlambda does with only local moves what GLC does, it’s the same).
I want to show you some pictures about it.
It is about computing Ack(3,2). Everybody will point that Ack(3,2) = 29 and moreover that Ack(3,n) has an explicit expression, but this would be cheating, because I don’t want to use precomputed stuff.
No, what I want to use is a lambda calculus term for the Ackermann function (and one which is not eta reduced, because chemlambda does not have eta reduction!), and I want to apply it to the arguments 3 and 2 written as lambda terms as well (using the Church encoding). Then I want to see if after the reductions performed by the algorithm I have I get 29 as a Church number as well.
During all the algorithm I use only graph reductions!
After all there are no calls, no functions and during the computation the molecules which appear are not even representing lambda terms.
Indeed, lambda calculus does not have operations or concepts like fanin nodes, or FOE nodes, not reductions like FAN-IN or DIST. That’s the amazing point (or at least one of them), that even if it veers outside lambda calculus, it ends where it should (or better, that’s for another time).
I used the programs which are available at the site of the chemlambda gui http://imar.ro/~mbuliga/gallery.html
(which is btw online again, after 2 days of server corruption.)Here are some pictures.The first one is a screenshot of the Ack(3,2) “molecule”, i.e. the graph which is to be reduced according to the chemlambda rules and according to the reduction strategy which I call “viral”.
ack_3_2_init
After almost 200 reductions I get 29, see the second figure, where it appears as the molecule which represents 29 as a Church numeral.
ack_3_2_finalWow, it really worked!
You can try it for yourself, I’ll give you the mol file to play with, but first some details about it.
I modified a bit the awk script which does the reductions, in the following place: when it introduces new nodes (after a DIST move) it has to invent new names for the new edges. In the script which is available for download the algorithm takes the max over all all ports names and concatenate it with a word which describes where the edge comes from. It is good for being able to track back where the nodes and edges come, but it results into a growth of the ports name which is exponential in the number of iterations of the reduction algorithm. This leads to very big names of some ports, after 200 iterations.
So I modified this part by choosing a naming procedure which is less helpful for tracking but better in the sense that now the growth of names is linear in the number of iterations. It is a quick fix, after all it is as easy to invent naming procedures which result in a logarithmic or almost constant length wrt the number of iterations.
For the Ackermann function the script which is available is just as good, it works well, only that it has this unpleasant feature of long names which enlarges unnecessarily the json files.
Details over, next now.
In the third picture you see the mol file for the Ack(3,2), i.e. the list of nodes and ports of the Ack(3,2) molecule, in the format used by the reduction program.
ack_3_2_mol
Btw, do you see in this screenshot the name of the updated script? Right, is foe_bubbles_09_10.awk, instead of foe_bubbles_06_10.awk which is available for download.
I don’t cheat at all, see?
I made some annotations which helps you to see which part corresponds to the Ackermann function (as a lambda term translated into chemlamda), which parts are the arguments “3” and “2”, and finally which part represents the Ackermann function applied to (3,2).
ackermann_3_2_mol
Soon enough, when I’ll be able to show you animated reductions (instead of the steps of reduction only), I think such an example will be very funny to examine, as it grows and then shrinks back to the result.
________________________________________

 

 

 

Saved version for direct download of the chemlambda gui

It appears that the site which hosts my chemlambda gui is down. Here is a save of the the playall archive for the chemlambda gui. You may use it if the original site is down.  Instructions about how to use it in this video:

UPDATE: The site is up again here  and I made a second video with a gun which shoots in two directions

_______________________________________________

DNA, err… tape replication pictures

Here are the kind of pictures you can get by using the chemlambda visualizer.

UPDATE: Here the first video about it:

Continuing with the post

The first is a screenshot of the initial tape  with bits on it (the tape contains “1010” as an example):

tape_with_bits_0And here is what you get after 6 reductions done by the algorithm:

tape_with_bitsI’ll explain in a moment what I did.

First I wrote the   tape.mol file which represents the initial molecule.

Then I used  bash_main_viral_foe_bubbles.sh  which can be downloaded from the explanations/downloads page of the visualizer.

The script waits me to choose a .mol file,  which I did by writing at the prompter tape.mol.

Then I typed firefox look.html &  (use whatever browser with javascript enabled) to see the results.

UPDATE: Attention, just found out that in some versions of safari there is a problem with working with local files. I suspect, but if you know more then please tell me, that even if safari does handle the file// protocol and opens the look.html, it does not handle well the part where the look.html opens the json files file_0.json … file_10.json.

These json files are produced by the scripts, then they are turned into d3 force graphs by look.html.

So, it may happen that safari opens the file look.html, but when you click on the buttons to see the molecules in action, then safari fails to open the json files which look.html needs, so nothing happens further.

I don’t know yet any solution for this, other than “use firefox” for example. There should be an elegant one.

UPDATE 2: solved!  just download playall.tar.gz .

_____

Now, everything (the scripts, libraries, the file look.html) are available at the said downloads page. This specific .mol file can be saved from the link provided.

I clicked on the “initial” button” and I got a whirling molecule. I let it settle a bit and then I used the click and drag to position some of the atoms in a fashion more understandable if there’s no move, in a picture.

Then I took the screenshot with a generic soft.

The same for the second picture, which shows what you get at step 6.  I combed the two replica of the tape (by click and drag) so that it is obvious that the replication went well.

Took a screenshot again.

And that’s it!

This is not yet part of the gallery of examples,  which I recommend in particular for getting other mol files.

The bit which I used (i.e. the green atoms molecule which is on the “tape” in some places) appears in the example named “the bit propagation“.

__________________________________________________

More input request about the chemlambda gui, thanks

 I get mixed messages from some of those who tried the chemlambda proto-gui. It works for  most, does not work for some of them. I am a mathematician, not a programmer, I learn as I do, I appreciate more input from everybody who tried it. Hope that in a month or so it will be much more evolved. Thanks for  sending private messages with your experience.
Downloads are here.

Visual tutorial for “the soup”

I started here a visual tutorial for chemlambda and it’s gui in the making. I call it a tutorial for the “soup” because it is about a soup of molecules. A living soup.

Hope that in  the  recent future will become THE SOUP. The distributed soup. The decentralized living soup.

Bookmark the page because content will be added on a daily basis!

_____________________________________________________

How to visualize artificial molecules in chemlambda

UPDATE:  I’ve updated the explanations page, where you can download a new variant of the formalism, which eliminated the CO-COMM and CO-ASSOC moves by the introduction of a new FO node (called “FOE”), something inspired from the analogy with DNA-RNA:

  • there were 4 main nodes in chemlambda, A, L, FI and FO, and there are 4 nucleotides in DNA,  namely G,A,C,T
  • in the new version appears a new node, like in RNA which uses three of the DNA nucleotides G,A,C and a new one, U.

In this new version of chemlambda appear two new dist moves, DIST-FI and DIST-FO, as well as modifications of FAN-IN and the old DIST moves which use in some places the FOE node instead of FO.

See it in action in the example on the correct self-multiplication of the S combinator, where the FOE node is yellow.

I am preparing  a click and play tutorial on that.

You can go already to the gallery of examples.  Look at them and play with the nice graphs!

But you can already play with the stuff which makes the graphs!

I shall explain in a moment how to do this. Before that I write a very short description of what is this all about.

Chemlambda  is an artificial chemistry like the Alchemy of Fontana and Buss but with rather big differences. They (Fontana and Buss) say basically that http://fontana.med.harvard.edu/www/Documents/WF/Papers/objects.pdf

  • a  molecule is a lambda term in normal form, and a (chemical)  reaction between  molecules A and B is the term AB obtained by using the application operation,  followed then by evaluation (ie reduction to normal form). They don’t get far enough with this so they import
    the notion of type, which would limit the possible reactions. For some reason they identify the  molecule’s  behaviour with the function associated to the lambda term (which implies of course that one has to assume eta reduction)
  •  in contradistinction, in  chemlambda  a molecule is a graph made by graphical elements called atoms. The  application and abstraction (operations from lambda calculus)  are just atoms, along with the fanout and the fanin atoms.  Some molecules  are associated (represent)  lambda terms. Some others are not.  Chemical reaction  means  reduction, dome by local graph rewrites (one reduction per chemical reaction). More specifically, each reduction move is seen as a manifestation of a chemical reaction between a molecule and an invisible enzyme specific to the type of reduction (there is a beta enzyme for example).
    There is no identification between a molecule and it’s function.

The dream is the same, though,  namely that if not all chemistry, maybe some parts of organic chemistry are used in real life like that, and not like in the bits-and-boolean-expressions- run-by-a-TM-automaton-model.

There is no need for seeing these graphs (molecules) in the plane or in 3D space (well, in 3D they embed anyways, and  maybe there are real chemicals which behave like this!) because graphs don’t need to be embedded somewhere to make sense. In particular, these graphs are not constrained to be planar.

_______________________________________

How to play with the visualizer for chemlambda already. Follow these steps:

  • download http://imar.ro/~mbuliga/play.tar.gz
    and you put it in a folder,
  • open a terminal window and typegunzip play.tar.gztar xvf play.tarthen you have all you need.
  • now you can play, type

bash main_viral.sh

and look what happens. You’ll be asked to choose a something.mol file. There are several in the tar.

  • then open the file look.html  with your favourite browser (with javascript enabled) to see the results.

You can play without being connected to the net.

The input files are called something.mol . I put in the archive some examples. You can write new ones like this. For this you have to read the post about the g-patterns notation.

In a something.mol  file there is a list in plain text (with space as separator character in the line and \n as separator character between lines). Is the list of the graphical elements of the g-pattern, but with the [ , ] deleted.

Thus instead of writing A[1,2,3] FO[3,4,5] you write

A 1 2 3

FO 3 4 5

Say you write a new .mol file, which is called blabla.mol. Save it  and then  type

bash main_viral.mol

There will be a text which appears which asks you to choose a mol file. You type blabla.mol and you hit enter. then you look with look.html, as explained.

For more explanations what it does, just open in a text editor the file check_and_balance*  and read there.  There are explanations inside.

If you look in the folder you see the appearance of several files with names starting with temp_* Open them to discover answers to some questions you may have.

For the moment, there is really no replacement for reading the chemlambda formalism. No chit-chat will suffice, I tell you from experience.

That is why, although I look for creative and open people to discuss it, I shall not engage in any meaningless stuff.

If you are creative yourself then you’ll understand and you shall not think the following applies to you.

OK, here goes the other part of the post.

I shall ignore naive questions (because I saw that most of the naive questions come from people who don’t like to really understand, so probably they won’t read my answers). Moreover, I shall not respond to any question which contains the word “bot”, because WTF is a bot anyway and what that has to do with more than a hundred posts about chemlambda and several articles? Nothing at all!  You want “bots” then don’t waste my time.

However…

-before asking the next most stupid question, let me answer: no man, the graphs are not processes. No! No chance! No, it’s not related to categories. No, it’s not ZX. No, has nothing to do with spiders, quantum diagrams and all this stuff, you know why? because these graphs don’t represent processes.

– if you don’t know what a graph is or if you deeply feel that a graph has to be embedded in some external physical space, then refresh your reading of the definition of a graph. As well you may go and read this post.

– if you don’t know what a graph rewrite is then  google it.

– if you don’t know what “local move” or “local graph rewrite” is it surely mean that you have not read anything about chemlambda, but here is the answer: a N-local move which consists into replacing   at most N nodes and edges. All moves of chemlambda are at most 10-local.

-if you don’t know what is the reducton strategy used, then congrats, that’s the first intelligent question. For the moment, the strategy of reduction is the most stupid one (I call it like this, but it is brilliant compared to others), described here

Reduction strategy. For the moment I am using a sequential strategy of reduction, with priority choices, like this:

At each reduction step do the following:

  • if no LEFT patterns of the moves BETA, DIST, FAN-IN and LOC-PR are present in the g-pattern, then stop, else
  • identify the LEFT patterns of the moves BETA, DIST, FAN-IN and LOC-PR. If there is a graphical element which is part of two distinct patterns then apply a PRIORITY  CHOICE
  • apply the moves from LEFT to RIGHT
  • apply the COMB moves until no Arrow element
    can be eliminated
  • repeat.

The priority choice is called “viral”, meaning that DIST > BETA>LOC PRUNING.

For the moment the moves CO-COMM and CO-ASSOC are not used.

This is not yet distributed GLC, there is a ladder of other strategies to explore. I personally think that they are not a big deal, but I see from experience that this is not obvious. Moreover it is very entertaining to see these strategies in action, all this gives me the occasion to learn new tricks, so in the future I shall add new strategies.

_________________________________

Tell me what you think, and most recommended is to play with it first.

____________________________________

You can play with the priority choice “viral”

UPDATE: go to the page the y combinator in chemlambda to see visualizations of chemlambda molecules and their reductions.

If you want to make your own then go to the explanations page and download and follow the instructions.

There is a gallery of examples now!

UPDATE 2: …phew, the fact that the shell script which launches the gui  is called “main_viral.sh” is related to the reduction strategy used, has definitely nothing to do with the shellstock vulnerability.

 

___________________________________

You can download  the awk file

check_and_balance_18_09.awk

and play with chemlambda with the priority choice “viral”. [see the UPDATE!]

This priority choice privileges the moves which increase the number of nodes in favour of those which decrease it.

More concretely DIST>BETA>LOC-PR. It is one of the priority choices from the post When priority matters.

How to use it:

  • a g-pattern (or molecule)  is in file.mol, as a list of graphical elements (i.e. nodes with ports), but with the characters “[”    “,” and “]” replaced by spaces ” “. That means T[a] appears as “T a”, Arrow[a,b] appears as “Arrow a b” and L[a,b,c] appears as “L a b c”.

Look at data_8.mol , which is the file for the initial pattern from the post When priority matters. Here is also data_7.mol, which is the file containing the initial pattern from the post When priority does not matter.

  • Download the check_and_balance_18_09.awk . Download one of the data_7.mol or data_8.mol, or create your own mol file.
  • open a terminal  (presuming you have linux, or mac with Xcode installed, I suppose) and type

awk -f check_and_balance.awk data_7.mol

to play with data_7.mol. Then type ls to find a number of files, each one starting with “temp_”.

The file temp_nodes_before is basically the same as the input file.

The file temp_proposed_moves has the proposed moves 🙂 , before any priority choice and before any COMB moves.

The file temp_final_nodes has the result after one reduction step.

You may remark the apparition of new nodes, like

FRIN 17

which is a “invisible” node which has only one port (in this case named “17”) which is an “out” port. It signals that port 17  is free (and it appears as a free “in” port, that is why FRIN, which caps it, has to have a paired “out” port).

FROUT 0

which is a invisible node with only one port (named “0” in this case) which is a “in” port. For similar reasons as before, it signals that 0 is a free “out” port.

This may change slightly the aspect of g-patterns, in the only sense that arrow elements with both ends free are replaced by  pairs FRIN and FROUT, for example if

Arrow[ 17 , 0 ]

has both ports free, you shall see it in the temp_final_nodes as

FRIN 17

FROUT 0

Otherwise the FRIN-FROUT thing helps the understanding, in the sense that it makes visible the free ports.

  • if you want to go further with the reduction then type

awk -f  check_and_balance.awk  temp_final_nodes

and look again at

temp_nodes_before   to see where you start in this reduction step

temp_proposed_moves to see the new moves proposed  before any priority choice

temp_final_nodes  to see the result.

And so on and so forth.

If you use data_7.mol or data_8.mol (or any  g-pattern from this blog which is reduced by the “viral” priority choice) then you should see exactly what is described in the respective posts.

There is a small trick, namely that when DIST moves are done, the script has a way to choose new names for the new edges which appear. The trick is that first it computes the max over existing port names ( that is the variable “tutext”) and then it baptizes the new ports with   tutext concatenated with “a”, tutext concatenated with “b”,  with “c” and with “d”.   This way one can be sure that the new ports don’t have names which conflict with the old ports.

I don’t have yet a visualizer for this, but work (mostly to understand) to use d3 for this.

UPDATE (20.09.2014):  I can see my first molecule during reduction, basically using this and the json file produced by the script.

Screen Shot 2014-09-20 at 23.41.58it  represents (Lx.y) Omega, where Omega= (Lx.xx) (Lx.xx) ).

I can move and play with it but I have to control the colors, the ports, oriented edges. Soon.

Enjoy! Criticize! Contribute!

_____________________________________________________________

 

 

I’m doing a GUI for chemlambda

I started to work on this, here is what I am doing right now and then what I need further.

Principle. I am using the g-patterns formalism to separate the reduction of molecules from the visual representation of them.  For those who want to know more about here is the definition of g-patterns and here is the definition of moves in terms of g-patterns.

Reduction strategy. For the moment I am using a sequential strategy of reduction, with priority choices, like this:

At each reduction step do the following:

  • if no LEFT patterns of the moves BETA, DIST, FAN-IN and LOC-PR are present in the g-pattern, then stop, else
  • identify the LEFT patterns of the moves BETA, DIST, FAN-IN and LOC-PR. If there is a graphical element which is part of two distinct patterns then apply a PRIORITY  CHOICE
  • apply the moves from LEFT to RIGHT
  • apply the COMB moves until no Arrow element
    can be eliminated
  • repeat.

There is a subtlety concerning the use of CO-COMM and CO-ASSOC moves, related to the fact that I don’t want to use them directly, and related to the goal which I have, which may be one of those:

  • use chemlambda regardless of its relation to lambda calculus (big goal). In this case there is no separation of reduction into self-multiplication and pure reduction. This strategy gets out quick, but in interesting ways, from lambda calculus, even if we start from a molecule which represents a lambda term.
  • use chemlambda for illustrating lambda calculus (small goal). In this case the reduction strategy involves a move called SHUFFLE (which is equivalent with  CO-COMM and CO-ASSOC) and a separation of the self-multiplication from pure reduction.

Where I am now. I wrote some shell scripts, using awk and perl, to do the first strategy and I know what to do to have the second strategy as well.

Mind that I learn as I do, so probably the main shell script should be named frankenstein.sh.

What I need next.  The format of g-patterns can be easily turned into a format (I lean towards json) which can be then visualized as a force directed d3 graph. I need help here, I know there are lots of things already done, the main idea is that it should be something which doesn’t use  java, has to be free, eventually has to need only the program I prepare (which will be freely available) and a browser.

What I need after.   Several things:

  • to be able to build a molecule in the window I see the graphs and to be able to convert back, to a g-pattern format. Basically this means that I need a way to add nodes which have ports, colors (red or green), such that if the node is 3valent then the cyclical order of ports is fixed. Once  added, there should be a json (say) file where the graph is saved, and then I can make a script to transform it into a g-pattern format.
  • a lambda calculus parser, which takes a lambda term (input from the user) and produces the g-pattern. See this post for the description of an algorithm which does this, starting from a lambda term  with the property that if x is a bound variable then it appears under the scope of only one abstraction and moreover it does not appear as a free variable. I can write a script which does that, but I could use something which transforms a lambda term into one which can be used in the algorithm. By extension, why not a lisp to lambda calculus convertor, which can the be plugged into the pipe of the GUI?

That’s it for the moment, I APPRECIATE  USEFUL HELP, thank you.

______________________________________________________________

 

 

Distributed GLC discussion

This is my contribution to a discussion about the distributed GLC model of computation and about the associated gui.

Read carefully.  It has a fractal structure.

Basics about chemlambda graphs and the GUI

The chemlambda graphs (molecules) are not flowcharts. One just has to specify certain (known) graphs with at most 4 nodes and how to replace them with other known simple graphs. That is all.

That means that one needs:

– a file which specifies what kind of graphs are used (by giving the type of nodes and arrows)

– a file which specifies which are the patterns (i.e. graphs) and which are the rewrite moves

– and a program which takes these files as input and a graph and does things, like checking if the graph is of the kind described in file 1, if there are any patterns from the file 2 and do the rewrite in a place where the user wants, do a sequence of rewrites until it forks, if the user wants, take as input a lambda expression given by the user and transform it into a graph.

– then there is the visualization of the graphs program(s), that is the hard part, but it is already done in multiple places. Means that one has to write only the possible conversions of file formats from and to the viz tool.

That is the minimal configuration.

Decorations

There are various reasons why one wants to be able to decorate the graphs, locally, as a supplementary thing, but in no way is this needed for the basic process.

Concerning decorations, one needs a file which specifies how to decorate arrows and which are the relations coming from nodes. But this is not part of the computation.

If we want to make it more powerful then it gets more complex because if we want to do symbolic computations of decorations (like elimination of a relation coming from a node) then probably it is better to output a file of decorations of arrows and relations from nodes and input it in a symbolic soft, like mathematica or something free, there is no need to reinvent the wheel.

After the graph rewrite you loose the decoration, that’s part of the fun which makes decorations less interesting and makes supposedly the computation more secure.

But that depends on the choice of decoration rules.

For example, if you decorate with types then you don’t loose the decoration after the move. Yes, there are nodes and arrows which disappear, but outside of the site where the move was applied, the decorations don’t change.

In the particular case of using types as decorations, there is another phenomenon though. If you use the decoration with types for graphs which don’t represent lambda terms then you will get relations between types, relations which are supplementary. a way of saying this is that some graphs are not well typed, meaning that the types form an algebra which is not free (you can’t eliminate all relations). But the algebra you get, albeit not free, is still an interesting object.

So the decoration procedure and the computation (reduction) procedure are orthogonal. You may decorate a fixed graph and you may do symbolic algebraic computations with the decorations, in an algebra generated by the graph, in the same way as a know generates an algebra called quandle. Or you may reduce the graph, irrespective of the decorations, and get another graph. Decorations of the first graph don’t persist, a priori, after the reduction.

An exception is decoration with types, which persists outside the place where the reduction is performed. But there is another problem, that even if the decoration with types satisfies locally (i.e. at the arrows of each node) what is expected from types, many (most) of the graphs don’t generate a free algebra, as it would be expected from algebras of types.

The first chemical interpretation

There is the objection that the reductions can’t be like chemical reactions because the nodes (atoms) can’t appear or disappear, there should be a conservation law for them.

Correct! What then?

The reduction, let’s pick one – the beta move say – is a chemical reaction of the graph (molecule) with an enzyme which in the formalism appears only with the name “beta enzyme” but is not specified as a graph in chemlambda. Then, during the reaction, some nodes may disappear, in the sense that they bond to the beta enzyme and makes it inactive further.

So, the reduction A –>beta B appears as the reaction

A + beta = B + garbage

How moves are performed

Let’s get a bit detailed about what moves (graph rewrites) mean and how they are done. Every move says replace graph_1 with graph_2 , where graph_1, graph_2 are graphs with a small number of nodes and arrows (and also “graph” may well be made only by two arrows, like is the case for graph_2 for the beta move).

So, now you have a graph G. Then the program looks for graph_1 chunks in G and adds some annotation (perhaps in an annotation file it produces). Then there may be script which inputs the graph G and the annotation file into the graph viz tool, which has as effect, for example, that the graph_1 chunk appears phosphorescent on the screen. Or say when you hover with the mouse over the graph_1 chunk then it changes color, or there is an ellipse which encircles it and a tag saying “beta”.

Suppose that the user clicks, giving his OK for performing the move. Then on the screen the graph changes, but the previous version is kept in the memory, in case the user wants to go back (the moves are all reversible, but sometimes, like in the case of the beta move, the graph_2 is too common, is everywhere, so the use of both senses of some moves is forbidden in the formalism, unless it is used in a predefined sequence of moves, called “macro move”).

Another example would be that the user clicks on a button which says “go along with the reductions as long as you can do it before you find a fork in the reduction process”. Then, of course it would be good to keep the intermediate graphs in memory.

Yet another example would be that of a node or arrow of the graph G which turn out to belong to two different interesting chunks. Then the user should be able to choose which reduction to do.

It would be good to have the possibility to perform each move upon request,

plus

the possibility to perform a sequence of moves which starts from a first one chosen by the user (or from the only one available in the graph, as is the case for many graphs coming from lambda terms which are obtained by repeated currying and nesting)

plus

the possibility to define new, composed moves at once, for example you notice that there is a chunk graph_3 which contains graph_1 and after reduction of graph_1 to graph_2 inside graph_3, the graph_3 becomes graph_4; graph_4 contains now a chunk graph_1 of another move, which can be reduced and graph_4 becomes graph_5. Now, you may want to say: I save this sequence of two moves from graph_3 to graph_5 as a new move. The addition of this new move does not change the formalism because you may always replace this new move with a sequence of two old moves

Practically the last possibility means the ability to add new chunks graph_3 and graph_5 in the file which describes the moves and to define the new move with a name chosen by the user.

plus

Finally, you may want to be able to either select a chunk of the input graph by clicking on nodes and arrows, or to construct a graph and then say (i.e. click a button) that from now on that graph will be represented as a new type of node, with a certain arity. That means writing in the file which describes the type of nodes.

You may combine the last two procedures by saying that you select or construct a graph G. Then you notice that you may reduce it in an interesting way (for whatever further purposes) which looks like this:

– before the chain of reduction you may see the graph G as being made by two chunks A and B, with some arrows between some nodes from chunk A and some nodes from chunk B. After the reduction you look at the graph as being made by chunks C, D, E, say.

– Then you “save” your chunks A, B, C, D, E as new types of nodes (some of them may be of course just made by an old node, so no need to save them) and you define a new move which transforms the chunk AB into the chunk CDE (written like this only because of the 1D constraints of writing, but you see what I mean, right?).

The addition of these new nodes and moves don’t change the formalism, because there is a dictionary which transforms each new type of node into a graph made of old nodes and each new move into a succession of old moves.

How can this be done:

– use the definition of new nodes for the separation of G into A, B and for the definition of G’ (the graph after the sequence of reductions) into C,D,E

– save the sequence of moves from G to G’ as new composite move between G and G’

– produce a new move which replaces AB with CDE

That’s interesting how should work properly, probably one should keep both the move AB to CDE and the move G to G’, as well as the translations of G into AB and G’ into CDE.

We’re getting close to actors, but the first purpose of the gui is not to be a sandbox for the distributed computation, that would be another level on top of that.

The value of the sequence of moves saved as a composite move is multiple:

– the graph_3 which is the start of the sequence contains graph_1 which is the start of another move, so it always lead to forks: one may apply the sequence or only the first move

– there may be a possible fork after you do the first reduction in graph_3, in the sense that there may be another chunk of another move which could be applied

GLC actors

The actors are a special kind of decoration which transform (some) moves (at the choice of the user) into interaction devices.

You decorate the nodes of a graph G with actors names (they are just names, for the moment, at your choice). As a convention let’s say that we denote actor names by :a , :b , etc

You also decorate arrows with pairs of names of actors, those coming from the decorations of nodes, with the convention that (:a, :a) is identified (in the user mind) with :a (nothing surprising here, think about the groupoid over a set X, which is the set of “arrows” X \times X and X appears as the set of objects of the groupoid and it identifies with the set of pairs (x,x) with x \in X).

Now, say you have a move from graph_1 to graph_2. Then, as in the boldfaced previous description, but somehow in the opposite sense, you define graphs A, B such that graph_1 is AB and graphs C,D such that graph_2 is CD.

Then you say that you can perform the reduction from graph_1 to graph_2 only if the nodes of A are all decorated with :a and the nodes of :b are decorated with :b, a different name than :a.

After reduction you decorate the nodes of C with :a and the nodes of D with :b .

In this way the actors with identities :a and :b change their state during the reduction (i.e. the graph made by the nodes decorated with :a and the arrows decorated with (:a,:a) change, same for :b).

The reduction can be done for the graph G only at chunks graph_1 which are decorated as explained.

To explain what actor :Bob is doing it matters from which point of view. Also, what is the relation between actors and the chemical interpretation, how they fit there?

So let’s take it methodically.

The point of view of the GUI

If we discuss from the point of view of playing with the gui, then the user of the gui has global, God’s view over what happens. That means the the user of the gui can see the whole graph at one moment, the user has a clock which is like a global notion of time. So from this point of view the user of the gui is the master of space and time. He sees the fates of :Bob, :Alice, :Claire, :Dan simultaneously. The user has the right in the gui world to talk about parallel stuff happening (i.e. “at the same time”) and sequential stuff happening (to the same actor or actors). The user may notice that some reductions are independent, in the sense that wrt to the user’s clock the result is the same if first :Bob interacts with :Alice and then :Claire interacts with :Dan or conversely, which makes the user think that there is some notion more general than parallelism, i.e. concurrency.

If we discuss from the point of view of :Bob, it looks different. More later.

Let’s stay at the user of the gui point of view and think about what actors do. We shall use the user’s clock for reference to time and the user’s point of view about space (what is represented on the screen via the viz tool) to speak about states of actors.

What the user does:

– he defines the graph types an the rules of reduction

– he inputs a graph

– he decorates it with actors names

– he click some buttons from time to time ( deus ex machina quote : “is a plot device whereby a seemingly unsolvable problem is suddenly and abruptly resolved by the contrived and unexpected intervention of some new event, character, ability or object.” )

At any moment the actor :Bob has a state.

Definition: the state of :Bob at the moment t is the graph formed by the nodes decorated with the name :Bob, the arrows decorated by (:Bob, :Bob) and the arrows decorated by (:Bob, :Alice), etc .

Because each node is decorated by an actor name, it follows that there are never shared nodes between different actors, but there may be shared arrows, like an arrow decorated (:Bob, :Alice), which is both belonging to :Bob and :Alice.

The user thinks about an arrow (:Bob, :Alice) as being made of two half arrows:

– one which starts at a node decorated with :Bob and has a free end, decorated with :Alice ; this half arrow belongs to the state of :Bob

– one which ends at a node decorated with :Alice and has a free start, decorated with :Bob ; this half arrow belongs to the state of :Alice

The user also thinks that the arrow decorated by (:Bob, :Alice) shows that :Bob and :Alice are neighbours there. What means “there”? Is like you, Bob, want to park your car (state of Bob) and the your front left tyre is close to the concrete margin (i.e. :Alice), but you may consider also that your back is close to the trash bin also (i.e :Elvis).

We may represent the neighboring relations between arrows as a new graph, which is obtained by thinking about :Bob, :Alice, … as being nodes and by thinking that an arrow decorated (:Bob, :Alice) appears as an arrow from the node which represents :Bob to the node which represents :Alice (of course there may be several such arrows decorated (:Bob, :Alice) ).

This new graph is called “actors diagram” and is something used by the gui user to put order in his head and to explain to others the stuff happening there.

The user calls the actors diagram “space”, because he thinks that space is nothing but the neighboring relation between actors at a moment in time (user’s time). He is aware that there is a problem with this view, which supposes that there is a global time notion and a global simultaneous view on the actors (states), but says “what the heck, I have to use a way to discuss with others about what’s happening in the gui world, but I will show great caution and restraint by trying to keep track of the effects of this global view on my explanation”.

Suppose now that there is an arrow decorated (:Bob, :Alice) and this arrow, along with the node from the start (decorated with :Bob) and the node from the end (decorated with :Alice) is part of the graph_1 of one of the graph rewrites which are allowed.

Even more general, suppose that there is a graph_1 chunk which has the form AB with the sub-chunk A belonging to :Alice and the sub-chunk B belonging to Bob.

Then the reduction may happen there. (Who initiates it? Alice, Bob, the user’s click ? let’s not care about this for a moment, although if we use the user’s point of view then Alice, Bob are passive and the user has the decision to click or not to click.)

This is like a chemical reaction which takes into consideration also the space. How?

Denote by Alice(t) and Bob(t) the respective states of :Alice and :Bob at the moment t. Think about the states as being two chemical molecules, instead of one as previously.

Each molecule has a reaction site: for Alice(t) the reaction site is A and for Bob(t) the reaction site is B.

They enter in the reaction if two conditions are satisfied:

– there is an enzyme (say the beta enzyme, if the reduction is the beta) which can facilitate the reaction (by the user’s click)

– the molecules are close in space, i.e. there is an arrow from A to B, or from B to A

So you see that it may happen that Alice(t) may have inside a chunk graph which looks like A and Bob(t) may have a chunk graph which looks like B, but if the chunks A, B are not connected such that AB forms a chunk which is like the graph_1 of the beta move, then they can’t react because (physical interpretation, say) they are not close in space.

The reaction sites of Alice(t) and Bob(t) may be close in space, but if the user does not click then they can’t react because there is no beta enzyme roaming around to facilitate the reaction.

If they are close and if there is a beta enzyme around then the reaction appears as

Alice(t) + Bob(t) + beta = Alice(t+1) + Bob(t+1) + garbage

Let’s see now who is Alice(t+1) and Bob(t+1). The beta rewrite replaces graph_1 (which is AB) by graph_2 (which is CD). C will belong to Alice(t+1) and D will belong to Bob(t+1). The rest of Alice(t) and Bob(t) is inherited unchanged by Alice(t+1) and Bob(t+1).

Is this true? What about the actors diagram, will it change after the reaction?

Actually graph_1, which is AB, may have (and it usually does) other arrows besides the ones decorated with (:Bob, :Alice). For example A may have arrows from A to the rest of Alice(t), i.e. decorated with (:Alice, :Alice), same for B which may have others arrows from B to the rest of B(t), which are decorated by (:Bob, :Bob).

After the rewrite (chemical reaction) these arrows will be rewired by the replacement of AB by CD, but nevertheless the new arrows which replace those will be decorated by (:Alice, :Alice) (because they will become arrows from C to the rest of Alice(t+1)) and (:Bob, :Bob) (same argument). All in all we see that after the chemical reaction the molecule :Alice and the molecule :Bob may loose or win some nodes (atoms) and they may suffer some internal rewiring (bonds), so this looks like :Alice and :Bob changed the chemical composition.

But they also moved as an effect of the reaction.

Indeed, graph_1, which is AB, may have other arrows besides he ones decorated with (:Bob, :Alice) , (:Bob, :Bob) or (:Alice, :Alice). The chunk A (which belongs to Alice(t)) may have arrows which connect it with :Claire, i.e. there may be arrows from A to another actor, Claire, decorated with (:Alice, :Claire), for example.

After the reaction which consist in the replacement of AB by CD, there are rewiring which happened, which may have as effect the apparition of arrows decorated (:Bob, :Claire), for example. In such a case we say that Bob moved close to Claire. The molecules move this way (i.e. in the sense that the neighboring relations change in this concrete way).

Pit stop

Let’s stop here for the moment, because there is already a lot. In the next message I hope to talk about why the idea of using a Chemical reaction network image is good, but still global, it is a way to replace the user’s deus ex machina clicks by random availability of enzymes, but still using a global time and a global space (i.e. the actors diagrams). The model will be better also than what is usually a CRN based model, where the molecules are supposed to be part of a “well stirred” solution (i.e. let’s neglect space effects on the reaction), or they are supposed to diffuse in a fixed space (i.e let’s make the space passive). The model will allow to introduce global notions of entropy.

Such a CRN based model deserves a study for itself, because it is unusual in the way it describes the space and the chemical reactions of the molecules-actors as aspects of the same thing.

But we want to go even further, towards renouncing at the global pov.

Notes for gamification of chemlambda

Here are some obvious notes  which are filed here about chemlambda graphs in GraphML.  Hope they may be used with … ? … why not Liviz.js  to get quick something OS to play with.

In the previous post The Quantomatic GUI may be useful for chemlambda (NTC vs TC, III) is mentioned the quantomatic gui, which can easily do all this, but is not free. Moreover, the goals for the gui proposed here are  more modest and easily attainable. Don’t care about compatibility with this or that notion from category theory because our approach is different and because the gui is just step 0. So any quick and dirty, but effective code will do, I believe.

______________________________

Recall the idea: gamification of chemlambda.

  • get quick a chemlambda GUI, as described  in  A user interface for GLC  and use it, with a collection of predefined goals to make a gamification of chemlambda.
  • obviously that means choosing a format for representing the graphs and moves, many variants here, in this post is described such a choice — GraphML. The work consists into transforming the definitions of graphs and moves into a chosen format.
  • the various buttons and options from the post describing the gui are simple scripts, perhaps in javascript?  of the kind: find and replace predefined patterns by others, all involving up to 4 nodes and 8 arrows, so almost a no brainer, consisting in writing into the chosen format which are the patterns (i.e. the configurations of at most 4 nodes and 8 arrows ) which are involved in the chemlambda moves and which are the replacement rules (i.e. transforming the definition of chemlambda moves into code)
  • open the possibility to define arbitrary patterns (named here “macros”) and arbitrary moves (named here “macro moves”)
  • transform into code the algorithm described in Conversion of lambda calculus terms into graphs , with the care to use instead chemlambda. This is good for having a button for importing lambda terms into chemlambda  easily.
  • with all this done, pick a visualization tool which is open, looks good and  is easy to use, like the one previously mentioned.
  • write some scripts for converting to and from GraphML (or whatever other choice one likes) to  the input of the viz tool.
  • pick some examples, transform them into challenges and make public the game.

___________________________

For those with a  non functional right hemisphere, here is the GraphML description of chemlambda graphs and what would mean to do a move.

I use this source for GraphML.

A chemlambda graph is  any graph which is directed, with two types of 3-valent nodes and one type of  1-valent node, with the nodes having some attributes. [For mathematicians, is an oriented graph made by trivalent, locally planar nodes, and by some 1-valent nodes, with arrows which may have free starts or free ends, or even loops.]

Moreover, we accept arrows (i.e. directed edges) with free starts, free ends, or both, or with start=end and no node (i.e. loops with no node). For all those we need, in GraphML, to use some “invisible” nodes [multiple variants here, only one is described.]

Here are the trivalent, locally planar nodes:

 

  • application node

<node id=”n0″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>green</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>

  • fanin node

<node id=”n3″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>red</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>

  • lambda node

<node id=”n1″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>red</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>

  • fanout node

<node id=”n2″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>green</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>

  • termination node

<node id=”n4″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>term</data> </node>

(where “term” denotes a color we agree to use for the termination node, in xfig made drawings this node  appears like this  –>–|  )
  • two invisible nodes 1 valent

<node id=”n5″ parse.indegree=”0″ parse.outdegree=”1″>
<data key=”d0″>invisible</data> </node>

<node id=”n6″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>invisible</data> </node>

(where “invisible” should be something to  agree to use)

  • invisible node 2 valent

<node id=”n7″ parse.indegree=”1″ parse.outdegree=”1″>
<data key=”d0″>invisible</data> </node>

Uses of  invisible nodes:

  • in chemlambda graphs we admit arrows which start from one of the 3 valent nodes but the end is free. Instead of the free end we may use  the invisible node  with id=”n6″ from before.

<edge source=”n101″ target=”n6″/>

  • There are also accepted arrows which end in a 3 valent node or in a 1 valent termination node, but their start is free. For those we may use the invisible node with id=”n5″ from before.

<edge source=”n5″ target=”n102″/>

  • There are accepted arrows with free starts and ends, so we represent them with the help of invisible nodes with id=”n5″ and id=”n6″.

<edge source=”n5″ target=”n6″/>

  • Finally, we accept also loops, with no nodes, these are represented with the help of the 2 valent invisible nodes line the one with id=”n7″

<edge source=”n7″ target=”n7″>

____________________________________________

 

Examples:
(a) – recognize pattern for beta move
(b) – perform (when called) the beta move

  • (a) recognize pattern for beta move.

– input is a chemlambda graph (in GraphML)

– output is the same graph and some supplementary file of annotations of the graph.

  • This program looks in the input graph for all patterns where the beta move can be applied.  This pattern looks like this in the GraphML convention:

<node id=”n101″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>green</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>
<node id=”n102″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>red</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>
<edge source=”n102″ target=”n101″ sourceport=”right_out” targetport=”left_in”/>
<edge source=”n106″ target=”n102″ sourceport=”???_1″ targetport=”middle_in”/>
<edge source=”n102″ target=”n103″ sourceport=”left_out” targetport=”???_2″/>
<edge source=”n105″ target=”n102″ sourceport=”???_3″ targetport=”right_in”/>
<edge source=”n101″ target=”n104″ sourceport=”middle_out” targetport=”???_4″/>

Here “???_i” means any port name.

If such a pattern is found, then the collection of id’s (of edges and nodes) from it is stored in some format in the annotations file which is the output.

  • (b) perform (when called) the beta move

When called, this program takes as input the graph and the annotation file for beta moves pattern and then wait for the user to pick one of these patterns (i.e. perhaps that the patterns are numbered in the annotation file, the user interface shows then on screen and the user clicks on one of them).

When the instance of the pattern is chosen by the user, the program erases from the input graph the pattern (or just comments it out, or makes a copy first of the input graph and then works on the copy, …) and replaces it by the following:

<edge source=”n106″ target=”n104″ sourceport=”???_1″ targetport=”???_4″/>
<edge source=”n105″ target=”n103″ sourceport=”???_3″ targetport=”???_2″/>

It works only when the nodes n101 or n102 are different than the nodes  n103 ,n104, n105, n106,  because if not then when erased leads to trouble. See the post Graphic beta move with details.

As an alternative one may proceed by introducing invisible nodes which serve as connection points for the arrows from n106 to n104 and n101 to n103, then erase the nodes  among n101, n102 which are not among  n103, n104, n105, n106 .

___________________________________________

A concrete example:

reg_1

  • The input graph is the one from the first row of the figure:

<node id=”n1″ parse.indegree=”0″ parse.outdegree=”1″>
<data key=”d0″>invisible</data>
<port name=”out”/>
</node>
<node id=”n2″ parse.indegree=”0″ parse.outdegree=”1″>
<data key=”d0″>invisible</data>
<port name=”out”/>
</node>
<node id=”n3″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>invisible</data>
<port name=”in”/>
</node>
<node id=”n4″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>invisible</data>
<port name=”in”/>
</node>

[comment: these are the four free ends of arrows which are numbered in the figure by “1”, … , “4”.   So you have a graph with two inputs and two outputs,  definitely not a graph of a  lambda term! ]

<node id=”n105″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>green</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>
<node id=”n106″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>green</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>
<node id=”n108″ parse.indegree=”2″ parse.outdegree=”1″>
<data key=”d0″>green</data>
<port name=”middle_out”/>
<port name=”left_in”/>
<port name=”right_in”/>
</node>

[comment: these are 3 application nodes]

<node id=”n107″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>red</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>
<node id=”n109″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>red</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>
<node id=”n110″ parse.indegree=”1″ parse.outdegree=”2″>
<data key=”d0″>red</data>
<port name=”middle_in”/>
<port name=”left_out”/>
<port name=”right_out”/>
</node>

[comment: these are 3 lambda abstraction nodes]

<edge source=”n1″ target=”n105″ sourceport=”out” targetport=”right_in”/>
<edge source=”n107″ target=”n105″ sourceport=”left_out” targetport=”left_in”/>
<edge source=”n105″ target=”n106″ sourceport=”middle_out” targetport=”left_in”/>

<edge source=”n2″ target=”n106″ sourceport=”out” targetport=”right_in”/>
<edge source=”n106″ target=”n107″ sourceport=”middle_out”
targetport=”middle_in”/>
<edge source=”n107″ target=”n108″ sourceport=”right_out” targetport=”left_in”/>

<edge source=”n108″ target=”n109″ sourceport=”middle_out”
targetport=”middle_in”/>
<edge source=”n110″ target=”n108″ sourceport=”right_out” targetport=”right_in”/>
<edge source=”n109″ target=”n110″ sourceport=”right_out”
targetport=”middle_in”/>

<edge source=”n109″ target=”n4″ sourceport=”left_out” targetport=”in”/>
<edge source=”n110″ target=”n3″ sourceport=”left_out” targetport=”in”/>

  • This graph reduces via 3 beta reductions to

<node id=”n1″ parse.indegree=”0″ parse.outdegree=”1″>
<data key=”d0″>invisible</data>
<port name=”out”/>
</node>
<node id=”n2″ parse.indegree=”0″ parse.outdegree=”1″>
<data key=”d0″>invisible</data>
<port name=”out”/>
</node>
<node id=”n3″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>invisible</data>
<port name=”in”/>
</node>
<node id=”n4″ parse.indegree=”1″ parse.outdegree=”0″>
<data key=”d0″>invisible</data>
<port name=”in”/>
</node>

<edge source=”n1″ target=”n3″ sourceport=”out” targetport=”in”/>
<edge source=”n2″ target=”n4″ sourceport=”out” targetport=”in”/>

____________________________________________

For this choice which consists into using invisible nodes, a new program is needed (which may be useful for other purposes, later)

(c) arrow combing

The idea is that a sequence of arrows  connected via 2-valent invisible nodes should count as an arrow in a chemlambda graph.

So this program does exactly this: if n1001 is different than n1002  then replaces the pattern

<node id=”n7″ parse.indegree=”1″ parse.outdegree=”1″>
<data key=”d0″>invisible</data>
<port name=”in”/>
<port name=”out”/>
</node>
<edge source=”n1001″ target=”n7″ sourceport=”???_1″ targetport=”in”/>
<edge source=”n7″ target=”n1002″ sourceport=”out” targetport=”???_2″/>

by

<edge source=”n1001″ target=”n1002″ sourceport=”???_1″ targetport=”???_2″/>

 

_________________________________________

 

A user interface for GLC

Before programming, is better to play first!

Really, not a joke, a new programming environment needs a lot of motivation and playing is a way to build some. Also, by playing we start to understand more, get all sorts of gut feelings and start collaborate with others.

As a first step towards programming with distributed GLC, a sort of playful gui seems attainable. Should be open source, of course.

Waiting for your input!

Further I describe what kind of gui would like to have. But before that, just a few words.

1. Recall that we want to play with GLC and chemlambda, at this moment, therefore the gui should be done with humans first, computers 2nd frame of mind.

2.  As we shall see, if this project starts to  pick momentum, there will a stream of ideas about how to really program with distributed GLC

3. But for the moment, forget about actors and asynchronous computation and let’s stick to GLC and chemlambda.

Here is how I see it, in the next figure. Which is btw probably not  pretty. It is very important to be pretty and simple, something not obvious to achieve, but desired.

gui_1

You can click on the figure to make it bigger.

The numbers in blue are for explanations.

So, what do we see? A window with some buttons.

The gui has some drawing related capabilities, like (following the blue numbers)

1)  select some nodes and arrows and form a group with them

2) deselect the group

3) magnify ; or magnify the selection, or put in front the selection, with the rest in the background

4) about how to draw arrows: if you choose this then arrows can cross (but see the problems from 14) and 15) )  and they try to be as straight as possible

5) about how to draw arrows: if you choose this then arrows are like in a kind of 2.5 dimensions; also they are not straight (in the euclidean sense) but like electronic circuits (i.e. straight in some Manhattan distance)

6) connect two arrows (by selecting the button and clicking on them

7) cut an arrow into two half arrows; delete arrow; delete node

Now, it’s not obvious how to well draw the arrows:

14) they should avoid the nodes , but they should also be as straight as possible, according to the choices made at 4) 5)

15) the arrow > should be positioned far from nodes and other arrows

We should be able to click on a node of the graph and move it with the mouse, and the gui should keep the connectivities.

The gui also has some basic graphical bricks, which depend on the formalism we use:

13) in the figure the chemlambda is chosen, which offers the 4 nodes (or maybe even the dilation node), arrows and loops. These should be buttons, click on one node and move it into the main window. The gui should propose connectivity variants, based on proximity with other available nodes. This should work like in a chemistry drawing program.

Important:

  • if chemlambda is chosen at 13), then the list of moves, reductions, macros, i.e. 8) 9) 10) changes to be compatible with chemlambda
  • and if another choice is made, like GLC or tibit, then the gui should be able to convert the graph from the main window in the respective formalism!
  • in particular, if you don’t like the aspect of the nodes, then you should be free to change their look. For example, I’ve done this with chemlambda, where there are two notations used:

propagator_1

11) there is also the possibility to use cores. Cores are inputs/outputs from Distributed GLC, but let’s forget this for the moment. We discuss later about this.

12) this is a way to draw graphs which represent lambda calculus terms. The gui has a windows where we write a lambda term and the program converts it into a graph, by running the algorithm described here (for GLC, but same for chemlambda).

________________________________

Before continuing with the other buttons, let’s look a bit at the first figure. We see in the TEXT window (\lambda x . xx)(\lambda x . xx) and we see a graph in the main figure.

Are they related anyways? Yes, look at the post about “metabolism of loops“.  You can see that graph (but it is made now with the more recent drawing convention) in the figure which explains how that lambda calculus combinator reduces in chemlambda. I reproduce that figure here:

chem_eval_2

_________________________________

Let’s go back to the buttons 8) 9) 10)

8) If you click this then you get the list of moves (from chemlambda for example, if at 13) you picked chemlambda). You click on a move, then you see on the graph the places where you can apply the move (they shine, or they are bigger, or something), or maybe as you hover the the mouse over the graph the places where this move can be applied are highlighted. Of course, this should work only for the “+” direction of the moves. In the opposite sense, should  work after you pick, for example, a pair of arrows (and then you can apply there, by clicking, a (beta-) move).

I picked this particular graph because it has the property that some of its nodes  are part of several different patterns where different moves can apply. (In the last figure you see this, because the patterns and the possible moves are described there).

9) two ways to use this: either you click on a highlighted pattern (of a move, selected with 8)) and the gui does the move for you (which involves redrawing the graph according to the graphical constraints described previously). Or the gui proposes to make choices (if possible) among different patterns which overlap and then does the reduction for al these at once. The chosen patterns should not overlap. The program does only one reduction step, not all (possible) reduction steps.

There should be the possibility to record a sequence of reductions, to make a kind of a movie with those.

10) Macros are special graphs, like the zipper. Practically you should be able to select a graph and save it as a macro, with a name. Likewise, you should be able to define and save macro moves, i.e. particular sequences of moves among particular graphs (or patterns).