language and a vast repertoire of mechanisms for assembling MP Systems, is available .... Note that the rules are unlinked from the Start/Halt signalling substances, that is ... and, at the same time, r1 : z â j tries to increase the value of j from 0 to 1 ..... the computations are defined as matter transferrals as well as on the inter-.
Arithmetical Metabolic P Systems Rosario Lombardo and Vincenzo Manca Department of Computer Science, University of Verona Strada Le Grazie, 15 – 37134 Verona, Italy {rosario.lombardo, vincenzo.manca}@univr.it
Abstract. Metabolic P systems, a class of P systems introduced for modeling metabolic processes, proved to be promising in many contexts from bio-modelling to function approximation. In this paper we define a deterministic computational model based on this systems. This on-line version introduces the preliminary metabolic framework Lamp in section 4.
1
Introduction
Metabolic P systems represent metabolic processes in a discrete mathematical setting. Based on Gh. Pˇaun’s membrane computing theoretical framework [14], MP systems [7–9] are deterministic mono-membrane [3] dynamical systems where multiset rewriting rules are regulated by functions. In fact, biochemical reactions occur at a specific rate, determined by the regulator functions rather then selected with non-deterministic strategies. The encouraging results of applying MP systems to modeling biological phenomena and to function approximation [11] inspired the idea of defining a deterministic model of computation, called Arithmetical MP Systems, accompanied by a suitable software framework. Since the P systems were introduced [13], several variants of the model were defined and many software application have been used. The P-Lingua [6] programming language, presented to be standard for non-deterministic P system models, supports the definition of a certain number of P system models offering a procedural calling of modules. The P-Lingua implementation simulator then runs one of the possible computations that the P system model may follow [4]. Arithmetical MP Systems introduce a deterministic model of computation for biological networks which can be composed together by defining a sequential composition among these systems. In Arithmetical MP systems the idea of sub-routine calling is not a procedural call but rather a regulatory composition mechanism allowing to regulate reaction rates by using the computational output of an adjacent system. Lamp, the preliminary framework implementing the language and a vast repertoire of mechanisms for assembling MP Systems, is available online at http://profs.sci.univr.it/~lombardo/lamp. In MP systems, a multiset rule like 2a + b → c means that a number u of molecules of kind a and the same number u of molecules b are replaced by u molecules of type c. The value of u is the flux of the rule application. Assume
to consider a system at some time steps 0, 1, 2, . . . , t and consider a substance x that is produced by rules r1 , r3 and is consumed by rule r2 . If u1 [i], u2 [i], u3 [i] are the fluxes of the rules r1 , r2 , r3 respectively, in the transition from step i to step i + 1, then the variation of substance x is given by x[i + 1] − x[i] = u1 [i] − u2 [i] + u3 [i] . In a MP system, for any state, the flux of each rule is provided by a function, called regulator of the reaction. Substances, reactions, and regulators (plus parameters which are physical variables different from substances occurring as arguments of regulators) specify a dynamics, given at discrete steps. At every step, the dynamics is governed by a partitioning of mass determined by the fluxes of rules consuming it. An MP system is described entirely by an MP grammar where multiset rewriting reactions are given with the corresponding regulators. An MP grammar is also specified by an MP graph where the relationships between reactions and regulators appear in a direct way (see Fig. 1).
x
φ1
φ1
r1
r1
φ2 r2
=
+
y
r3
x
φ2 r2
r3
φ3 Stoichiometry
Flux Regulation
y
MP Graph
φ3
Fig. 1. MP graphs define the stoichiometric and regulatory components: substances (circles), input and output gates (green triangles) are connected by reactions arrows. The regulators (rectangles) determining the flux of rules are linked with dashed arrows.
2
Arithmetical MP systems
The Arithmetical MP Systems are a class of MP Systems describing a universal computational model. Universality can be easily proved modelling a register machine or, with a little more effort, the µ–recursive functions. Notational Conventions. A set of substances S, considered in a conventional order, determines a vector X = (x1 , . . . , xn ) ∈ Nn of substance quantities providing the metabolic state of the system. When there is no possibility of ambiguity, for any j, 1 ≤ j ≤ n, we use the notation xj as substance quantity rather then substance symbol. Let R be the set of reactions having the set of regulators Φ = {φr | r ∈ R}. A reaction r is then represented by a left vector r− ∈ Nn of reactants and a right
vector r+ ∈ Nn of products. The component-wise difference r# = r+ − r− is the stoichiometry balance of r. Definition 1. (x-availability constraint) Let x ∈ S, if R− (x) is the subset of reactions consuming x, then x verifies the x-availability constraint with respect to Φ when ∑ |r− |x φr (X) ≤ x . r∈R− (x) −
Where |r |x is the multiplicity of x in r− using the Parikh notation. Definition 2. (Blocked rule) Let R be a set of reactions with regulators Φ. If, for a given substance x, the x-availability constraint is not satisfied with respect to Φ, then the reactions of R− (x) are said to be blocked on x with respect to Φ. Definition 3. (Simple regulators) A set of regulators Φ = {φr | r ∈ R} is simple when, given the state X = (x1 , . . . , xn ), (constant) k ∈ N ∀r ∈ R, φr (X) = or xj | 1 ≤ j ≤ n (projection) . Definition 4. (Arithmetical MP System) An Arithmetical MP System of type (n, m, k) having n substances, m reactions and k parameters, is specified by the construct: M = (S, R, H, Φ, In, Out, Start, Halt) where: S is a set of n substances, considered in a conventional order, determining the metabolic state X ∈ Nn of the system. − + , rm ), whose stoichiometric balances R is a set of m reactions (r1− , r1+ ), . . . , (rm # are the columns of the stoichiometric matrix A = (r1# , . . . , rm ). k H is a function H : N → N providing, at each step i ∈ N, the vector H[i] of parameters. Φ is the set of simple regulators {φr | r ∈ R} such that, ∀X ∈ Nn each reaction r ∈ R has associated the regulator: { 0 if r is blocked w.r.t. Φ φ br (X) = φr (X) otherwise . In, Out are a set of substances with In ⊆ S, Out ⊆ S. Start, Halt are two substances with Start ∈ S, Halt ∈ S. Let X[0] ∈ Nn be the initial state of the system M , its dynamics is specified by the vector recurrent equation, called Equational Matabolic Algorithm, defined in MP Systems [8]: b [i] + X[i] X[i + 1] = A × U (1) providing in X[i + 1] the metabolic state of the system by means of the vector of b [i] = (b fluxes U ur [i] | r ∈ R) where u br [i] = φ br (x1 [i], . . . , xn [i], p1 [i], . . . , pk [i]) are computed upon the components of the status X[i], H[i].
Arithmetical MP Systems compute functions according to the following: Definition 5. (MP–Computable function) A function f : Nk → Nh such that f (a1 , . . . , ak ) = (b1 , . . . , bh ) is MP–computable if there exist an Arithmetical MP System M in which, when the IN substances contain the values a1 , . . . , ak respectively, setting the Start substance to 1, M eventually ends having 1 in its Halt substance and the values b1 , . . . , bh in the OUT substances. Moreover, M never reaches the value 1 in the Halt substance if and only if f (a1 , . . . , ak ) is undefined. The Equational Metabolic Algorithm (1), expressed in algebraic terms in Def. 4, can also be expressed as multiset operations. Given the substances a, b, c ∈ S, we use the polynomial representation for denoting the multisets α, β, γ such as α = [[na a + nb b + nc c + . . . ]], where na , nb , nc , . . . are the multiplicities for each molecular species. The multiset sum is easily defined summing component by component as, for example, [[a + 2b]] + [[3b + c]] = [[a + 5b + c]]. The limited subtraction is analogously defined only if the subtrahend is less or equal then the subtracter, while the multiplication of a number times a multiset follows the distributive property of polynomials as for example 3 × [[a + 2b]] = [[3a + 6b]]. Given a reaction r : 2a + b → c, we can naturally read its reactants and products as multisets, using again with some abuse of notation, r− = [[2a + b]] and r+ = [[c]] respectively. Now we can use the multiset operations to express the Equational Metabolic Algorithm (1), whereas, at each step i ∈ N, the rule r subtracts φ br (X[i]) times the multiset r− and adds φ br (X[i]) times the multiset + r to the metabolic state X[i]: ( ) ∑ ∑ + − X[i + 1] = X[i] + φ br (X[i]) × r − φ br (X[i]) × r . (2) r∈R
2.1
r∈R
Simple Arithmetical MP Systems
In this section some introductory MP–computable functions are described in order to get the reader acquainted with the Arithmetical MP Systems, MP grammars and MP graphs. In MP graphs the flux regulators are written besides the rule nodes and the graphical notations of Table 2.1 will be used. Limited Subtraction. The limited subtraction, written as x ⊖ y, is properly defined only if the subtrahend can actually be subtracted from the subtracter. More formally: { x − y if x ≥ y ⊖ : N × N 7→ N, x⊖y = x otherwise . The Arithmentical MP system implements the operation in one step as shown in Fig. 2, where the rule tries to expel x and y with a flux equals to the subtrahend
Table 1. Graphical notations Description
⃝ ⃝ ⃝ ⃝ ⃝ ⃝ · ▽
In substances Out substances In–Out substances Start substance Halt substance open system input rule λ → a open system output rule a → λ substance membrane
→
Symbol
↕
→ ↓ ↓
∩
∩
▽ ⃝
s
y
x y
h
Fig. 2. Limited Subtraction. Note that x contains part of the input and the output.
y. If there is not enough of both molecular species the rule blocks and the input will be left untouched. Otherwise a proper subtraction x − y will be left in x. Note that the rules are unlinked from the Start/Halt signalling substances, that is, the system needs the In substances to be fed at the same time with the Start substance. Moreover, after the system has provided the result, the In/Out substances (x, y) are likely to be left in state which does not allow to safely start another computation. The definition of the MP-Limited-Subtraction is: S = {x, y, s, h} R Φ In = {y} z }| { z }| { In/Out = {x} r 1 : s → h φ1 = 1 Start = s r2 : xy → ∅ φ2 = y Halt = h Conditional Construct. The Conditional construct is implemented addressing the notes mentioned above: the whole network is linked to the Start/Halt signalling substances and there are clean-up reactions making the system slightly more complicated but also reusable. Given two alternative biological MP networks, one must be chosen depending on the value of a guard. The idea is therefore to produce two alternative substances used to Start the corresponding system (see Fig. 3). Encoding the truth values {true, false} as {1, 0} we are defining the function:
{ Cond : N 7→ {0, 1} × {0, 1},
Cond(z) =
(1, 0) if z = 0 (0, 1) otherwise .
1 0
s 1
s
s x
0
t
0 s
1
z
0
j y j
0 s
h
Fig. 3. The conditional construct is a function N 7→ {0, 1} × {0, 1}.
The following MP grammar defines the Conditional construct: z r1 S = {x, y, z, j, t, s, h} r2 In = {z} r3 Out = {x, y} r4 Start = s r5 Halt = h r6 r7 r8
R }| { :z→j :j→z :∅→x :x→y :x→∅ :y→∅ :s→t :t→h
Φ z }| { φ1 = s φ2 = 1 φ3 = s φ4 = j φ5 = s φ6 = s φ7 = 1 φ8 = 1
Once the Start s becomes 1, x is incremented to 1 from the environment and, at the same time, r1 : z → j tries to increase the value of j from 0 to 1 with a flux of s = 1. Input z = 0: the rule r1 : z → j blocks and the value of j remains 0. In the next step the rule t → h signals the end of computation and the result in Out is (x, y) = (1, 0). Input z ̸= 0: the value of j actually changes to 1 and in the next step the rule r4 : x → y inverts the values of x and y, leading to a final configuration where the Out is (x, y) = (0, 1). The reactions r5 : x → ∅ and r6 : y → ∅ clean up the Out substances at the beginning of any new computation. The rule r2 : j → z, restores the In substance to its original value, if needed. However the ancillary substance j is not introduced as much for the restoration of x but rather for its two properties. First, it is the complementary of input z when needed to invert the output and, second, being always zero at the beginning, the rule r4 : x → y never blocks the cleaning of r5 : x → ∅. Finally the temporary t is introduced for timing purposes suggesting that the system always takes two steps to execute.
3
Adding Membranes
In the examples above there was the implicit assumption that the IN values were available at once and together with the Start. Indeed biological networks transform matter as soon as appropriate rules and substances are put together. If we want to compose two computation processes together, a sort of buffering layer is needed in-between preventing any partial values being fed into the second system possibly corrupting its initial configuration and triggering altered computations. We want to be sure that such a composition is possible at all. Theorem 1. (Sequential Composition) Given two MP Computable functions f and g, the composition f ◦ g is a MP Computable function. A mechanism proving the theorem is shown in Fig. 4 where top and bottom substances belong to f and g respectively. Let’s consider, without loss of generality, only the output x′ of f being transformed into the input x for g.
t
h x' x'
... t
z'
h
t
z'
1
1
1 x 0
z
0
s
Fig. 4. The Sequential Composition mechanism.
Anytime before h reaches 1, both the rules consuming x′ are blocked because the total requested flux x′ +t exceeds the value of x′ . Once h reaches 1, substance t gets its value decreased to 0 and the x′ –availability constraint is satisfied: Start and In substances are synchronously provided to g. The Start and Halt substances of f ◦ g are the Start of f and the Halt of g, respectively. 3.1
Multicompartimental Setting
The functional composition, a very desirable property when complex algorithms are to be designed, naturally brings the idea of having separate and composable computing entities: the membranes. A boundary rule [2] is localized in the membrane of its reactants. Let k, l be regions, a boundary rule has always the form of localizedk reactants → localizedl products. If the regions k and l are the same, the rule transforms matter, otherwise there is a communication and a transformation of substances across membranes. Definition 6. (Multicompartimental Arithmetical MP System) A Multicompartimental Arithmetical MP System of type (n, m, k) is a construct:
M = (S, R, H, Φ, L, C, K) where: S, H, Φ are as in Definition 4; L is set of membrane labels that are identified with the membranes their-selves. C is a membrane structure describing the initial configuration. R is a set of localized reactions associated to membranes k, l ∈ L with the forms: meta [k α → [k β :: φ the classical MP reaction rewritten in the multicompartimental context: in membrane k at step i, φ(X[i]) b units of multiset α are transformed into φ(X[i]) b units of multiset β. in α [k → [k β :: φ if α is in the immediate outside region of membrane k, φ(X[i]) b units of α are introduced in k and transformed into φ(X[i]) b units of β. out [k α → β [k :: φ if α is contained in the membrane k, the reaction expels φ(X[i]) b units of α from k transforming it into φ(X[i]) b units of β. trans [k α → [l β :: φ if α is contained in the membrane k and in the immediate outside region of k there is the sibling membrane l, the reaction transforms φ(X[i]) b units of α into φ(X[i]) b units of β transferring it from k to l. extra-in [k → [k α :: φ the reaction introduces φ(X[i]) b units of α into membrane k from the environment external to system M . extra-out [k α → [k :: φ the reaction expels φ(X[i]) b units of α from membrane k into the environment external to system M . K is a labelling of substances and membranes marking – as input In and output Out substances or membranes: In, Out ⊆ S × L – as Start and Halt only substances: Start, Halt ⊆ S. The dynamics of M is written according to (2) following the semantics of the rules in R. The multicompartimental Arithmetical MP System defines a membrane model with flux regulators in which the model of calculus is deterministic and therefore effective for the implementations. Example 1. (Abacus) Let’s define a 3-digit abacus with carry in base 10. Two input numbers N = 728 and M = 322 are encoded, using the substance u inside the input membranes as [7u]N1 [2u]N2 [8u]N3 and [3u]M1 [2u]M2 [2u]M3 . An insight is given in Fig. 5, where substances and membranes are denoted by circles and rounded boxes respectively. Substance u (not shown for simplicity) from input membranes is summed by transferring it digit-by-digit into the output membranes. The output membrane R1 encodes the digit of thousands possibly yielded by the carry rules, each trying to consume 10 units from its right region to produce 1 carry unit on its left region.
k s k
N1
N2
N3
4 s
t
s
M1
M2
M3
h 0 t 1 A
R1
1
R2
1
R3
R4
Fig. 5. A 3-digit abacus with carry.
The computation, including the carry, may take up to k = 4 steps counted by the countdown network as follows. When s becomes 1, the reaction r10 : k → t occurs leaving k = 3 and t = 1. At each next step k is decreased, while the rules consuming t are blocked because they want to globally consume t + s = t + 1 units of t. When k becomes 1 the rule r13 : s → h unblocks producing the Halt substance h and decreasing the value of s to 0. Now r11 : t → k can refill k making the counter network re-usable. The overall efficiency, as in digital computers, has an important limitation in the carry mechanism unless some additional optimizations are implemented. Notice that the reaction arrows can transform matter either in the same region or also communicate substances across membranes. The MP grammar in standard boundary notation is given by: z r1 r2 r3 r4 r5 In = {N1 , N2 , N3 , M1 , M2 , M2 } ⊆ L r6 Out = {R1 , R2 , R3 , r4 } ⊆ L Start = s ∈ S r7 Halt = h ∈ S r8
R }| { : [N1 u → [R2 u : [M1 u → [R2 u : [N2 u → [R3 u : [M2 u → [R3 u : [N3 u → [R4 u : [M3 u → [R4 u
Φ z }| { φ1 = u φ2 = u φ3 = u φ5 = u φ4 = u φ6 = u
: [R4 10u → [R3 u φ7 = 1 : [R3 10u → [R2 u φ8 = 1 r9 : [R2 10u → [R1 u φ9 = 1
r10 r11 r12 r13
: [A k → [A t : [ A t → [A k : [ A t → [A k : [A s → [A h
With the initial configuration C = [A 4K[7u]N1 [2u]N2 [8u]N3 [3u]M1 [2u]M2 [2u]M3 []R1 []R2 []R3 []R4 ] .
φ10 φ11 φ12 φ13
=s =t =s =k
4
LAMP: the Metabolic Framework
Lamp is a metabolic framework implementing a programming language and a vast repertoire of mechanisms for assembling MP Systems. The language, designed to support different variants of MP Systems, is presented in a computational framework, giving syntactic and semantic specifications along with language-level mechanisms. Additional features provided as part of the Lamp IDE are syntax-highlighting text editor and GUI applications. Lamp is written in Java, implementing most of modern compiler’s techniques [1], by means of the ANTLR1 v3 parser generator and the SWT2 for the crossplatform graphical user interface. The syntax of the Lamp language (see § 4.5) is defined using the Extended Backus–Naur Form [12, 5], i.e. BNF grammars augmented with repetition and optional operators as well as parenthesized subrules to support clear grammatical descriptions. The main distinguishing features of one Arithmetical MP System model are presented hereafter. 4.1
Reactions
Reactions are the basic computation statement in Lamp. The general form for a reaction is: A -> B :: regulator A and B are the reactants and products multisets, respectively, of the reaction, while regulator is the regulatory function. Reactions can be written as follows: • evolution: • input: x[] • output: • communication: • remote evolution: • remote output: [x] • remote comm: [x]
a -> b :: foo -> [y] :: [x] -> y[] :: [x] => [y] bar :: [a -> b] bar :: foo -> y[] :: bar => [y] foo ::
reg reg reg reg reg reg reg
Remote rules3 are a shorthand for writing code which will be executed inside any specified remote membrane as far as it is in in-scope (see § 4.3). The flux definition reg in a reaction of a Arithmetical MP System can be: – constant or substance identifier (strict specification: default) – any expression – regulatory composition calls (see § 4.4). 1 2 3
ANTLR, ANother Tool for Language Recognition, version 3. http://www.antlr.org/ The Standard Widget Toolkit, http://www.eclipse.org/swt/ Remote input-rules [a[] foo -> [b]] bar are currently not supported only for their cumbersome syntax.
a -> b :: reg;
[a -> b]_bar :: reg;
a[]_foo -> [b] :: reg; membrane bar membrane foo [b] -> a[] :: reg; [a] => [b]_bar :: reg;
[a]_bar => [b]_foo :: reg;
[a]_foo -> b[] :: reg; Fig. 6. A figurative representation for the semantics of Lamp rules. The dotted arrows unveil the membrane where the remote rule is bound to.
A program option allows changing which expression is accepted as regulator. Example: // evolution 2a + 3b -> c + d :: 1; // input a[]_Alpha -> [c] :: 1; // output [a] -> b[] :: a; // communication [a] => [b]_siblingMembrane :: 1; // remote evolution [a ->b]_siblingMembrane :: 1; // remote output [a]_siblingMembrane -> b[] :: 1; // remote comm [a]_siblingMembrane => [b]_siblingMembrane :: 1; 4.2
Membranes
Arithmetical MP Systems are naturally constituted by membrane definitions. Membranes can be defined to be: – independent computational units, defined as: membrane Beta { ... } – Lamp membranes, defined as: membrane Eta(input a,b; output c,d; start s; halt h) { ... } The body of a membrane is made of zero or more statements, which include also inner membranes. An independent computational unit makes use of bare rules, while a Lamp membrane has full-language-support in terms of computational and compositional mechanisms (see more details below). Example:
membrane Beta { 2b + 3d -> c + 2a :: 3; membrane Eta(input z; output a,b; start s; halt h) { a -> b :: 3a; } substances a := 2, b := 3, c := 44; } 4.3
Scoping
Substances, Parameters, Promoters and Membranes belong to separate name spaces. Each name space coincides with the context of the membrane scope they are defined. Substances, Promoters and Membranes can be defined in each membrane with local visibility. This means that, for every membrane, there exist a distinct name space for each of them. Parameter identifiers can be defined only in a global section and have global visibility, i.e. there is one single name space containing parameters and such name space is globally accessible. Substance identifiers are bound in current membrane until there is at least one object of that substance. Since an identifier might refer both to a local substance or to a global parameter, a disambiguation construct is available in the language allowing to directly access the parameter name space: P.par name (see § 4.5). Name resolution. Regulators are defined by expressions made of identifiers. The semantics of identifiers depend on the entities they refer to. The name resolution in Lamp is defined as follows: – All identifiers are initially resolved as local substance identifiers. – Local substance identifiers supersede parameter identifiers (parameter shadowing). – If an identifier is not found among local substances it is then resolved against the parameters name space. – If the identifier is not a parameter it is then considered to be a substance with multiplicity zero (used to block rules). – A qualified parameter identifier (P.par name ) is only resolved in parameter name space: if it is not found an error is raised.
4.4
Language mechanisms for Lamp membranes
All Lamp programs support the features shown above. The “bio-programmer” has to take care that all the rules work smoothly together as expected in a concurrent context. The Lamp membranes exposes a set of language-supported mechanisms enabling more flexible and abstract programming.
parameters { c := 1; p := 2; } 3a + b a -> c :: c Fig. 7. A figurative representation for the semantics of dynamic parameter shadowing. If the substance c happens to be produced, the name c will be bound to the substance, unless the explicit parameter accessor P.c is used.
Start/Halt. At the beginning, if no Start substance is present the membrane is blocked. The same happens if the Halt substance is present or both Start and Halt are present. After a Start substance is introduced the computation keeps going, even if the Start is consumed, until either the Halt is available or the rules block. As soon as the Halt is available the membrane’s status changes into halted. A program option (see § 4.5) allows to globally specify if the reactions of such an halted membrane must block or can keep evolving. In the second case is, for example, possible to expel the Out substances outside. Sequential Composition. Composing independent computing units together, as described in § 3, requires particular attention from the bio-programmer who should in general take care to set up the appropriate “buffering” reaction networks. The Sequential Composition language-mechanism, controlled via program options (see § 4.5), is introduced to easy the creation of glueing biological networks among Lamp membranes. The mechanism is activated by following conditions: – the source membrane is halted and the Halt substance is available – the target membrane is halted and is missing the Halt substance – comm–reactions (see § 4.1) from the source membrane have • all the Out substances of the source membrane among its reactants • all the In substances of the target membrane among its products • any of the reactants being the Halt of the source membrane • any of the products being the Start of the target membrane Example: membrane Beta(input a, output b, start s, halt h) { ...
[b + h] => [in + s]_Eta :: 1; } membrane Eta(input in, output b, start s, halt h) { ... in -> b :: 3; } Regulatory Composition: the call/require keywords. In Arithmetical MP Systems, all reactions are regulated by a flux functions (regulators) defined to be either a constant value or a substance reference (see Def. 3). The Lamp language provides a program option (see § 4.5) that allows to use the value returned by Lamp membranes as regulator flux: something usually referred to as subroutine-calling. This mechanism, called Regulatory Composition, behind the scenes brings together composition of independent computational units and Turing-computable regulatory functions. The callee must be a Lamp membrane, this implying it accepts the parameters as specified by its In substances. The reaction and the callee membrane must be contained in the same compartment. In fact, the identifiers of both the callee and the parameters are resolved according to the scoping rules specified in § 4.3. The parameters are passed by value and the callee membrane must have only one Out substance whose value will be used as regulator for the rule. A possible extension is to define an array-like syntax for accessing some of the specific Out substances. Two mechanisms are available: – Call – the rule gets blocked until the callee has returned a value – Require – all rules in the same membrane – but not the inner membranes – get blocked until the callee has returned The Lamp language takes care to (see Fig. 8): – Block the involved entities: single rule for Call, all sibling rules for Require. • All other entities, such as sibling membranes or rules, continue evolving. – Create an abstract instance of the callee, initialized as defined in the source program. – Pass the parameters by value. – Pass the Start to the callee and wait for its Halt. – Fetch the Out and pass it back as regulatory value. – Unblock the involved entities of first point and continue with actual values. Note that, from the first point, derives an actual asynchronous system in which the caller’s clock is beat by the callee computation timings. Example:
.. -> .. .. -> ..
}
a -> b :: Require Eta(2a+b);
membrane Eta(in a,b; out c,...)
membrane Eta(in a,b; out c,...)
Fig. 8. A figurative representation for the semantics the regualtory composition mechanism. The dashed box highlights the membrane abstraction created for executing the Require-call.
membrane Beta(input a,z; output a; start s; halt h) { z -> a :: z; s -> h :: 1; } a -> b :: Call Beta(2a+3z); 4.5
Lamp Syntax
The syntax of the Lamp language is defined as follows using the Extended Backus–Naur Form [12, 5], i.e. BNF grammars augmented with repetition and optional operators as well as parenthesized subrules to support clear grammatical descriptions.
Identifiers. A valid identifier is a sequence of characters whose first character is a letter or ’ ’. IDENT := (LETTER | ’_’) (LETTER | DIGIT | ’_’)* ; LETTER := ’a’ .. ’z’ | ’A’ .. ’Z’; DIGIT := ’0’ .. ’9’; Valid identifiers are used for – – – –
Substances Parameters Membranes Promoters.
Types. Two user-types are available: – floating point: 64bit signed in the range of about ±1.7976931348 × 10+308 – integer: unlimited precision Automatic casting and rounding is performed if needed. A program-option (see § 4.5) controls whether a warning is emitted to console during run-time casting/conversion.
Expressions. Full support is available for expressions which are written as customary in programming languages. Supported operations are: – arithmetic operations: +, -, *, /, %, ˆ, log, ln – trigonometric operations: sin, cos, tan Numbers can be expressed both in scientific notation with floating point (64bit) or integer (arbitrary precision) literals. Parameters. All parameters must be declared in a specific heading section and must have an initial value. It is also possible to defined the evolution rule of the parameters as: – Expression – Timeseries A timeseries evolution rule values can be provided as: – literal value list – read from file Timeseries values can generally be fewer then the total computation steps. In this case a policy can be specify in place of the evolution rule: – persist: the last value of the timeseries is taken as persistent. – cycle: the entire timeseries is taken to be a circular array. – halt: the Arithmetical MP is halted right after the last value has been read. PARAMETER_DECL := ’parameters’ ’{’ PARAM_DEF+ ’}’ ; PARAM_DEF := IDENT ’:=’ INIT (’::’ EVOLUTION)? ’;’ ; INIT := INTEGER | FLOAT | TIMESERIES_LITERAL | TIMESERIES_FILE ; EVOLUTION := EXPRESSION | TIMESERIES_ITER ; TIMESERIES_LITERAL := ’{’ (INTEGER | FLOAT) (’,’ (INTEGER | FLOAT))* TIMESERIES_FILE := ’read’ FILEPATH ; TIMESERIES_ITER := ’persist’ | ’cycle’ | ’halt’; Example: parameters { P1 := 12.332; P2 := 0.0 :: P1^3-4*P3; P3 := {1, 3.1,2,4} :: persist; P4 := read "/path/to/timeseries.txt" :: cycle; } The scope of parameters are global: they are always visible from any membrane and expression. Since an identifier might refer both to a local substance or to a global parameter, the following disambiguation construct to directly access the parameter name space: QUALIFIED_PAR := ’P.’
IDENT
’}’
;
Multisets. Multisets, expressed in the polynomial notation, are extensively supported with the complete multiset arithmetic. MULTISET_EXPR := POPULATION ((’sum’ | ’diff’ | ’div’) POPULATION)* ; POPULATION := (INTEGER ’mul’)? MULTISET | ’(’ MULTISET_EXPR ’)’ ; MULTISET := (IDENT | INTEGER IDENT) (’+’ IDENT | INTEGER IDENT)* ; Example: a+2b // = [a, b, b] 3a+4a // = 7a 13 mul 11b+c ((3a+4b) sum (7c+14v)) div 3 mul 9a Reactions accepts only literal multisets (no multiset expressions) both in products and reactants. Statements. The statements of Lamp, which are being detailed in next paragraphs, are: STATEMENT := SUBSTANCE_DEF
|
RULE_DEF
|
MEMBRANE_DEF
|
PROMOTER_DEF
;
Substances. A set of substances can be declared at once. Each substance must be initialized to an integer value (arbitrary precision). SUBSTANCE_DECL := ’substances’ IDENT
’:=’
INTEGER
(’,’ IDENT ’:=’ INTEGER)*
’;’;
Example: substances Potassium := 12, BB := 1; Substances must be declared only for initializing with a positive value. In fact it is not needed to declare substances which are not available at beginning, but that will be produced by rules afterwards. A substance identifier exists in current compartment until there is at least one object of that substance. Reactions. The general form for a reaction (see § 4.1) is: A -> B :: regulator; A and B are the reactants and products multisets, respectively, of the reaction, while regulator is the regulatory function. Any reaction is regulated by its flux definition regulator. Arithmetical MP Systems are defined to be either a constant value or a substance reference. The Lamp language allows the use of more sophisticated regulator specifications:
– strict specification with only constant or substance identifier (by default) – any expression, must be activated via program option (see § 4.5) – regulatory composition calls (see § 4.4) enabled via program option (see § 4.5). RULE_DEF := ( E-RULE | I-RULE ’::’ FLUX ; E-RULE I-RULE O-RULE C-RULE R-EVOL R-OUT R-COMM
:= := := := := := :=
|
O-RULE
|
C-RULE
|
R-EVOL
|
R-OUT
|
R-COMM
MULTISET ’->’ MULTISET ; MULTISET ’[]_’ IDENT ’->’ ’[’ MULTISET ’]’ ; ’[’ MULTISET ’]’ ’->’ MULTISET ’[]’ ; ’[’ MULTISET ’]’ ’=>’ ’[’ MULTISET ’]_’ IDENT ; ’[’ MULTISET ’->’ MULTISET ’]_’ IDENT ; ’[’ MULTISET ’]_’ IDENT ’->’ MULTISET ’[]’ ; ’[’ MULTISET ’]_’ IDENT ’=>’ ’[’ MULTISET ’]_’ IDENT
FLUX := MATH_EXPR | REGULATORY_COMPOSITION ; REGULATORY_COMPOSITION := ( ’Call’ | ’Require’ MATH_EXPR := ...
)
IDENT
’(’
)
;
MULTISET
’)’
;
Membranes. The core of the Arithmetical MP Systems are constituted by membrane definitions (see § 4.2). Membranes can be defined to be: – independent computational units – Lamp membranes. MEMBRANE_DEF := ’membrane’ IDENT MPCOMP? ’{’ STATEMENT* ’}’ ; MPCOMP := ’(’ MPCOMP_PAR ’;’ MPCOMP_PAR ’;’ MPCOMP_PAR ’;’ MPCOMP_PAR := ’input’ IDENT (’,’ IDENT)* | ’output’ IDENT (’,’ IDENT)* | ’start’ IDENT | ’halt’ IDENT ; The body of the membrane is made of zero or more statements, which include also inner membranes. Regulatory Composition: the call/require keywords. The Lamp language provides a program option (see § 4.5) that allows to use a value returned by Lamp membranes: something usually referred to as subroutine-calling. This mechanism is called Regulatory Composition (see § 4.4). Two mechanisms are available: – Call – the rule gets blocked until the callee has returned a value
MPCOMP_PAR
’)’
;
– Require – all rules in the same membrane – but not the inner membranes – get blocked until the callee has returned REGULATORY_COMPOSITION := CALL | REQUIRE ; CALL := ’Call’ IDENT ’(’ MULTISET ’)’ REQUIRE := ’Require’ IDENT ’(’ MULTISET ’)’
; ;
Promoters. Substances that increase the activity of catalysts are called promoters. In Lamp the presence of a promoter simply allows all reactions in the current membrane to evolve. Its absence blocks all rules. The inner membranes are not affected. A series of promoters can be declared, meaning that the reactions can evolve only if all of them are available in the current compartment. A promoters’s multiplicity is unquantified : only its presence has any effect. PROMOTER_DEF := ’promoters’
IDENT
(’,’
IDENT)*
’;’
Comments. There are two kind of comments: – single line comment, which extends from // to the end-of-line. – multi line comment, extending from /* to */ and spanning across lines.
The using keyword. The using keyword provides access to external organs or computing units. Not implemented yet.
Options. The available program options, grouped by category, are: – composition.sequential – enables the Automatic Sequential Composition (see § 4.4) – composition.regulatory – enables the Regulatory Composition (see § 4.4) – membrane.halting – enables membrane halting in presence of Halt (see § 4.4) – flux.strict – enables strict regulatory functions (see § 4.5) – math.warnings – enables casting/rounding warnings (see § 4.5) OPTION := ’option’ PROGRAM_OPT PROGRAM_OPT := ’composition.sequential’ | ’composition.regulatory’ | ’membrane.halting’ | ’flux.strict’ | ’math.warnings’
’;’
;
’=’ ’=’ ’=’ ’=’ ’=’
(’on’ (’on’ (’on’ (’on’ (’on’
| | | | |
’off’) ’off’) ’off’) ’off’) ’off’)
;
4.6
Source example
organ Liver; option composition.sequential = on; option composition.regulatory = off; parameters { P1 := 12.332; P2 := 0.0 :: P1^3-4*P3; P3 := {1, 3.1,2,4} :: persist; P4 := read "/path/to/timeseries.txt" :: cycle; } begin substances Potassium := 12, BB := 13, A := 3; 2Potassium+3b[]_Beta -> [b+2c] :: A; BB -> b :: 1; membrane Beta { 2b + 3d -> c + 2a :: 3; membrane Eta(input z; output a,b; start s; halt h) { a -> b :: 3; } substances a := 2, b := 3, c := 44; } end
5
Conclusions
Bio-inspired dynamics and computation, under investigation in this article, are developed by means of a special class of membrane structure, the Arithmetical MP systems, defined as a computational model based on MP systems, a robust method for biological modeling [10]. The deterministic model of calculus, with data and processes localized in a membrane structure, come with the Lamp applicative framework implementing a programming language and a vast repertoire of mechanisms for assembling MP Systems. The goal of the Arithmetical MP Systems model, where calculi are essentially carried out by matter transferrals, is to attack interesting computations, for example, where algorithmical cyclic structures are more noticeable.
Deeper investigation is needed on algorithmic and modelling aspects where the computations are defined as matter transferrals as well as on the interoperability with non-deterministic models and enhancements to the framework.
References 1. A. Aho, R. Sethi, and J. Ullman. Compilers: principles, techniques, and tools. Reading, MA,, 1986. 2. F. Bernardini and V. Manca. Dynamical aspects of P systems. Biosystems, 70(2):85 – 93, 2003. Cell Computing. 3. L. Bianco and V. Manca. Encoding-decoding transitional systems for classes of P systems. Membrane Computing, pages 134–143, 2006. 4. D. D´ıaz-Pernil and I. P´erez-Hurtado and M. P´erez-Jim´enez and A. Riscos-N´ un ˜ez. A P-Lingua programming environment for Membrane Computing. Membrane Computing, pages 187–203, 2009. 5. ISO/IEC. 14977 : 1996(E) – Syntactic Metalanguage – Extended BNF. Technical report, International Organization for Standardization, Geneva, Switzerland, 1996. 6. M. Garcıa-Quismondo and R. Guti´errez-Escudero and I. P´erez-Hurtado and M.J. P´erez-Jim´enez and A. Riscos-N´ unez. An overview of P-lingua 2.0. In Membrane Computing: 10th International Workshop. Springer-Verlag New York Inc, 2010. 7. V. Manca. Fundamentals of Metabolic P Systems. Handbook of Membrane Computing, 2009. 8. V. Manca. Metabolic P systems. Scholarpedia, 5(3):9273, 2010. 9. V. Manca, L. Bianco, and F. Fontana. Evolution and Oscillation in P Systems: Applications to Biological Phenomena. In Membrane Computing, volume 3365 of LNCS, pages 63–84. Springer Berlin / Heidelberg, 2005. 10. V. Manca and L. Marchetti. Goldbeter’s mitotic oscillator entirely modeled by MP systems. In Proceedings of the Eleventh International Conference on Membrane Computing (CMC11), page 277. book-on-demand. de, 2010. 11. V. Manca and L. Marchetti. Metabolic approximation of real periodical functions. Journal of Logic and Algebraic Programming, 79(6):363–373, 2010. 12. P. Naur, editor. Revised Report on the Algorithmic Language ALGOL 60, volume 3, pages 299–314. Communications of the ACM, May 1960. 13. G. P˘ aun. Computing with Membranes. Journal of Computer and System Sciences, 61(1):108–143, 2000. 14. G. P˘ aun. Membrane Computing. In Fundamentals of Computation Theory, volume 2751 of LNCS, pages 177–220. Springer Berlin / Heidelberg, 2002.