Combinatory Chemistry: Towards a Simple Model of Emergent Evolution

Germn Kruszewski1∗ and Tomas Mikolov2

1Naver Labs Europe, Grenoble, France 2CIIRC CTU, Prague, Czech Republic [email protected]

Abstract A r An explanatory model for the emergence of evolvable units AA r1 IA((S(SK)I)A) 2 A((S(SK)I)A must display emerging structures that (1) preserve themselves in time (2) self-reproduce and (3) tolerate a certain amount of S I variation when reproducing. To tackle this challenge, here we A introduce Combinatory Chemistry, an Algorithmic Artificial

Chemistry based on a minimalistic computational paradigm r3 A(SKA(IA)) r4 A(SKAA) named Combinatory Logic. The dynamics of this system comprise very few rules, it is initialized with an elementary S I tabula rasa state, and features conservation laws replicating natural resource constraints. Our experiments show that a sin- A gle run of this dynamical system with no external intervention r AA discovers a wide range of emergent patterns. All these struc- r5 A(KA(AA)) 6 tures rely on acquiring basic constituents from the environ- S ment and decomposing them in a process that is remarkably K AA similar to biological . These patterns include au- topoietic structures that maintain their organisation, recursive Figure 1: Metabolic cycle (showing one of the possible path- ones that grow in linear chains or binary-branching trees, and most notably, patterns able to reproduce themselves, dupli- ways) of a self-reproducing structure that emerges from the cating their number at each generation. dynamics of Combinatory Chemistry. Starting from (AA), where A = (SI(S(SK)I)), it acquires three copies of A from its environment and uses two to create a copy of itself, Introduction metabolising the third one to carry out the process. Finding the minimal set of conditions that lead to open- ended evolution in a is a central question in Artificial Life and a fundamental question of science in Artificial Chemistries seek to mimic as closely as possi- general. One prominent hypothesis in this line of research ble the properties of the chemistry that gave rise to life on is that living systems emerge from the complex interaction Earth (Flamm et al., 2010; Hogerl,¨ 2010; Young and Ne- of simple components. Environments like Avida (Ofria and shatian, 2013), others abstract away from the particulari- Wilke, 2004) or Tierra (Ray, 1991) have been used to ex- ties of natural chemistries to focus only on their hypoth- plore this question by allowing self-reproducing programs esized core computational properties (Fontana and Buss, to mutate and evolve in time. Yet, the reproductive and arXiv:2003.07916v2 [nlin.AO] 19 Jun 2020 1994; di Fenizio and Banzhaf, 2000; Tominaga et al., 2007; mutation mechanisms, as well as the organisms’ capacity Buliga and Kauffman, 2014). In line with this latter line to tolerate such mutations were fixed by design. Instead, of work, in this paper we introduce an Algorithmic Artifi- Artificial Chemistries try to uncover how such evolvable cial Chemistry based on Combinatory Logic (Schonfinkel,¨ units emerge in the first place by simulating the proper- 1924; Curry et al., 1958) featuring a minimalistic design and ties of natural chemical systems at different levels of ab- three key properties. First, it is Turing-complete, enabling it straction (see Dittrich et al. (2001) for a thorough review). to express an arbitrary degree of complexity. Second, it is The driving hypothesis is that complex organizations emerge strongly constructive (Fontana et al., 1993), meaning that as thanks to self-organising attractors in chemical networks, the system evolves in time it can create new components that which preserve their structure in time (Walker and Ashby, can in turn modify its global dynamics. Third, it features 1966; Wuensche et al., 1992; Kauffman, 1993). While some intrinsic conservation laws so that the number of atomic el- ∗ Work done while the author was at Facebook AI. ements remains always constant. Previous work has relied on applying extrinsic conserva- this system, which they called level 0 organisations. Further- tion laws, such as for instance keeping a maximum num- more, when these expressions were explicitly prohibited, a ber of total elements in the system by randomly removing more complex organization emerged where every expression exceeding ones (Fontana and Buss, 1994; di Fenizio and in a set was computed by other expressions within the same Banzhaf, 2000). Instead, intrinsic conservation laws allow set (level 1 organisations). Finally, mixing level 1 organisa- us to bound the total number of elements without introduc- tions could lead to higher order interactions between them ing extraneous perturbations. Furthermore, limiting the total (level 2 organisations). Yet, this system had some limita- amount of basic elements can create selective pressures be- tions. First, each level of organisation was only reached af- tween emergent structures. ter external interventions. Also, programs must necessarily We simulate a System (Hordijk et al., reach a normal form, which happens when there are no more 2015; Dittrich et al., 2001) based on Combinatory Logic, λ-calculus rules than can be applied. Thus, recursive pro- which starting from a tabula rasa state consisting of only grams, which never reach a normal form, are banned from elementary components, it produces a diversity explosion the system. Furthermore, two processes where introduced as that develops into a state dominated by self-organized emer- analogues of food and waste, respectively. First, when ex- gent structures, including autopoietic (Varela and Maturana, pressions are combined, they are not removed from the sys- 1973), recursive and self-replicating ones. Notably, all these tem, allowing the system to temporarily grow in size. Sec- types of structures emerge at different points in time dur- ond, expressions which after being combined with existing ing a single run of the system without requiring any external expressions do not match any λ-calculus reduction rules are interventions. Furthermore, these structures preserve them- removed. Without these processes, complex organisations selves by absorbing compounds from their environment and fail to emerge. Yet, it is not clear under which circumstances decomposing them step-by-step, in a process that has a strik- these external interventions would not be needed anymore ing resemblance with the of biological organ- in order for the system to evolve autonomously. Finally, isms. Finally, we introduce a heuristic to emulate the effects bounding the total number of expressions by randomly re- of having larger systems without having to compute them moving excess ones creates perturbations to the system that explicitly. This makes considerably more efficient the search can arbitrarily affect the dynamics. Fontana and Buss (1996) for these complex structures. later proposed MC2, a chemistry based on Linear Logic that The paper is organized as follows. First, we describe ear- addressed some of these limitations (notably, conservation lier work in Artificial Chemistry that is most related to our of mass), but we are not aware of empirical work on it. approach. Then, we explain the basic workings of Combi- Here, we propose an AC based on Combinatory Logic. natory Logic and how we adapted it into an Artificial Chem- This formalism has been explored before in the context of istry. Third, following earlier work, we discuss how autoca- AC by di Fenizio and Banzhaf (2000). While this work talytic sets can be used to detect emerging phenomena in this shares with us the enforcement of conservation laws, it relies system, and propose a novel measure of emergent complex- for it on a normalisation process that introduces noise into ity, which is well-adapted to the introduced system. Finally, the system dynamics. Furthermore, as AlChemy, it reduces we describe our experiments that showcase the emergence expressions until they reach their normal forms, explicitly of complex structures in Combinatory Chemistry. forbidding recursive and other type of expressions that do not converge. Artificial Chemistries Finally, Chemlambda (Buliga and Kauffman, 2014) is a Artificial Chemistries (AC) are models inspired in natural Turing-complete graph rewriting AC that allows the encod- chemical systems that are usually defined by three differ- ing of λ-calculus and combinatory logic operators. As such, ent components: a set of possible , a set of reac- it is complementary in many ways with the system proposed tions, and a reactor algorithm describing the reaction vessel here. Yet, we are not aware of conservation laws defined and how molecules interact with each other (Dittrich et al., within this formalism, nor of any reactor algorithm allowing 2001). In the following discussion we will focus on algo- explorations of emerging phenomena. rithmic chemistries that are the closest to the present work. AlChemy (Fontana and Buss, 1994) is an AC where Combinatory Logic molecules are given by λ-calculus expressions. λ-calculus Combinatory Logic (CL) is a minimalistic computa- is a mathematical formalism that, like Turing machines, can tional system that was independently invented by Moses describe any computable function. In AlChemy, pairs of ran- Schonfinkel,¨ and Haskell Curry (Car- domly sampled expressions are joined through function ap- done and Hindley, 2006). Other than its relevance to com- plication, and the corresponding result is added back to the putability theory, it has also been applied in Cognitive Sci- population. To keep the population size bounded, expres- ence as a model for a Language of Thought (Piantadosi, sions are randomly discarded. Fontana and Buss showed that 2016). One of the main advantages of CL is its formal expressions that computed themselves quickly emerged in simplicity while capturing Turing-complete expressiveness. In contrast to other mathematical formalisms, such as λ- the K combinator discards a part of the expression (the ar- calculus, it dispenses with the notion of variables and all gument g), S duplicates its third argument x. Thus, to make the necessary bookkeeping that comes with it. For instance, a chemical system with conservation laws, we define reduce a function f(x) = 1 + x + y would be nonsensical, and a reactions for an expression αXβ, as follows: function-generating system based on λ-calculus would need to have explicit rules to avoid the formation of such expres- α(If)β → αfβ[+I] (1) sions. Instead, CL expressions are built by composing ele- α(Kfg)β → αfβ[+g + K] (2) mentary operators called combinators. Here, we restrict to α(Sfgx)β [+x] → α(fx(gx))β [+S] (3) the S, K and I combinators, which form a Turing-complete |{z} |{z} basis1. Given an expression e of the form e = αXβ, it can reactant by-product be rewritten in CL, as follows: An expression in Combinatory Chemistry is said to be re- α(If)β αfβ ducible if it contains a Combinatory Chemistry redex (CC- B redex). A CC-redex is a plain CL redex, except when it α(Kfg)β B αfβ involves the reduction of an S combinator, in which case α(Sfgx)β B α(fx(gx))β a copy of its third argument x (the reactant) must also be present in the multiset P for it to be a redex in Combina- When αXβ matches the left hand side of any of the rules tory Chemistry. For example, the expression SII(SII) is above, the term X is called a “reducible expression” or re- reducible if and only if the third argument of the combinator dex. A single expression can contain multiple redexes. If no S, namely (SII), is also present in the set. When a reduc- rule is matched, the expression is said to be in normal form. tion operation is applied, the redex is rewritten following the The application of these rules to rewrite any redex is called rules of combinatory logic, removing any reactant from P a (weak) reduction. For example, the expression SII(SII) and adding back to it all by-products, as specified in brackets could be reduced as follows (underlining the corresponding on the right hand size of the reaction. The type of combina- redexes being rewritten): SII(SII) B I(SII)(I(SII)) B tor being reduced gives name to the reaction. For instance, SII(I(SII))BSII(SII). Thus, this expression reduces to the S-reaction operating on SII(SII) + (SII) removes itself. We will later see that expressions such as this one will these two elements from P, adding back I(SII)(I(SII)) be important for the self-organizing behaviour of the system and S to it. Notably, each of these reduction rules pre- introduced here. In contrast, (SII) is not reducible because serves the total number of combinators in the multiset, in- 2 S requires three arguments and I at least one. Also note trinsically enforcing conservation laws in this chemistry. It that I(SII)(I(SII)) has two redexes that can be rewritten, is also worth noticing that each of these combinators plays namely, the outermost or the innermost I combinators. Even different roles in the creation of novel compounds. While though many different evaluation order strategies have been K-reactions split the expression, decreasing its total size defined (Pierce, 2002), here we opt for picking a redex at and complexity, S-reactions create larger and possibly more 3 random , both because this is more natural for a chemical complex expressions from smaller parts. system and to avoid limitations that would come from fol- Completing the set of possible reactions in this chemistry, lowing a fixed deterministic evaluation order. condensations and cleaveges can generate novel expressions through random recombination: Combinatory Chemistry One of our main contributions deals with reformulating x + y ←→ xy (4) these reduction rules as reactions in a chemical system. For this, we postulate the existence of a multiset of CL expres- In Combinatory Chemistry, computation takes prece- sions P that react following reduction rules, plus random dence. This means that whenever an expression admits at condensation and cleavages. Note that if we were to apply least one reduce reaction, this reaction (or one at random, if plain CL rules to reduce these expressions, the total number there are multiple) is immediately applied. Otherwise, if an of combinators in the system would not be preserved. First, expression cannot be reduced, it is either cleaved at a ran- because the application of a reduction rule always removes dom point, or condensed together with another irreducible the combinator from the resulting expression. Second, while expression. As reducing reactions take priority over random recombination ones, we construe them as auto-catalysed. 1As a matter of fact, S and K suffice because I can be written as In line with the Gillespie algorithm (Gillespie, 1977), the SKK. The inclusion of I simply allows to express more complex system is simulated by sampling expressions from P with programs with shorter expressions. probability proportional to their concentration and applying 2Precedence rules are left-branching, thus (SII) = ((SI)I) and thus, the second I is not an argument for the first I but to SI. one reaction at a time. In this way, we uniformly distribute 3For practical efficiency reasons, we restrict to sampling from the computational budget between all programs in the sys- the first 100 possible reductions in an outer-to-inner order. tem. Moreover, we do not need to take additional precau- tions to avoid recursive expressions that never reach a nor- some emergent structures of interest and thus, we propose to mal form, allowing these interesting functions to form part instead track reactant consumption rates as a proxy metric of our system’s dynamics. to uncover the presence of these structures. Finally, inspired Finally, we note that while other chemistries start from a by the concept of food sets in autocatalytic sets, we propose population of randomly constructed compounds, this system a heuristic to accelerate their emergence. can be initialised with elementary combinators only. In this way, diversity materializes only as emergent property rather Autocatalytic sets than through the product of an external intervention. Self-organized order in complex systems is hypothesized to The complete algorithm describing the temporal evolution be driven by the existence of attracting states in the system’s of our system is summarized on Algorithm 14. dynamics (Walker and Ashby, 1966; Wuensche et al., 1992; Kauffman, 1993). Autocatalytic sets (Kauffman, 1993) were first introduced by in 1971 as one type of Algorithm 1: Reactor Algorithm such attractors that could help explaining the emergence of life in chemical networks. (See Hordijk (2019) for a com- Input: Total number of combinators NI , NK , NS prehensive historical review on the topic.) Related notions Initialize multiset P ← {{I : NI ,K : NK ,S : NS}} while True do are the concept of (Varela and Maturana, 1973), P[e] and the model (Eigen and Schuster, 1978). Sample e ∈ P with P (e) = |P| Autocatalytic sets (AS) are reaction networks that per- if Reducible?(e) then petuate in time by relying on a network of catalysed reac- Let (e[+x] → eˆ[+y]) ∈ Reductions(e) tions, where each reactant and catalyst of a reaction is either Remove one e from P produced by at least some reaction in the network, or it is Remove one reactant x from P (if applicable) freely available in the environment. This notion was later Add one eˆ and all by-products y to P formalized in mathematical form (Hordijk and Steel, 2004; else Hordijk et al., 2015) with the name of Reflexively Autoca- Randomly pick cleave or condense talytic Food-generated sets (RAFs). Specifically, they de- if cleave then fine a Chemical Reaction System (CRS) as a mathematical Let x, y such that e = (xy) construct defining the set of possible molecules, the set of Remove one e from P possible reactions and a set indicating which reac- Add one x and one y to P tions are catalysed by which molecules. Furthermore, a set else if eLEFT is defined then of freely available molecules in the environment, called the Remove one e and one eLEFT from P food set, is assumed to exist. An autocatalytic set (or RAF Add (eLEFTe) to P set) S of a CRS with associated food set F is a subset of Undefine eLEFT reactions, which is: else reflexively autocatalytic r ∈ S Define eLEFT ← e 1. (RA): each reaction is Function Reducible?(e): catalysed by at least one that is either present if e = (If) or e = (Kfg) or in F or can be formed from F by using a series of reac- e = (Sfgx) and x ∈ P then tions in S itself. return True 2. food-generated (F): each reactant of each reaction in S is else if e ∈ {S, K, I} then either present in F or can be formed by using a series of return False reactions from S itself. else 0 0 return ∃e : e = (αe β) and Reducible?(e’) Autocatalytic sets in Combinatory Chemistry In Combinatory Chemistry, all reducing reactions take precedence over random condensations and cleavages, and Emergent Structures thus, they proceed at a higher rate than random reac- tions without the need of any catalyst (i.e. they are auto- Having described the dynamics of Combinatory Chemistry, catalysed). Therefore, they trivially satisfy condition 1. we now turn to discuss how can we characterise emergent Thus, autocatalytic sets in this system are defined in terms structures in this system. For this, we first discuss how can of subsets of reduce reactions in which every reactant is pro- autocatalytic sets be applied for this purpose. Second, we duced by a reduce reaction in the set or is freely available in observe that this formalism may not completely account for the environment (condition 2). For example, if we assume 4Implementation and supplementary materials at https:// that A = (SII) is in the food set, Figure 2 shows a sim- germank.github.io/combinatory-chemistry ple emergent autocatalytic set associated with the expression SII A r2 SII(I(SII)) r4 r SIAA SII(SII) r1 I(SII)(I(SII)) I I AA r1 SIA(IA) 2

r3 I(SII)(SII) r5 S S I I I A

r3 IA(AA) r4 A(AA) Figure 2: r1–r5 form an autocatalytic set, granted that (SII) belongs to the food set. (SII(SII))’s metabolic cycle starts S I with r reducing the S combinator, while taking (SII) as 1 Figure 3: One of the possible pathways in the reduction of reactant. Then, the cycle is completed by the reduction of the tail-recursive structure (AA) with A = (S(SI)I). It ap- the two identity combinators, in any of the possible orders. pends one A to itself by metabolising another copy absorbed from the environment.

(AA) = (SII(SII)). As shown, a chain of reduce reac- tions keep the expression in a self-sustaining equilibrium: itself that are later released as new expressions in the envi- When the formula is first reduced by reaction r1, a reactant ronment. For instance, consider a metabolic cycle in Figure A is absorbed from the environment and one S combina- 1 with the form (AA) + 3A  2(AA) + φ(A). This struc- tor is released. Over the following steps, two I combinators ture creates a copy of itself from 2 freely available units of are sequentially applied and released back into the multiset A and metabolises a third one to carry out the process. P, with the expression returning back to its original form. All these structures have in common the need to absorb We refer to this process as a metabolic cycle because of its reactants from the environment to preserve themselves in strong resemblance to its natural counterpart. For conve- homoeostasis. Furthermore, because they follow a cyclical nience, we write this cycle as (AA) + A  (AA) + φ(A), process, they will continually consume the same types of re- where φ is a function that returns the atomic combinators in actants. Thus, we propose tracking reactants consumption A and the double head arrow means that there exists a path- as a metric that can capture all these different types of struc- way of reduction reactions from the reactives in the left hand tures. For this, we note that the only operation that allows side to the products in the right hand side. an expression to incorporate a reactant into its own body is While autocatalytic sets provide a compelling formalism the reduction of the S combinator, and thus focus on only to study emergent organization in Artificial Chemistries, counting the reactants consumed by S-reactions. it also leaves some blind spots for detecting emergent structures of interest. Such is the case for recursively Reactant assemblage growing expressions. Consider, for instance, e = We also note that emergent structures must necessarily rely (S(SI)I(S(SI)I)). This expression is composed of two on freely available expressions that are at least produced copies of A = (S(SI)I) applied to itself (AA). As by the environment through random collisions. However, shown in Figure 3, during its metabolic cycle it will con- longer reactants come in exponentially smaller concentra- sume two copies of the element A, metabolising one to per- tions, and thus exponentially larger systems should be sim- form its computation, and appending the other one to it- ulated for them to arise in large numbers. This makes the self, thus (AA) + 2A  (A(AA)) + φ(A). As time pro- experimental process considerably inefficient, particularly ceeds, the same computation will take place recursively, thus for allowing the emergence of complex structures that de- (A(AA)) + 2A  (A(A(AA))) + φ(A), and so on. While pend on such reactants. Here, we introduce a heuristic that this particular behaviour cannot be detected through autoca- we call reactant assemblage to facilitate the exploration of talytic sets, because the resulting expression is not exactly larger systems without needing to simulate them in full. The equal to the original one, it still involves a structure that pre- central idea is to arbitrarily define a food set containing the serves in time its functionality. expressions that would be freely available in a larger system. Moreover, while the concept of autocatalytic set captures For this, we fix a maximum food size F . Then, whenever an both patterns that perpetuate themselves in time and patterns S-reduction requires a reactant that is not present in P, but that also multiply their numbers, it does not explicitly differ- is part of this predefined food set, the reactant would be con- entiate between them. A pattern with a metabolic cycle of structed on the spot from freely available atomic combina- the form AA + A  AA + φ(A) (as in Figure 2) keeps its tors. More precisely, we modify Algorithm 1 at the point of own structure in time by metabolising one A in the food set, sampling a reduction with the steps in Algorithm 2. In this but it does not self-reproduce. We call such patterns sim- way, we can simulate the productivity of sufficiently large ple autopoietic (Varela and Maturana, 1973). In contrast, environments, without explicitly needing to compute them. for a pattern to be self-reproducing it must create copies of However, this technique does not bypass the need of discov- ering the substrate, namely, the expression e being reduced. sumption rates to detect whether specific reactants where Instead, it just focuses on creating the required reactants. more prominently used. In particular, we looked at the 10 Furthermore, as the total number of combinators in the sys- most frequently used reactants, from which we are selecting tem is limited, ceiling effects can be observed if the number a few to simplify the presentation. Results are shown in Fig- of freely available atoms start to dwindle. Even with these ure 5 for five different runs. In each of these, we can see the concerns in mind, we experimentally show that this heuristic emergence of different types of structures, including simple facilitates the emergence of more complex patterns. autopoietic, recursively growing, and self-reproducing pat- terns. Interestingly, they can emerge at different points in Algorithm 2: Reactant assemblage time, co-exist, and sometimes some of them can drive others to extinction. Input: Maximum reactant size F Let (e[+x] → eˆ[+y]) ∈ Reductions(e) We first observed that expressions that consume any given if x 6∈ P and |x| ≤ F then reactant A are typically composed of multiple juxtaposed copies of this reactant, confirming the old adage: “Tell me Let nI , nK , nS = Combinators(x) what you eat and I will tell you what you are”. For instance, if P[I] ≥ nI and P[K] ≥ nK and P[S] ≥ nS then in Figure 5a we can appreciate the emergence of the au- Remove nk K from P topoietic pattern (SII(SII)), composed of two copies of Remove nI I from P the reactant A = (SII), and a metabolic cycle of the form Remove nS S from P Add one x to P (AA) + A  (AA) + φ(A), as shown on Figure 2. Binary reactants such as (KK) and unitary ones such as I do not form part of any stable structure, and the ex- pressions consuming them are produced by chance. Yet, Experiments and Discussion they are used with considerable frequency because S com- We initialized P with 10k evenly distributed S, K, and I binators are more likely to be applied to shorter arguments combinators and applied reactant assemblage with reactant than longer ones. For this reason, the consumption of I is size parameter F on a range between 1 (corresponding to no considerable higher than the consumption of (KK). Yet, reactant assemblage) and 20, simulating 10 different runs of even though by the same argument the consumption rate Combinatory Chemistry for 10M iterations. of A = (SII) should be below binary reactants, self- We then began by analysing general metrics of the sys- organization into autopoietic patterns drives the usage of tem for different values of F . Figure 4a shows the expres- this reactant above what would be expected would chance sion diversity as a function of the number of performed re- be the only force at play. At around 2M-3M reactions, the actions. As it can be seen, diversity explodes in the first few system reaches a point in which the consumption levels of 200k reactions, before reaching a peak of about 300 differ- this reactant stabilizes, constrained by the free availability ent expressions. Then, it starts to decline at different speeds, of the reactant. Yet, when we assemble reactants of size at depending on the value of F . When this mechanism is dis- most F = 3 (Figure 5b), the availability of SII reactants is abled (F = 1), the decline occurs at a slow and steady rate. greatly expanded as long as S and I combinators are freely Yet, when F = 3, the decline of diversity becomes much available in the environment, thus allowing the formation of faster, only accelerating with higher F . This effect could be an even larger number of (SII(SII)) structures. explained by the fact that S-reductions, the only ones that At the same time, rarer autopoietic structures can emerge compute increasingly longer expressions, are more likely to in this condition, such as one based on three juxtaposed be successful thanks to the reactant assemblage mechanism copies (AAA) of A = (SSK). This expression has a getting into action. Therefore, the limited available combi- metabolic cycle of the form (AAA) + 2A  (AAA) + nators tend to be clustered in fewer and longer expressions. A + φ(A)5. Here, we note that one copy of A is used but This is also consistent with the evolution of the mean ex- then released intact, which could be construed as an emer- pression length shown in Figure 4b. Yet, when F is set to gent catalyst for the reaction: Indeed, even though we can the high end of the range, reduce operations peak, but then interpret each reduce reaction to be auto-catalysed, reaction start being replaced by random cleavages and condensations chains can have emergent properties, such as in this case, as freely available combinators needed to assemble reactants where a reactant is just used to complete the metabolic cycle plummet (Figure 4c). Thus, the system self-regulates the ra- and then released. tio of deterministic operations (reductions) to random ones From F = 4 we start to see growing structures. In par- (condensations and cleavages) occurring in it. ticular, recursively growing ones. In Figure 5c (F = 6) we However, it is unclear from these results whether the en- can observe two such structures. The first one uses the reac- suing reduction in diversity is driven by emergent complex tant A = (S(SI)I), and follows a tail-recursive cycle that structures that act as attractors, or by some other different reason. To answer this question, we tracked reactant con- 5Derivations are available at the supplementary materials. 400 F 350 1.00 11.00 0.35 350 2.00 12.00 300 3.00 13.00 300 0.30 4.00 14.00 250 250 5.00 15.00 6.00 16.00 200 0.25 200 7.00 17.00 8.00 18.00 150 0.20 150 9.00 19.00 100 10.00 20.00 Reductions (%) 100 Distinct expressions 0.15 50 50 Expressions mean length 0 0.10 0 2 4 6 8 10 0 2 4 6 8 10 0 2 4 6 8 10 Reactions [M.] Reactions [M.] Reactions [M.] (a) Diversity (b) Mean expressions length (c) Reductions

Figure 4: System metrics for different values of reactant assemblage size F . linearly increases the size of the structure: (AA) + 2A  exponentially, this structure quickly grows into one of the A(AA) + φ(A) (Figure 3). The second one is a more most active ones. Yet, when resources run out it enters in complex binary-branching recursive structure, with reactant direct competition with the recursive structure based on the A = (S(SSI)K). When recursive structures come into (S(SI)I) reactant. In 5d the reactant consumption rate for play, we can see that simple autopoietic patterns are driven this last structure is considerably lower than in 5e, seizing into extinction. These extinction events are related to the less resources for itself. This may be due to the fact that the assemblage mechanism, as it puts recursive and autopoietic recursive structure (A(AA)) can either reduce the internal structures in direct competition for atomic combinators. Fig- part, consuming one copy of A, or at the most external level, ure 5f displays the amount of freely available combinators in consuming (AA), which in the latter case is facilitated by this simulation. As shown, S combinators are exhausted at reactant assemblage when F = 8. Yet, the self-reproducing around 3M reactions. At around this point the simple au- pattern suffers from the same problem of simple autopoi- topoietic structure consuming the (SII) reactant goes into etic structures: When it fails to acquire its reactant from a slow decline. Yet, when all freely available I combina- the environment it decomposes into an expression that loses tors are depleted, this structure is driven into a quick ex- its functionality. However, in contrast with simple autopoi- tinction: Without the needed reactant S-reactions start to etic patterns that rely on being produced by chance, self- fail, and thus the expression is either cleaved or combined reproducing ones can recover their population through re- with another one. When (SII(SII)) is broken into two production. Nevertheless, the recursive structure still keeps independent (SII) elements it loses its ability to compute an advantage over the self-reproducing one, especially when itself. In contrast, recursive structures can cope with con- F = 8, where it quickly drives the self-reproducing pattern ditions of low resources quite effectively, as demonstrated into extinction. by the fact that they still continue to consume at stable rate their corresponding reactants after S and I combinators are Conclusions not freely available anymore. A possible reason why this does not bring them into catastrophic failure is their frac- We have introduced Combinatory Chemistry, an Algorith- tal structure: A recursive structure broken up will still have mic Artificial Chemistry based on Combinatory Logic. Even the same function, but it will be smaller. For instance, though it has simple dynamics, it gives rise to a wide range A(AA) → A + (AA) still leaves a functioning (AA) struc- of complex structures, including recursively growing and ture. When new resources become available through the self-reproducing ones. Thanks to Combinatory Logic be- continuous influx of combinators released by every com- ing Turing-complete, the presented system can theoretically puted reduction, it can consume them and grow back again. represent patterns of arbitrary complexity. Furthermore, In the future, to avoid such direct competition for basic re- the computation is distributed uniformly across the system sources between all emergent structures, the reactant assem- thanks to single-step reactions applied at each iteration while blage could be limited, for instance, to be applied only when conservation laws keep the system bounded without intro- there is a minimum buffer of freely available combinators. ducing any extrinsic perturbations. The emerging structures that result from these dynamics feature reaction cycles that Finally, in Figures 5d and 5e we can observe the emer- bear a striking resemblance to natural metabolisms. gence of a full-fledged self-reproducing structure with reac- Moreover, this system does not need to start from a ran- tant A = (SI(S(SK)I)). It follows a cycle of the form dom set of initial expressions to kick-start diversity. Instead, (AA) + 3A  2(AA) + φ(A), thus duplicating itself, and this initial diversity is the product of the system’s own dy- metabolising one reactant in the process. As it replicates namics, as it is only initialized with elementary combinators. (a) F = 1 (b) F = 3 (c) F = 6

3500 Subexpression I 3000 K S 2500

2000

1500 Population 1000

500

0 0 2 4 6 8 10 Reactions [M.] (d) F = 6 (e) F = 8 (f) Combinator population in the simulation of Fig. (c)

Figure 5: (a-e) Reactants consumption computed over a window of 500k reactions on different runs with different reactant assemblage sizes F . Different line styles distinguish reactants used by different types of expressions: Dotted lines represent reactants consumed by simple non-attracting expressions; dash-dotted lines are reactants used by simple autopoietic patterns; dashed lines are reactants used by recursively growing patterns; solid lines are reactants used by self-reproducing patterns. .

In this way, we can expect that this first burst of diversity is ture, we will seek to apply it to explaining the emergence of not just a one-off event, but it is deeply embedded into the evolvability, one of the central questions in Artificial Life. mechanics of the system, possibly allowing it to keep on de- While many challenges lie ahead, we believe that the sim- veloping novel structures continually. plicity of the model, the encouraging results presently ob- tained, and the creativity obtained from balancing compu- Finally, we noted that emerging structures require a con- tation with random recombination to search for new forms, stant influx of specific types of reactants. While only much leaves it in good standing to tackle this challenge. larger systems than the ones simulated here would allow for such continual production of many of these food elements, we proposed a heuristic to make them available without ex- Acknowledgements plicitly simulating them. In this way, have observed a wide variety of emerging structures, including those that would We thank the anonymous reviewers and Mattia De Stefano self-sustain, albeit not changing their numbers (simple au- for their feedback, Sebastian Riedel for his invaluable sup- topoietic); recursive expressions that would keep growing port, and the FAIR London team, the Complexity Interest until reaching the system’s limit; and self-reproducing pat- Group, and the CSSS’19 Machine Creativity reading group terns that increase their number exponentially. for the interesting discussions. A special thanks to Alessan- To conclude, we have introduced a simple model of emer- dra Macillo for suggesting the idea behind reactant assem- gent complexity in which self-reproduction emerges au- blage and for all the feedback, and Jordi Piero for his literary tonomously from the system’s own dynamics. In the fu- recommendations. References Pierce, B. C. (2002). Types and programming languages. MIT Buliga, M. and Kauffman, L. (2014). Chemlambda, universality press. and self-multiplication. In Artificial Life Conference Pro- Ray, T. S. (1991). An approach to the synthesis of life. Artificial ceedings 14, pages 490–497. MIT Press. life II, pages 371–408. Cardone, F. and Hindley, J. R. (2006). History of lambda-calculus Schonfinkel,¨ M. (1924). Uber¨ die bausteine der mathematischen and combinatory logic. Handbook of the History of Logic, logik. Mathematische annalen, 92(3):305–316. 5:723–817. Tominaga, K., Watanabe, T., Kobayashi, K., Nakamura, M., Kishi, Curry, H. B., Feys, R., Craig, W., Hindley, J. R., and Seldin, J. P. K., and Kazuno, M. (2007). Modeling molecular computing (1958). Combinatory logic, volume 1. North-Holland Ams- systems by an artificial chemistryits expressive power and ap- terdam. plication. Artificial Life, 13(3):223–247. di Fenizio, P. S. and Banzhaf, W. (2000). A less abstract artificial Varela, F. J. and Maturana, H. R. (1973). De maquinas´ y seres chemistry. Artificial Life, 7:49–53. vivos: Una teor´ıa sobre la organizacion´ biologica.´ Santiago de Chile: Editorial Universitaria. Dittrich, P., Ziegler, J., and Banzhaf, W. (2001). Artificial Chemistries-A Review. Articial Life, 7:225–275. Walker, C. and Ashby, W. R. (1966). On temporal characteristics of behavior in certain complex systems. Kybernetik, 3(2):100– Eigen, M. and Schuster, P. (1978). The hypercycle. Naturwis- 108. senschaften, 65(1):7–41. Wuensche, A., Lesser, M., and Lesser, M. J. (1992). Global Dy- Flamm, C., Ullrich, A., Ekker, H., Mann, M., Hogerl,¨ D., namics of Cellular Automata: An Atlas of Basin of Attraction Rohrschneider, M., Sauer, S., Scheuermann, G., Klemm, K., Fields of One-Dimensional Cellular Automata, volume 1. Hofacker, I. L., et al. (2010). Evolution of metabolic net- Andrew Wuensche. works: a computational frame-work. Journal of Systems Chemistry, 1(1):4. Young, T. J. and Neshatian, K. (2013). A constructive artificial chemistry to explore open-ended evolution. In Australasian Fontana, W. and Buss, L. W. (1994). What would be conserved Joint Conference on Artificial Intelligence, pages 228–233. if ’the tape were played twice’? Proceedings of the Na- Springer. tional Academy of Sciences of the United States of America, 91(2):757–761.

Fontana, W. and Buss, L. W. (1996). The barrier of objects: From dynamical systems to bounded organizations.

Fontana, W., Wagner, G., and Buss, L. W. (1993). Beyond digital naturalism. Artificial life, 1(1 2):211–227.

Gillespie, D. T. (1977). Exact stochastic simulation of cou- pled chemical reactions. The journal of physical chemistry, 81(25):2340–2361.

Hogerl,¨ D. (2010). Simulation of prebiotic chemistries. Master’s thesis, Institute for Theo- retical Chemistry, University of Vi- enna.

Hordijk, W. (2019). A history of autocatalytic sets. Biological Theory, 14(4):224–246.

Hordijk, W., Smith, J. I., and Steel, M. (2015). Algorithms for detecting and analysing autocatalytic sets. Algorithms for Molecular Biology, 10(1):15.

Hordijk, W. and Steel, M. (2004). Detecting autocatalytic, self- sustaining sets in chemical reaction systems. Journal of the- oretical biology, 227(4):451–461.

Kauffman, S. A. (1993). The origins of order: Self-organization and selection in evolution. Oxford University Press, USA.

Ofria, C. and Wilke, C. O. (2004). Avida: A software platform for research in computational evolutionary biology. Artificial life, 10(2):191–229.

Piantadosi, S. T. (2016). The computational origin of representa- tion and conceptual change. (under review).