MCparseModalFormula — C function that parses a modal mu-calculus formula and saves it to an ATerm.
#include "libmcparse.h"
ATermAppl MCparseModalFormula( | *formStream, | |
reduce, | ||
acLevel, | ||
vbLevel, | ||
saveToMCRLFormat) ; |
FILE *formStream
;_Bool reduce
;int acLevel
;int vbLevel
;_Bool saveToMCRLFormat
;The following preconditions have to be satisfied:
the ATerm library is initialised
formStream
points to a stream from which can be read
0 <=
acLevel
<= 2
0 <=
vbLevel
<= 3
if saveToMCRLFormat
, an mCRL data specification is present in the mCRL library
Function MCparseModalFormula
parses the modal formula in formStream
and saves it to a value of type ATermAppl. The structure of the modal formula is explained in mucalculus(7)
. The structure of the ATermAppl value is explained in the next subsection.
During parsing the formula is checked for monotonicity and adherence to the variable convention. Also the occurrences of dangerous nestings of fixed point variables are checked. If the first two checks fail, an error generated. If the third check succeeds a warning is generated.
If reduce
is true, all regular operations are replaced by equivalent non-regular operations.
Alpha conversion is applied based on the value of acLevel
:
0 (none) | no alpha conversion |
1 (scope) | names of bound variables that are in each other's scope are different |
2 (full) | all names of bound variables are different |
The printing of intermediate messages on stdout
(besides error messages) is controlled by the value of vbLevel
:
0 (silent) | no messages are printed |
1 (normal) | warnings are printed |
2 (verbose) | warnings and short status information is printed |
3 (debug) | many messages are printed to make debugging possible |
If saveToMCRLFormat
is true, the types of expressions occurring in the modal formula are checked and the formula is translated to the internal mCRL format, using the data specification that is present in the mCRL library. During this translation, a version of full alpha conversion is performed that is provided by the mCRL library. Therefore, it isn't necessary to provide the parameter acLevel
with the value 2; however, you are advised to do so, because this generates more readable names.
If parsing succeeded and no errors are generated, the parsed ATermAppl value is returned; otherwise NULL
is returned and an appropriate error message is printed on stderr
.
We describe the syntax and partly the semantics of the resulting ATerm of function MCparseModalFormula
. In the following BNF syntax lowercase words are ATerm function symbols, expressions f(e0,...,en)
are ATerm function applications of arity n
, and expressions [e0,...,en]
are ATerm lists of length n
. Therefore, these terms have type AFun, ATermAppl and ATermList, respectively.
Preliminaries:
AN ::= RNAME(DT,...,DT) VO ::= RNAME(DT,...,DT) DT ::= NAME(DT,...,DT) DT_LIST ::= [DT,...,DT] VD ::= v(RNAME,RNAME) VD_LIST ::= [VD,...,VD]
Here NAME
and RNAME
both denote mCRL names, AN
represents action names, VO
variable occurrences, DT
data terms, DT_LIST
lists of data terms, VD
variable declarations and VD_LIST
lists of variable declarations. Action and data names have to be declared, the data terms should be well typed and the right part of a variable declaration should be a declared sort. An RNAME
is restricted such that the keywords "T"
, "F"
, "forall"
, "exists"
, "nil"
, "mu"
and "nu"
are not allowed. To be able to distinguish function symbols of the mu-calculus from mCRL function symbols, NAME
and RNAME
are quoted ATerms of type ATermAppl.
Action formulas:
AF ::= act(AN) | T | F | not(AF) | and(AF,AF) | or(AF,AF) | imp(AF,AF) | eq(AF,AF) | forall(NAME,NAME,AF) | exists(NAME,NAME,AF)
Here the symbol 'act
' indicates that its parameter is an action name. The symbol 'T
' stands for true, 'F
' for false, 'not
' for negation, 'and
' for conjunction, 'or
' for disjunction, 'imp
' for implication, 'eq
' for equivalence, 'forall
' for universal quantification and 'exists
' for existential quantification.
Regular formulas:
RF ::= AF | nil | concat(RF,RF) | choice(RF,RF) | tr_close(RF) | t_close(RF)
A regular formula denotes a path of action formulas. Here 'nil
' stands for the empty path, 'concat
' for the concatentation of two paths, 'choice
' for the choice between two paths, 'tr_close
' for the transitive and reflexive closure of a path and 't_close
' for the transitive closure of a path.
Modal formulas:
MF ::= form(DT) | T | F | not(MF) | and(MF,MF) | or(MF,MF) | imp(MF,MF) | eq(MF,MF) | forall(NAME,NAME,MF) | exists(NAME,NAME,MF) | may(RF,MF) | must(RF,MF) | loop(RF) | rec(VO) | mu(NAME, VD_LIST, MF, DT_LIST) | nu(NAME, VD_LIST, MF, DT_LIST)
Here the symbol 'form
' indicates that its parameter is a boolean data term. The symbols 'T
', 'F
', 'not
', 'and
', 'or
', 'imp
', 'eq
', 'forall
' and 'exists
' are analogous to the corresponding symbols in action formulas. The symbol 'may
' stands for the may operator, 'must
' for the must operator and 'loop
' for the infinite looping operator. The symbol 'mu
' stands for the smallest fixed point operator, 'nu
' for the largest fixed point operator and 'rec
' for the occurrence of a fixed point variable.
The may and must operators and the infinite looping operator have the following meaning. In a state of the state space a formula may(R,phi)
is valid if there exists a path starting in this state, that satisfies R
and leads to a state such that phi
is valid. In a state of the state space a formula must(R,phi)
is valid if all paths starting in this state, satisfying R
, lead to a state such that phi
is valid. In a state of the state space loop(R)
holds if there exists a path starting in this state that is an infinite concatenation of sequences that satisfy R
.
The generated formula adheres to the variable convention and it is monotonic, which means that every occurrence of a fixed point variable may only be in the scope of an even number of 'not
' operations.
We call the operations 'nil
', 'concat
', 'choice
', 'tr_close
', 't_close
' and 'loop
' regular operations. When parameter reduce
of function MCparseModalFormula
has value true, then each regular operation in the modal formula is replaced by an equivalent non-regular operation. This is achieved by repeatedly applying the following properties from left to right, where X
is fresh variable, i.e. X
may not occur free in phi
or R
:
may(nil,phi) = may(tr_close(F),phi) may(concat(R1,R2),phi) = may(R1,may(R2,phi)) may(choice(R1,R2),phi) = or(may(R1,phi),may(R2,phi)) may(tr_close(R),phi) = mu(X,[],or(phi,may(R,X),[]) may(t_close(R),phi) = may(concat(R,tr_close(R)),phi) must(nil,phi) = must(tr_close(F),phi) must(concat(R1,R2),phi) = must(R1,must(R2,phi)) must(choice(R1,R2),phi) = and(must(R1,phi),must(R2,phi)) must(tr_close(R),phi) = nu(X,[],and(phi,must(R,X),[]) must(t_close(R),phi) = must(concat(R,tr_close(R)),phi) loop(R) = nu(X,[],may(R,X),[])
The type _Bool is used instead of bool
to avoid conflicts with reserved words in the mCRL library. This type is defined in the header file mcfunc.h
.
If saveToMCRLFormat
is true, the types of actions are not checked because actions are not present in the internal mCRL format.
Written by Aad Mathijssen <A.H.J.Mathijssen@tue.nl>
. Please send all complaints, comments and bug fixes to me.
More information on the mu-calculus can be found in mucalculus. More information on the ATerm library can be found at the website of the CWI.