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

  • 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
    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


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.


-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.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s