P-Lingua

From The P-Lingua Website

(Difference between revisions)
Jump to: navigation, search
Line 5: Line 5:
== Example ==
== Example ==
-
 
+
<nowiki>
/* Module that defines a family of recognizer P systems
/* Module that defines a family of recognizer P systems
   to solve the SAT problem */
   to solve the SAT problem */
Line 74: Line 74:
      
      
} /* End of main module */
} /* End of main module */
 +
</nowiki>

Revision as of 16:18, 21 August 2009

P-Lingua is a programming language for membrane computing which aims to be a standard to define P systems. It and its associated tools have been developed by members of the Research Group on Natural Computing, at the University of Sevilla, Spain.

The P-Lingua programmes define P systems in an easy-to-learn, modular and parametric way. In this sense, it is possible to define a family of P systems with the use of parameters.


Example

/* Module that defines a family of recognizer P systems to solve the SAT problem */ @variant<membrane_division> def Sat(m,n) { /* Initial configuration */ @mu = [[]'2]'1; /* Initial multisets */ @ms(2) = d{1}; /* Set of rules */ [d{k}]'2 --> +[d{k}]-[d{k}] : 1 <= k <= n; { +[x{i,1} --> r{i,1}]'2; -[nx{i,1} --> r{i,1}]'2; -[x{i,1} --> #]'2; +[nx{i,1} --> #]'2; } : 1 <= i <= m; { +[x{i,j} --> x{i,j-1}]'2; -[x{i,j} --> x{i,j-1}]'2; +[nx{i,j} --> nx{i,j-1}]'2; -[nx{i,j} --> nx{i,j-1}]'2; } : 1<=i<=m, 2<=j<=n; { +[d{k}]'2 --> []d{k}; -[d{k}]'2 --> []d{k}; } : 1<=k<=n; d{k}[]'2 --> [d{k+1}] : 1<=k<=n-1; [r{i,k} --> r{i,k+1}]'2 : 1<=i<=m, 1<=k<=2*n-1; [d{k} --> d{k+1}]'1 : n <= k<= 3*n-3; [d{3*n-2} --> d{3*n-1},e]'1; e[]'2 --> +[c{1}]; [d{3*n-1} --> d{3*n}]'1; [d{k} --> d{k+1}]'1 : 3*n <= k <= 3*n+2*m+2; +[r{1,2*n}]'2 --> -[]r{1,2*n}; -[r{i,2*n} --> r{i-1,2*n}]'2 : 1<= i <= m; r{1,2*n}-[]'2 --> +[r{0,2*n}]; -[c{k} --> c{k+1}]'2 : 1<=k<=m; +[c{m+1}]'2 --> +[]c{m+1}; [c{m+1} --> c{m+2},t]'1; [t]'1 --> +[]t; +[c{m+2}]'1 --> -[]Yes; [d{3*n+2*m+3}]'1 --> +[]No; } /* End of Sat module */ /* Main module */ def main() { /* Call to Sat module for m=4 and n=6 */ call Sat(4,6); /* Expansion of the input multiset */ @ms(2) += x{1,1}, nx{1,2}, nx{2,2}, x{2,3}, nx{2,4}, x{3,5}, nx{4,6}; /* To define another P system of the family, call the Sat module with other parameters and expand the input multiset with other values */ } /* End of main module */

Personal tools