Tag Archives: visual languages

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


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


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


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



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.




From a stain on the wall to five visual languages

Do you know about the “stain on the wall”  creativity technique of Leonardo da Vinci? Here is a quote [source used]:

I will not forget to insert into these rules, a new theoretical invention for knowledge’s sake, which, although it seems of little import and good for a laugh, is nonetheless, of great utility in bringing out the creativity in some of these inventions.    This is the case if you cast your glance on any walls dirty with such stains or walls made up of rock formations of different types.  If you have to invent some scenes, you will be able to discover them there in diverse forms, in diverse landscapes, adorned with mountains, rivers, rocks, trees, extensive plains, valleys, and hills. You can even see different battle scenes and movements made up of unusual figures,  faces with strange expressions,  and myriad things which you can  transform into a complete and proper form constituting part of similar walls and rocks. These are like the sound of bells, in whose tolling, you hear names and words that your imagination conjures up.

I propose to you  five graphical formalisms, or visual languages, towards the goal of “computing with space”.

They all come from a “stain on the wall”,  reproduced here  (is the beginning of the article What is a space? Computations in emergent algebras and the front end visual system, arXiv:1009.5028),  with  some links  to more detailed explanations and related material which I invite you to follow.

Or better, to threat them as  a stain on the wall. To share, to dream about, to create, to discuss.

In mathematics “spaces” come in many flavours. There are vector spaces, affine spaces, symmetric spaces, groups and so on. We usually take such objects as the stage where the plot of reasoning is laid. But in fact what we use, in many instances,are properties of particular spaces which, I claim, can be seen as coming from a particular class of computations.

There is though a “space” which is “given” almost beyond doubt, namely the physical space where we all live. But as it regards perception of this space, we know now that things are not so simple. As I am writing these notes, here in Baixo Gavea, my eyes are attracted by the wonderful complexity of a tree near my window. The nature of the tree is foreign to me, as are the other smaller beings growing on or around the tree.  I can make some educated guesses about what they are: some are orchids, there is a smaller, iterated version of the big tree. However, somewhere in my brain, at a very fundamental level, the visible space is constructed in my head, before the stage where I a capable of recognizing and naming the objects or beings that I see.


The five visual languages are to be used with the decentralized computing model called Distributed GLC.  They point to different aspects, or they try to fulfil different goals.

They are: