All posts by chorasimilarity

can do anything

More experiments with the dynamic GoI abstract machine visualiser and chemlambda

This post continues from Diagrammatic execution models (Lambda World Cadiz 2018) compared with chemlambda . For the context, I quote from  this MonkeyPatchBlog post

Koko Muroya and Steven Cheung, working under the direction of Dan Ghica, gave a fantastic overview of their work on diagrammatic execution model.  […] There is a nice demo of their work hosted on github

The demo is the “GoI Visualiser”. In this post I continue to play with this visualiser and with chemlambda as well.

You can play too by using the link to the GoI Visualiser demo and an archive available here, which contains all is needed for running chemlambda and for producind anything from this post.

There is a readme.txt inside which you may enjoy, with instructions to use and some background.

OK, let’s play.

The Goi Visualiser comes with the untyped lambda term

A = ((λf. λx. f (f x)) ((λy. y) (λz. z))) (λw. w)

and in the preceding post I reduced this term in chemlambda. Now I take this term and remark that there are inside 3 identity terms: (λy. y) , (λz. z) and (λw. w). That is why I take the term

B = (λu.(((λf.λx.f(fx))(uu))u))(λw.w)

which has the property that by one BETA reduction it becomes A.

I filmed the reduction of B with the call-by-need, in the GoI Visualiser:


and, out of curiosity, remarked that call-by-name does not work actually it does but I misunderstood what I see!



What about chemlambda? The “molecule” (i.e. chemlambda graph) for the lambda term B can be either goi-5.mol, i.e.

A out2 in2 out3
L out in1 out2
A 1 2 out
A 3 4 1
L 5 f 3
FO f 7 9
A 7 8 6
A 9 x 8
L 6 x 5
A 10 11 4
FO in1 2 13
FO 13 10 11
L w w in2

or the goi-6.mol, i.e.

A out2 in2 out3
L out in1 out2
A 1 2 out
A 3 4 1
L 5 f 3
FO f 7 9
A 7 8 6
A 9 x 8
L 6 x 5
A 10 11 4
FO in1 13 2
FO 13 10 11
L w w in2

These two molecules differ in only one place:

FO in1 2 13  (goi-5.mol)   vs.  FO in1 13 2  (goi-6.mol)

Everything is in the archive! Go check for yourself, please 🙂

This difference is due to the fact that the algorithm for building a chemlambda molecule from a lambda term leaves freedom for the way to duplicate variables. Here in the case of the term B, this freedom is in relation with the variable “u”.  Indeed

B = (λu. … (uu))u) …

and to produce 3 u’s from one we need two FO (fanout) nodes, but we may arrange them in two ways.

The algorithm is the one to be expected, here the one from section 3, M. Buliga, Graphic lambda calculus, Complex Systems 22, 4 (2013), 311-360, arXiv:1305.5786.  In chemlambda we transform terms from lambda calculus by this algorithm, but mind that in Graphic Lambda Calculus (GLC) there is only one fanout node, the FO. In chemlambda there are two fanout nodes, the FO and the FOE. What is interesting is that there are no other nodes but the fanin FI, two fanouts FO, FOE, application A, lambda L, arrow Arrow, free input FRIN, free output FROUT, termination T. There are no brackets, boxes, tags!

You want to see again the rewrites of chemlambda? arXiv:1811.04960

So the algorithm of conversion is the one from GLC, with only FO nodes in the initial molecule for the term. There are two possible ways to convert the term B, these are goi-5.mol and goi-6.mol.

The goi-6.mol behaves very cool all the time (i.e. under the random reduction algorithm of chemlambda)



The goi-5.mol behaves very well in about 87.5% cases (i.e. in 7/8 cases), from experiments. In most of the cases the reduction ends with an identity, as it should, but in 1/8 cases we end with this siamese brothers identity:



which is in mol notation:

FI 1 2 out

L z z 1

L v v 2

i.e. a fanin FI is left alone and it does not know that his left and right inputs are the same.

Why is that?

From all examples where I reduced molecules from lambda terms, I encountered this phenomenon only once, see the story of The factorial and the little lisper  .  In that case, I was able to produce a working example, and as well some funny ones, like this version of the factorial of 5:



(taken from the Chemlambda for the people html/js slides)

This happens because there is a mix between execution and duplication which sometimes goes astray. For example if I take the molecule goi-2.mol

FO out out1 out2
A 1 2 out
A 3 4 1
L 5 f 3
FO f 7 9
A 7 8 6
A 9 x 8
L 6 x 5
A 10 11 4
L y y 10
L z z 11
L w w 2

which is exactly like the molecule goi.mol for the lambda term A (seen in the previous post), only with

FO out out1 out2

