Documentation

## Syntax

### Processes

An LMNtal process is a multiset (unordered sequence) of the following:

1. atoms --- &math(p(X_{1}, \ldots , X_{n})); --- a graph node with a symbolic name &math(p); and an ordered sequence of links &math(X_i);,
2. cells --- { Process } --- a process recursively enclosed with a membrane (curly braces),
3. rules --- ( Head :- Guard | Body ) --- a rewrite rule for processes, explained below.

Both periods and commas can be used to sequence the elements of a multiset. An LMNtal program is written as an LMNtal process.

Links are written using alpha-numeric tokens starting with capital letters, while the other alpha-numeric tokens are treated as names. Quoted symbols can also be used for atom names.

### Term Abbreviation Scheme

All links in LMNtal have at most two occurrences. This enables us to abbreviate

&math(p(s_1,\ldots,s_m), q(t_1,\ldots,t_n)); to &math(p(s_1,\ldots,s_{k-1},q(t_1,\ldots,t_{n-1}), s_{k+1},\ldots,s_m)); if &math(t_{n}); and &math(s_{k}); are the same link.

For example, c(1,c(2,n),L0) is an abbreviated form of c(A,L1,L0),c(B,L2,L1),n(L2),1(A),2(B).

#### Unification Atoms

Binary atoms with the name = of the form X=Y are called unification atoms. Unification atoms state that the two links in the arguments are identical (in the sense of structural equivalence. Another instance of structural equivalence is the reordering of multiset elements). For example, p(A,X,C),X=B is always identical to p(A,B,C), as well as to p(A,B,X),C=X, and, finally, to C=p(A,B).

The typical usage of unification can be found in the following example:

( append([],Y,Res)    :- Res=Y ),
( Res=append([A|X],Y) :- Res=[A|append(X,Y)] )

### Rules

The basic syntax of a rule is: ( Head :- Body ).

The enclosing parentheses can be omitted if periods are used to delimit the rule. Both of Head and Body are process templates.

Head specifies processes to be rewritten and Body specifies the result of rewriting. Rules work only for the processes residing in the same membrane.

The full syntax of a rule that contains Guard part will be explained later in a separate section.

#### Process Templates

A process template is a multiset of the following:

1. atoms --- &math(p(X_{1}, \ldots ,X_{n})); --- same as in a process,
2. cells --- { Template } or { Template }/ --- a process template enclosed with a membrane,
3. rules --- ( Head :- Guard | Body ) --- allowed only in a Body,
4. process contexts --- $p or &math(\$p[X_1,\ldots,X_n]); or &math(\$p[X_1,\ldots,X_n|\mathrm{*}X]); --- matches with a multiset of atoms and cells, 5. rule contexts --- &math(@p); --- matches with a multiset of rules. A membrane template with / (the stable flag) can only match with a stable cell (i.e., a cell containing no applicable rules). The link arguments of a process context specify the set of free links that must exist in the matched process. The &math(\mathrm{*}X); represents an arbitrary number of extra free links. We will abbreviate &math(p(s_1,\ldots,s_{k-1},X, s_{k+1},\ldots,s_m),\$q[X]); to &math(p(s_1,\ldots,s_{k-1},\\$q,s_{k+1},\ldots,s_m));.

Note that the current implementation does not fully support process contexts with explicit arguments.