# Lambda calculus to chemlambda parser (2) and more slides

This post has two goals: (1) to explain more about the lambda to chemlambda parser and (2) to talk about slides of presentations which are connected one with the other across different fileds of research.

(1) There are several incremental improvements to the pages from the quine graphs repository. All pages, including the parser one, have two sliders, each giving you control about some parameters.

The “gravity” slider is kind of obvious. Recall that you can use your mose (or pinching gestures) to zoom in or out the graph you see. With the gravity slider you control gravity. This allows you to see better the edges of the graph, for example, by moving the gravity slider to the minimum and then by zooming out. Or, on the contrary, if you have a graph which is too spreaded, you can increase gravity, which will have as aeffect a more compactly looking graph.

The “rewrites weights slider” has as extrema the mysterious words “grow” and “slim”. It works like this. The rewrites (excepting COMB, which are done preferentially anyway) are grouped into those which increase the number of nodes (“grow”) and the other ones, which decrease the number of nodes (“slim”).

At each step, the algorithm tries to pick at random a rewrite. If there is a COMB rewrite to pick, then it is done. Else, the algorithm will try to pick at random one “grow” and one “slim” rewrite. If there is only one of these available, i.e. if there a “grow” but no “slim” rewrite, then this rewrite is done. Else, if there is a choice between two randomly choses “grow” and “slim” rewrites, we flip a coin to choose among them. The coin is biased towards “grow” or “slim” with the rewrites weights slider.

This is interesting to use, for example with the graphs which come from lambda terms. Many times, but not always, we are interested in reducing the number of nodes as fast as possible. A strategy would be to move the slider to “slim”.

In the case of quines, or quine fights, it is interesting to see how they behave under “grow” or “slim” regime.

Now let’s pass to the parser. Now it works well, you can write lambda terms in a human way, but mind that “xy” will be seen as a variable, not as the application of “x” to “y”. Application is “x y”. Otherwise, the parser understands correctly terms like

(\x.\y.\z.z y x) (\x.x x)(\x. x x)\x.x

Then I followed the suggestion of my son Matei to immediately do the COMB rewrites, thus eliminating the Arrow nodes given by the parser.

About the parser itself. It is not especially short, because of several reasons. One reason is that it is made as a machine with 3 legs, moving along the string given by the lexer. Just like the typical 3-valent node. So that is why it will be interesting to see it in action, visually. Another reason is that the parser first builds the graph without fanout FO and termination T nodes, then adds the FO and and T nodes. Finally, the lambda term is not prepared in advance by any global means (excepting the check for balanced parantheses). For example no de Bruijn indices.

Another reason is that it allows to understand what edges of the (mol) graph are, or more precisely what port variables (edge variables) correspond to. The observation is that the edges are in correspondence with the position of the item (lparen, rparen, operation, variable) in the string. We need at most N edge names at this stage, where N is the length of the string. Finally, the second stage, which adds the FO and T nodes, needs at most N new edge names, practically much less: the number of duplicates of variables.

This responds to the question: how can we efficiently choose edge names? We could use as edge name the piece of the string up to the item and we can duble this number by using an extra special character. Or if we want to be secretive, now that we now how to constructively choose names, we can try to use and hide this procedure.

Up to now there is no “decorator”, i.e. the inverse procedure to obtain a lambda term from a graph, when it is possible. This is almost trivial, will be done.

I close here this subject, by mentioning that my motivation was not to write a parser from lambda to chemlambda, but to learn how to make a parser from a programming language in the making. You’ll see and hopefully you’ll enjoy ðŸ™‚

(2) Slides, slides, slides. I have not considered slides very interesting as a mean of communication before. But hey. slides are somewhere on the route to an interactive book, article, etc.

So I added to my page links to 3 related presentations, which with a 4th available and popular (?!) on this blog, give together a more round image of what I try to achieve.

These are:

• popular slides of a presentation about hamiltonian systems with dissipation, in the form baptized “symplectic Brezis-Ekeland-Nayroles”.Â  Read them in conjuction with arXiv:1902.04598, see further why
• (Artificial physics for artificial chemistry) Â  is a presentation which, first, explains what chemlambda is in the context of artificial chemistries, then proceeds with using a stochastic formulation of hamiltonian systems with dissipation as an artificial physics for this artificial chemistry. An example about billiard ball computers is given. Sure, there is an article to be written about the details, but it is nevertheless interesting to infer how this is done.
• (A kaleidoscope of graph rewrite systems in topology, metric geometry and computer science)Â  are the most evolved technically slides, presenting the geometrical roots of chemlambda and related efforts. There are many things to pick from there, like: what is the geometrical problem, how is it related to emergent algebras, what is computation, knots,Â  why standard frames in categorical logic can’t help (but perhaps it can if they start thinking about it), who was the first programmer in chemlambda, live pages where you can play with the parser, closing with an announcement that indeed anharmonic lambda (in the imperfect form of kali, or kaleidoscope) soves the initial problem after 10 years of work. Another article will be most satisfactory, but you see, people rarely really read articles on subjects they are not familiar with. These slides may help.
• and for a general audience my old (Chemlambda for the people)Â  slides, which you may appreciate more and you may think about applications of chemlambda in the real world. But again, what is the real world, else than a hamiltonian system with dissipation? And who does the computation?

