Successful computation of a relative of the factorial by a function f(a,b)=(succ(a),succ(a) b +1). It is done with lisfact_4.mol and the script moving_random_metabo.sh from the gh-pages branch of the repo. (Don't forget to verify in the script check_1_mov2_rand_metabo.awk that the variable cycounter is set to 1000, for the computation to end before the maximum number of cycles.)
This is like the factorial, with a small difference. It computes the function F(0)=1, F(n+1)=(n+1)F(n)+1. That is an interesting function, check it out in the Wolfram Alpha engine. The only difference from the factorial is that it uses the function tms(a,b)=ab+1, instead of times(a,b)=ab. See the computation of tms(3,3)=10.
Recall the results obtained by using a modification of the molecule obtained from the lambda term proposed in the lambda calculus tutorial by Mayer Goldberg from the little-lisper.org, par. 57, page 14. In about 80% of the cases the molecule for the factorial of 3 does not reduce to the number 6 (as seen as a molecule which corresponds to the Church encoding of 6). An example of an unsuccessful reduction is this. In about 20% of the runs the computation is successful, as shown in this example.
Another example is the extremely resilient computation of the Ackermann function. I made the molecule for it from the same little lisper tutorial, see the cited work, par. 46, page 12. That molecule works superbly in random conditions. The best example is this, where the molecule for Ack(2,2) reduces to 7 while in the same time self-reproduces itself! Why then a simpler function, the boring factorial, leads to such failures when reduced in chemlambda? The answer is, I guess, because in chemlambda nothing is lost. Is like in nature, you can throw something to the garbage, but it does not dissapear. The equivalent of throwing to the garbage, in chemlambda, is the application of a termination node, which then kills the molecule slowly by the PRUNING moves. But remember that in chemlambda it may well happen that while some parts of a molecule are killed by pruning moves, other parts are not yet dead and they continue to interact and perhaps self-multiply. But, in many other experiments this seems not to be a problem! Let's look closer, the real problem seems to be related to the currying and uncurrying. Indeed, in the Ackermann function example the function has two arguments but it has only one value. In the factorial example we work with a function which takes a pair of arguments and returns a pair of values. But in chemlambda there are no values (and no functions properly speaking). The pair construction and its selectors does not work well, because every time when only one component of the pair is needed, the other one is thrashed. What a waste! A relic of the industrial revolution, to be sure. This thrashing interacts badly with the other parts of the molecule. And the evidence for this is this demo, where the Church number c0 (which contains a termination node) is replaced by c1 (hence the modification of the function computed) which does not contain any termination node. And so, the computation is successful every time, regardless of the fact that it is random, purely local! We have to learn to program ecologically.