1 When enumeration is necessary
The following motivating example  demonstrates a typical problem in which levels are necessary:
KaiC proteins have 6 independent phosphorylation sites. (De)phosphorylation of every site is independent. The more sites are phosphorylated, the bigger the probability that KaiC binds KaiA is.
A typical way to deal with this example consist in explicitly encoding rules for the internal states of the sites of interest. However, doing so induces an exponential blow-up in the number of rules (in the number of levels).
The BNGL  language introduces a notion of indistinguishable sites. i.e. one can define an agent with sites that all have the same name. Consequently, a single rule to specify that sites (out of ) are phosphorylated is enough. Moreover, the number of species is also reduced. Still, there are exponentially many ways to go from one level to another and enumeration is necessary to faithfully respect the dynamics of the system.
We now show that adding a syntactic layer to Kappa that offers support for counting will avoid the explosion in the number of rules.
2 Encoding counters
In Kappa, agents are typed and their signature is given. In the extension we are presenting, counters are part of an agent’s signature and the upper bound of the counter has to be specified.
Extended rules can test counter values (“equals” and “bigger than”). They can also modify their value (increase, decrease or assign a new value). Lastly, levels can be used in the rates of the rules.
We now present two possible ways of encoding counters.
2.1 Unary numbers
We define a new agent type
succ with 2 sites
n. A chains of
succ agents denotes a counter with
value . Agents equipped with counters are encoded as agents with an
extra site for each counter, which is used to bind to a chain
succ agents. For example, in the figure on the right, an agent
A has a counter
c set to 111Representing level
by a chain of length means that we do not have to make a special case for
it in the rules!.
Testing whether a counter is equal to consists in checking whether
there is a chain of
succ agents. A greater than
test checks whether there is a chain
succ agents, where
n of the last
succ agent does not matter.
A counter is incremented by adding
succ agents between the
agent and its
succ chain. The rule depicted on the right
A by one. Removing the beginning of the
succ chain decreases the level.
It is important to stress that counter modifications are independent of its value as the
encoding only manipulates the beginning of a
In our encoding, a rule whose rate depends on levels is expanded into several rules, one for each level. This operation imposes the user-defined upper bound on the levels.
Creation of agents with levels also creates the necessary chain of
succ to represent the levels.
Deletion is more problematic: the chain of
succ is disconnected
from the deleted agent, but not deleted. A possible solution is to collect free chains of
succ by using a rule that says
succ agents with their sites
p free are deleted “at
A second encoding allows tests “smaller than” in addition of “equal” and “greater than”, but is also more verbose and increases the size of states.
As before, counters are encoded as a chain of
succ agents. In
this encoding however, a
succ agent has 3 sites:
n to form chains but also
a, which is where the other
Every agent with a counter bounded by has attached a chain of
succ. The value of the counter is given by which
succ agent it is bound to on site
a. For example, in
the figure on the right, an agent
A has a counter
n are distinct, a direction can be
attached to the chain of
succ. The level is if the agent is
bound to the “bottom” of the chain, and it is if it is bound to the
Incrementing/decrementing the levels are implemented by sliding on the
Testing whether a level is equal or greater than consists of
inspecting the chain of
succ “below” the connection to the
agent. Whereas inspecting the length of the chain “above” the connection to
the agent enables to test if the level is smaller than a value .
While fairly trivial, encoding counters in the Kappa simulator has
greatly simplified some of the models written by the Kappa team.
However, it comes with two drawbacks. First, there is a computational
cost (mainly in term of memory management) to synthetize and degrade
succ agents. Secondly, the simulator works with a plain Kappa
model. There is an implementation cost to go back from the plain Kappa
model to the user-written model, which is necessary when giving
feedback to the user (for example, dumping the current state of the
system). As a result, we plan to implement a native treatment of the
counters in the Kappa simulator.
Another direction for future work is the static detection of overflow
for counters. Currently, the maximal level of the counter has to be declared by
the user. Nevertheless, this means the rules have to be written such that they can never increase a level beyond the defined boundary. The level of the counter can be
checked by static analysis using
interval computation, but for the meantime we have simply added
watchdogs that dynamically raise the alarm if the site of a level becomes
free, or if a chain of
succ that is too long appears.
-  Pierre Boutillier, Jérôme Feret, and Jean Krivine. Kappa and KaSim development page. http://kappalanguage.org.
-  Vincent Danos, Jérôme Feret, Walter Fontana, Russell Harmer, and Jean Krivine. Rule-based modelling, symmetries, refinements. In Formal Methods in Systems Biology, First International Workshop, FMSB 2008, Cambridge, UK, June 4-5, 2008. Proceedings, pages 103–122, 2008.
-  James R. Faeder, Michael L. Blinov, and William S. Hlavacek. Rule-Based Modeling of Biochemical Systems with BioNetGen, pages 113–167. Humana Press, Totowa, NJ, 2009.
-  Susan S Golden. Integrating the circadian oscillator into the life of the cyanobacterial cell. In Cold Spring Harbor symposia on quantitative biology, volume 72, pages 331–338. Cold Spring Harbor Laboratory Press, 2007.