# Quine graphs (5), anharmonic logic and a flute

Several things:

• added a new control to the quine graphs pages (all can be accessed from here). Is caled the “rewrites weights slider”: you can either favor the rewrites DIST, which add nodes to the graph, or the rewrites Î²Â  which take away nodes from the graph (for chemlambda these are the L-A rewrite, but also the termination rewrites and FI-FOE). This changes, sometimes radically, the result of the algorithm. It depends what you want. In the case of reductions of lambda terms, you may want to privilege Î² rewrites, but as usual this is not generally true, see the last example. In the case of the fight arena for quines, you can favor a species of quines over another by your choice.
• of course in the background I continue with kali, or anharmonic lambda calculus. The new thing is that why not conceive a programming language which compiles to kali? It works fine, you can say things as

“from a see b as c” or

“let a mark b as c” or

“is a as b” or

“c := let xÂ  = b in c”

and many others! Soon, hope at the beginning of December, will be available.

• It helps to do new things, so I finished t day my first flute. Claudia, my wife, is a music professor and her instrument of choice is the flute. From a physics point of view a flute is a tube with holes placed in the right possitions, how hard would it be to make one? After I made it, it is usable but I started to learn a lot of stuff about how unnatural is the modern flute and how much you can play with all variables. As a mathematician IÂ  oscilate between “is a known thing to simulate a flute numerically” and “I shall concentrate on the craft and will play with various techniques”. My first flute was a craft only effort, but now, when I know more, I am hooked!

OK, so that’s the news, I like to make things!

# A small ouroboros has a short life (Quine graphs 4)

As I said many times, there is a lot of background to the hundreds of chemlambda mol files and associated simulations. Now that I took the Quine graphs repository seriously, I have to select rather clear and short strings of facts associated to the mol files, so that I can tell clear and short enough stories.

So it came out of the depth of this pile of stuff I have that the ouroboros is not an immortal quine. It can die and his life is of the order exp(length) where length is the length of the double track it contains.Â  The shortest ouroboros appears here (look in the MENU).

Otherwise, I reorganize (and continue to do so) the js scripts, so that they become easy to understand. Now there is a chemistry, nodes, etc. so thare will be a convergence with the modules of hapax.

# Quine graphs (3), ouroboros, hapax and going public

Several news:

I decided that progressively I’m going to go public, with a combination of arXiv, Github and Zenodo (or Figshare), and publication. But there is a lot of stuff I have to publish and that is why this will happen progressively. Which means it will be nice to watch because it is interesting, for me at least,Â  to answer to the question:

What the … does a researcher when publishing? What is this for? Why?

Seriously, the questions are not at all directed against classical publication, nor are they biased versus OA. When you publish serially, like a researcher, you often tell again and again a story which evolves in time. To make a comparison, it is like a sequence of frames in a movie.

Only that it is not as simple. It is not quite like a sequence of frames,Â  is like a sequence of pictures, each one with it’s repeating tags, again and again.

Not at all compressed. And not at all like an evolving repository of programs which get better with time.

# Quine graphs (2)

UPDATE: This page has now comments for each graphÂ  , or its sister page. Now I can start to mass produce ðŸ™‚

There are several technical details to add before I arrive to a final version, but now there are, as usual, two sister pages:

• (the one I want to write about today) here
• and the one at the quinegraph repository here (link changed, mentioned in the last post)

The first page, ie the newer one, has the algorithm involving the COMB rewrites and Arrow nodes, even for Interaction Combinators, which is part of the original chemlambda programs.Â  It may be funny to see the Arrows and COMB rewrites in action in the case of IC.

This part is needed because the way a graph quine is defined. The Arrow and COMB rewrites allow to make purely local parallel rewrites. For the case of Interaction Combinators, where the graphs are not oriented, a hack can be done in order to use Arrows, which consists into using a pair of them, tip to tip, instead of only one. (Not the first time when I think that IC is bosonic and chemlambda is fermionic ðŸ™‚ )

That being said, what more is needed?

