Programming Behaviour

An program is interactive: it reads input over time, and updates its output over time.

This may see like a trivial point, but it is often overlooked. A common way to think about programs is that, given some input, they compute an output. The assumption that these are the only kind of programs is a primary reason a number of philosophers of biology into denying that DNA contains programs.[^reactive] These programs are called transformative programs.

An AND program continuously reads from its input registers, and updates its memory and output registers over time. It is a reactive program. A controller for a robot. Or, a way of capturing behaviour.

Consider the program above. One way to understand what it does is to see how it responds to different inputs.

Here, I adopt Harel’s terminology which contrasts a reactive program to a transformative program (Harel and Pnueli 1985). Common objections to the idea that DNA contains a program assume all programs are transformative. See Calcott (2020) and Capraru (2024) for discussion, and the defence of the idea of genetic programs (Note: in Calcott (2020) I call transformative programs “batch programs” and reactive programs “interactive programs”).

First, I must clarify what AND programs do. A crucial misstep in the genetic programs debate assumes programs only produce one output from one input. TOOD: we that a program functions like Dawkins’ Biomorph algorithm: taking an input and producing an output. This will also sharpen the analogy with genetic programs. Many objections to the analogy stem from too narrow a view of what programs can do.

Programming Behaviour

So what do programs do?

One type of program takes input, processes it through steps, and produces output. Think of a calculator program, a compiler, or a data analysis script—they transform input into output and then finish. We call these transformative programs, or batch programs. A program solves a problem, then stops. Most people think of this when they hear “program”. These programs have a clean input-output structure, making them easy to understand and analyse.

Most programs we use nowadays are not transformative, but reactive. A reactive program continuously monitors events, responding by adjusting its internal state and modifying its output. Think of a web server handling HTTP requests, a GUI application responding to mouse clicks, or an operating system managing hardware interrupts. They don’t just process and finish—they keep running and reacting.

I use the terms transformative and reactive to distinguish these two program types.

AND is a reactive programming language. It mimics gene regulation and interactively generates behaviour.

We need to describe behaviour. The simplest description maps stimulus to response. A bell rings and a dog salivates. More generally, environmental cues trigger organismal actions.

Organisms with nervous systems show this behaviour. The same principle operates at the cellular level. Escherichia coli use chemoreceptors to sense nutrients and regulate flagellar rotation. When nutrients appear, flagella drive forward motion (“run”); when absent, rotation reverses, causing “tumbles” that reorient the cell.

We need a simple, abstract way to capture our program’s behaviour. Two key features matter:

  1. Counterfactual: Behaviour depends on what happens under different conditions. A dog salivates when it hears a bell, but just as importantly, it does not salivate when the bell is silent.
  2. Temporal structure: Behaviour unfolds over time. Durations, delays, and ordering matter. Rather than simple stimulus-response pairs, we map sequences of stimuli to sequences of responses. This captures the program’s reactive nature.

We capture both aspects by tracking stimuli and responses over time under multiple environmental conditions. To keep it simple, we use discrete time steps and Boolean variables (either present or absent). Table 1 shows our dog’s behaviour in minimal form: doing nothing when the bell is silent, and salivating (B) immediately after a bell (A) rings.

t No Bell Bell Rings
Stim. Resp. Stim. Resp.
0 A B A B
1 A B A B
2 A B A B
3 A B A B
4 A B A B
5 A B A B
Table 1: The dog does nothing when it is silent. But when the bell rings (A), the dog salivates (B).

Our behaviour model uses just a few Boolean variables (A and B) over discrete time steps. But this simple structure captures a wide variety of behaviours.

Programming Behaviour

Now that we have described the behaviour, we can see how our genomic program generates it. Figure 1 shows the AND program that produces the dog behaviour from Table 1. This program contains one expression that generates a B response one time-step after detecting an A stimulus.

 BNUa_->B 
Figure 1: The smallest possible AND program, consisting of just one expression.

How does this program work? This expression mimics a DNA section containing a single gene with a regulatory region (BNUa_) and a coding region (B), separated by a promoter site (->).

The regulatory region contains two motifs (a and _) preceded by an operator (BNU). Think of motifs as binding sites where regulatory molecules attach—just like transcription factors binding to DNA. Each motif binds to its corresponding element: a binds to A, while _ binds to nothing.

The operator BNU specifies the logic: turn on gene expression when the left motif is bound AND the right motif is unbound. In our case: produce B when A is present and nothing else interferes.

We can combine the program with the behaviour to see how this works. Table 2 shows the same behaviour as Table 1, but displays the program state at each time step. When A is absent, nothing binds to the motif, so the gene stays silent and produces no B. When A appears, it binds to its complementary motif a. Because the left motif is bound and the right is not (following the BNU operator), the gene turns on, producing B in the next time step.

t No Bell Bell Rings
Stim. Resp. Program State Stim. Resp. Program State
0 A B
BNUa_->B
A B
A ↪B
BNUa_->B
1 A B
BNUa_->B
A B
BNUa_->B
2 A B
BNUa_->B
A B
BNUa_->B
3 A B
BNUa_->B
A B
A ↪B
BNUa_->B
4 A B
BNUa_->B
A B
BNUa_->B
5 A B
BNUa_->B
A B
BNUa_->B
Table 2: The program state shows whether the stimulus (A) is bound to the regulatory region, and whether or not the gene is turned on (● above the coding region). If the gene is on, the response (B) is produced in the next time step.

The program in Figure 1 is the smallest and simplest AND program, and the behaviour it produces is the most basic form of conditional response.

