The PRISM preprocessor (beta)

We have developed a simple preprocessor tool for PRISM files, which can be used to automate generation of PRISM model and properties files that contain a lot of repetition. Instructions for the preprocessor are embedded in a PRISM file and identified by placing them within a pair of hash symbols (#...#). Here is a simple example:

#const N#
mdp

module proc1
	s1: [0..1];
	[] true -> (s1'=1-s1);
endmodule

#for i=2:N#
module proc#i# = proc1 [ s1=s#i# ] endmodule
#end#
Download: pp_example1.nm.pp

The resulting PRISM model file (for N=4) is:

mdp

module proc1
	s1: [0..1];
	[] true -> (s1'=1-s1);
endmodule

module proc2 = proc1 [ s1=s2 ] endmodule
module proc3 = proc1 [ s1=s3 ] endmodule
module proc4 = proc1 [ s1=s4 ] endmodule
Download: pp_example1.nm

With the preprocessor, you can:

Some other points:

Examples

Here are some examples of preprocessor files:

Running the preprocessor

The preprocessor is actually included in the PRISM tool; you just need a script to run it. Currently we only have a Linux version of the script, which is here. Save the file as prismpp, make it executable (chmod 755 prismpp), ensure that both prism (which is needed by the preprocessor) and prismpp are in your path. You can then run it as in the following example:

The output of the tool can be redirected to a file as shown. The values of constants (N=4 in this case) are included after the name of the input file, in the order in which they appear in the file. Constants for multiple constants are separated by spaces.

Feedback

Please note that the PRISM preprocessor is an experimental tool. Bug reports, suggestions for additions/improvements, and any other comments are always welcome.