• to fully implement the greedy algorithm, because only the sequential random one is in the js version (let’s recall again that the js-only version was first done by ishanpm, then modified by me according to (many) needs. It is a marvel, even if it needs more tweaks, in particular from my point of view because by using it I discovered that the 10 quine can reproduce itself). Needed because of the definition of a quine.
• to put a graph matching function. There is one in the more ambitious project hapax. (It does not have pretty pictures, but I’ll modify it after, maybe that is why it does not attract?) Useful for the verification of a quine.
• depending on time, implement a sort of arena where quines compete. Needed for a part of the article (or maybe a supplement?) where I explain some things mentioned in the deleted g+ chemlambda collection (adaptation is another semantic ilusion)
• finally I need to arrive to a not too primitive form of html presentation, these days people are used to such things and the academic who just want to show a proof of principle will be ignored without. Needed because it can be done and is good for my education.

All in all, ironically, my initial awk program (4364 sloc) does that and more (Turing machines, to come in js version, as well as Formality Core) in so many lines because perhaps they were needed? I say ironically because that program is written without the use of functions, so perhaps it is about 1000 sloc with functions. Compare with the js version which has the same number of lines, written by ishanpm. Compare with the Haskell version written by synergistics,Â  Compare with the python version by 4lhc.

Most of these lines are needed to destroy the information added to the system by the semantic assumptions of those who wrote the programming languages. Yes.

I close here by saying that even if I don’t believe in semantics, as it is understood since Aristotle (but not by Plato), I do believe in the existence of a different, more beautiful replacement, which can be glimpsed in the way nature needs randomness for creating structure.

# Quine graphs (1)

Update: here is the template page for the demos, which will be released soon with the article. Thank you for letting me know about any suggestions, improvements, bugs, requests. The demos will support the article and they will be grouped on families, based on subject or on common phenomena. In this article, up to now,Â  only chemlambda and Interaction Combinators are touched, not kali or hapax.

________

While hapax and anharmonic lambda calculus enter the final stage, it is time I prepare for publication the quines exploration project. I intend to make an article (first to arXiv) with a paired github repository and some github.io pages where the real things happen. For the search of new quines I might go back to twitter and make a dedicated account. Let’s see how all this will work together.

For the moment I collect here the posts from this chorasimilarity blog, or other linksÂ  which are related to theÂ  project. (Well there is a collection of google+ posts which are going to be useful, I have to see what I do with these).

So here is it, in reverse time order:

A very useful yool was the full js chemlambda editor written by ishanpm. I modified it and tuned it in many places and I shall continue or I’ll write a new one, but definitely I learned stuff by using it, thanks!

I might explore also quines in other

although I shall not touch the relations with knot theory, in this article. Only look for quines, as example.

If you have questions, suggestions, or if you want to contribute to the subject, let me know.

# Anharmonic lambda calculus (II)

Some news after the anouncement of kali, or anharmonic lambda calculus. I use again two pages, which are updated in tandem:

At the moment I write this post the github.io version is more recent. I think the termination rewrites are better than before.

There is still some work on the exact choice of rewrites, among the many possible which are compatible with the underlying geometric structure. But you can see by looking at kali24.js that there is some connection between the nodes and the anharmonic group.

All this will be explained when I’ll arrive to the most satisfying version.

I added to the lambda calculus examples some more, not lambda calculus ones. Among them the much discussed 10-node quine and also the most amazing molecule I discovered until now. It appears in the menu as “10 nodes sometimes becomes quine from [graph A-L-FI-FOE 540213]” and please do reload it often and let it unfold. For an archived video see this one. It is a graph which basically shatters the notion that a quine is enough, conceptually, to describe life. More simply put, it can evolve in so many ways, among them in a chemlambda quine way, but not uniquely. Amazing.

You can see it also on the menu of the find a quine page. There the graphs look more compact and you can see more of the overall structure, but less the detailed linking of nodes.

Coming back to kali24, the chunk which I need to explain first is what does it have to do with em-convex. That is an enriched lambda calculus which describes my work on emergent algebras. It ends with the proof that in the presence of an axiom called “convex”,Â  we end up with usual vector spaces over terms of type N (in the paper) and that also the term of type N have an em calculus themselves, which is a way of saying that we recover on them a structure which is like the Riemann sphere.

What is not proved are two things: (1) isÂ  there is a graphical rewrite system which can reproduce the proofs of em-convex, under the algorithm of rewrites used with chemlambda? (2) can we dispense of the lambda calculus part (the abstraction and application operations) and redo everything only with the pure em calculus?

Back to earth now, just for the fun, don’t you think that a geometrical modelÂ  of lambda calculus on the Riemann sphere would be nice?