Data library
The mCRL2 language describes processes with data. The Data Library contains everything that has to do with the data part of the language. The main concepts are sorts and functions working upon these sorts. The meaning of these functions can be described by means of equational axioms. In the language reference these concepts are explained in more detail.
The library provides:
Data specifications and expressions (this page)
Sort aliases and sort normalisation — making sort representations unique across a specification
Data rewriters — evaluating data expressions using equational axioms
Rewriter implementation notes — mathematical foundations (HRS theory, match trees)
Capture-avoiding substitutions — formal substitution over data expressions
Data enumerator — enumerating values satisfying a predicate
Data specifications
Data specifications contains the declaration of data types. It contains sorts, sort aliases, constructors, mappings and conditional equations.
A specification can straightforwardly be constructed by declaring the required objects and adding them to a specification. The elements that are added to the specification are not checked.
#include "mcrl2/data/data_specification.h"
#include "mcrl2/data/basic_sort.h"
#include "mcrl2/data/function_symbol.h"
#include "mcrl2/data/variable.h"
#include "mcrl2/data/data_equation.h"
using namespace mcrl2::data;
data_specification spec;
basic_sort D("D"); // sort D
spec.add_sort(D);
function_symbol m("m",D); // map m:D;
function_symbol c1("c1",D); // cons c1:D;
function_symbol c2("c2",function_sort(D,D)); // c2:D->D;
spec.add_mapping(m);
spec.add_constructor(c1);
spec.add_constructor(c2);
variable x("x", D); // var x:D;
data_application e1(c2,x);
data_equation e(variable_list({x}), sort_bool::true_(), e1, m); // eqn true -> c1(x)=m;
spec.add_equation(e);
basic_sort E("E"); // sort E=D; (add a sort alias)
spec.add_alias(E,D);
For any specification it is possible to retrieve the elements that have been added to the specification as follows:
sorts_const_range s=spec.user_defined_sorts();
constructors_const_range c=spec.user_defined_constructors();
mappings_const_range m=spec.user_defined_mappings();
equations_const_range e=spec.user_defined_equations();
ltr_aliases_mapping a=spec.user_defined_aliases();
If sorts are added to a data specification, automatically certain functions, mappings and in some cases even derived sorts are added to the specification. For every sort D, there functions if then else (if:Bool#D#D->D), equality (==:D#D->Bool), inequality (!=:D#D->Bool) and inequalities (<,<=,>=,>:D#D->Bool) are added. For structured sorts (e.g. sort Tree=struct leaf(Nat) | node(Nat,Nat)) the constructors, projection functions and recognizers are added to the specification. For container sorts (List(D), Set(D) and Bag(D) for arbitrary sort D) all standard functions for these sorts are also added automatically to the specification. The same holds for standard sorts Bool (booleans), Pos (Positive numbers), Nat (Natural numbers), Int (Integers) and Real (Real numbers).
Standards sorts cannot explicitly be added to a specification. In order to indicate that certain sorts must be present in a data specification, these must be added explicitly to the context sorts. The sort Bool is always present in a specification. Sorts that occur in other sorts, constructors and mappings are automatically defined. For instance, if the sort Real and its operations should be made available in a specification, it is sufficient to add Real to the context sorts as follows:
add_context_sort(sort_real::real());
The function context_sorts gives a list of sorts added to the context.
In order to retrieve all sorts, constructors, mappings or equations in a specification (including those that are automatically generated), there are functions listed below. As generally these functions are of interest, instead of their counterparts which only define the user_defined elements, they have the shorter and more natural names.
sorts_const_range s=spec.sorts();
constructors_const_range c=spec.constructors();
mappings_const_range m=spec.mappings();
equations_const_range e=spec.equations();
ltr_aliases_mapping a=spec.aliases();
When adding sort aliases to a specification, the names of sorts are not unique anymore. When declaring in mCRL2
sort Time=Nat;
D=List(Nat);
E=struct f(E)|g;
the sorts Time and Nat, as well as D and List(Nat) and even E and struct f(E)|g are pairwise equal. In a specification it is not very inefficient to have different names for equal sorts. Therefore the sorts in a specification are made unique. The algorithm that is used maps every structured and container sort for which an alias is introduced to the sort alias at the left hand side. Every sort alias between basic sorts is mapped to the right hand side. In the example above every occurrence of Time is replaced by Nat, and occurrences of List(Nat) and struct f(E)|g are replaced by D and E respectively.
The method sort_alias_map() delivers a mapping from sorts to sorts giving for each sort the unique name. Using the function template <class T> T normalise_sorts(T t) the sorts in each object t can be renamed to their unique representation. If this is not done, objects can be equal except for their types, and this will not be recognized. This is particularly problematic when using the rewriter. Eg. in the following process specification
sort Time=Nat;
map too_late:Time->Bool;
var t:Time;
eqn too_late(t) = t>10;
proc P(u:Time)=too_late(u) -> a.delta;
init P(9);
the data specification will normalise the equation too_late(t)= t>10 to such that t has sort Nat as all occurrences of the sort Time are replaced by Nat. When this is not done in process P, the parameter u still has sort Time and too_late(u) will not be rewritten as the sorts do not match. Therefore, it is necessary to apply normalise_sorts to any object used in the context of a specification. If sort aliases are added to a data specification, all sorts in the context of this specification must be renormalised.
There are a few utility functions that help to determine the nature of sorts. The function bool is_certainly_finite(const sort_expression) indicates that a sort has a finite number of elements. This is in general an undecidable property, but in certain cases it can be determined that there are at most a finite number of elements in a sort.
The function bool is_constructor_sort(const sort_expression s) indicates whether there is a constructor with target sort s. If so, the sort is called a constructor sort.
Expressions
In this section we first introduce the basic structures of sort expressions
and data expressions. We then continue to defining the sort expressions
with operations that are predefined in the Data Library.
The code in the Data Library is inside the namespace mcrl2::data.
Sort expressions
Except for the untyped identifiers, all expressions in the Data Library are typed. There are many different kinds of sorts in the mCRL2 language, all of which can be represented in the data library.
Type |
Meaning |
|---|---|
basic_sort |
basic sort |
function_sort |
function sort |
structured_sort |
structured sort |
container_sort |
container sort |
multiple_possible_sorts |
expression matching any of multiple sorts |
unknown_sort |
unknown sort expression |
Warning
The types multiple_possible_sorts and unknown_sort should not occur
after type checking.
These sort expressions correspond to the grammar:
S ::=Sb|Sc|Sx ... xS->S|SstructSc ::= List(S) | Set(S) | FSet(S) | Bag(S) | FBag(S) Sstruct ::= p ( proj* )? p proj ::=S| p :S
where Sb is a given set of basic sorts, always including the booleans
(sort Bool). S x ... x S -> S denotes the function sorts, where -> is right
associative. Sc is the set of container sorts, and Sstruct is the set of
structured sorts. FSet(S) and FBag(S) represent finite sets and finite bags
respectively.
In general, structured sorts have the following form (with n a positive number,
ki a natural number with 1 <= i <= n):
struct c1(pr1,1:S1,1, ..., pr1,k1:S1,k1)?is_c1 |
c2(pr2,1:S2,1, ..., pr2,k2:S2,k2)?is_c2 |
...
cn(prn,1:Sn,1, ..., prn,kn:Sn,kn)?is_cn;
We refer to ci as the constructors of the structured sort. Si,j are the
sorts of the arguments of the constructors. pri,j are names for optional
projection functions, retrieving the corresponding argument for a constructor.
is_ci are the names of optional recognizer functions, returning a boolean
value.
As an example of some of the introduced concepts, consider the following code snippet that constructs a structured sort
struct c1(p0:S0, S1)?is_c1 |
c2(p0:S0);
The construction of this structured sort is as follows, assuming that also all of the subexpressions still need to be defined:
basic_sort s0("S0"); /* Name for the sort S0 */
basic_sort s1("S1"); /* Name for the sort S1 */
structured_sort_constructor_argument p0(s0, "p0"); /* Constructor argument p0: S0 */
structured_sort_constructor_argument p1(s1); /* Constructor argument S1 */
structured_sort_constructor_argument_vector a1; /* p0: S0, S1 */
a1.push_back(p0);
a1.push_back(p1);
structured_sort_constructor_argument_vector a2; /* p0 */
a2.push_back(p0);
structured_sort_constructor c1("c1", a1, "is_c1"); /* c1(p0:S0, S1)?is_c1 */
structured_sort_constructor c2("c2", a2); /* c2(p0:S0) */
structured_sort_constructor_vector cs; /* c1(p0:S0, S1)?is_c1 | c2(p0:S0) */
cs.push_back(c1);
cs.push_back(c2);
structured_sort s(cs); /* struct c1(p0:S0, S1)?is_c1 | c2(p0:S0) */
Data expressions
The class data_expression represents expressions like true,
and
. Each data
expression
d has a type or sort d.sort() of type sort_expression.
Let’s look at a simple example that constructs the numbers two and three, and
builds the expression 2 + 3:
#include "mcrl2/data/data.h"
#include <cassert>
using namespace mcrl2::data;
int main()
{
data_expression two = sort_nat::nat(2);
data_expression three = sort_nat::nat(3);
data_expression five = sort_nat::plus(two, three);
assert(five.sort() == sort_nat::nat());
return 0;
}
Expression |
Meaning |
|---|---|
data_expression |
any data expression |
function_symbol |
function symbol |
variable |
variable |
abstraction |
expression with variable binding |
lambda |
lambda abstraction |
forall |
universal quantification |
exists |
existential quantification |
where_clause |
where clause |
application |
function application |
identifier |
untyped identifier (not to be used after type checking) |
Warning
The expression identifier should not occur after type checking, as it entails an
untyped sort expression, whereas all libraries and tools in the toolset in
general assume fully typed expressions.
An overview of all data expressions in the Data Library is given in the table
above. More detailed, data expressions are divided into function symbols, represented
by the class function_symbol, variables, represented by variable,
abstractions, represented by the class abstraction, where clauses,
represented by where_clause, and applications of expressions to expressions,
represented by application. Furthermore, when used in the initial phases
of parsing and type checking, the use of untyped identifiers, represented
by identifier is allowed.
Abstractions provide a mechanism for variable binding. As such, they are
further subdivided into lambda abstraction, represented by lambda,
and universal and existential quantifications, represented by
forall and exists respectively.
More formally, data expressions e, with sort expression S and variable names
x correspond to the following grammar:
e ::= x | n | e(e, ..., e)
| lambda x:S, ..., x:S . e
| forall x:S, ..., x:S. e
| exists x:S, ..., x:S. e
| e whr x = e, ..., x = e end
| {x:S | e}
Here e(e,...,e) denotes application of data expressions, lambda x:S, ..., x:S . e
denotes lambda abstraction, forall x:S, ..., x:S . e and exists x:S, ..., x:S . e
denote universal and existential quantification. The form {x:S | e} is set or bag
comprehension: a set when e has sort Bool, a bag when e has sort Nat.
Predefined sorts
The mCRL2 language has a number of predefined sorts, given in the table below:
Expression |
Sort |
|---|---|
|
booleans |
|
positive numbers |
|
natural numbers |
|
integers |
|
real numbers |
Furthermore, a number of container sorts is predefined. Assuming that s is
a sort expression, all container sorts are given in the table below:
Expression |
Type |
|---|---|
|
lists |
|
sets |
|
finite sets |
|
bags |
|
finite bags |
Note that the source code for all predefined sorts is generated from specification files.
Operations on data expressions
Default operations
For all sorts, a number of operations is available by default. The corresponding
functions can be found in standard.h.
Let b be a data expressions of sort Bool, and let x
and y be two data expressions with the same sort. Then the following
operations are supported:
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
equality |
|
|
inequality |
|
|
conditional expression |
|
|
less than |
|
|
less than or equal to |
|
|
greater than |
|
|
greater than or equal to |
For the predefined sorts, the most important operations are also available by default.
Note
In all definitions of operations on predefined sorts, elements of which the syntax starts with @ cannot directly be entered by the user when writing an mCRL2 specification. The @ means that the specified operation is implementation specific. Printing such an expression as feedback to the user should be prevented at all times.
Booleans
All standard operations for the Booleans are available in bool.h, and can be
found in the namespace data::sort_bool. First of all
the two constants true and false can be constructed.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
true |
|
|
false |
Furthermore the following functions are available on Booleans (for details
about the allowed types also see bool.spec). Let b and c be Boolean expressions.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
negation |
|
|
conjunction |
|
|
disjunction |
|
|
implication |
Positive numbers
All standard operations for positive numbers are available in pos.h, and can
be found in the namespace data::sort_pos. The positive numbers have two
constructors, facilitating an encoding with size logarithmic in the number
that is represented.
Let b be a Boolean expression, and p be a positive expression.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
1 |
|
|
2*p + b |
Furthermore the standard operations are available on Positive numbers.
Let b and c be Boolean expressions, and p, q, and r be positive
numbers.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
maximum |
|
|
minimum |
|
|
absolute value |
|
|
successor |
|
|
addition |
|
|
addition with carry (p + q + b) |
Natural numbers
All standard operations for natural numbers are available in nat.h, and can
be found in the namespace data::sort_nat. The natural numbers have two
constructors, representing 0 and a positive number interpreted as a
natural number.
Let p be a positive expression.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
0 |
|
|
p interpreted as natural number |
Furthermore the standard operations are available on Natural numbers.
Let b and c be Boolean expressions, p, q be positive numbers,
and n, m, u, v be natural numbers.
Note
Operations marked ??? in the following tables are implementation-internal
operations whose precise semantics are not yet documented here.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
maximum |
|
|
maximum |
|
|
maximum |
|
|
minimum |
|
|
absolute value |
|
|
successor |
|
|
predecessor |
|
|
??? |
|
|
addition |
|
|
addition |
|
|
addition |
|
|
substraction with borrow |
|
|
multiplication |
|
|
integer division |
|
|
modulus |
|
|
exponentiation |
|
|
exponentiation |
|
|
predicate to indicate |
|
|
|
|
|
??? |
|
|
??? |
|
|
??? |
|
|
??? |
|
|
??? |
To facilitate efficient rewriting, also a sort @NatPair is available. Code
for this is also present in nat.h, in namespace data::sort_nat.
Let m, n be expressions of sort Nat.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
tuple (m,n) |
Also functions for these pairs are available.
Let b be a Boolean expression, p, q be positive numbers,
and n, m, u, v be natural numbers.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
projection of first argument |
|
|
projection of second argument |
|
|
simultaneous division and modulus |
|
|
generalised simultaneous division and modulus |
|
|
doubly generalised simultaneous division and modulus |
Integers
All standard operations for integers are available in int.h, and can
be found in the namespace data::sort_int. The integers have two
constructors, one interpreting a natural number as integer, and one
interpreting a positive number as a negative integer.
Let p be a positive expression, and n be a natural number.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
|
|
|
|
Furthermore the standard operations are available on Natural numbers.
Let b be a Boolean expression, p, q be positive numbers,
n, m be natural numbers, and x, y be integers.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
maximum |
|
|
maximum |
|
|
maximum |
|
|
maximum |
|
|
maximum |
|
|
minimum |
|
|
absolute value |
|
|
unary minus |
|
|
unary minus |
|
|
unary minus |
|
|
successor |
|
|
predecessor |
|
|
predecessor |
|
|
??? |
|
|
addition |
|
|
subtraction |
|
|
subtraction |
|
|
subtraction |
|
|
multiplication |
|
|
integer division |
|
|
modulus |
|
|
exponentiation |
Real numbers
All standard operations for real numbers are available in real.h, and can
be found in the namespace data::sort_real. The real numbers do not have
any constructors, because they cannot be finitely enumerated.
Standard functions for real are available however.
Let p, q be positive numbers,``n``, m be natural numbers, x, y be integers,
and r, s be real numbers.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
explicit conversion of |
|
|
maximum |
|
|
minimum |
|
|
absolute value |
|
|
unary minus |
|
|
successor |
|
|
predecessor |
|
|
addition |
|
|
subtraction |
|
|
multiplication |
|
|
division |
|
|
division |
|
|
division |
|
|
division |
|
|
floor |
|
|
ceil |
|
|
round |
|
|
reduce fraction x/y w.r.t. lowest common multiple |
|
|
??? |
|
|
??? |
Important
The sorts that are allowed as arguments to the functions for numeric sorts
are exactly the ones that correspond to the sorts of the variables in the tables
with functions. Note that e.g. sort_real::max(p,q) is also allowed, and the
correct result sort of Pos will automatically be inferred.
Lists
All standard operations for lists are available in list.h, and can
be found in the namespace data::sort_list. The lists have two
constructors, the empty list ([]), and inserting an element into a list (|>).
Let x be an element of sort S, and l of sort List(S).
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
The empty list of sort S |
|
|
The list l prefixed with x |
Also, the following functions operating on lists are available. Again, let x be an element of sort S, l of sort List(S), and n of sort Nat.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
Test whether |
|
|
The size of |
|
|
The list |
|
|
The concatenation of |
|
|
The element at position |
|
|
The first element of |
|
|
|
|
|
The last element of |
|
|
|
Finite sets
The finite sets quite closely resemble lists. For sort FSet(S) the following
constructors are available, assuming a sort S, an element x of sort S, and
t being of sort FSet(S).
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
The empty finite set of sort |
|
|
The finite set |
Let b be a Boolean, x an element of sort S, f, g be functions of sort
S -> Bool, and s, t be of sort FSet(S). The operations of finite
sets are defined as follows.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
Insert |
|
|
??? |
|
|
Test whether |
|
|
|
|
|
Union of |
|
|
Intersection of |
Finite bags
Finite bags are defined in a similar vein as finite sets.
For sort FBag(S) the following
constructors are available, assuming a sort S, an element x of sort S,
p being a positive number, and
b being of sort FBag(S).
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
The empty finite bag of sort |
|
|
The finite bag |
Let x an element of sort S, f,``g`` be functions of sort
S -> Nat, t of sort FSet(S), and b,``c`` be elements of sort FBag(S).
The operations on finite bags are defined as follows.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
Insert |
|
|
??? |
|
|
Test count the number of occurrences of |
|
|
Test whether |
|
|
|
|
|
Join of |
|
|
Intersection of |
|
|
Difference of |
|
|
Convert |
Sets
Like the Real numbers, sets and bags do not have constructors. This means that elements of these sorts are built using functions, as well as their more simple counterparts, the finite sets and bags.
For sets the following functions are available. Let d, e be of sort Set(S),
x be of sort S, s be of sort FSet(S), and f and g be function of
sort S -> Bool.
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
Construct a set from a function and a finite set |
|
|
Empty set of sort S |
|
|
Interpret finite set s as a set |
|
|
The set of all elements of sort |
|
|
Test whether |
|
|
Set complement of |
|
|
Union of |
|
|
Intersection of |
|
|
Difference of |
|
|
The constant function returning false |
|
|
The constant function returning true |
|
|
The constant function returning false |
|
|
The function returning |
|
|
The function returning |
|
|
The function returning |
Note that the *_function operations are used as implementation details for representing sets.
Bags
For bags the following functions are available. Let b, c be of sort FBag(S),
e of sort S, f,``g``, of sort S -> Nat, h of sort S -> Bool, s of sort
FSet(S), and x,``y`` of sort Bag(S).
Expression |
Syntax |
Meaning |
|---|---|---|
|
|
Construct a bag from a function and a finite bag |
|
|
Empty bag of sort S |
|
|
Interpret finite bag |
|
|
The bag of all elements of sort |
|
|
The number of occurrences of |
|
|
Determine whether |
|
|
Join of |
|
|
Intersection of |
|
|
Difference of |
|
|
Convert bag |
|
|
Convert set |
|
|
The constant function returning |
|
|
The constant function returning |
|
|
The function returning |
|
|
The function returning |
|
|
The function returning |
|
|
The function returning false if |
|
|
The function returning |
Note that, like for sets, the *_function operations are used as implementation details for representing bags.
Creating data expressions
Data expressions can be created in two ways: directly using constructors, or using a parser.
Constructing data expressions directly can be quite tedious:
basic_sort X("X");
basic_sort Y("Y");
basic_sort Z("Z");
sort_expression XYZ = function_sort(function_sort(X, Y), Z);
variable x("x", XYZ);
variable three("3", sort_pos::pos());
variable zero("0", sort_nat::nat());
For convenience a function parse_data_expression is available. This function
takes a variable declaration as optional second argument, that can be used to
specify unbound variables that appear in the expression. An example of this
is:
#include "mcrl2/data/parse.h"
#include "mcrl2/data/pos.h"
#include "mcrl2/data/nat.h"
int main()
{
// two ways to create the expression m + n
std::string var_decl = "m, n: Pos;\n";
data_expression d1 = parse_data_expression("m+n", var_decl);
variable m = parse_data_expression("m", var_decl);
variable n = parse_data_expression("n", var_decl);
data_expression d2 = sort_pos::plus(m, n);
return 0;
}
See also
Sort aliases and sort normalisation — required reading before using the rewriter; sorts must be normalised so that expressions with aliased sorts are recognised as equal.
Data rewriters — evaluating and simplifying data expressions.
Formal foundations
This section gives the mathematical definitions underlying the mCRL2 data language. Practical usage is described in the sections above; the material here provides the formal reference for the concepts implemented in the library.
Data specification
Definition (Data specification)
A data specification is a triple
where is a set of sorts,
is a set of operations, and
is a set of equations. In an mCRL2 specification, sorts are
declared with the
sort keyword, constructors with cons, mappings with
map, and equations with eqn.
Sort expressions
We assume a fixed set of basic sorts , always
containing the booleans
, positive naturals
, naturals
, integers
,
and reals
.
Definition (Sort expressions)
Sort expressions are defined as follows (
right-associative):
with container sorts
In , the sorts
are the domain and
is the codomain.
Sorts outside
are function sorts.
The language also supports sort aliases ; only one of the
two is treated as the canonical sort.
Example (Sort aliases)
Given alias ,
data expressions of sort
and of sort
are interchangeable.
Definition (Variables)
We assume a set of variable names with associated sorts. We write
for the variables of sort
.
Operations
Definition (Operations)
The set of operations consists of constructors
and mappings
:
Every element is a typed symbol . Constructors are restricted
to basic-sort codomains:
We write for the constructors whose codomain is
.
Definition (Signature)
A signature pairs a set of
basic sorts with a set of operations. The signature always contains at least
.
Data expressions
Definition (Data expressions)
Data expressions , with sort expressions
and variables
, are defined inductively:
Here is application,
is
abstraction, and
is set or bag comprehension (a set
when
, a bag when
).
Convention (Binding operators)
We write to denote any binding operator
(
,
,
,
) when
stating rules that apply to all of them uniformly.
Convention (System-defined operators)
System-defined operators are written infix; for example
for
. Standard operator precedence applies.
Valid data expressions
Type validity is defined relative to a context —a set of
typing statements for variables and operations. We write
for
and
to mean exactly one such sort
exists.
Definition (Valid data expressions)
Equations
Definition (Equations)
The syntax of equations is:
An unconditional equation has the form ; a conditional
equation
requires
to be true.
Validity under context :
Semantics
Definition (-algebra)
A -algebra
for
assigns:
a carrier set
to each sort
, containing all elements of that sort;
a total function
to each operation
.
All elements of are obtainable by applying the constructors
.
Example (-algebra for natural numbers)
With and
, one
-algebra
sets
,
,
, and
.
An assignment is a family of functions
. The value of expression
under
and
is written
.
Definition (Value of a data expression)
Here denotes abstraction in the semantic domain.
Remark (Substitution vs. assignment)
There is a close relation between the syntactic notion of substitution and
the semantic notion of assignment: for all substitutions
,
-algebras
, assignments
, and data expressions
,
where is defined by
.
See the Capture-avoiding substitutions page for the full definition of syntactic substitution.
Equational logic
Definition (Satisfaction)
For a -algebra
, condition
, and expressions
of the same sort:
If is omitted it is treated as
.
Definition (Model and logical consequence)
A -algebra
is a model of
if
for all
; we denote this
. The class of all models is
.
An equation is a logical consequence of
, written
, if
for all
.
Finiteness of sorts
Determining whether a sort is finite underlies the is_certainly_finite
function described under Data specifications.
Let and
be defined as follows:
The predicate is:
Free variables and closed expressions
Definition (Free variables)
The set of free variables is defined inductively:
Definition (Closed expression)
A data expression is closed iff
.
Equality checking
Equality of data expressions can be checked by a rewriter or a prover; see
Data rewriters. An equality checker
must satisfy:
That is, and
are distinct, and
is sound: it only reports equality when it holds.
Historical notes
Design decisions
The mCRL2 data language was designed with the following explicit constraints:
Layout-neutral semantics. Whitespace and indentation have no effect on the semantics of a specification. This means that declarations must be terminated by a semicolon; without it, the grammar would be ambiguous. For example, without semicolons the two lines:
X = f(g) (k) = Y
could be parsed either as
X = f(g)and(k) = Y, or asX = fandY = (g)(k), because layout is not significant.