![]() |
To create a new model checker which only need to enrich a existing modeling
language, may use the following ways. You can create new data types and support
new libraries or extend the language syntax by implementing certain classes and
interfaces. Extensible Data Type and Library For simplicity, existing modules in PAT only support integer variables,
Boolean variables and (multi-directional) arrays of integer or Boolean. However,
sometimes user defined data type is necessary and can simplify the model
substantially. In the Common project, PAT defines the interface for variable
valuations, which includes methods for hashing (or encoding) the value for state
representation, a to-string method for simulator display and deep-clone method
for duplicating the values. PAT provides the functionality to create arbitrary
data type by simply creating a C# class inheriting the Value interface. These
classes can be imported into the model (based on the reflection mechanism in
.NET) and used as normal variables. We demonstrate the idea by creating a Set
data type using the code in the following Listing. First, Set class implements the Value interface in order to be used
in PAT. ExpressionID property returns the unique string representation
of the data type at any time. ToString method produces the pretty print
of the set elements, which can be used in the simulator. GetClone
method implements the PROTOTYPE design pattern. To implement the operations of a
set, Set class inherits the generic HashSet class in the .NET
framework. Therefore existing methods in HashSet like Add,
Remove are inherited automatically. New methods can also be created
easily, for example IsDisjoint method. Compared with Bogor's set
extension, our approach is much simpler. To use the Set class, users only need
to import the compiled DLL and declare the variable of Set type. The
variable can be initialized using new keyword and methods of Set class
can be invoked as in traditional OO program. The syntax of using the user
defined data type can be found in section 2.5 Using C# Code as Libraries. Another benefit of the extensible data type design is that users can control
the data hashing function, which may reduce the state space significantly. For
example, a check board can be presented by the position of pieces only without
including the empties spaces. Therefore, the ExpressionID property can
be defined to contain only positions of pieces to speedup the verification. Language Syntax Extension In general, the input language of a model checker must be carefully designed,
with preciseness, intuitiveness and efficiency in mind. A minor syntax extension
or modification may require re-examination of the whole system. PAT facilitates
such extensions with the following design supports. Taking the probabilistic module PCSP as an example, it extends the concurrent
system modling language CSP# with one additional language feature, i.e.,
probabilistic choices. Knowledge about existing modules is required and a new
parser is created for the extended language features.