added, then the execution (reduction) of the two copies of A while they duplicate, it goes great:



That is because the nodes FO, FOE and FI satisfy the shuffle trick, which guarantees the duplication of FO trees from lambda terms molecules (in particular).

I suspect that there is a choice of the FO fanout trees in the conversion of a lambda term into a molecule which does the job.

Don’t know how to prove it 🙂



Diagrammatic execution models (Lambda World Cadiz 2018) compared with chemlambda

Via this MonkeyPatchBlog post I learned about a keynote presented at the Lambda World Cadiz 2018, on Diagrammatic execution models, quote:

Koko Muroya and Steven Cheung, working under the direction of Dan Ghica, gave a fantastic overview of their work on diagrammatic execution model.   […]

There is a nice demo of their work hosted on github, which was used during the presentation. […]

Applied category theory is booming right now, and this work led me to wonder if they were considering describing their work in a categoretic way (yes, it seems). Some of the demos they showed were reminiscent of chemlambda: a graph evolving given rewriting rules (which incidently provided the illustration for the ACT 2019 announcement).”

So I wanted to see how does the lambda term reduce in chemlambda (with the random reduction).

Here is the GoI Visualiser in action: the term is ((λf. λx. f (f x)) ((λy. y) (λz. z))) (λw. w)

reduced with call-by-need looks like this:


Comparison with chemlambda. The mol file goi.mol for this lambda term is:

A 1 2 out

A 3 4  1

L 5 f 3

FO f 7 9

A 7 8 6

A 9 x 8

L 6 x 5

A 10 11 4

L y y 10

L z z 11

L w w 2

I prepared an archive with all needed, taken from the chemlambda repository. You may just download it and then you shall see in the mol folder the goi.mol file. To produce (a) reduction you write in terminal


then you write


then you see that a file goi.html appeared. You write

firefox goi.html &

and you see this:



or something equivalent. So that’s how the reduction of this term looks in chemlambda. 🙂 Well, the animated gif shows that again and again…

UPDATE: Thank you for the interest and nice words. If you don’t like my way of writing code, which is to be expected because geometer here, then there is this Haskell implementation.

My opinion is still that the most interesting ideas of chemlambda are:

As concerns the first point, this justifies the accent on the dumbest, random, local reduction algorithm, and the experiments outside graphs which represent lambda terms (from all those chemlambda quines to mixtures of busy beavers and lambda terms).

As for the second point, there is really a lot of mathematics, perhaps logic too, to be explored here.





Chemlambda collection afterlife [updated]

Still, hundreds of posts available via reshares from the chemlambda collection. Recall that I deleted the collection some time ago, see here.

I arrived at the conclusion that there is no reason to hide recent or (sometimes) older research from public, just because I believe the academic publishing is close to collapse.


So I started by posting on arXiv a text version of the experimental article Molecular computers, available now as arXiv:1811.04960.  The JS animations are replaced with links and there is a note to the reader added.

The same article is also posted at Figshare:


Open Science is rwx science

Preamble: this is a short text on Open Science, written a while ago,  which I now put it here. It is taken from this place at The link (not the content) appeared here at the Chemlambda for the people post. I can’t find other traces, except the empty github repository “creat”,  described as “framework for research output as a living creature“.


I am a big fan of Open Science. For me, a good piece of research is one which I can Read Write eXecute.

Researchers use articles to communicate. Articles are not eXecutable. I can either Read others’ articles or Write mine. I have to trust an editor who tells me that somebody else, whom I don’t know, read the article and made a peer-review.

No. Articles are stories told by researchers about how they did the work. And since the micromanagement era, they are even less: fungible units to be used in funding applications, by the number or by the keyword.

This is so strange. I’m a mathematician and you probably know that mathematics is the most economical way to explain something clearly. Take a 10 pages research article. It contains the intensive work of many months. Now, compress the article further more by the following ridiculous algorithm: throw away everything but the first several bits. Keep only the title, the name of the journal, keywords, maybe the Abstract. That’s not science communication, that’s massive misuse of brain material.

So I’m an Open Science fan, what should I do instead of writing articles? Maybe I should push my article in public and wait after that for somebody to review it. That’s called Open Access and it’s very good for the readers. So what? the article is still only Readable or Writable, pick only one option, otherwise it’s bad practice. What about my time? It looks that I have to wait and wait for all the bosses, managers, politicians and my fellow researchers to switch to OA first.

It’s actually much easier to do Open Science, remember! something that you can Read, Write and eXecute. As an author, you don’t have to wait for the whole society to leave the old ways and to embrace the new ones. You can just push what you did: stories, programs, data, everything. Any reader can pull the content and validate it, independently. EXecute what you pushed, Read your research story and Write derivative works.

