PAT: Process Analysis Toolkit

An Enhanced Simulator, Model Checker and Refinement Checker for Concurrent and Real-time Systems

Monthly archives for September, 2007

Complete Graphical User Interface

  • Line Number Display.
  • Syntax Highlight with Configuration File.
  • Multi Documents Working Enviroment.
  • Various Shortcuts Editing Function.

How to write Process Definitions

This document presents the EBNF syntax of the specifica tion language used in our model checker. The name vCSP stands for variables enriched Communicating Sequential Processes.

SYNTAX

NOTE: the rules for expression and definition are written using a hierarchical order to show the precedences between these rules.

the starting rule for the specification
specification : specBody*;

specBody : letDefintion global definitions
| definition process definitions
| assertion assertion definitions
| alpha alphabets definitions
| define global constants and condition declarations
| channel global channel declarations
;

various assertion definitions
assertion : ‘#’ ‘assert’ definitionRef
(
( ‘|=’ ( ‘(‘ | ‘)’ | ‘[]’ | ‘<>’ | ID | ‘!’ | ‘&&’ | ‘||’ | ‘->’ | ‘<->’ | ‘/\’ | ‘/’ | ‘.’ | INT )+ ) LTL checking
| ‘deadlockfree’ deadlock testing
| ‘feasible’ feasibility testing
| ‘reachable’ ID reachability testing
| ‘=T=’ definitionRef trace equivalence
| ‘=F=’ definitionRef falure equivalence
| ‘=FD=’ definitionRef falure divergence equivalence
| ‘[T=’ definitionRef trace refinement
| ‘[F=’ definitionRef falure refinement
| ‘[FD=’ definitionRef falure divergence refinement
)
‘;’
;
definitionRef : ID actualParameterList;

alphabets definitions for CSP processes
alpha : ‘alpha’ ‘(‘ ID ‘)’ ‘=’ ‘{‘ eventName (‘,’ eventName )* ‘}’ ‘;’ ;

define : ‘#’ ‘define’ ID INT ‘;’ global Int constant declaration
| ‘#’ ‘define’ ID (‘true’ | ‘false’) ‘;’ global Boolean constant declaration
| ‘#’ ‘define’ ID conditionalOrExpression ‘;’global condition declaration, used in assertions
;

global channel declarations
channel : ‘channel’ ID additiveExpression;

statement expression
statement : block
| funExpression
| recfunExpression
| applicationExpression
| ifExpression
| whileExpression
| letExpression
| expression ‘;’!
| ‘;’!
;

block : ‘{‘ statement+ ‘}’ ;
funExpression : ‘fun’ notEmptyIdentifierList ‘->’ statement ;
notEmptyIdentifierList : ‘(‘ ID (‘,’ ID)* ‘)’;
recfunExpression :’recfun’ ID notEmptyIdentifierList ‘->’ statement;
applicationExpression : ‘(‘ expression notEmptyExpressionList ‘)’ ;
notEmptyExpressionList : expression+ ;
ifExpression : ‘if’ ‘(‘ expression ‘)’ s1=statement (‘else’ s2=statement)? ;
whileExpression : ‘while’ ‘(‘ expression ‘}’ statement ;
recordExpression : ‘[‘ expression (‘,’ expression)* ‘]’ ;
letExpression : ‘let’ letDefintion+ ‘in’ expression;
letDefintion : ID ‘=’ expression ‘;’
| ID ‘=’ recordExpression ‘;’
| ID ‘=’ funExpression ‘;’
| ID ‘=’ recfunExpression ‘;’
| ID'[‘ expression ‘]’ ‘;’ integer array with initial values 0
;

expression : conditionalOrExpression (‘=’ expression)? ;
conditionalOrExpression : conditionalAndExpression ( ‘||’ conditionalAndExpression )* ;
conditionalAndExpression : equalityExpression ( ‘&&’ equalityExpression)* ;
equalityExpression : relationalExpression ( (‘==’ |’!=’) relationalExpression)* ;
relationalExpression : additiveExpression ( (‘<‘ | ‘>’ | ‘<=’ | ‘>=’) additiveExpression)* ;
additiveExpression : multiplicativeExpression ( (‘+’ | ‘-‘) multiplicativeExpression)* ;
multiplicativeExpression : unaryExpression ( (‘*’ | ‘/’ | ‘%’ ) unaryExpression)* ;
unaryExpression : ‘+’ unaryExpression
| ‘-‘ unaryExpression
| unaryExpressionNotPlusMinus
;
unaryExpressionNotPlusMinus
: ID (‘[‘ conditionalOrExpression ‘]’)?
| INT
| ‘true’
| ‘false’
| ‘(‘ conditionalOrExpression ‘)’
| ‘!’ conditionalOrExpression negation
;

CSP process definition
definition : ID formalParameters ‘=’ ifExpr ‘;’ ;
formalParameters : ‘(‘ (ID (‘,’ ID )*)? ‘)’ ;
ifExpr : ‘if’ (ifExprCondition+ (‘else’ ifExpr)? ) ‘fi’
| interleaveExpr
;
ifExprCondition : (conditionalOrExpression ‘:’ ifExpr);

interleaveExpr : parallelExpr (‘|||’ parallelExpr)*
| ‘|||’ (paralDef (‘;’ paralDef )*) ‘@’ ifExpr
;
parallelExpr : internalChoiceExpr (‘||’ internalChoiceExpr)*
| ‘||’ (paralDef (‘;’ paralDef )*) ‘@’ ifExpr
;
paralDef : ID ‘:’ ‘{‘ additiveExpression (‘,’ additiveExpression)* ‘}’
| ID ‘:’ ‘{‘ additiveExpression ‘..’ additiveExpression ‘}’
;
internalChoiceExpr : conditionalChoiceExpr (‘<>’ conditionalChoiceExpr)*;
conditionalChoiceExpr : externalChoiceExpr ( conditionalOrExpression >> externalChoiceExpr)* ;
externalChoiceExpr : interruptExpr (‘[]’ interruptExpr)* ;
interruptExpr : hidingExpr (‘|>’ hidingExpr)*;
hidingExpr : sequentialExpr (‘\’ ‘{‘ eventM (‘,’ eventM )* ‘}’)? ;
sequentialExpr : guardExpr (‘;’ guardExpr)*;
guardExpr : channelExpr
| ‘[‘ conditionalOrExpression ‘]’ ‘@’ channelExpr
;
channelExpr : (‘wl’ | ‘sl’ | ‘sf’ | ‘wf’) ‘(‘ ID ‘!’ expression ‘)’ ‘->’ eventExpr
| (‘wl’ | ‘sl’ | ‘sf’ | ‘wf’) ‘(‘ ID ‘?’ ID ‘)’ ‘->’ eventExpr
| ID ‘!’ expression ‘->’ eventExpr
| ID ‘?’ ID ‘->’ eventExpr
| eventExpr
;

eventExpr : eventM (block)? ‘->’ eventExpr
| atom
;
atom : ID actualParameterList
| ‘Skip’ (‘(‘ ‘)’)?
| ‘Stop’ (‘(‘ ‘)’)?
| ‘(‘ ifExpr ‘)’
;

actualParameterList : ‘(‘ (expression (‘,’ expression )*)? ‘)’ ;

eventM : eventName
| (‘wl’|’sl’|’wf’|’sf’) ‘(‘ eventName ‘)’
;
eventName : ID ( ‘.’ additiveExpression)* ;

ID : (‘a’..’z’|’A’..’Z’|’_’) (‘a’..’z’|’A’..’Z’|’0′..’9’|’_’)* ;
INT : (‘0’..’9′)+ ;

COMMENT : ‘/*’ TEXT ‘*/’ ;
LINE_COMMENT : ‘‘ TEXT ‘r’? ‘n’;

OPERATOR PRECEDENCE

The operators at the top of the table bind more tightly than those lower down.

Class Operators Description Associativity


Sequential -> prefix right

; sequence left


Hiding hiding


Choice |> interrupt left

[] external choice left

<b> external choice left

<> internal choice left


Parallel || parallel left

||| interleave left

EXAMPLES

The spefication of two Dining Philoshpors:
phi0()=((t0->phi0())[](wl(g01)->(g00->(e0->(p01->(p00->phi0()))))));
f0()=((g00->(wl(p00)->f0()))[](g10->(wl(p10)->f0())));
phi1()=((t1->phi1())[](wl(g10)->(g11->(e1->(p10->(p11->phi1()))))));
f1()=((g11->(wl(p11)->f1()))[](g01->(wl(p01)->f1())));
DiningPhilosophers()=(phi0()||f0()||phi1()||f1());

How to write LTL Formulae

LTL – linear time temporal logic formulae for specifying correctness requirements.

SYNTAX

Grammar:
ltl ::= opd | ( ltl ) | ltl binop ltl | unop ltl

Operands (opd):
true, false, and user-defined names starting with a lower-case letter.

Unary Operators (unop):
[] or G (the temporal operator always)
<> or F (the temporal operator eventually)
! (the boolean operator for negation)
X (next)

Binary Operators (binop):
U (the temporal operator strong until)
V or R (release: the dual of U): (p V q) means !(!p U !q))
&& (the boolean operator for logical and)
|| (the boolean operator for logical or)
/ (alternative form of &&)
/ (alternative form of ||)
-> (the boolean operator for logical implication)
<-> (the boolean operator for logical equivalence)

DESCRIPTION
Our tool will translate LTL formulae into never claims automatically. So you do not need to write the negation for the property to be checked. The never claim that is generated encodes the Buchi acceptance conditions from the LTL formula. Formally, any omega-run that satisfies the LTL formula is guaranteed to correspond to an accepting run of the never claim.

All binary operators are left-associative. Parentheses can be used to override this default. Note that implication and equivalence are not temporal but logical operators.

EXAMPLES
[] p
!( <> !q )
p U q
p U ([] (q U r))

Peterson’s Algorithm




Dining Philosophers

The dining philosophers problem is summarized as five philosophers sitting at a table doing one of two things – eating or thinking. While eating, they are not thinking, and while thinking, they are not eating. The five philosophers sit at a circular table with a large bowl of spaghetti in the center. A fork is placed in between each philosopher, and as such, each philosopher has one fork to his or her left and one fork to his or her right. As spaghetti is difficult to serve and eat with a single fork, it is assumed that a philosopher must eat with two forks. The philosopher can only use the fork on his or her immediate left or right.

The CSP Definition of Dining Philosophers:




The property interested states that every philosopher will always eventually eat, i.e., no one shall starve.




The following defintion is the Dining Philosophers example with size 3.
====================Process Definitions====================
phi0()=((t0->phi0())[](wl(g01)->(g00->(e0->(p01->(p00->phi0()))))));
f0()=((g00->(wl(p00)->f0()))[](g20->(wl(p20)->f0())));
phi1()=((t1->phi1())[](wl(g12)->(g11->(e1->(p12->(p11->phi1()))))));
f1()=((g11->(wl(p11)->f1()))[](g01->(wl(p01)->f1())));
phi2()=((t2->phi2())[](wl(g20)->(g22->(e2->(p20->(p22->phi2()))))));
f2()=((g22->(wl(p22)->f2()))[](g12->(wl(p12)->f2())));
DiningPhilosophers()=(phi0()||f0()||phi1()||f1()||phi2()||f2());

============================Assertions===========================

  1. assert DiningPhilosophers() |= []<>e0;
  2. assert DiningPhilosophers() deadlockfree;
  3. assert DiningPhilosophers() feasible;
  4. assert DiningPhilosophers() |= []<>e0 && []<>e1 && []<>e2;