Now consider more complex behaviour, such as our E. coli bacterium. It switches between running (D) and tumbling (E). Without nutrients (A), the bacterium alternates between tumbling and running in a regular pattern. When nutrients appear, it switches to continuous running. When nutrients disappear, it returns to the tumble-run pattern. Table 3 shows this behaviour.

t No Food Food Appears Food disappears
Stim. Resp. Stim. Resp. Stim. Resp.
0 A DE A DE A DE
1 A DE A DE A DE
2 A DE A DE A DE
3 A DE A DE A DE
4 A DE A DE A DE
5 A DE A DE A DE
6 A DE A DE A DE
7 A DE A DE A DE
8 A DE A DE A DE
9 A DE A DE A DE
Table 3: Bacterial chemotaxis behaviour: running (D) when food is present, tumbling (E) and running in cycles when food is absent.

This behaviour requires a more complex AND program. Figure 2 shows one possible implementation with four expressions, or genes.

 XNUcc+BVUab->B   QZQb_->C   BNUb_->D   QNQb_->E 
Figure 2: A more complex AND program, consisting of multiple expressions working together.

Two new features appear here.

First, one expression (XNUcc+BVUab->B) contains two regulatory regions separated by a + operator. These regions work independently: if either region activates, the gene turns on. This mimics how genes respond to multiple regulatory modules that interact (Buchler, Gerland, and Hwa 2003).

Second, we now have genes producing elements (B and C) that don’t directly appear in the behaviour. These are regulatory genes, and they decouple sensory input from behavioural output, enabling more complex processing. They serve as internal state for the system, so I label their products as memory, alongside stimuli and response.

Table 4 displays the “Food Appears” sequence from Table 3. We added the “memory” column to track the system’s internal state, and the program state to show how regulatory interactions produce the observed response.

Food Appears
t Stim. Mem. Resp. Program State
0 A BC DE
↪B ↪E
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
1 A BC DE
B ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
2 A BC DE
CC B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
3 A BC DE
CC ↪B ↪E
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
4 A BC DE
AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
5 A BC DE
CC AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
6 A BC DE
CC AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
7 A BC DE
CC AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
8 A BC DE
CC AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
9 A BC DE
CC AB ↪B B ↪C B ↪D B
XNUcc+BVUab->B QZQb_->C BNUb_->D QNQb_->E
Table 4: The regulatory dynamics underlying bacterial chemotaxis when food appears.

Memory elements (B and C) enable the system to maintain state over time, including switching between tumbling and running. When food appears, A binds to its motif, activating the first expression, which produces B.

Behaviour as a Phenotype

We should not understate how much of a shift this is from the just recording. Rather than encoding form, we encoding a behavioural phenotype.

We now have our first genotype-phenotype mapping. The genome is a program written in AND, and the phenotype is the behaviour this program produces. This phenotype maps sequences of stimuli to sequences of responses. We can visualise the program’s structure as a regulatory network.

Both the dog and bacterium illustrate how internal wiring mediates behaviour and can be modified. In dogs, neural circuits mediate behaviour, learning to associate bells with food. In bacteria, regulatory gene networks mediate behaviour, evolving to connect chemical sensing to flagellar action (Wadhams and Armitage 2004).

The tables and networks here lack the visual appeal of Dawkins’ Biomorph phenotypes. But our phenotype is considerably richer. A genotype specifies not one outcome, but a repertoire of context-dependent responses. The same genomic program produces tumbling in one environment and smooth swimming in another.

This already connects to several important biological concepts. Plasticity, reaction norms, and gene regulation all appear in this simple model. Our genotype encodes a reaction norm—a mapping from environment to phenotype. This is phenotypic plasticity at its simplest: one genotype, multiple phenotypes, depending on environment.

Environmental responsiveness opens new evolutionary possibilities. Selection can favour genomes that produce adaptive behaviour across multiple environments, not just optimal behaviour in one context. The genome becomes a program for sensing, processing, and responding to environmental cues. This represents a crucial step toward building more complex phenotypes.

What precisely is the phenotype? As with real biological organisms, what counts as a phenotype depends on what interests us. A trait could be one behaviour, a set of behaviours, or the entire behavioural repertoire. What matters evolutionarily is what selection acts on. So we must be clear about what we select for.

References

Buchler, Nicolas E., Ulrich Gerland, and Terence Hwa. 2003. “On Schemes of Combinatorial Transcription Logic.” Proceedings of the National Academy of Sciences 100 (9): 5136–41.
Calcott, Brett. 2020. “A Roomful of Robovacs: How to Think About Genetic Programs.” In Philosophical Perspectives on the Engineering Approach in Biology: Living Machines?, edited by Sune Holm and Maria Serban. Routledge. https://doi.org/10.4324/9781351212243.
Capraru, Mihnea. 2024. “Making Sense of ‘Genetic Programs’: Biomolecular PostNewell Production Systems.” Biology & Philosophy 39 (2): 6. https://doi.org/10.1007/s10539-024-09943-3.
Harel, D., and A. Pnueli. 1985. “On the Development of Reactive Systems.” In Logics and Models of Concurrent Systems, edited by Krzysztof R. Apt, 477–98. Berlin, Heidelberg: Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-642-82453-1_17.
Wadhams, George H., and Judith P. Armitage. 2004. “Making Sense of It All: Bacterial Chemotaxis.” Nature Reviews Molecular Cell Biology 5 (12): 1024–37. https://doi.org/10.1038/nrm1524.