I tried this! Want to know how to build a molecular computer which is indiscernible from how we are made? Use this playground called chemlambda. It’s a made up, simple chemistry. It works like the real chemistry does, that is locally, randomly, without any externally imposed control. My bet is that chemlambda can be done in real life. Now, or in a few years.

I use everything available to turn this project into Open Science. You name it: old form articles, html and javascript articles, research blog, Github repository, Figshare data repository, Google collection [update: deleted], this 🙂

Funny animations obtained from simulations. Those simulations can be run on your computer, so you can validate my research. Here’s what chemlambda looks like.

[Here come some examples and animations. ]


During this project I realized that it went beyond a Read Write Execute thing. What I did was to design many interesting molecules. They work by themselves, without any external control. Each molecule is like a theorem and the chemical evolution is the proof of the theorem, done by a blind, random, stupid, universal algorithm.

Therefore my Open Science attempt was to create molecules, some of them exhibiting a metabolism, some of them alive. Maybe this is the future of Open Science. To create a living organism which embodies in its metabolism the programs and research data. It’s valid if it lives, grow, reproduces, even die. Let it cross breed with other living creatures. In time the natural selection will do marvels. Life is not different than Science. Science is not different than life.

I deleted the Google+ chemlambda collection

This 400 posts collection, 60 000 000 views,  was as much a work of research popularization as a work of art. Google cannot be trusted with keeping high density data (scientific, art, etc). Read here about this.


It pained me to delete it, but it had to be done. It was harder than when I quit Facebook, Twitter.

The collection and richer material exist, I have them. Still, the Github repository is available, as well as the demos. For example, the dodecahedron multiplication animation used as background for a conference site of was made from a screencast of a d3.js which can be seen  here.


Mail me for access to more material. I have to think what I am going to do with them, long term. Meanwhile look for updates at my professional homepage or the alternative page.

John Baez’ Applied Category Theory 2019 post uses my animation without attribution [updated]

The post, dated Oct 2, appears at John Baez Azimuth blog. Here is what I see today Oct 4th:


UPDATE: now there is a link to the chemlambda repository, but see also the comments, there and here. The real problem is related to the attitude concerning  Open Science. Link to archived post.

This is the gif which illustrates the chemlambda github repository.

The original animation appeared for the first time in the chemlambda collection post Metabolism as failed replication. The later post (Sept 2016) contains more about this idea and useful links.

[ UPDATE: Recently, I deleted the chemlambda collection. The content of it will become public again in a new form. Meanwhile mail me for access. However, the github repo, libraries, demos and articles are public.]

The chemlambda molecule which is used is available at the chemlambda library of molecules, as tape_long_4653_2.mol . You can download the simulation itself (which was used to make the animation) from the Chemlambda collection of simulations at Figshare, the file tape_long_4653_2.js.

The last time when one of my animations was used withot attribution, the situations was quickly solved.  I explained then that the chemlambda project is an Open Science project and that correct attribution is what is fair to do.

Now, I would expect from an academic researcher more.

Anyway, again the magic of chemlambda strikes. Let me tell you what the animation is really about. Metabolism and replication are two fundamental ingredients of life. Which came first? Are these independent?  I prepared the molecule and experimented with it to show that (in the artificial toy chemistry chemlambda) metabolism and replication may be related, in the sense that metabolism may appear as failed replication.

The molecule in question is a “tape”, topologically the same as a DNA loop. On the tape there is a very small part which triggers the duplication of the tape molecule. The duplication works perfectly, there are several examples in the chemlambda collection. But this time I took a tape which duplicates without problems and I modified it in a single place. The result is a failed duplication which is spectacular in the sense that the tape molecule produces a number of disconnected graphs (i.e. other molecules), some of them are quines.




Torsor rewrites

With the notation conventions from em-convex, there are 3 pairs of torsor rewrites.  A torsor, figured by a fat circle here, is a term T of type  T: E \rightarrow E \rightarrow E \rightarrow E

with the rewrites:




Finally, there is a third pair of rewrites which involve terms of the form \circ A for A: N


The rewrite T3-1 tells that the torsor is a propagator for \circ A, the rewrite T3-2 is an apparently weird form of a DIST rewrite.

Now, the following happen:

  • if you add the torsor rewrites to em-convex then you get a theory of topological groups which have a usual, commutative smooth structure, such that the numbers from em-convex give the structure of 1-parameter groups
  • if you add the torsor rewrites to em, but without the convex rewrite then you get a more general theory, which is not based on 1-parameter groups,  because the numbers from em-convex give a structure more general
  • if you look at the emergent structure from em without convex, then you can define torsor terms whch satisfy the axioms, but of course there is no em-convex axiom.

Lots of fun, this will be explained in em-torsor soon.