Formal Methods For Software Engineering Languages, Methods, Application
Formal Methods For Software Engineering Languages, Methods, Application
An EATCS Series
Markus Roggenbach · Antonio Cerone ·
Bernd-Holger Schlingloff ·
Gerardo Schneider · Siraj Ahmed Shaikh
Formal
Methods
for Software
Engineering
Languages, Methods, Application
Domains
Texts in Theoretical Computer Science.
An EATCS Series
Series Editors
Juraj Hromkovič, Gebäude CAB, Informatik, ETH Zürich, Zürich, Switzerland
Mogens Nielsen, Department of Computer Science, Aarhus Universitet, Aarhus,
Denmark
More information about this series at https://link.springer.com/bookseries/3214
Markus Roggenbach · Antonio Cerone ·
Bernd-Holger Schlingloff · Gerardo Schneider ·
Siraj Ahmed Shaikh
Formal Methods
for Software Engineering
Languages, Methods, Application Domains
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
The title page shows detail from the cover of the book “Rechnung auff der Linihen und Federn”
by Adam Ries, Sachsse, Erffurdt, 1529.1 It depicts the following scene: “A table-abacus competes
against longhand calculations using ‘Arabic’ numerals, which were still new in Europe. Either one
could trounce calculating by hand with Roman numerals—but which was faster? Are the coins a
wager on the outcome?”2
In his book Ries describes two practices: working with the calculation board (established practice)
and numerical calculations with digits (new practice). Historically, as we all know, the new practice
as the superior one took over.
In the same sense, the authors of this book hope that their advocated approach of utilising Formal
Methods in software engineering will prove to be of advantage and become the new standard.
1 Cover of the book “Rechnung auff der Linihen und Federn” by Adam Ries, Sachsse, Erffurdt,
1529. Digitized by SLUB Dresden.
Link to the image: http://digital.slub-dresden.de/id267529368/9.
Link to the rights notice: https://creativecommons.org/publicdomain/mark/1.0/.
2 See: https://www.computerhistory.org/revolution/calculators/1/38/139.
Foreword by Manfred Broy
vii
viii Foreword by Manfred Broy
is error-prone. Too many things have to be kept in mind and thought of when writing
a line of program text such that it is very likely that what we are writing is sometimes
not what we want.
Here formal theories can help a lot to give a precise meaning and some deep
understanding, not only for programs and the behaviours they generate, but also for
specifications which formally describe certain aspects of program behaviour. The
main contribution of formalization is precision, abstraction, and helpful redundancy.
Redundancy means that we work out different—if possible formal—more adequate
formulations of specific aspects that support the concentration onto specific proper-
ties. This way, relevant aspects are represented in isolation to be able to study them
independently which may reduce complexity. This has led to a number of formal
theories addressing quite different aspects of programs including their functional
behaviour, quality issues, and questions of robustness.
This shows that theories providing formal foundations for formalisms, languages,
and also for methods in software construction are indispensable artifacts to support
software development.
In the academic community, having all this in mind, soon the term “Formal Meth-
ods” has been become popular. This term is carefully defined and explained in this
book. It is illustrated both by examples and use cases as well as by careful discussion
and proper definitions.
For Formal Methods, the challenge is to keep the balance between being formal
and providing methods. In this book, numerous examples are given for such a line of
attack, but we have to always keep in mind that it is dangerous to define a formalism
and to believe that this formalism is already a development method. However, here is
another challenge: in the details of the definitions of formalisms, we have to decide
about concepts that are critical and difficult. A simple example would be the use
of partial functions in specifications: as long as all functions are total, expressions
written with these functions have well-defined values. For partial functions, it gets
much trickier: what is the value of an expression when certain subexpressions are
built of partial functions which happen not to provide a result for this particular
application? What is the value of the overall expression then? Is it always undefined?
What are the rules to deal with this and to reason about it? Of course, there are
many different ways to provide a theory for expressions with partial functions, but
obviously not all of them are equally well-behaving and well-suited for engineering.
Therefore, when defining formal theories, a rich number of delicate questions have
to be solved—many of them related to the goal to use the formalism as an element
of a Formal Method.
Another example is how to represent concurrency. Concurrency is a fact of
everyday life. We are living in a concurrent world. Our software systems are
connected and run concurrently. There are a number of constructs that have been
invented to describe concurrent structures and concurrent processes of software
systems by formal theories, and again there are challenges—first of all, to come
up with a sound theory and a formal model and second to deal with the question
whether the theory is exactly addressing the structures and behaviours which are
typical for practical systems on one side and are easy to deal with on the other side.
Foreword by Manfred Broy ix
xi
xii Preface
This book addresses final year B.Sc. students, M.Sc. students, and Ph.D. students in
the early phases of their research. It is mainly intended as a underlying textbook for
a university course. Formal Methods are one means in software engineering that can
help ensure that a computer system meets its requirements. They can make descrip-
tions precise and offer different possibilities for analysis. This improves software
development processes, leading to better, more cost-effective, and less-error-prone
systems.
Due to their ubiquity, software failures are overlooked by society as they tend
to result in nothing more serious than delays and frustrations. We accept it as mere
Preface xiii
3See, e.g., Cerone et al., Rooting Formal Methods within Higher Education Curricula for Computer
Science and Software Engineering, 2020, https://arxiv.org/abs/2010.05708.
xiv Preface
Chapter 1
Fundamentals
Formal Methods
Part I Chapter 2 Chapter 3
Languages Logic CSP
Part II Chapter 4 Chapter 5
Methods Alg. Spec. Testing
Part III Chapter 6 Chapter 7 Chapter 8
Application domains Contracts HCI Security
Part IV Chapter 9
Wrapping up Origins and Development of FM
Conclusion
An alternative path starts with Chap. 3, thoroughly covering CSP both in theory
and practice. Chapter 5 offers a formal perspective on testing. Chapters 7 and 8
provide case studies both using CSP to demonstrate how the process algebra is
applied. Only the last part of Chap. 7 depends on logic, limited to temporal logic.
Chapter 9, written by our colleague John V. Tucker, puts the contents of the
previous chapters into the historical context. It can be read at any time and it is
independent of any of the other chapters.
The conclusion serves to summarise and remind the reader of the final message
of the book. It is the natural ending to any reading path.
Preface xv
Book History
The inception of this book is due to the first International School on Software Engi-
neering and Formal Methods held in Cape Town, South Africa, from late October
to early November of 2008, organised by Antonio on behalf of the United Nations
University International Institute for Software Engineering (UNU-IIST), which was
located in Macau, SAR China. The two-week school consisted of five courses on
the application of Formal Methods to software design and verification delivered to
an audience of graduate and research tudents from several African countries, who
were hosted by UNU-IIST. In line with the UNU-IIST mandate, the authors were
encouraged to find young minds taking up the challenge of Formal Methods and
demonstrating commitment to it. The book draws upon the topics of the school with
a similar audience in mind and a strong desire to make the subject more widely
accessible. Hence learning is promoted through examples running across the book.
The pedagogic style is largely owed to the instructional setting offered by the school.
Two more schools followed, in Hanoi, Vietnam, in November 2009, and in Thes-
saloniki, Greece, in September 2012, are also hosted by UNU-IIST. These events
provided additional opportunities for feedback and reflection from school partici-
pants. UNU-IIST hosted Markus for one week in 2009. During that meeting, Antonio
and Markus sketched the first structure of the book. UNU-IIST organised a one-week
workshop in August 2012 in Mezzana (Val di Sole), Italy. During this workshop, the
authors decided the final structure and content of the book. After the closing of UNU-
IIST in 2013, the authors continued the collaboration through regular virtual meet-
ings and some physical meetings in Coventry and Swansea, UK. Since January 2020,
Antonio Cerone, School of Engineering and Digital Sciences, Nazarbayev University,
Nur-Sultan, Kazakhstan, has been partly funded to work on the book by the Project
SEDS2020004 “Analysis of cognitive properties of interactive systems using model
checking”, Nazarbayev University, Kazakhstan (Award number: 240919FD3916).
During the years since the Mezzana workshop, the book content has been updated
and widely tested in undergraduate and postgraduate courses by the authors and a
xvi Preface
number of their colleagues at various universities around the world. The intense
cycle of collaborative writing, internal reviewing, and in-class testing was followed
by an external reviewing process, in which the reviewers offered their reflections on
individual chapters and then incorporated in the final revision by the authors.
Author Team
The book’s content, organisation, and writing style were curated by the five book
authors. The author team reached out to John V. Tucker, who kindly accepted our
invitation to contribute a chapter on the origins and development of Formal Methods.
For the writing of some individual chapters, the author team invited Liam O’Reilly
for the chapter on algebraic specification in Casl and Hoang Nga Nguyen for the
chapter on formal verification of security protocols. The book authors are grateful
for their contributions, which made it possible for the book to appear in its current
form.
The authors would like to express their gratitude to a number of people. The following
colleagues, listed in alphabetical order, were so kind to contribute in different
ways, including reading (parts of) the book and commenting on it: Ulrich Berger,
Mihai Codescu, Alan Dix, Stephen Fenech, Marie-Claude Gaudel, Michael Harrison,
Magne Haveraaen, Yoshinao Isobe, Alexander Knapp, Ranko Lazić, Antónia Lopes,
Faron Moller, Till Mossakowski, Gordon Pace, Jan Peleska, Cristian Prisacariu, Jörn
Müller-Quade, Fernando Schapachnik, Steve Schneider, and David Williams. We are
grateful for their input and feedback that helped greatly shaping and improving our
book. Manfred Broy provided a foreword to our book, which we very much appre-
ciate. We also would like to thank Alfred Hoffman, Ronan Nugent, Wayne Wheeler,
and Francesca Ferrari from Springer Verlag for their help, support, and patience.
xvii
Contents
1 Formal Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Markus Roggenbach, Bernd-Holger Schlingloff,
and Gerardo Schneider
1.1 What Is a Formal Method? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 An Application in Space Technologies . . . . . . . . . . . . . . . . . . 2
1.1.2 An Everyday Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Formal Methods in Software Development . . . . . . . . . . . . . . . . . . . . . 12
1.2.1 The Software Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.2.2 Formal Methods: When and Where . . . . . . . . . . . . . . . . . . . . . 16
1.2.3 A Classification Scheme for Formal Methods . . . . . . . . . . . . 19
1.2.4 Tool Support for Formal Methods . . . . . . . . . . . . . . . . . . . . . . 21
1.3 Formal Methods in Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.3.1 Comparative Surveys and Case Studies . . . . . . . . . . . . . . . . . . 25
1.3.2 Industrial Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
1.3.3 How to Get Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.4 Closing Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.4.1 Current Research Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Part I Languages
2 Logics for Software Engineering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Bernd-Holger Schlingloff, Markus Roggenbach,
Gerardo Schneider, and Antonio Cerone
2.1 Logic in Computer Science . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.2 Propositional Logic—An Archetypical Modelling Language . . . . . . 51
2.2.1 Example: Car Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.2.2 Syntax and Semantics of Propositional Logic . . . . . . . . . . . . 53
2.2.3 Propositional Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.3 A Framework for Logics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.3.1 Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
xix
xx Contents
Part II Methods
4 Algebraic Specification in CASL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Markus Roggenbach and Liam O’Reilly
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
4.2 A First Example: Modelling, Validating, Consistency
Checking, and Testing a Telephone Database . . . . . . . . . . . . . . . . . . . 203
4.2.1 Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
4.2.2 Validating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
4.2.3 Consistency Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Contents xxi
Part IV Wrapping up
9 Origins and Development of Formal Methods . . . . . . . . . . . . . . . . . . . . . 455
John V. Tucker
9.1 Where do Formal Methods for Software Engineering Come
From? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
9.2 Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
9.3 Specifying Programming Languages and Programs . . . . . . . . . . . . . . 458
9.4 Specifications of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
9.5 Reasoning and Proof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
9.6 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
9.7 Formal Methods Enter Specialist Areas . . . . . . . . . . . . . . . . . . . . . . . . 474
9.8 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
xxv
List of Examples
xxvii
xxviii List of Examples
Abstract Formal Methods are one means in software engineering that can
help to ensure that a computer system meets its requirements. Using exam-
ples from space industry and every programmer’s daily life, we carefully
develop an understanding of what constitutes a Formal Method. Formal
Methods can play multiple roles in the software design process. Some soft-
ware development standards actually require the use of Formal Methods for
high integrity levels. Mostly, Formal Methods help to make system descrip-
tions precise and to support system analysis. However, their application is
feasible only when they are supported by tools. Consequently, tool qualifi-
cation and certification play a significant role in standards. Formal Methods
at work can be seen in the many (academic) surveys, but also in numerous
published industrial success stories. Hints on how to study Formal Methods
in academia and on how to apply Formal Methods in industry conclude the
chapter.
You have just bought a book on Formal Methods and are making holiday
plans in the Caribbean to read it on the beach. In order to guarantee the
reservation, your travel agent requires a deposit. You decide to pay electron-
ically via credit card.
When performing such a transaction, obviously you have certain expec-
tations on the electronic payment system. You don’t want the agent to be
Markus Roggenbach
Swansea University, Wales, United Kingdom
Bernd-Holger Schlingloff
Humboldt University and Fraunhofer FOKUS, Berlin, Germany
Gerardo Schneider
University of Gothenburg, Sweden
able to withdraw more than required. The agent wants at least the amount
which was asked for. Thus, both you and the agent expect that the payment
system gets its numbers right. The payment should go through—as, clearly,
your credit card is a valid one. Also, you don’t want too much information to
be disclosed, e.g., your PIN should stay secret. The transaction should solely
concern the holiday reservation, no further contracts shall follow from this.
Finally, you want to be able to use the system without the need to consult
a user manual of hundreds of pages. All these points are typical require-
ments for an electronic payment system. Formal Methods are one way how
software engineering can help to ensure that a computer system meets such
requirements.
So, what is a Formal Method? Instead of trying to start with a compre-
hensive definition of the term, we give two motivating examples.
Formal Methods are often used in safety-critical areas, where human life
or health or a large sum of money depends on the correctness of software.
We start with an example from the largest aerospace project mankind has
endeavored so far.
Lamport et al. use the following story to exemplify the distributed consensus
problem [LSP82]:
1 Formal Methods 3
We imagine that several divisions of the Byzantine army are camped outside an
enemy city, each division commanded by its own general. The generals can com-
municate with one another only by messenger. After observing the enemy, they
must decide upon a common plan of action. However, some of the generals may be
traitors, trying to prevent the loyal generals from reaching agreement. The generals
must have an algorithm to guarantee that
The loyal generals will all do what the algorithm says they should, but the traitors
may do anything they wish. The algorithm must guarantee condition A regardless
of what the traitors do. The loyal generals should not only reach agreement, but
should agree upon a reasonable plan. We therefore also want to ensure that
• B. A small number of traitors cannot cause the loyal generals to adopt a bad
plan.
layer, there still was the possibility of errors in the underlying communication
layer.
In Chap. 3, which is devoted to the process algebra Csp, we will give
precise definitions of deadlock and livelock. Furthermore, we will provide
proof techniques to show their absence.
automated
“invent & refinement
verify” check with
FDR2
Algorithm in
Abstraction in CSP
Pseudocode
Our second example is from the area of formal languages and text processing.
It shows the importance of having a precise formal semantics even in common-
day tools such as text processing.
this case, it is essential that the result of any replacement command is unique
and predictable.
The problem is that both for Word and Emacs, there is no formal semantics
of “replacement of regular expressions”. Whereas the syntax of admissible
regular expressions is (more or less) fixed in the documentation, the semantics
is only informally explained.
This example allows us to show the key ingredients of a Formal Method:
syntax, semantics and method.
Syntax
Syntactically, each Formal Method deals with objects from a formal lan-
guage. A formal language is a well-defined set of words from a given alphabet.
Usually it is defined by a grammar, which is a set of rules determining the
membership of the language.
There are also Formal Methods dealing with graphical objects (e.g., Petri
nets). In most of these cases, there is a textual description of these objects
as well (e.g., in XML). For such models, the syntax is fixed by a metamodel,
which determines membership of the class of graphical objects under consid-
eration.
ing’ mechanism: ‘\+’ refers to the letter of the alphabet, whereas ‘+’ denotes the
symbol.
Semantics
The semantics identifies for each syntactical object a unique object in the
chosen interpretation domain. Probably the fundamental question which can
be answered by a semantics is: when can two different syntactical objects
be considered equal? For our regular expression case study this means to
determine when two different expressions are to be the same. As another
example from computer science, we would like to know whether two different
programs compute the same result.
Other questions include whether one object entails another one. For
instance, we would like to know whether one regular expression includes
another one, one program extends another one, or one specification refines
another one.
In contrast to syntax, the semantics of Formal Methods is not always
decidable. That is, membership of a word or model in the formal language
defined by a grammar or metamodel is usually trivial to decide. Semantical
equality, however, is often undecidable as can be seen by the example of
program equivalence.
There are three main ways of defining a semantics for formal languages:
denotational, operational, and axiomatic.
In denotational semantics the denotation of an object is defined. That is,
a denotational semantics is a function defining for each syntactic object an
object in some semantical domain. For example, a regular expression denotes
a language (a set of words) over the alphabet. That is, the semantical domain
for regular expressions is the set of all languages. As another example, a
program in a functional language denotes a function (set of tuples) from the
input parameters to the output type. In Chap. 3 we will discuss three different
denotational semantics for the process algebra Csp.
With the special case n = 0, this definitions entails that for any ϕ,
the empty word (consisting of zero letters) is in [[ϕ∗ ]] .
Methods
The V-model
Agile Development
While process models describe development phases and their order, software
development standards give a legal framework prescribing which activities
have to be performed. For example, a standard might prescribe that “for
each phase of the overall ...system and software safety lifecycles, a plan for
the verification shall be established concurrently with the development for the
phase. The verification plan shall document or refer to the criteria, techniques,
tools to be used in the verification activities.” [IEC10].
There are various standards on the development of software, e.g., EN-
50128, IEC-61508 and DO-178 B/C. Some of these standards prescribe
that Formal Methods are being used for high integrity levels. For example,
IEC 61508, the international standard on functional safety of electrical/elec-
tronic/programmable electronic safety-related systems, is a ‘meta-standard’,
1 Formal Methods 17
methods such as code review, testing and debugging. They increase the con-
fidence in the correctness of the software under consideration.
This is shown in the software development for the ISS as described in
Example 1. It illustrates how Formal Methods can help to analyse a system.
Given a system model, the model checker FDR could prove the presence of
several deadlocks and livelocks. This helped to improve the quality of the
safety-critical system.
Aligned with current practices in software development, Formal Methods
may be used from the very beginning (when a system is initially conceived) up
to the end (when the final product is shipped). Model checking, for instance,
does not require that a single line of code has been written: it may already be
used when the first formal specifications and high-level models are available.
As another example, runtime verification can be used in a pre-deployment
phase, when (part of) the code is ready to run, and even after deployment to
control/enforce desirable properties at runtime.
Formal Methods usually start on the ‘blackboard’: toy examples are treated
in an exemplary way. With paper and pen one checks if a method works
out. In the long run, however, Formal Methods need tool support in order
to become applicable. This is the case as software systems are fundamentally
different compared to mathematical theories:
Numbers of axioms involved. In Chap. 4, we will formalise and ver-
ify control programs written in Ladder Logic. Here, each line of code
is represented by one logic axiom in the specification language Casl.
The toy example presented, a traffic light controller, cf. Example 44, has
about 10 lines of code, i.e., the model consists of about 10 Casl axioms.
Our approach scales up to actual railway interlockings. Such interlockings
describe for a railway station how to position the points and how to light
the signals in such a way that trains can move safely. A typical interlock-
ing program written in Ladder Logic consist out of 500–1500 lines of code,
i.e., its model has 500–1500 Casl axioms in its formalisation.
In contrast, the whole realm of group theory is based on three axioms only,
namely that the operation + is associative (axiom 1), that + has the unit
0 (axiom 2), and, finally, that every element has an inverse (axiom 3).
These example indicate that the number of axioms when applying For-
mal Methods is by magnitudes larger than the number of axioms involved
in mathematical theories. Consequently, tool support is needed in Formal
Methods for sheer book keeping.
Ownership and interest. The interlocking program for a railway station
is commissioned by a rail operator. Intellectual property rights ensure that,
besides the rail operator, only the company writing the code and the rail-
way authorities have access to design documents, code, and verification
documentation, etc. These artefacts are studied only when the software
lifecycle dictates it:
Tool Qualification
When software tools are used to validate software, the questions is, who is
validating the tools? In other words, for highly safety-critical systems there
needs to be evidence why the tools which are used in their development
should be trusted. There are two kinds of tools: for artefact generation and
for artefact validation. This holds for all artefacts occurring in the software
design cycle, e.g., binary code, program text, formal model, specification, or
even the user manual. In industry, there are contradicting views concerning
the importance of these tool classes. In some areas, generating tools are con-
1 Formal Methods 23
sidered to be more critical than validating tools, since they directly affect the
behaviour of the system. In other areas it is argued that faulty behaviour of
a generator can anyway be found by the validation tools, which therefore are
more critical.
If a generating tool is faulty, then the generated artefact will not corre-
spond to its source. In the case of executable code, e.g., this may mean that
the runtime behaviour is not as expected. In the case of a model transforma-
tion, the generated model might miss out on properties already established
for the source model.
1 int x = 4;
2 int y;
3
4 void foo (void) {
5 for (y = 1; y < 8; y += 7) {
6 int *p = &y;
7 *p = x;
8 }
9 }
If a validation tool is inaccurate or faulty, there are two cases: the tool
might report an error where there is none (false positive), or the tool might
miss to report an error where there is one (false negative). For example,
an erroneous program verifier might fail to verify a correct program (false
positive), or it might claim to have found a proof for an incorrect program
(false negative). Often, false negatives are more critical than false positives
since they convey a deceptive certainty. False positives are a hassle, because
they need to be dealt with manually.
24 M. Roggenbach, B.-H. Schlingloff, G. Schneider
To make this more concrete, consider the tool Cppcheck for static analysis
of C programs:
What are now the possibilities for the validation of tools? The usual
approach is to resort on tools which are proven-in-use, i.e., where experi-
ence from many previous projects suggests that the tool is ‘correct’. This is
especially the case for certain public-domain tools which have been applied by
many users for a long period of time. In order to claim that a tool is proven-
in-use, it is necessary to provide evidence in which comparable projects it was
used. As the above example of the GCC compiler error shows, proven-in-use
is no guarantee against subtle, hidden errors.
For new or newly introduced methods and tools, the proven-in-use prin-
ciple poses the problem of how to begin such a chain of trust. So, what to
do when proven-is-use is not applicable? In order to be allowed to use tools
which are not proven-in-use in a safety-oriented development, at least one
has to perform a tool qualification. That is, the tool has to be applied to a
number of selected examples under controlled conditions, where the tool’s
behaviour must be analysed and documented in detail. Tool certification is
the process of confirming the qualification by a designated authority. Usually
this is done only for tools to be applied in several different projects. The soft-
ware development standard DO-333, e.g., prescribes in detail how to qualify
and certify tools for different safety integrity levels in aerospace.
1 Formal Methods 25
Of course there is still a possibility that even certified tools might contain
errors. There are further methods that can improve the reliability of Formal
Methods tools.
In the case of generating tools, one possibility is to verify the genera-
tor itself. For instance, there are a number of research projects and results
dealing with compiler verification. One challenge here is that the correctness
argument needs to deal with several different languages: the language the
generator is written in, the source language, and the target language. Due
to the sheer size of the problem, often compiler verification is supported by
automated tools. Yet another possibility is to generate, besides the code, also
certain proof conditions from program annotations, which can be checked
automatically in the generated code with a suitable verification tool. This
way, if the compiler is faulty in its code generation part, this will be detected
by the following verification tool.
Both these suggestions to improve the dependability of generating tools
rely on the existence of correct verification tools. In order to increase the
trust in the correctness of verification tools themselves, one can run several
different provers on the same problem and compare their results. If at least
two of them agree, then, under the assumption that different tools do not
make the same mistake, the result is as given. If one prover claims to have
found a proof, while another one claims that the property is not valid, one
of them must be faulty.
Another approach to increase the trust in theorem provers is to augment
them with a proof checking component. For this, the prover must not only
give a boolean result but also produce some term which allows to check
whether the proof is a valid one.
The Formal Methods community has compiled several surveys with the aim
of comparing different approaches for the application of Formal Methods in
various areas. The characteristic of these surveys is to discuss one coherent
example in the context of several Formal Methods.
26 M. Roggenbach, B.-H. Schlingloff, G. Schneider
• Lewerentz and Lindner [LL95] discuss a production cell. This cell is consid-
ered to be safety critical, i.e., a number of properties must be enforced in
order to avoid injuries of people. The system is reactive, i.e., it has to react
permanently to changes of the environment. In principle this is a real-time
problem, as the reaction of the control software must be guaranteed within
a certain interval of time.
Abrial et al. [ABL96], use Formal Methods for various purposes: formal
requirement specifications, intermediate refined models, analysis of system
properties, proofs, automated synthesis of conditions implying safety for
parameters of the controller, design or generation of executable code. The
overall twenty-one contributions used algebraic, logical, and operational lan-
guages similar to those treated in the subsequent chapters of this book.
• Frappier and Habrias [FH01] discuss a classical commercial software appli-
cation:
The methods applied to the Mondex case study are the Alloy model-finding
method, the KIV system, Event-B, UML and OCL, RAISE, and Z/Eves.
• Rausch et al. [RRMP08] document a competition on the so called Common
Component Modelling Example (CoCoME). Given a prescribed architec-
ture, the challenge lies in using a specific formalism for modelling and
analysing the CoCoME according to this architecture.
Rausch et al. [RRMP08] documents more than ten formal component models
and their use in verification and quality prediction. A jury evaluation con-
cludes the volume. We discuss similar examples in Chap. 6 on “Specification
and Verification of Electronic Contracts”.
• Cortier and Kremer [CK11] collect several popular symbolic approaches
to formal security. Different research groups demonstrate their techniques,
taking a flawed public key protocol (and its correction) as a common exam-
ple:
1 Formal Methods 29
This protocol shall provide secrecy: the secret s shall only be known to A
and B. The above handshake protocol, however, is vulnerable to a ‘man
in the middle’ attack. Various techniques are used to (automatically) find
this flaw and to prove that adding the identities of the intended participant
changes the protocol into a correct one. These techniques include rewrite
rules, Horn clauses, strand spaces, constraint systems, process algebra, and
Floyd–Hoare style logics. Further protocols are consider in order to demon-
strate the strengths of individual techniques. In Chap. 8 on the “Formal
Verification of Security Protocols” we verify a protocol for authentication.
For good reason, the above compilations refrain from giving a concrete
recommendation which method is ‘the best’. Similar to the problem of select-
ing a suitable programming language for a particular project, the suitability
of a method strongly depends on the context. For example, a method for
analysing functional correctness might not be suitable for deadlock analysis
of protocols.
Success Stories
The German Verisoft project [Ver07] demonstrates that with present For-
mal Methods it is not only possible to verify an operating system, but that
the systematic use of computer-aided verification tools is possible throughout
all layers of abstractions.
lot for several Eurocopter models, several nuclear power plants as well as
the interlocking and train control system of the Eurostar trains between
London and Paris.
Example 16 demonstrates that tools for Formal Methods not only signifi-
cantly contribute to system safety, but also can have a considerable market.
From the management point of view, the project went off according to the initial
schedule, although the software produced is quite large, thanks to a straightforward
process and efficient tools.
Every verification stage throughout the process was useful and led to early error
detection: analysis of software document specification, type checking, inspections,
proof of abstract model safety properties, refinement proof of correct implementa-
tion.
The previous sections give the right impression that the variety of Formal
Methods is overwhelming. This might leave the beginner or potential user to
be lost in the field. Which method shall be selected in a given context? We
discuss this question in two different scenarios. One possible scenario is that
of a research student learning a Formal Method. The other scenario is that
of a Formal Method to be selected in a specific industrial project.
For the first scenario, this book provides a good starting point. It offers a
non-representative selection of methods, where each chapter provides a solid
introduction to one method. Specialisation in one method is unproblematic,
as the foundations of Formal Methods are well connected. Concepts studied,
say, in the context of process algebra, are also to be found in temporal logics,
which again are closely connected to automata theory, and are applied, e.g.,
in testing. Within a discipline, there are often attempts to unify structural
insights. In logics, for example, the theory of institutions provides a general
framework in which logical properties can be studied in a uniform way (see
Chap. 2). The methodological approach to different Formal Methods often is
comparable. Consequently, one should not be afraid of intensively studying
one specific method, even if it is not in the direct line of one’s own research.
The best approach of studying a specific method is by example. One should
select a suitable case study of medium complexity (this book is full of these).
The first step is to formalise the case study, i.e., to transfer it into the language
of the chosen method. Already in this step one might find limitations or
restrictions that one would like to study further. The next step is to check
if the formalisation is an adequate representation of the case study. The
modelling of systems and of proof obligations needs to be faithful.
Now, it is time for reflection: what insight can be gained into the formal
representation with the chosen Formal Method? Here, one can try to derive
properties manually—using a calculus, or even directly applying the seman-
1 Formal Methods 37
tics. Only in the next step one should reproduce the manual results in tools,
if available. This order of first thinking and then using tools is important
for keeping one’s mind open to the possibilities of a Formal Method. Tools
usually cover only certain aspects, namely those most relevant to their devel-
opers. Experience suggests that such a case study-driven approach creates
good research topics.
Having identified a suitable Formal Method, the next step is to carry out
a pilot project. Here, a small but relevant part of the problem is solved in
an exemplary way using the selected Formal Method. This involves thor-
ough time measurement and documentation for all activities that the Formal
Method incurs: modelling, installing the tools, using the tools, integrating
the tools, interpreting the results, etc. Reflecting upon this allows to check if
the chosen approach is indeed feasible. On the management level, the pilot
project then has to be evaluated as to whether it is an improvement with
respect to current practice. It should be both more effective, in that it allows
to achieve better results than previous methods, and more efficient, i.e., in
the long run it should offer a better cost/result ratio.
In this section we point out several challenges and current research topics for
Formal Methods.
Advancement. An account of the historical development of Formal Meth-
ods is given in Chap. 9. In this context, the question is whether there still is
a need for Formal Methods to evolve further. Considering computational
systems, we see that their size and complexity is ever increasing. Also,
computers for executing Formal Methods tools become more powerful.
However, the increase of the problem size often outgrows what tools can
handle. This is due to the fact that most algorithms in Formal Methods
are complex. As a consequence, there is a constant need to improve meth-
ods and tools. Therefore, the questions of how to develop ‘good’ Formal
Methods, i.e., Formal Methods which are efficient and usable, will stay.
1 Formal Methods 39
bined physical and logical modelling. For modelling systems which have
both discrete and continuous state changes, hybrid automata have been
suggested as a formal framework. However, current methods are not yet
sophisticated enough to allow the verification of industrial strength appli-
cations. Additionally, cyber-physical systems have to deal with unreliable
communication, imprecise sensors and actors, faulty hardware etc. For each
of these problems, initial individual approaches are being developed, how-
ever, it is an open research topic to develop convincing Formal Methods
tackling them in combination.
Artificial intelligence and machine learning. Techniques based on arti-
ficial intelligence (AI) in general, and machine learning (ML) in partic-
ular, are massively being used in deployed software. Many applications
using AI/ML are safety-critical (e.g., autonomous cars), so correctness is
paramount. But the interaction between Formal Methods and AI/ML goes
beyond the standard ‘let us use a Formal Methods technique to prove the
correctness of this algorithm—which happens to use AI/ML.’ Indeed, the
use of AI/ML introduces new challenges for formal verification, in partic-
ular in the area of deep neural networks where sometimes an algorithm
has been learned without a clear understanding of the process of its cre-
ation. This makes it difficult to assert the correctness of the outcomes of
the algorithm, which might require transparency in the underlying mod-
els and the used techniques and methods for learning algorithms, that is
to get ‘explainable’ AI [Mol19]. Other interesting research directions are
the use of machine learning to improve Formal Methods [ALB18], and the
application of Formal Methods to AI/ML [HKWW17, SKS19, WPW+18].
Finally, we briefly mention further applications of Formal Methods beyond
software engineering, such as biological systems and, more recently, ecology,
economics and social sciences.
References
[Aal11] Wil M. P. Van Der Aalst. Process Mining: Discovery, Conformance and
Enhancement of Business Processes. Springer, 2011.
[ABL96] Jean-Raymond Abrial, Egon Börger, and Hans Langmaack, editors. Formal
Methods for Industrial Applications, Specifying and Programming the Steam
Boiler Control (the book grew out of a Dagstuhl Seminar, June 1995), LNCS
1165. Springer, 1996.
[Abr94] Jean-Raymond Abrial. Steam-boiler control specification problem. https://
www.informatik.uni-kiel.de/~procos/dag9523/dag9523.html, 1994.
[ALB18] Moussa Amrani, Levi Lúcio, and Adrien Bibal. ML + FV = ♥? A survey
on the application of machine learning to formal verification, 2018. http://
arxiv.org/abs/1806.03600.
[BA05] F. Badeau and A. Amelot. Using B as a high level programming language in
an industrial project: Roissy VAL. In ZB 2005, LNCS 3455, pages 334–354.
Springer, 2005.
[Bac59] J. W. Backus. The syntax and semantics of the proposed international alge-
braic language of the zurich acm-gamm conference. In Proceedings of the
International Conference on Information Processing. UNESCO, 1959. Avail-
able via the web site of the Computer History Museum’s Software Preserva-
tion Group, http://www.softwarepreservation.org.
[Bar11] Janet Elizabeth Barnes. Experiences in the industrial use of formal methods.
In AVoCS’11. Electronic Communications of the EASST, 2011.
[BBBB09] Christoph Baumann, Bernhard Beckert, Holger Blasum, and Thorsten
Bormer. Formal verification of a microkernel used in dependable software
systems. In SAFECOMP 2009, LNCS 5775, pages 187–200. Springer, 2009.
[BCB+10] Thomas Anung Basuki, Antonio Cerone, Roberto Barbuti, Andrea Maggiolo-
Schettini, Paolo Milazzo, and Elisabetta Rossi. Modelling the dynamics of an
aedes albopictus population. In AMCA-POP 2010, volume 33 of Electronic
Proceedings in Theoretical Computer Science, pages 18–36. Open Publishing
Association, 2010.
[BCH+12] Craig Burton, Chris Culnane, James Heather, Thea Peacock, Peter Y. A.
Ryan, Steve Schneider, Sriramkrishnan Srinivasan, Vanessa Teague, Roland
Wen, and Zhe Xia. A supervised verifiable voting protocol for the Victorian
electoral commission. In EVOTE 2012, volume 205 of LNI, pages 81–94. GI,
2012.
[Bec02] Kent Beck. Test Driven Development: By Example. Addison-Wesley, 2002.
[BH95a] Jonathan P. Bowen and Michael G. Hinchey. Seven more myths of formal
methods. IEEE Software, 12(4):34–41, 1995.
[BH95b] Jonathan P. Bowen and Michael G. Hinchey. Ten commandments of formal
methods. IEEE Computer, 28(4):56–63, 1995.
1 Formal Methods 43
[GJBB13] James Gosling, Bill Joy, Guy Steele Gilad Bracha, and Alex Buckley. The
Java language specification, 2013.
[GKB11] Wolfgang Grieskamp, Nico Kicillof, and Bob Binder. Microsoft’s protocol doc-
umentation program: Interoperability testing at scale. Communications of the
ACM, 2011.
[GKSB10] Wolfgang Grieskamp, Nicolas Kicillof, Keith Stobie, and Victor Braberman.
Model-based quality assurance of protocol documentation: tools and method-
ology. Softw. Test. Verif. Reliab., 2010.
[Hal90] Anthony Hall. Seven myths of formal methods. IEEE Software, 7(5):11–19,
1990.
[Hal12] Nicolas Halbwachs. A Synchronous Language at Work: The Story of Lustre,
pages 15–31. Wiley, 2012.
[Har03a] David Harel. A grand challenge for computing: Towards full reactive modeling
of a multi-cellular animal. Bull. EATCS, 81:226–235, 2003.
[Har03b] J. Harrison. Formal verification at Intel. In 18th Annual IEEE Symposium of
Logic in Computer Science, pages 45–54, 2003.
[HKW+07] Sebastian Herold, Holger Klus, Yannick Welsch, Constanze Deiters, Andreas
Rausch, Ralf Reussner, Klaus Krogmann, Heiko Koziolek, Raffaela Mirandola,
Benjamin Hummel, Michael Meisinger, and Christian Pfaller. CoCoME - the
common component modeling example. In CoCoME, LNCS 5153, pages 16–
53. Springer, 2007.
[HKWW17] Xiaowei Huang, Marta Kwiatkowska, Sen Wang, and Min Wu. Safety verifica-
tion of deep neural networks. In CAV’17, LNCS 10426, pages 3–29. Springer,
2017.
[HLQB] Brian Hackett, Shuvendu K. Lahiri, Shaz Qadeer, and Thomas Ball. Scalable
modular checking of system-specific properties: Myth or reality?
[HS12] James Heather and Steve Schneider. A formal framework for modelling coer-
cion resistance and receipt freeness. In FM 2012, LNCS 7436, pages 217–231.
Springer, 2012.
[IEC10] International Electrotechnical Commission. Functional Safety of Elec-
trical/Electronic/Programmable Electronic Safety-related Systems, IEC
61508:2010, 2010.
[JW08] Cliff B. Jones and Jim Woodcock, editors. Formal Aspects of Computing,
volume 20, No 1. Springer, 2008.
[KAE+10] Gerwin Klein, June Andronick, Kevin Elphinstone, Gernot Heiser, David
Cock, Philip Derrin, Dhammika Elkaduwe, Kai Engelhardt, Rafal Kolan-
ski, Michael Norrish, Thomas Sewell, Harvey Tuch, and Simon Winwood.
seL4: formal verification of an operating-system kernel. Communications of
the ACM, 53(6):107–115, 2010.
[KBP+01] Erik Kamsties, Daniel M. Berry, Barbara Paech, E. Kamsties, D. M. Berry,
and B. Paech. Detecting ambiguities in requirements documents using inspec-
tions. In First Workshop on Inspection in Software Engineering, 2001.
[KDE09] Gerwin Klein, Philip Derrin, and Kevin Elphinstone. Experience report: seL4:
formally verifying a high-performance microkernel. In ICFP 2009, pages 91–
96. ACM, 2009.
[KM18] Alexander Knapp and Till Mossakowski. Multi-view consistency in UML: A
survey. In Graph Transformation, Specifications, and Nets - In Memory of
Hartmut Ehrig, LNCS 10800, pages 37–60. Springer, 2018.
[KNP10] Marta Kwiatkowska, Gethin Norman, and David Parker. Probabilistic model
checking for systems biology. In Symbolic Systems Biology, pages 31–59. Jones
and Bartlett, May 2010.
[Koz94] Dexter Kozen. A completeness theorem for Kleene algebras and the algebra
of regular events. Information and Computation, 110:366–390, 1994.
1 Formal Methods 45
[KRT13] Dalia Khader, Peter Y. A. Ryan, and Qiang Tang. Proving prêt à voter receipt
free using computational security models. USENIX Journal of Election Tech-
nology and Systems (JETS), 1(1):62–81, 2013.
[KS12] Dexter Kozen and Alexandra Silva. Left-handed completeness. In Relational
and Algebraic Methods in Computer Science, LNCS 7560, pages 162–178.
Springer, 2012.
[Lie96] Jochen Liedtke. Toward real microkernels. Communications of the ACM,
39(9):70–77, September 1996.
[LL95] Claus Lewerentz and Thomas Lindner, editors. Formal Development of Reac-
tive Systems – Case Study Production Cell, LNCS 891. Springer, 1995.
[LSGP07] T Lecomte, T Servat, and G G Pouzancre. Formal methods in safety-critical
railway systems. In Brazilian Symposium on Formal Methods: SMBF, 2007.
[LSP82] Leslie Lamport, Robert E. Shostak, and Marshall C. Pease. The Byzantine
generals problem. ACM Trans. Program. Lang. Syst., 4(3):382–401, 1982.
[MCT15] Patrick Mukala, Antonio Cerone, and Franco Turini. Process mining event
logs from floss data: State of the art and perspectives. In SEFM 2014 Collo-
cated Workshops, LNCS 8938, pages 182–198. Springer, 2015.
[Mol19] Christoph Molnar. Interpretable machine learning, 2019. https://
christophm.github.io/interpretable-ml-book/.
[MS08] Satish Mishra and Bernd-Holger Schlingloff. Compliance of CMMI process
area with specification based development. In Conference on Software Engi-
neering Research, Management and Applications, SERA ’08, pages 77–84.
IEEE Computer Society, 2008.
[Pău98] Gheorghe Păun. Computing with membranes. Technical Report 208, Turku
Centre for Computer Science, November 1998.
[Pău00] Gheorghe Păun. Computing with membranes. Journal of Computer and Sys-
tem Science, 61(1):108–143, 2000.
[PB99] Jan Peleska and Bettina Buth. Formal methods for the international space
station ISS. In Correct System Design, LNCS 1710. Springer, 1999.
[PRS09] Gheorghe Păun, Grzegorz Rozemberg, and Arto Salomaa, editors. The Oxford
Handbook of Membrane Computing. Oxford Handbooks in Mathematics.
Oxford University Press, December 2009.
[RA08] Anne Rozinat and Wil M. P. Van Der Aalst. Conformance checking of pro-
cesses based on monitoring real behavior. Information Systems, 33(1):64–95,
2008.
[RBH+09] Peter Y. A. Ryan, David Bismark, James Heather, Steve Schneider, and Zhe
Xia. Prêt à voter: a voter-verifiable voting system. IEEE Transactions on
Information Forensics and Security, 4(4):662–673, 2009.
[RRMP08] Andreas Rausch, Ralf Reussner, Raffaela Mirandola, and Frantisek Plasil,
editors. The Common Component Modeling Example: Comparing Software
Component Models [result from the Dagstuhl research seminar for CoCoME,
August 1-3, 2007], LNCS 5153. Springer, 2008.
[Sal66] Arto Salomaa. Two complete axiom systems for the algebra of regular events.
J. ACM, 13(1):158–169, January 1966.
[SB01] Ken Schwaber and Mike Beedle. Agile Software Development with Scrum.
Prentice Hall, 2001.
[SBMC15] Sheema Sameen, Roberto Barbuti, Paolo Milazzo, and Antonio Cerone. A
mathematical model for assessing KRAS mutation effect on monoclonal anti-
body treatment of colorectal cancer. In SEFM 2014 Collocated Workshops,
LNCS 8938, pages 243–258. Springer, 2015.
[SCW00] Susan Stepney, David Cooper, and Jim Woodcock. An electronic purse: Spec-
ification, refinement, and proof. Technical monograph PRG-126, Oxford Uni-
versity Computing Laboratory, July 2000.
46 M. Roggenbach, B.-H. Schlingloff, G. Schneider
[SKS19] Xiaowu Sun, Haitham Khedr, and Yasser Shoukry. Formal verification of
neural network controlled autonomous systems. In HSCC 2019, pages 147–
156. ACM, 2019.
[SLC+11] Steve Schneider, Morgan Llewellyn, Chris Culnane, James Heather, Sriramkr-
ishnan Srinivasan, and Zhe Xia. Focus group views on prêt à voter 1.0. In
REVOTE 2011, pages 56–65. IEEE, 2011.
[SSC+12] Steve Schneider, Sriramkrishnan Srinivasan, Chris Culnane, James Heather,
and Zhe Xia. Prêt á voter with write-ins. In VoteID 2011, LNCS 7187, pages
174–189. Springer, 2012.
[THSS98] L. Twele, B-H. H. Schlingloff, and H. Szczerbicka. Performability analysis of
an avionics-interface. In Proc. IEEE Conf. on Systems, Man and Cybernetics,
1998.
[TW09] Michael Carl Tschantz and Jeannette M. Wing. Formal methods for privacy.
In FM’09, volume 5850 of LNCS, pages 1–15. Springer, 2009.
[VDAS11] Wil M. P. Van Der Aalst, and Christian Stahl. Modeling Business Processes:
A Petri Net-Oriented Approach. MIT Press, May 2011.
[Ver07] Eyad Alkassar, Mark A. Hillebrand, Dirk Leinenbach, Norbert Schirmer and
Artem Starostin. The verisoft approach to systems verification. In Verified
Software: Theories, Tools, Experiments, Second International Conference,
VSTTE 2008, Toronto, Canada, October 6–9, 2008. Proceedings, volume
5295 of LNCS, pages 209–224. Springer, 2008. https://doi.org/10.1007/
978-3-540-87873-5_18.
[WPW+18] Shiqi Wang, Kexin Pei, Justin Whitehouse, Junfeng Yang, and Suman Jana.
Formal security analysis of neural networks using symbolic intervals. In
USENIX’18, pages 1599–1614. USENIX Association, 2018.
[YCER11] Xuejun Yang, Yang Chen, Eric Eide, and John Regehr. Finding and under-
standing bugs in C compilers. SIGPLAN Not., 46(6):283–294, June 2011.
Part I
Languages
Chapter 2
Logics for Software Engineering
Abstract Logic is the basis for almost all formal methods in computer sci-
ence. In this chapter, we introduce some of the most commonly used log-
ics by examples. It serves as a reference for subsequent chapters. We start
with propositional logic, introduce its syntax, semantics, and calculus. Then
we extend our view of propositional logic as a so-called institution, discuss
model transformations and modular specifications. Subsequently, we turn to
first- and second-order logic and show how these can be obtained as natu-
ral extensions of propositional logic. Finally, we discuss non-classical logics:
multimodal and deontic logics to deal with alternative and subjective view-
points, respectively, and dynamic and temporal logics for reasoning about
time. The chapter concludes with an elaborate example of how to transform
an informal natural language description into a formal specification in linear
temporal logic.
Today’s your lucky day! You are the candidate in a big TV quiz show, and
so far you have mastered all challenges. In the final round, there are three
Bernd-Holger Schlingloff
Humboldt University and Fraunhofer FOKUS, Berlin, Germany
Markus Roggenbach
Swansea University, Wales, United Kingdom
Gerardo Schneider
University of Gothenburg, Sweden
Antonio Cerone
Nazarbayev University, Nur-Sultan, Kazakhstan
baskets, one of which contains the big prize, the other two being empty. The
quiz master gives you the following facts.
1. Either the prize is in the middle basket, or the right basket is empty.
2. If the prize is not in the left basket, then it is not in the middle.
Which basket do you choose?
This example is typical for a number of ‘logic puzzles’ which have been
popular since the middle of the 19th century. In this chapter we will show
how to formalize and solve such puzzles—not just for the sake of winning
in TV quiz shows, but also to construct software solutions for all sorts of
problems.
Seen from a hardware perspective, nowadays every ‘classical’ computer is
a binary device, built from switching elements which can be in one of two
states each—on or off, high or low, zero or one etc. Therefore, hardware can
be described and analysed with logical means.
From a software perspective, every programming language incorporates
some logic, e.g., propositional logic for Boolean conditions in control flow
decisions such as branches or loops. Thus, the study of logic is fundamental
for programming. There even are special programming languages like, e.g.,
PROLOG, in which logic is turned into a programming paradigm. For many
programming languages, there are special logics to express certain properties
of program phrases, e.g., pre- and postconditions. Examples include ACSL
for C, JML for Java, and Spark Ada.
Moreover, logic can be used as a means for specification of systems, inde-
pendent of the particular programming language. Examples are Casl (see
Chap. 4) and the Z, B, and Event-B specification languages. Given a system
specification, logic can be used to verify that a particular program is cor-
rect with respect to it. Specialised logics have been developed for this task,
including temporal and dynamic logics which are treated in this chapter.
From these examples it should be clear that there is not ‘one’ logic in
computer science, but many different logics are being used. Each of these can
be considered to be a Formal Method:
What is behind the scene of such a scenario? We now develop the example
towards modelling and analysis with propositional logic.
52 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
After the language for reasoning about the domain of discourse has been
fixed, it is possible to formulate properties in this language.
Note that the set of proposition symbols may be empty; in this case, the
only formulae which can be built according to the definition are ⊥, (⊥ ⇒ ⊥),
((⊥ ⇒ ⊥) ⇒ ⊥), (⊥ ⇒ (⊥ ⇒ ⊥)), etc.
This syntax is ‘minimalistic’ in the sense that it only contains the constant
⊥ and the junctor ⇒. This allows easy proofs by induction on the structure of
54 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
• M |= ,
• M |= (ϕ ∨ ψ) if and only if M |= ϕ or M |= ψ (or both),
• M |= (ϕ ∧ ψ) if and only if both M |= ϕ and M |= ψ,
• M |= (ϕ
⊕ ψ) if and only if M |= ϕ or M |= ψ, but not both,
• M |= (ϕ1 , . . . , ϕn ) if and only if for exactly one i ≤ n it holds that
M |= ϕi .
The model checking problem is defined as follows: given a model M and a
formula ϕ, determine whether M |= ϕ. For propositional logic, this problem
can be solved with a complexity which is linear in the length of the formula
and the access time of the truth value of a proposition symbol in a model
(which is, depending on the representation of the model, typically either
constant or linear in the size of the model). Model checking for propositional
formulae involves parsing the formula according to its syntax, looking up
the values of the proposition symbols in the model, and then assigning the
truth value to compound formulae according to the above clauses. Detailed
pseudocode-algorithms for this task are given below.
Definition 3 (Satisfiability, Validity) Given any formula ϕ, we say that ϕ is
satisfiable if there exists a model M such that M |= ϕ. A formula ϕ which is
valid in every model is called universally valid or logically true or a tautology,
denoted by |= ϕ.
Clearly, each universally valid formula is satisfiable. Moreover, if ϕ is unsat-
isfiable, then ¬ϕ must be universally valid. The satisfiability problem SAT
problem is to find out whether any given formula is satisfiable; likewise, the
validity problem is to determine whether a given formula is universally valid.
Any algorithm which solves the satisfiability problem also is a solution to the
validity problem: in order determine whether |= ϕ it is sufficient to find out
whether ¬ϕ is satisfiable or not: If ¬ϕ is satisfiable, then there is a model M
such that M |= ¬ϕ; hence M |= / ϕ and thus ϕ cannot be universally valid.
If ¬ϕ is unsatisfiable, then for all models M we have M |= / ¬ϕ; hence for
all M we have M |= ϕ and thus ϕ is universally valid. In summary, ¬ϕ is
satisfiable if and only if ϕ is not universally valid; i.e., ϕ is universally valid
if and only if ¬ϕ is not satisfiable. Thus, given an algorithm for SAT, we can
find out whether a formula ϕ is universally valid by checking whether ¬ϕ is
unsatisfiable. Likewise, any algorithm for the validity problem can be used
as a solver for the satisfiability problem.
Satisfiability can be generalized and relativized to sets of formulae: let Γ
be any set of formulae and ϕ be a formula. We say that Γ is satisfiable, if
there is a model M satisfying all ψ ∈ Γ . Similarly, ϕ follows from Γ (written
as Γ ϕ), if ϕ holds in every model M which satisfies all ψ ∈ Γ .1 Similar
to above, it holds that Γ ϕ if and only if Γ ∪ {¬ϕ} is unsatisfiable.
1 Here, we use the symbol for the semantic consequence relation between formulae,
which is different from the symbol |= for the satisfaction relation between a model and a
formula. For universal validity, the notions coincide: |= ϕ if and only if {} ϕ.
56 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
In model theory, a set of formulae often is identified with the set of its
models. We write Mod (Γ ) {M | M |= ψ for all ψ ∈ Γ } Clearly, Γ is sat-
isfiable if and only if Mod (Γ ) = ∅, and Γ is universally valid if and only if
Mod (Γ ) is the set of all models for the given proposition symbols.
Various methods have been developed for propositional logic. In the following,
we discuss model checking, checking for satisfiability, and so-called deduction
systems.
In the second case, we need a pushdown store of values {true, false} for
parsing the formula.
Propositional Satisfiability
Much work has been invested in the design of efficient SAT-solvers [BBH+09].
Examples include Chaff, MiniSAT, PicoSAT and others. There are annual
competitions to compare the performance of these tools on large formulae.
If the validity problem is too complex for fully automated tools, sometimes it
is possible to ‘manually’ construct a proof. For propositional logic, there exist
quite a few proof methods: axiomatic systems, tableaux systems, systems of
natural deduction, resolution systems, and others. Each such system describes
how to obtain a proof for a given propositional formula. There are two basic
ways of constructing a proof for formula ϕ. Either, one starts with a set
of valid formulae, and derives further valid formulae from these, until ϕ is
obtained. Or, one starts with ϕ, and iteratively decomposes it until only valid
constituents remain.
We give an example for the first of these methods. Our Hilbert-style proof
system for propositional logic is given by the following axioms and derivation
rule:
(weak) (ϕ ⇒ (ψ ⇒ ϕ))
(dist) ((ϕ ⇒ (ψ ⇒ ξ)) ⇒ ((ϕ ⇒ ψ) ⇒ (ϕ ⇒ ξ)))
(tnd) (¬¬ϕ ⇒ ϕ)
(mp) ϕ, (ϕ ⇒ ψ) ψ
2 Logics for Software Engineering 59
Here, the symbol denotes derivability in the following sense. The first
three lines are axioms; they are known as weakening, distributivity, and ter-
tium non datur (law of the excluded middle), respectively. A propositional
formula is a substitution instance (or simply instance) of an axiom, if it can
be obtained by consistently replacing the symbols ϕ, ψ and ξ by propositional
formulae.
Both Hilbert-style proof systems and natural deduction may not be opti-
mal for automated theorem proving. In 1960, Davis and Putnam proposed
theorem proving by resolution, which is based on the single rule
(ϕ ∨ ξ1 ∨ . . . ∨ ξn ), (¬ϕ ∨ ψ1 ∨ . . . ∨ ψm ) (ξ1 ∨ . . . ∨ ξn ∨ ψ1 ∨ . . . ∨ ψm )
Given any proof system, logicians are usually interested in two questions:
Correctness: Are all provable formulae valid?
Completeness: Are all valid formulae provable?
For our Hilbert-style proof system, this amounts to showing that only valid
formulae are derivable, and that for any valid formula there exists a deriva-
tion. The first of these questions usually is easy to affirm (one wouldn’t want
to work with an incorrect proof system!), whereas the second one often is
more intricate. For reference purposes, we sketch the respective proofs; they
are not necessary for the rest of the book and can be safely skipped by the
casual reader.
Theorem 1 (Correctness of Hilbert-style proof system) Any derivable for-
mula is valid: if ϕ, then |= ϕ.
Proof The proof is by induction on the length of the derivation. We show
that all instances of axioms are valid, and that the consequent of (mp) is
valid if both antecedents are. Consider the axiom (weak). Assume any model
M, and any substitution of propositional formulae ϕσ and ψ σ for ϕ and ψ,
respectively. Then, M |= ϕσ or M |= / ϕσ , and likewise for ψ σ . Thus, there
are four possibilities for the truth values of ϕσ and ψ σ in M. We give a truth
table for these possibilities:
ϕσ ψ σ (ψ σ ⇒ ϕσ ) (ϕσ ⇒ (ψ σ ⇒ ϕσ ))
false false true true
false true false true
true false true true
true true true true
Since in any case the value of (ϕσ ⇒ (ψ σ ⇒ ϕσ )) is true, this instance
is valid. For axioms (dist) and (tnd), the argument is similar. For (mp),
assume that ϕσ and (ϕσ ⇒ ψ σ ) are derivable. According to the induction
hypothesis, ϕσ and (ϕσ ⇒ ψ σ ) are also valid. Therefore, M |= ϕσ and
M |= (ϕσ ⇒ ψ σ ) for any model M. From the definition, M |= (ϕσ ⇒ ψ σ ) if
and only if M |=/ ϕσ or M |= ψ σ . Therefore, M |= ψ σ . Since we did not put
any constraint on M, it holds that |= ψ σ .
Theorem 2 (Completeness of Hilbert-style proof system) Any valid formula
is derivable: if |= ϕ, then ϕ.
Proof We show that any consistent formula is satisfiable. A formula ϕ is said
to be consistent, if it is not the case that ¬ϕ is derivable. More generally,
a
the case that ¬ ϕ∈Φ ϕ is
finite set of formulae Φ is consistent, if it is not
derivable. In other word, Φ is inconsistent, if ¬ ϕ∈Φ ϕ.
For the completeness proof, we first show that for any finite consistent set Φ
of formulae and any formula ψ it holds that Φ∪{ψ} or Φ∪{¬ψ} is consistent.
This fact is called the extension
lemma. Assume for contradiction, that both
¬( ϕ∈Φ∪{ψ} ϕ) and ¬( ϕ∈Φ∪{¬ψ} ϕ). According to the definition of
62 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
and ∧, this is the same as ¬¬( ϕ∈Φ
ϕ ⇒ ¬ψ) and ¬¬( ϕ∈Φ ϕ ⇒ ¬¬ψ).
With (tnd) and (mp), we get ( ϕ∈Φ ϕ ⇒ ¬ψ) and ( ϕ∈Φ ϕ ⇒ ¬¬ψ).
Using also (dist) and (weak), we can show that ( ϕ∈Φ ϕ ⇒ ψ). The proof
also allows to show ((ϕ ⇒ ψ) ⇒ ((ϕ ⇒ ¬ψ) ⇒ ¬ϕ)). Therefore,
system
¬ ϕ∈Φ , which is a contradiction to the consistency of Φ.
To continue with the completeness proof, let SF (ϕ) denote the set of all
subformulae of a given formula ϕ. That is, SF (ϕ) contains all constituents
according to the inductive definition of ϕ, including ϕ itself. For example,
if ϕ = ((p ⇒ q) ⇒ p), then SF (ϕ) = {ϕ, (p ⇒ q), p, q}. For any consistent
formula ϕ, let ϕ# be a maximal consistent extension of ϕ (i.e., ϕ ∈ ϕ# , and
for every ψ ∈ SF (ϕ), either ψ ∈ ϕ# or ¬ψ ∈ ϕ# ). The existence of such a
maximal consistent extension is guaranteed by the above extension lemma.
However, for any given consistent formula, there might be many different
maximal consistent extensions. Any maximal consistent extension defines a
unique model: for a given ϕ# , the canonical model Mϕ# is defined by
The truth lemma states that for any subformula ψ ∈ SF (ϕ) it holds that
Mϕ# |= ψ if and only if ψ ∈ ϕ# . The proof of this lemma is by induction on
the structure of ψ:
• Case ψ is a proposition: by construction of I.
• Case ψ = ⊥: in this case, Φ ∪ {ψ} cannot be consistent ( ¬( ϕ∈Φ ϕ ∧ ⊥)).
• Case ψ = (ψ1 ⇒ ψ2 ): by induction hypothesis, Mϕ# |= ψi if and only if
ψi ∈ ϕ# , for i ∈ {1, 2}. Since ϕ# is maximal, either ψ ∈ ϕ# or ¬ψ ∈ ϕ# ,
and the same holds for ψ1 and ψ2 . There are four cases:
(i) ¬ψ1 ∈ ϕ# and ¬ψ2 ∈ ϕ# , (ii) ¬ψ1 ∈ ϕ# and ψ2 ∈ ϕ# , (iii) ψ1 ∈ ϕ#
and ¬ψ2 ∈ ϕ# , and (iv) ψ1 ∈ ϕ# and ψ2 ∈ ϕ# . In case (i) and (ii),
we have Mϕ# |= / ψ1 , therefore Mϕ# |= ψ; and since ¬ψ1 ∈ ϕ# and
(¬ψ1 ⇒ (ψ1 ⇒ ψ2 )), we must have ψ ∈ ϕ# (or otherwise ϕ# would be
inconsistent). Likewise, in case (ii) and (iv), we have Mϕ# |= ψ2 , therefore
Mϕ# |= ψ; and since ψ2 ∈ ϕ# and (ψ2 ⇒ (ψ1 ⇒ ψ2 )), we must have
ψ ∈ ϕ# . In case (iii), if Mϕ# |= ψ1 and Mϕ# |= / ψ2 , then Mϕ# |=
/ ψ; and
from (ψ1 ⇒ (¬ψ2 ⇒ ¬(ψ1 ⇒ ψ2 ))) we conclude that ¬ψ ∈ ϕ# .
Let ϕ be any consistent formula. By definition, ϕ ∈ ϕ# for any maximal
consistent extension ϕ# of ϕ. Therefore, Mϕ# |= ϕ. Hence we have shown
that any consistent formula is satisfiable. In other words, any unsatisfiable
formula is inconsistent. Let ϕ be any valid formula (|= ϕ). Then ¬ϕ is unsat-
isfiable, and therefore inconsistent. This means that ¬¬ϕ. From this, with
(tnd) and (mp) we get ϕ.
Similar completeness proofs can be given for natural deduction and reso-
lution calculi.
2 Logics for Software Engineering 63
ϕ if and only if ϕ.
Γ ϕ if and only if Γ ϕ.
It is not hard to see that the above proofs can be adapted to this case.
The above discussion of propositional logic showed the typical elements that
constitute a logic. The syntax definition started with a set of proposition
symbols P. Often, this collection of symbols is called a signature. Relatively
to the signature P, the set of propositional formulae PLP was introduced.
Symbols need interpretation. This is where models come into play. Models
are the semantical side of a logic: each symbol gets an interpretation. In
propositional logic, models are functions P → {true, false} assigning a truth
value to every proposition symbol. Syntax and semantic level of a logic is
finally connected via a validation relation |=. Some people also speak of a
satisfaction relation. M |= ϕ holds if the formula ϕ is valid in the model M.
The notion of an institution by Goguen and Burstall [GB92] captures the
general idea of what a constitutes a logic. An institution consists of
• a signature Σ which collects the symbols available,
• a set of formulae For (Σ) defined relatively to the signature,
• a class of models Mod (Σ) which interpret the symbols, and
• a satisfaction relation |= ⊆ Mod (Σ) × For (Σ),
where furthermore the so-called satisfaction condition needs to be fulfilled—
which we will discuss in Sect. 2.3.1 below.
Given a logic with these four elements, one can state several algorithmic
questions on the relations between models and formulae:
Model checking problem. Given a model M and a formula ϕ, is it the
case that M |= ϕ?
Satisfiability problem. Given a formula ϕ, is there any model M such
that M |= ϕ holds?
Validity problem. Given a formula ϕ, does M |= ϕ hold for any model
M? This problem is dual to the satisfiability problem.
Uniqueness problem. Given a formula ϕ, is there one unique model M
satisfying this formula, i.e., are any two models for ϕ isomorphic (identical
up to renaming)? A specification formula with this property sometimes is
called monomorphic or categorical.
64 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
Model checking and satisfiability for propositional logic have been consid-
ered above. Subsequently, we study possible relation between different mod-
els.
2.3.1 Specification
A typical way of using logic for specification is to say: all models that satisfy a
given set of formulae are considered to be ‘interesting’. Consider for instance
Example 18 on Car Configuration. When a customer has still some choices
left, one might be interested in the question: what car configurations can the
customer still choose? The customer might be interested in a minimal choice,
as it probably is the cheapest. The car seller, however, might be interested
in a maximal choice. This leads to several questions on logics:
1. How do models relate to each other? Is the relation between the models
compatible with the one defined by the logic?
2. Are we interested in all models, or just a selected ‘minimal’ or ‘maximal’
model?
These questions can be studied for logics in general. In this section we will
show how to answer these questions for Propositional Logic.
To address the first question, we relate models by the notion of a model
morphism:
Definition 4 (Model morphism for Propositional Logic) Let M1 and M2 be
models over the same signature P. There is a model morphism from M1 to
M2 if for all p ∈ P holds: M1 (p) = true implies M2 (p) = true.
The set of variables which are set to true is growing along a model morphism.
In other words: truth is preserved along a morphism. We write M1 ≤ M2 if
there is a model morphism from M1 to M2 .
1. M ≤ M.
2. If M1 ≤ M2 and M2 ≤ M3 , then M1 ≤ M3 .
3. If M1 ≤ M2 and M2 ≤ M1 , then M1 = M2 .
Proof 1. holds trivially. For 2. let M1 (p) = true for some p ∈ P. Then,
by M1 ≤ M2 , we know that M2 (p) = true. Moreover, by M2 ≤ M3 , we
know that M3 (p) = true. Thus, M1 ≤ M3 . For 3. we argue as follows. If
M1 ≤ M2 , then it holds that for all p with M1 (p) = true, also M2 (p) = true.
Similarly, if M2 ≤ M1 then for all p with M2 (p) = true, also M1 (p) = true.
Thus, M1 (p) = true if and only if M2 (p) = true. As a propositional model
is a total function from proposition symbols to truth values, this has as a
consequence that M1 = M2 .
The result in Theorem 3 (3.) is unusual for a logic. In general, models
mutually related by model morphisms need not be identical.
With the notion of a morphism available, there are now two ways to com-
pare models. The first one uses the logical formulae. Two models are defined
to be ‘equivalent’ if they validate the same set of formulae. The second way
is to use the notion of a morphism: two models are considered ‘equivalent’
if they cannot be distinguished by morphisms, i.e., in our context, if they
are identical. The following proposition shows that for PL these two notions
coincide:
Theorem 4 (Isomorphism property for PL) Let M1 and M2 be models over
the same signature P. Then the following holds:
{ϕ | M1 |= ϕ} = {ϕ | M2 |= ϕ} if and only if M1 = M2
The specification has the name Car Config. After the keyword preds we
declare the propositional signature. The requirements for the car are listed
after the bullet points. Within “%( ” and “ )%” we provide a name for the
axiom.
Of the eight potential models for P , the following two satisfy both formu-
lae:
navi audio cd audio dvd
M1 false true false
M2 true true false
With regards to morphisms, we have M1 ≤ M2 . We now discuss the question
what the ‘intended meaning’ of the specification Car Config is.
In Casl, the meaning of a specification is the collection of all models which
satisfy all specification formulae:
As the meaning of a specification may contain more than one model, this
kind of semantics for the specification language is called loose. There are two
other possible choices.
• The specification language can be defined such that it uses initial seman-
tics; that is, the meaning of a specification is the smallest model with
respect to the relation ≤. In Propositional Logic, this is the model with a
minimal number of propositional symbols set to true, which validates all
formulae in the specification. According to Theorem 3, there is at most
one such model. For the car configuration example, this is the car with a
minimal number of features:
Mod initial (Car Config)
= {M ∈ Mod Casl (Car Config) |
for all models M ∈ Mod Casl (Car Config) holds: M ≤ M }
= {M1 }.
Tucker & Bergstra have studied systematically which kind of data can be
described with initial, loose, and final semantics [BT87]. Algebraic specifica-
tion languages usually employ initial or loose semantics. Final semantics is
studied in the field of Coalgebra. Co-Casl [MSRR06] provides a specification
language which offers initial, loose, and final semantics. It is an open field for
research to study the interplay between these three approaches.
Modular Specification
spec Colors =
preds color red, color blue, color green : ()
• (color red ∧ ¬ color blue ∧ ¬ color green)
∨ (color blue ∧ ¬ color red ∧ ¬ color green)
∨ (color green ∧ ¬ color blue ∧ ¬ color red ) %(only one color)%
end
spec Equipment =
preds navi, audio cd, audio dvd : ()
• (audio cd ∧ ¬ audio dvd ) ∨ (audio dvd ∧ ¬ audio cd )
%(cd or dvd)%
end
spec Configuration =
Colors and Engines And Gearshifts and Equipment
then • motor diesel ⇒ ¬ audio dvd %(dvd not available with diesel engine)%
end
68 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
M(p) = M (σ(p)).
morphism. Then the following holds for all formulae ϕ ∈ PLP and for all
model M over P :
|= |=
σ
ϕ σ(ϕ)
2.4.1 FOL
First-order logic, or FOL for short, has been ‘the’ language for the formal-
ization of mathematics. Let us start with an example.
If M = (U, I, v), we often write M(f ), M(R) and M(x) instead of I(f ),
I(R), or v(x), respectively, to denote the ‘meaning’ of a function, relation or
variable in the model.
Definition 13 (Semantics of first-order terms) In order to define a semantics
of first-order formulae, we first have to declare what the ‘meaning’ of a term
is. Generally, each term denotes a value; that is, it is evaluated to an element
of the universe. The term valuation induced by a model M = (U, I, v) is
defined by
74 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
It can be shown that the above Hilbert-style calculus is correct and complete,
i.e., all derivable formulae are valid, and all valid formulae can be derived. The
completeness proof proceeds as in the propositional case by constructing the
canonical model from a maximal consistent extension of a satisfiable formula.
For space reasons, it is omitted; the reader is referred to textbooks on logic.
As in the case of propositional logic, Hilbert-style axiom systems can
be hard to use. Finding a proof by natural deduction can be much easier.
Together with the propositional rules from above, the following sequent rules
yield a correct and complete natural deduction system for first-order logic.
Γ ϕ[x := t] Γ ∪ {ϕ} ψ Γ ∀xϕ Γ ϕ
——————– ——————– —————— ————–
Γ ∃xϕ Γ ∪ {∃xϕ} ψ Γ ϕ[x := t] Γ ∀xϕ
(ex) (part) (in) (gen)
It can be shown that no finite set of FOL formulae can characterize equal-
ity on the universe in general. Therefore, in the logic FOL= Σ (FOL with
identity) we add equalities as new atomic formulae.
F OL= = = =
Σ :: = R(TΣ , . . . , TΣ ) | (TΣ = TΣ ) | ⊥ | (F OLΣ ⇒ F OLΣ ) | ∃xF OLΣ
Note the similarity of this formula to the above induction principle: P (c) ∧
∀x(P (x) ⇒ P (f (x)) means that M(P ) contains M(c) and with every object
also all objects which can be obtained from M(c) by applying function M(f ).
That is, M(P ) contains the interpretations of all ground terms in the sig-
nature. The formula (∗) states that any such P must contain all elements of
the universe. Stated negatively, M is not term-generated if and only if there
exists a set containing the interpretations of all ground terms, but not the
whole universe.
Definition 18 (Freely term-generated model) A model is called freely term-
generated, if for any element k in the universe there exists a unique ground
term t such that I(t) = k.
A model is freely term-generated, if it is term-generated and additionally
it holds that functions do not overlap and function applications to different
arguments yield different results. This can be expressed in FOL= , here again
for the above signature:
Whereas the above first- and second-order logics were designed to be as small
as possible to ease theoretical investigations, they are inconvenient for system
specification and verification. Therefore, various dialects and extensions of
these logics have been suggested, among them
• the program development languages “Vienna Development Method” VDM,
Z, B and Event-B,
• the OBJ family of languages, including CafeOBJ and Maude,
• the Meta-Environment ASF+SDF, which combines the “Algebraic Speci-
fication Formalism” ASF and the “Syntax Definition Formalism” SDF,
• the logics for program verification “ANSI/ISO C Specification Language”
ACSL and “Java Modelling Language” JML,
to name just a few. Here, we discuss the extension to first- and second-order
logics that were introduced with the algebraic specification language Casl
(to be discussed in Chap. 4). The material presented can be safely skipped
by the casual reader.
The “Common Algebraic Specification Language” Casl [Mos04, BM04] is
a specification formalism developed by the CoFI initiative [Mos97] through-
out the late 1990s and early 2000s. The aim of the CoFI initiative was to
design a Common Framework for Algebraic Specification and Development
in an attempt to create a de facto platform for algebraic specification. The
main motivation for the CoFI initiative came from the existence of a num-
ber of competing algebraic specification languages with varying levels of tool
support and industrial uptake.
The logic of Casl basically consists of many-sorted first-order logic with
equality, which allows for partial functions and also includes sort generation
constraints. In the following we introduce these concepts step by step, and
discuss finally syntax and semantics of Casl specifications.
Note that Casl also includes the concept of subsorting. Here, we refrain
of introducing this concept and refer to the literature [Mos04].
One issue with FOL is that the universe of discourse is not structured.
Whereas this is mostly unproblematic for mathematical theories (which deal,
e.g., solely with natural or real numbers), computer science specifications
often refer to different sorts of data.
82 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
Note that the above is not a FOL formula, as, e.g., it makes use of
indexed variables in combination with the “...” notation—to be filled
with meaning by the human reader.
In this mathematical formulation, i and j range over natural num-
bers, x and y denote strings, and xi and yj are characters. The sym-
bols “<” and “≤” denote the ordering between integers, characters and
strings, respectively, i.e., these symbols are ‘overloaded’. However, each
variable is used to refer to objects of one type only.
In order to deal with these issues, one can introduce types into FOL.
Each variable ranges over a certain type. Functions and predicates have
argument types and result types. Using the sorts String and Nat, we
can formulate lexicographic ordering in many-sorted FOL= :
In the logic many-sorted FOL= , sort symbols are added to the signature
and relations, functions and variables are typed.
Definition 19 (Many-sorted signature) A first-order signature with sorts or
many-sorted signature Σ = (S, F , R, V) consist of a nonempty finite set S
2 Logics for Software Engineering 83
of sort symbols (or type symbols2 ) and a first-order signature (F, R, V). In
contrast to plain FOL, where each function just has an arity, with each f ∈ F
is associated a list of argument types, and a result type. A function symbol
named f with argument types (T1 , . . . , Tn ) and result type T is written as
f : T1 × . . . × Tn → T . Again, if the list of argument types is empty, then
f is called a constant symbol of type T . Similarly as with functions, in a
many-sorted signature each R ∈ R consists of a relation name and a list
of argument types, but no result type. A relation symbol sometimes is also
called a predicate symbol.3 Finally, each variable from V consists of a name
and a type. We write x : T for the variable with name x and type T .
The definitions of terms, atomic formulae and formulae of many-sorted
first-order logic are similar to the ones for normal first-order logic, with the
exception that each term must respect typing.
Definition 20 (Syntax of many-sorted FOL= ) Terms and formulae of many-
sorted first-order logic are defined as follows.
• If x is the name of a variable of type T , then x is a term of type T .
• If t1 , . . . , tn are terms of types T1 , . . . , Tn , respectively, and f is the name
of an n-ary function symbol with argument types (T1 , . . . , Tn ) and result
type T , then f (t1 , . . . , tn ) is a term of type T .
• If t1 and t2 are terms of the same type, then t1 = t2 is an atomic formula.
• If t1 , . . . , tn are terms of type T1 , . . . , Tn , respectively, and R is the name
of an n-ary relation with argument types (T1 , . . . , Tn ), then R(t1 , . . . , tn )
is an atomic formula.
• An atomic formula is a formula.
• ⊥ is a formula, and (ϕ ⇒ ψ) is a formula, if ϕ and ψ are formulae.
• If x is the name of a variable of type T , and ϕ is a formula, then ∃x : T . ϕ
is a formula.
2 In this book, the words “sort” and “type” are mutually exchangeable. Historically,
logicians prefer the word “type”, whereas computer scientists prefer to use the word
“sort”.
3 In Casl, the word “predicate” is used instead of the word “relation”. Thus, in algebraic
≤ : Nat × Nat;
< : String × String;
< : Char × Char
∀ x, y : String
•x <y
⇔ (∃ i : Nat
• i ≤ min(length(x ), length(y)) ∧ elem(x, i ) < elem(y, i )
∧ ∀ j : Nat • j < i ⇒ elem(x, j ) = elem(y, j ))
∨ (length(x ) < length(y)
∧ ∀ j : Nat • j ≤ length(x ) ⇒ elem(x, j ) = elem(y, j ))
end
Partial Functions
In mathematics and computer science, there are functions which are defined
only for certain arguments. A prominent example is the division function div
on naturals, which is undefined if the divisor is 0. Strictly speaking, division
is not a function on pairs of naturals, as in a function each input is related
to exactly one output. Another example would be the function which returns
the first element of a string, which is undefined for the empty string. In order
to deal with such a situation, there are several possibilities:
• One can restrict the domain to those arguments, where the function
returns a value; in our example, div : Nat × Nat \ {0} → Nat.
• One can extend the range by a value ω for ‘undefined’; in our example,
div : Nat × Nat → Nat ∪ {ω}
• One can introduce the new syntactic category of partial functions, where
in a partial function each input is related to at most one output; in our
example, div : Nat × Nat →? Nat
What the ‘best’ solution would be, depends on personal taste, the applica-
tion domain, and also the availability of tools. Casl offers total and partial
functions.
Definition 22 (Signature with partiality) A signature with partiality Σ =
(S, F t , F p , R, V) is a signature where (S, F t , R, V) forms a many-sorted sig-
nature as above, and F p is a set of partial function symbols. We require that
function symbols are either total or partial, i.e., there is no f with argument
types (T1 , . . . , Tn ) and result type T which is both in F t and F p . A par-
tial function f ∈ F p with argument types (T1 , . . . , Tn ) and result type T is
written as f : T1 × . . . × Tn →? T .
• M |= (t1 = t2 ) if and only if v(t1 ) and v(t2 ) are both undefined, or both
defined and v(t1 ) = v(t2 ).
• M |= def t if and only if v(t) is defined.
• M |=/ ⊥, and
• M |= (ϕ ⇒ ψ) if and only if M |= ϕ implies M |= ψ.
• M |= ∃x : T.ϕ if and only if M |= ϕ for some M = (U, I, v , T ) such
that for all y = x it holds that v (y) and v(y) are both undefined, or both
defined and v (y) = v(y).
We illustrate this definition by continuing our example of the first function
on strings, namely the interplay of partiality with predicates and equality.
spec PropertyOfLooseStrings =
LooseStrings
then pred < : Char × Char %(any relation on Char)%
then %implies
∀ s, t : String
• first(s) < first(t) ⇒ ¬ isEmpty(s) %(*)%
end
In Casl, a set of axioms is separated from its semantic consequences
through the annotation implies. (For a further explanation of this con-
struct, see Chap. 4 on Casl.) The formula (*) is a logical consequence
of the specification LooseStrings extended by the operation < .
The predicate first(s) < first(t) is only true if both terms first(s) and
first(t) are defined. Therefore, first(s) < first(t) implies that s (and also
t) is not empty. If we would replace formula (∗) by the following
spec String2 =
sort Char
type String ::= eps | :: (Char ; String)
end
The type construct declares the sort String, and operations eps and
:: , which have the sort String as their result type.
The type construct can be qualified by the keyword generated:
spec String3 =
sort Char
generated type String ::= eps | :: (Char ; String)
end
This means that we are considering only models in which the sort
String3 is term-generated by eps, :: , and variables of sort Char.
Note that it is possible to declare further operations with result type
String3. However, these further operations don’t contribute to the
terms needed for generatedness.
2 Logics for Software Engineering 89
spec String4 =
sort Char
free type String ::= eps | :: (Char ; String)
end
This means that we are considering only models in which the sort
String4 is freely term-generated by eps, :: , and variables of sort
Char.
As these examples demonstrate, Casl offers handy syntax for the second-
order formulae discussed above in Sect. 2.4.
Classical logics (i.e., PL, FOL, MSO, and extensions thereof) have been
very successful as a basis for the formalization of mathematical reasoning.
Hence these logics are often referred to as “mathematical logic”. However,
for the formalization of other areas of interest, many competing approaches
have been proposed. The reason is that classical logics have a number of
shortcomings. Basically, they support a “static” view onto things only, lacking
(among other things)
• alternative aspects: Classical logic can describe how things are, but not
how they could be;
• subjective viewpoints: Personal and common knowledge, beliefs, obliga-
tions, and ambitions are not easily described in classical logics;
• dynamic aspects: To model a change of state in classical logics, time is
treated like any other relation parameter. This does not reflect the ubiquity
of time in, e.g., computer science applications;
• spacial aspects: Likewise, for reasoning about robot positions or distributed
computing, the location of objects plays a dominant role;
• resource awareness aspects: Dealing with objects which cease to exist or
come into existence is not easy in classical logics, since the universe of
discourse is fixed. However, it is essential when arguing about limited
resources.
For each of these aspects, special logics have been proposed which allow
a convenient modelling and arguing about systems in which the respective
aspect is important.
92 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
Modal logic is the logic of possibility and necessity. It started out as a syn-
tactical exercise when philosophers were asking questions such as
If it is necessarily the case that something is possibly true, does it follow that it is
possible that this thing is necessarily true?
E.g., if it necessarily is possible that tomorrow will be cloudy, is it possible that it
tomorrow will be necessarily cloudy?
In the beginning of the 20th century this was formalized with the operators
(for “possibly”) and (for “necessarily”).
Definition 25 (Syntax of modal logic) Given a propositional signature P,
the syntax of modal logic can be defined as follows.
M LP :: = P | ⊥ | (M LP ⇒ M LP ) | M LP
Of course, we use all abbreviations from propositional logic (∧, , ⇔, etc.).
The operator can be defined by ϕ ⇐⇒ ¬¬ϕ. That is, a sentence is
necessarily true if it is not the case that it could be possibly false.
With this syntax, the above question could be written as
In the beginning of modal logic, researchers were busy to find out which
formulae could be syntactically derived from other axioms in this way. A
major step was the definition of a semantic foundation for modal logics by
Saul Kripke [Kri59]. He proposed that a model for modal logic consists of
a universe of possible worlds, a binary accessibility relation between these
worlds, and an interpretation which assigns a set of possible worlds to each
proposition symbol. With this semantics, ϕ is true in some possible world w,
if ϕ is true in all possible worlds w which are accessible from w. Thus, modal
models basically are graphs, consisting of nodes (possible worlds) and edges
(the accessibility relation between possible worlds). Modal logic therefore is
well-suited to reason about all sorts of graph structures. Before giving the
formal definitions, we discuss a widely known graph structure.
94 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
The operator [R] is the dual of the operator R, much the same as ∀ is
the dual of ∃. Formally, [R]ϕ is defined to be an abbreviation for ¬R¬ϕ.
The intended reading of Rϕ is “there is a node accessible via R in which ϕ
holds”, and [R]ϕ reads “for all nodes accessible via R it holds that ϕ is true”.
This is made precise by the semantics of MML. A (modal) frame for the
modal signature Σ is a tuple (U, I R ), where
• U is a nonempty set of possible worlds or evaluation points, and
• I R is a mapping R → 2U ×U assigning a binary accessibility relation over
U to every relation symbol.
A model M for MML is a structure M = (U, I R , I P ), where
2 Logics for Software Engineering 95
formula does not hold at w4 , since there is no link from this node. Like-
wise, the formula [int]intisHome expresses that every page reachable
by an internal link has an internal link to the homepage. This formula
is not satisfied at w0 and w1 , since (w0 , w3 ) and (w1 , w3 ) ∈ I R (int), but
w3 does neither link back to w0 nor to w1 . If we consider an alternative
model, where
• I R (int) = {(w0 , w2 ), (w0 , w3 ), (w1 , w2 ), (w1 , w3 ), (w2 , w0 ), (w3 , w1 )}
and
• I R (ext) = {(w2 , w4 ), (w3 , w5 ), (w5 , w5 ), (w4 , w5 )},
then all specification formulae and both properties are satisfied.
There are many formal systems for deontic logic. In what follows we will
introduce Standard Deontic Logic (SDL). The starting point when defining
SDL was to take different modal logics and to make analogies between “neces-
sity” and “possibility”, with “obligation” and “permission”. Thus, the modal
operators and became “P” and “O”. However, this turned out to be
difficult as many of the rules in modal logic did not transfer to deontic logic
(as seen in the example below), though it was useful to make a start in
understanding these normative concepts.
In modal logic with axiom (T) the following holds:
• If p then p (if p is true, then it is possible).
• If p then p (if it is necessary that p, then p is true).
While this makes perfect sense for the interpretation of and as possibility
and necessity, it might not do so when considering possibility as permission
and necessity as obligation:
• If p then P p (if p is true, then it is permissible).
• If O p then p (if it is obligatory that p, then p is true).
This is clearly counter-intuitive as any obligation then must be satisfied, and
given any fact or action, it would be permissible.
We introduce now the syntax of the logic.
98 B.-H. Schlingloff, M. Roggenbach, G. Schneider, A. Cerone
That is,
• if ϕ is a propositional formula, then P ϕ is an SDL formula, and
• every propositional combination of SDL formulae is an SDL formula.
In contrast to multimodal logic, in SDL the modalities cannot be nested, since
it appears pointless to state that “it is obligatory that it is obligatory that
something must be done.” Besides the usual derived operators inherited from
propositional logic (conjunction, disjunction, etc), the following additional
two modalities are useful:
O p ¬P ¬p (obligation)
F p ¬P p (= O ¬p) (prohibition)
From the above we also get the intuitive relation that being permitted is the
same as not being forbidden and vice-versa.
SDL has a Kripke-like modal semantics based on: (i) a set of possible worlds
(with a truth assignment function of propositions per possible world), and
(ii) an accessibility relation associated with the O-modality. The accessibility
relation points to ideal or perfect deontic alternatives of the current world,
and to handle violations of obligations and prohibitions the semantics needs
to be extended. Here, we will not present such a semantics; instead, we will
instead see in more detail a proof system for SDL.
Definition 30 The axiomatic system of SDL consists of the following axioms
and rules.
(PL) all propositionally valid formulae
(KO ) (O(ϕ ⇒ ψ) ⇒ (O ϕ ⇒ O ψ)))
(DO ) ¬O ⊥
(NO ) ϕOϕ
(MP) ϕ, (ϕ ⇒ ψ) ψ
In fact, this axiomatic system is the same as for the classic modal logic
K (see Definition 26), with the additional axiom (DO ). This axiom states
that it cannot be obligatory to do something impossible. E.g., it cannot be
obligatory to go and not go to the party.
(O tell ∧ O ¬tell )
This statement claims that John ought to tell, and at the same time
ought not to tell that he goes to the party. It is known as Chisholm’s
paradox [Chi63]. We refrain from giving a formal Hilbert-style derivation
and rather describe the reasoning in plain English.
• From 2 and KO , by M P , we get that (O party ⇒ O tell )
• From 1 and the above, by M P , we get O tell
• From 3 and 4, by M P , we get O ¬tell
• So, we can infer (O tell ∧ O ¬tell )
So, we can conclude that John is obliged to tell that he is coming to
the party, and at the same time that he must not tell about it.
This example shows that deontic logic as it was defined originally may
not be adequate in every context. However, it set the basis for subsequent
development of variants of the logic for specifying situations and properties
where paradoxes are avoided.
Let us finish our presentation on deontic logic with a discussion on some
philosophical issues concerning the logic. It has been observed that norms
as prescriptions for conduct are not true nor false. Now, if norms have no
truth-value, how can we reason about them and detect contradictions and
define logical consequence? This was a question that bothered many logicians
since the very beginning, as for many a logic should be concerned with a
formalisation of truth. Von Wright (summarising his own point of view and
interpreting early works in the area [Wri99]) has argued that logic has a
wider reach than truth, and thus norms and valuations are still subject to a
2 Logics for Software Engineering 101
In temporal logic the modal operators and are interpreted with respect
to the flow of time. That is, ϕ means “it will eventually be the case that ϕ
holds”, and ϕ stands for “it is always the case that ϕ holds”.5
Before giving the formal definitions, we start with a classical example.
As axiomatic calculus for LT L, we can use the following axioms and rules:
(PL) all propositionally valid formulae
(K) ((ϕ ⇒ ψ) ⇒ (ϕ ⇒ ψ))
(U) (¬ p ⇐⇒ ¬p)
(Rec) ((ψ ∨ ϕ ∧ (ϕ U ψ)) ⇒ (ϕ U ψ))
(N) ϕ ϕ
(MP) ϕ, (ϕ ⇒ ψ) ψ
(Ind) ((ψ ∨ ϕ ∧ (ϕ U ψ)) ⇒ χ) ((ϕ U ψ) ⇒ χ)
This axiomatic system is sound and complete, cf. [KM08].
Moreover, it is minimal in the sense that every axiom can be shown to
be independent from the others. However, it is not very convenient to use
in practical derivations. Without proof, we state that the following formulae
are derivable.
(F1) ((ϕ ⇒ ψ) ⇐⇒ (ϕ ⇒ ψ))
(F2) ((ϕ ⇒ ψ) ⇒ (ϕ ⇒ ψ))
(F3) ((ϕ ⇒ ψ) ⇒ (ϕ ⇒ ψ))
(F4) ((ϕ ∧ ψ) ⇒ (ϕ ∧ ψ))
(F5) ((ϕ ∧ ψ) ⇐⇒ (ϕ ∧ ψ))
(n) ((ϕ ⇒ ϕ) ⇒ (ϕ ⇒ ϕ)
(F6) (ϕ ⇐⇒ (ϕ ∨ ϕ))
(F7) (ϕ ⇐⇒ (ϕ ∧ ϕ))
(F8) (ϕ U ψ) ⇐⇒ (ψ ∨ (ϕ ∧ (ϕ U ψ))))
(F9) (ϕ R ψ) ⇐⇒ (ψ ∧ (ϕ ∨ (ϕ R ψ)))
The last four of these formulae are recursive characterizations of the tem-
poral operators. Since the formulae are valid, they can be used as additional
axioms to derive many interesting properties.
left or the one on the right. Notice that the events in processes Fork(i)
are the same as those in processes Phil(i).
Process College() models the whole system. || is the parallel
composition operator which indicates that all Phil(x)- and Fork(x)-
processes execute in parallel, synchronising on the common events.
The first assertion states that process College() is deadlock-free,
where deadlockfree is a reserved keyword. The second assertion is
an LTL formula which states that within process College(), always
eventually event eat.0 occurs. This is equivalent to stating that the
respective philosopher will not starve to death.
With this input, PAT will quickly find and output a situation where
the system deadlocks (and, thus, everybody starves). If we change the
order in which forks are picked up, i.e.,
Notice that in PAT, events like eat.0 are used in formulae instead of
propositions like phil0 eating. We refrain from a formal semantics here and
rely on the reader’s intuition instead.
Between 1910 and 1930s metalogic was developed, that is the study of the
metatheory of logic. Pioneers include David Hilbert (1862–1943), Leopold
Löwenheim (1878–1957) and Thoralf Albert Skolem (1887–1963), and most
notably Kurt Gödel (1906–1978) and Alfred Tarski (1901–1983) who worked
on the combination of logic and metalogic. One of the greatest achievements
in the history of logic is Gödel’s incompleteness theorem (1931).
Claude Shannon (1916–2001) made the connection between Boolean alge-
bra (logic) and electrical circuits of relays and switches, advancing the devel-
opment of the new discipline concerning hardware circuit design. This was
presented in his master thesis A Symbolic Analysis of Relay and Switching
Circuits (1937).
Two classical books on propositional and first-order logic are the Intro-
duction to Mathematical Logic by Church [Chu96] and First-order Logic by
Smullyan [Smu68]. For a comprehensive presentation of dynamic logic see the
book by Harel et al. [HTK00]. Concerning deontic logic see articles by von
Wright [Wri51, Wri99].
The use of temporal logic in computer science was introduced by Kröger
[Krö76] and Pnueli [Pnu77], who took inspiration from the work done in
philosophy by Prior and others. For a more extensive presentation of tem-
poral logic, including a proposal of a deductive system for the logic, see
the book series by Manna and Pnueli [MP92], and the book by Kröger and
Merz [KM08].
One of the first books on model checking was written by Clarke et
al. [CGP01], and a few more books have appeared after that presenting dif-
ferent techniques for software verification (e.g., by Baier and Katoen [BK08]
and by Peled et al. [PGS01]).
A good source for surveys, introductory presentations, and more advanced
material concerning many different logics, are the volumes and correspond-
ing chapters of various handbooks: Handbook of Logics in Computer Sci-
ence [AGM95], Handbook of Philosophical Logic [GG04], Handbook of Modal
Logic [BvBW07], and Handbook of Model Checking [CHVB18]. Finally, for a
historical presentation of logic, see the different volumes (1-11) of the Hand-
book of the History of Logic [GW09].
science (FOCS, MFCS, STACS, STOC, ETAPS). The European and North
American Summer Schools in Logic, Language and Information (ESSLLI and
NASSLLI) provide good opportunities for beginning Ph.D. students to get
an insight into special topics.
According to our personal view, the following major trends in this area
can be identified:
• Firstly, there is the never ending quest for new methods and tools in the
analysis of computational systems: algorithms for model checking, rewrit-
ing, satisfiability solving, game-based methods, etc.
• Secondly, researchers strive for more general, abstract results, e.g., by
means of category theory, to get a better understanding of general princi-
ples.
• Furthermore, there is a lot of research extending the scope of logical anal-
ysis to new types of computation: multi-agent systems, machine learning
and artificial intelligence, symmetric computation and quantum comput-
ing, etc.
• Finally, researchers are designing methods and tools for practical use to
solve problems which are of industrial interest, e.g., for security analysis.
Undoubtedly, logic is a necessary foundation for almost all research in
Formal Methods, and even computer science in general. Thus, studying logic
is certainly beneficial, even if the reader wants to make a contribution in a
different area.
References
[BvBW07] Patrick Blackburn, J. F. A. K. van Benthem, and Frank Wolter, editors. Hand-
book of Modal Logic, volume 3 of Studies in logic and practical reasoning.
North-Holland, 2007.
[CGP01] Edmund M. Clarke, Orna Grumberg, and Doron A. Peled. Model checking.
MIT Press, 2001.
[Chi63] Roderick M. Chisholm. Contrary-to-duty imperatives and deontic logic. Anal-
ysis, 24:33–36, 1963.
[Chu96] A. Church. Introduction to Mathematical Logic. Annals of Mathematics Stud-
ies. Princeton University Press, reprint, revised edition, 1996.
[CHVB18] Edmund M. Clarke, Thomas A. Henzinger, Helmut Veith, and Roderick Bloem,
editors. Handbook of Model Checking. Springer, 2018.
[Dij71] Edsger W. Dijkstra. Hierarchical ordering of sequential processes. Acta Infor-
matica, 1:115–138, 1971.
[Fia05] José Luiz Fiadeiro. Categories for software engineering. Springer, 2005.
[For16] Peter Forrest. The Identity of Indiscernibles. In Edward N. Zalta, editor, The
Stanford Encyclopedia of Philosophy. Metaphysics Research Lab, Stanford Uni-
versity, winter 2016 edition, 2016.
[GB92] J.A. Goguen and R.M. Burstall. Institutions: Abstract model theory for spec-
ification and programming. Journal of the ACM, 39:95–146, 1992.
[GG04] Dov M. Gabbay and Franz Guenthner, editors. Handbook of Philosophical
Logic, volume 11. Springer, 2004.
[GW09] Dov M. Gabbay and John Woods, editors. Handbook of the History of Logic,
volume 5. Elsevier, 2009.
[HTK00] David Harel, Jerzy Tiuryn, and Dexter Kozen. Dynamic Logic. MIT Press,
Cambridge, MA, USA, 2000.
[Kam68] Johan Anthony Willem Kamp. Tense logic and the theory of linear order, 1968.
PhD Thesis.
[KM08] Fred Kröger and Stephan Merz. Temporal Logic and State Systems. Texts in
Theoretical Computer Science. An EATCS Series. Springer, 2008.
[Kri59] Saul Kripke. A completeness theorem in modal logic. J. Symb. Log., 24(1):1–14,
1959.
[Krö76] Fred Kröger. Logical rules of natural reasoning about programs. In Third Inter-
national Colloquium on Automata, Languages and Programming, pages 87–98.
Edinburgh University Press, 1976.
[Mos97] Peter D. Mosses. CoFI: The common framework initiative for algebraic spec-
ification and development. In TAPSOFT’97, LNCS 1214, pages 115–137.
Springer, 1997.
[Mos04] Peter D. Mosses. CASL Reference Manual: The Complete Documentation Of
The Common Algebraic Specification Language. Springer, 2004.
[MP92] Zohar Manna and Amir Pnueli. Temporal Logic of Reactive and Concurrent
Systems: Specification, The. Springer-Verlag New York, Inc., 1992.
[MSRR06] Till Mossakowski, Lutz Schröder, Markus Roggenbach, and Horst Reichel.
Algebraic-coalgebraic specification in CoCasl. J. Log. Algebraic Methods Pro-
gram., 67(1-2):146–197, 2006.
[PAT12] Process analysis toolkit (PAT) 3.5 user manual, 2012. https://www.comp.nus.
edu.sg/~pat/OnlineHelp/index.htm.
[PAT20] Process analysis toolkit (PAT) 3.5 user manual, 2020. https://pat.comp.nus.
edu.sg.
[PGS01] Doron A. Peled, David Gries, and Fred B. Schneider. Software Reliability Meth-
ods. Springer-Verlag, 2001.
[Pnu77] Amir Pnueli. The temporal logic of programs. In FOCS’77, pages 46–57. IEEE
Computer Society Press, 1977.
[Smu68] Raymond R. Smullyan. First-Order Logic, volume 43 of Ergebnisse der Math-
ematik und ihrer Grenzgebiete. 2. Folge. Springer, 1968.
2 Logics for Software Engineering 111
3.1 Introduction
Let’s start our discussion of Csp by taking a break. By the way, Csp stands
for “Communicating Sequential Processes”, and we will see in the subsequent
sections why this is an excellent name for this modelling language. Anyway,
to properly enjoy your free time, you go over to this nice, cosy bistro for,
say, a cup of coffee. This requires some interaction between you and the
waiter. The two of you have to arrange for ordering an item (“I want a cup of
Markus Roggenbach
Swansea University, Wales, United Kingdom
Siraj Ahmed Shaikh
Coventry University, Coventry, United Kingdom
Antonio Cerone
Nazarbayev University, Nur-Sultan, Kazakhstan
coffee, please.”), getting the item, handing over the coffee (“Here you are.”),
informing you about the price (“That’s 2 Euros.”), handing over an amount
(“Here you are.”), and, possibly, giving out change (“Here is your change.”).
Both of you run a ‘protocol’. Should your protocols fail to fit, the purchase
will not take place successfully. For instance, you might first want the item,
before to pay—while the waiter insists on payment first: that would lead to
a deadlock. Or, maybe to get the item, the waiter goes to the kitchen, gets
engaged in a never ending chat, and forgets to serve you. That would lead
to a livelock. Finally, the bistro might have the policy to serve tea instead
of coffee in case the kitchen runs out of coffee beans. That would make the
protocol non-deterministic.
Process algebra allows to model such protocols in a precise way. Further-
more, it provides definitions of mathematical strength for the above men-
tioned phenomena deadlock, livelock, and determinism. This is one require-
ment for the formal analysis of safety-critical systems, where deadlock and
livelock could have serious consequences. Additionally, process algebra has
tool support in the form of simulators, model checkers and theorem provers.
Finally, there are implementation strategies for process algebra: given a sys-
tem, modelled and analyzed within process algebra, this protocol can be
transformed into, say, Java code such the Java program exhibits the same
properties as the process algebraic model.
Typical applications of process algebra include protocols. These can, e.g.,
describe the interaction of humans with computers. Here, Csp is utilised,
e.g., to detect cognitive errors, see Chap. 7 on “Formal Methods for Human-
Computer Interaction”. Furthermore, Csp plays an important role in security
analysis, see Chap. 8 on “Formal Verification of Security Protocols”: using
Csp, in 1995, Gavin Loewe exhibited a flaw within the Needham Schroeder
security protocol for authentication and showed how to correct it. Further
applications of Csp include control systems (see Sect. 3.2.2 on modelling a jet
engine controller), distributed systems such as credit card systems [GRS04] or
railways [IMNR12], as well as distributed or parallel algorithms [IRG05]. On
the more fundamental level, for studying distributed systems, process algebra
plays a role like the lambda calculus does for sequential systems: phenomena
such as deadlock, fairness, causality can be made precise and studied within
process calculi.
In this chapter, we introduce the process algebra Csp, see, e.g., [Hoa85,
Ros98, Sch00, Ros10], in an example-driven approach. Section 3.2 shows how
to model systems in Csp, discusses how to give semantics to Csp, and how
to use Csp’s notions of refinement for verification purposes. In Sect. 3.3, we
discuss various Csp tools for simulation, model checking, theorem proving
and code generation. Finally, Sect. 3.4 provides advanced material on Csp,
including a presentation of the three standard models, algebraic laws, giving
semantics to recursion by using fixed point theory, and refinement based proof
methods for deadlock, livelock, and determinism analysis.
3 The Process Algebra CSP 115
In this section we provide a set of case studies that illustrate Csp’s range
of applications. These case studies introduce core concepts of the language
in an example driven way: modelling an automated teller machine intro-
duces Csp’s syntax in an intuitive way and provides a basic understanding of
Csp’s constructs—see Sect. 3.2.1. While modelling a jet engine controller, we
develop first insights into Csp’s operational and denotational semantics—see
Sect. 3.2.2. Modelling buffers and later a communication system in Csp, we
discuss the concepts of refinement and verification—see Sect. 3.2.3.
The first step in Csp modelling is to extract the events that define system
evolution. Example 36 explicitly mentions four events. We name them as
follows: cardI represents the insertion of the card by the customer and the
machine accepting it, pinE represents the user entering a pin to authenticate
themselves to the machine, cashO represents the machine delivering the cash,
and cardO represents the machine returning the card. A ready event is used
to represent a fresh session of the ATM when it is ready to serve a new
customer. These events constitute the alphabet of communications Σ that
the system can perform. For our model of the ATM we have
The above specification prescribes a certain order on these events. So, for
example, delivering cash requires the customer to insert a bank card first.
However, there is no order between the delivery of the cash and the return of
the card. Csp allows for specifying causal relationships using action prefix .
The Csp process Stop stands for a system that does not perform any events.
We are now ready to specify our first ATM process.
ATM0 starts with a ready event followed by the events cardI , pinE ,
cardO and cashO in this order, before it stops to engage in any further
event. There is no other order in which ATM0 is willing to engage in the
events of the alphabet Σ. This means the specified causal order is a total
one, in which any two events are related. This fails to be traceable back
to the natural language specification where there is no order prescribed
on events cardO and cashO as discussed above. However, this over
specification in ATM0 is justified as most ATMs operate as such.
ATM0 allows for a single session only. We overcome this by using
recursion in ATM1 :
atomic in the sense that it is not possible to specify that other events may
occur ‘while event e is happening’.
The process Stop does not engage in any event. Given an event a and a
process P we write a → P to form a new process which is willing to engage
in event a and then behave as P . We write N = P to define the behaviour
of the process name N to be identical with the behaviour of the process P.
Should P contain the process name N the equation becomes a recursive one.
Recursion is how Csp expresses infinite behaviour.
The Csp syntax for processes seen so far can be summarised in the fol-
lowing grammar, which is defined relatively to an alphabet of events Σ and
a set of process names PN.
P :: = Stop
|a→P
|N
N =P
Up to now, the alphabet of events is a plain set without any further structure.
In the case of the ATM, one might want to ‘tag’ the events with the name
of the interface at which they take place. Yet another motivation to give
structure to the alphabet is when one uses the same datatype in different
contexts. For example, on a more concrete level of abstraction, the value of a
PIN and the amount of cash might both be modelled as integers. Here, one
would like to add a tag in order to indicate whether an integer value is a PIN
or the amount of cash to dispensed. Csp offers the construct of a channel for
this purpose.
We give a bit more detail on how an ATM is structured:
ATM2 displays ready message at the Display, receives a cardI over the
CardSlot, etc.
{| c1 , . . . , cn |} events(c1 ) ∪ . . . , ∪events(cn ).
Using this notation, we can write the alphabet of ATM2 in a structured way:
o
cessful termination, and the operator 9 for sequential composition of
processes.
Before and after the event KeyPad.pinE, the customer can activate the
cancel button—see process Session. When Session terminates, i.e., there
was no interrupt, control is passed over to SessionEnd, which returns
the card and gives out the cash.
P, Q :: = . . .
| Skip
| P o9 Q
| P Q
In the following sections we refrain from dealing with the cancel button in
order to keep the example focused upon the new operators used.
120 M. Roggenbach, S. A. Shaikh and A. Cerone
Csp external choice, written as P Q, offers the initial events from both
these processes. Should the environment choose an initial event from P, P Q
behaves like P, should the initial event be from Q, P Q behaves like Q.
After displaying the menu, ATM4 offers two different behaviours. If the
customer presses the checkBalance button on the Keypad, the account
balance is displayed, the card returned, and the process starts over
again. If, however, the customer presses the withdrawCash, the process
behaves as seen before.
External choice can also be regarded as reading input from the environ-
ment. When the input is read over one channel c, this can be expressed in
3 The Process Algebra CSP 121
Csp by c?x → P (x) : initially, this process offers to engage in any event
c.e ∈ events(c), when the choice is made it binds x to e and behaves like
P . P ’s behaviour can depend upon the value of the variable x. Such a
variable x can be used, e.g., in the condition cond of the Csp conditional
if cond then P else Q, where P and Q are processes. Should cond evaluate
to true, if cond then P else Q behaves like P, otherwise like Q. When one
wants to express that one is ‘sending’ the event e over the channel c, one can
write c!e instead of c.e.
Note how we again use process names in order to break up the process
ATM5 into sensible units. Rather than having names for all states, we
give names only for those which matter.
Yet another possibility to express the customer choice is the Csp prefix
choice operator ?x : A → P (x), which allows the environment to choose any
event e from the set A, binds x to this event, and then behaves like P (e).
Using this formulation, we can equivalently rewrite ATM5:
Our above claim that ATM4 and ATM5 are equivalent can be established,
e.g., by using a model checker, see Sect. 3.3 on tool support of Csp. Such a
122 M. Roggenbach, S. A. Shaikh and A. Cerone
P, Q :: = . . .
| ?x : A → P
| c?x → P
| c!e → P
| P Q
| if cond then P else Q
The difference is that UserDialog requests a PIN check after the PIN has
been entered on the keypad. It then offers the environment the choice
if the PIN was OK or not. Note that here we use the external choice
operator. In the positive case Services are offered, in the negative case
the user is informed that a wrong PIN was entered, and the UserDialog
goes back to the ready state. Services are as before:
Services = Display.menu
→ (CashWithdrawal BalanceCheck )
ATM6 = UserDialog
[| {|requestPCheck , Check |} |]
PinVerification
The process P \ A behaves like the process P where the events from the
set A ⊆ Σ are turned into internal ones, which are invisible to the outside.
In this section, we extend our Csp grammar by the following process con-
structions:
P, Q :: = . . .
| P Q
| P [| A |] Q
| P [A B ]Q
| P ||| Q
| P Q
| P \A
where A, B ⊆ Σ are a sets of events.
Parametrised Processes
Most ATMs offer the customer several attempts to enter the correct PIN.
ATM8 = UserDialog
[| {|requestPCheck , Check |} |]
PinVerification
ATM9 = ATM8 \ {|requestPCheck , Check , comparePinWithCard |}
Process parameters structure the name space relative to which the lan-
guage Csp is defined. In the above example n ranges over the integers, i.e.,
we introduce the (countably many) names
..., Pincheck(-1), PinCheck(0), PinCheck(1), ...
For each of these, the equation PinCheck(n) = ... defines how the process
behaves. In ATM8, however, only finitely many of these are reachable, namely
PinCheck(1), PinCheck(2), and PinCheck(3). Processes can have an arbitrary
but finite number of parameters.
Any datatype can serve as a process parameter. The values of this type
can be part of the alphabet of communications, but—as the above example
demonstrates—this is not necessarily the case.
Process parameters use expressions of a datatype-specific sublanguage,
with type-specific operands and operators, as we know them from primitive
data types (int, bool, ...) and abstract data types like lists, stacks, sets, bags.
The general convention is that the type-specific sublanguage is not part of the
Csp syntax. This is similar to UML/SysML, where expressions for guards,
operation bodies, and general actions are not part of the UML/SysML, but
‘opaque expressions’ that are interpreted in the context of the expression
language.
As illustrated in the example, the process parameter x of a process name
N on the left hand side on a process equation N (x) = P (x) can be used as
a variable in the process P (x) on the right hand side.
It is not necessary to expand our Csp grammar at this point. Introducing
process parameters provides more detail how the elements of the set of process
names PN look like. As the Csp grammar is defined relatively to PN, it needs
no change.
Some ATMs can deal with different currencies, e.g., those placed at airports.
R = {(Buttons.withdrawCash, Buttons.withdrawEuro),
(Buttons.withdrawCash, Buttons.withdrawSterling)
(Buttons.withdrawCash, Buttons.withdrawDollar )}
The effect is that the customer can choose among the Buttons to with-
draw money in Euro, Sterling, or Dollar. In each case, the card is
returned, cash is delivered, and the ATM starts over with the User-
Dialog.
This new process CashWithdrawal is the only change that we make
to ATM8 and ATM9 in order to obtain ATM10 and ATM11: it nicely
illustrates the power of a one to many renaming.
Looking at the example from a point of modelling, naturally there are
other, equivalent ways of how the desired effect can be achieved: as with
programming languages, also in specification languages there are many
different, equivalent ways to express one behaviour. Concerning the cho-
sen level of abstraction, one might criticise that the resulting ATMs are
kind of ‘imbalanced’: while the user can choose between different cur-
rencies, the machine just returns ‘cash’, not further differentiated into
different currencies. The reader might want to try to remedy this and
develop the example further.
P :: = . . .
| P [[R]]
Replicated Processes
Upon starting an ATM first determines how many notes there are in its
various cash cartridges.
The cartridges work in parallel, they are independent of each other, i.e.,
we can interleave the processes. We instantiate the process Cartrige-
Counter(x) for all elements of the set of denominations {five, ten, twenty}
and combine the resulting processes by interleaving:
We do not care about the order in which the ATM reads from the
cartridges. However, we want to ensure that it reads from all of them
once. The parameter X of the process Init is the set of denominations,
for which the quantity has still to be read. We instantiate the process
Quantity.x → Init(X\{x}) for all elements of the set X and combine
the resulting processes by external choice:
ATM12 = CartridgeCounterS
[| {|Quantity|} |]
Init(setofDenominations)
expands to
P (a1 ) op . . . op P (an ) op Q
where Q is some suitably chosen ‘neutral’ process—in the case of the general
parallel we have Q Skip—see Sect. B.2.2 for the details.
Note that the set index set {a1 , . . . , an } might vary during process execu-
tion. This is the case in the above process Init(X) : X is the set of cartridges
that still have to communicate the number of notes available.
In the case of parallel operators, replicated process operators create |I| + 1
many parallel processes. In contrast to this, in the case of choice operators,
replicated process operators create choice among |I|+1 many processes. After
this choice has been resolved, there is only one line of execution.
As syntactic sugar, Csp also includes a Boolean guard process cond & P
which expands to if cond then P else Stop.
In this section, we extend our Csp grammar by the following process con-
structions:
P, Q :: = . . .
| cond & P
| x:I P (x)
| x:I P (x)
| |||x:I P (x)
| [| A |] x:I P (x)
| [| A(x) |] x:I P (x)
where cond is a condition in a logic of choice (not determined by Csp), I is
an index set, A ⊆ Σ is a set of events, (P (x))x∈I is a family of processes,
(A(x))x∈I is a family of sets with A(x) ⊆ Σ for all x ∈ I.
The process x:A P (x) is well-formed for A = ∅. The processes |||x:I P (x),
[| A |] x:I P (x), and [| A(x) |] x:I P (x) are wellformed only for finite index
sets I. The process [| A(x) |] x:I additionally requires that, for all x ∈ I, the
alphabet of P (x) is a subset of A(x).
In the case of external and internal choice, replication allows to combine
infinite families of processes into one process. In the case of the replicated par-
allel operators, suitable algebraic laws concerning commutativity and asso-
ciativity ensure that the order in which the processes are combined does not
matter.
130 M. Roggenbach, S. A. Shaikh and A. Cerone
In system design, one often considers what steps are needed in order to
reach a certain goal. In our case, one is interested in the sequence of events
that actually starts the engine and in the possibilities to interrupt this pro-
cedure:
In the following, we model the first and the third component in the lan-
guage CspM [Sca98]. Our model includes an interface for reading reports from
the aeroplane electronics. CspM is a machine readable version of Csp which
also includes language constructs for the description of data. This means espe-
cially that the alphabet of communications needs to be constructed as well.
The FDR webpages https://cocotec.io/fdr/ provide a syntax reference
for CspM .
We begin with the first component, namely the buttons that the pilot can
use to initiate or abort the starting process. Some of these are Switch Buttons.
Such buttons have two states: ON and OFF. Pressing a button in state OFF will
turn it ON, releasing a button in state ON will turn it OFF. In CspM we can
model such a button in the following way:
3 The Process Algebra CSP 133
After the CspM keyword channel, one can declare a list of events. In our
example, we declare the events press and release. Each channel declaration
augments the currently defined alphabet by adding the defined constants
to it.
Our Csp specification behaves like the automaton shown in Fig. 3.2. This
connection is made more precise by the operational Csp semantics. The Csp
operational semantics takes Csp processes as states and defines transition
rules between them using firing rules:
a τ if there is an equation N = P
(a → P ) −→ P N −→ P
Provided that the preconditions (the text above the line and besides the
rule) of such a rule are fulfilled, there is a labelled transition between the
two states shown in the conclusion (the text below the line). There is exactly
one state for each process. The operational semantics, cf. Sect. 1.1.2, of a
given Csp process expression P is the smallest automaton generated from
P by the given rules. Often we call this automaton also a transition system.
Here, τ ∈/ Σ is the so-called ‘silent’ event. τ represents a non observable, i.e.,
internal, step of the automaton. The transition from the state representing a
process name, take for example ButtonOff, to the state representing the rhs
of its defining equation, in our example press -> ButtonOn, is considered
134 M. Roggenbach, S. A. Shaikh and A. Cerone
traces M (a → P ) {
} ∪ {
a s | s ∈ traces M (P )}
traces M (N ) M (N )
In the context of Csp, one usually writes the sign for the concatenation of
two traces. As seen above,
stands for the empty trace.
For a process equation N = P we require that
traces M (N ) = M (N ) = traces M (P ).
Section 3.4.3 will discuss the semantics of such (potentially) recursive equa-
tions. As semantics is defined using an equation, the typical three questions
appear:
1. Is there a solution to the equation?
2. Is the solution unique?
3. How can we construct the solution (should it exist)?
In the case that the solution exists, we write the semantics of N of a process
name as
traces(N )
i.e., without referring to the process interpretation M .
Coming back to our case study, we see that the pilot has several switch-
buttons in order to control the engine start. In order to model these, we
3 The Process Algebra CSP 135
Here, sR∗ t is the lifting of R from events to traces of events, see Sect. B.4.1
for its definition.
Here, we see one typical benefit of formal modelling: the used Formal Methods
forces one to clarify details. In our case, modelling in Csp requires us to
answer the question: “which events can happen in the system?” In case of a
Switch Button the answer is: press and release, in case of a Press Button
the answer is: press only. This leads to the insight, that the diagram in Fig.
3.1 depicts the buttons in a wrong way: it shows all of them with the same
rendering, although they are different.
We give here the firing rules for the general parallel operator. As seen
above, the interleaving operator can be defined in terms of general parallel
operator: P ||| Q P [| ∅ |] Q.
136 M. Roggenbach, S. A. Shaikh and A. Cerone
For each pair of traces s ∈ traces M (P ) and t ∈ traces M (Q) one forms a set
s [| A |] t. Such ‘overloading’ of operators is typical
for denotational
semantics
in general. The above clause uses the notation {xi | i ∈ I} i∈I xi . The
function [| A |] on traces has to mirror all possible combinations of when
a process can make progress. It is inductively defined by:
x t1 [| A |]
x t2 {
x u | u ∈ t1 [| A |] t2 }
x t1 [| A |]
x t2 ∅
x t1 [| A |]
y t2 {
y u | u ∈
x t1 [| A |] t2 }
x t1 [| A |]
∅
y t1 [| A |]
x t2 {
y u | u ∈ t1 [| A |]
x t2 }
y t1 [| A |]
y t2 {
y u | u ∈ t1 [| A |]
y t2 } ∪
{
y u | u ∈
y t1 [| A |] t2 }
y t1 [| A |]
{
y u | u ∈ t1 [| A |]
}
[| A |]
x t2 ∅
[| A |]
y t2 {
y u | u ∈
[| A |] t2 }
[| A |]
{
}
where x, x ∈ A ∪ {}, y, y ∈
/ A ∪ {}, x = x , and t1 , t2 ∈ Σ ∗ ∪ Σ ∗ . The
event will be discussed below. From now on, we refrain from presenting
the semantical clauses for the Csp traces semantics and refer the reader to
Sect. B.4.
Going on with our case study, we check next if the second component gives
an OK for the start:
3 The Process Algebra CSP 137
CheckConditions =
aircraftCondition ? ac
-> engineCondition ? ec -> Checking(ac,ec)
[] engineCondition ? ec
-> aircraftCondition ? ac -> Checking(ac,ec)
Skip −→ Ω
where Ω is a special process term that is intended to represent any terminated
process. Using these notations, we can extend the operational semantics of
the renaming operator and the parallel operator.
Renaming has no effect on termination:
P −→ P
P [[R]] −→ Ω
Concerning the parallel operator, we state first of all that each process can
terminate independently:
P −→ Ω Q −→ Ω
τ τ
P [| A |] Q −→ Ω [| A |] Q P [| A |] Q −→ P [| A |] Ω
If both processes have terminated, indicated by the special state Ω, their
parallel composition can do so as well:
Ω [| A |] Ω −→ Ω
Now let’s study sequential composition P o9 Q. As long as P can perform
events different from , this is what the combined process performs. Only,
when P terminates, the second process takes over:
x
P −→ P P −→ P
x x = τ
P o9 Q −→ P o9 Q P o9 Q −→ Q
3 The Process Algebra CSP 139
Note, that we again use τ in order to provide a label for the control flow from
P to Q.
Hiding is simple when it comes to the operational semantics. Events to be
hidden are turned into a τ, all others remain:
x a
P −→ P P −→ P
τ x∈A a a∈
/ (A ∪ {})
P \ A −→ P \ A P \ A −→ P \ A
Hiding has no effect on termination, but we follow again the convention that
Ω represents all terminated processes (this is necessary, as the operational
rule for the termination of the parallel operator recognizes the termination
of the subprocesses by pattern matching with Ω):
P −→ P
P \ X −→ Ω
Region = (StartInit /\
(mc_release -> abortStart -> STOP));
(MasterSpeed
|||
(ButtonON [[press < - mc_press,
release < - mc_release]]
)
)
The expected flow of events is that sav.open and fc press hap-
pen in any order. Then the process Fuel shall take over. Finally, the
MasterSpeed process is called, which models the final phase of the start-
ing procedure.
140 M. Roggenbach, S. A. Shaikh and A. Cerone
Such kind of rule set is useful whenever one models a concrete system. It
allows one to trace modelling decisions. Furthermore, it can serve as a refer-
ence point when discussing the question: “where do the axioms come from?”
Concerning our findings with regards to the jet engine controller, we can
state:
Modelling a system happens usually with a purpose. In our case the pur-
pose was to create a formal model in order to test the controller. For more
details, see [HKRS09]. Purposes for modelling include:
• Better understanding of the system (by, e.g., making it accessible to sim-
ulation).
• Clarification of an informal specification.
• Testing.
• Verification.
• Performance analysis.
In this section, we were using predominately the operational semantics to
provide an understanding of the various Csp operators. However, “Histor-
ically, the operational semantics of Csp was created to give an alternative
view to the already existing denotational models rather than providing the
intuition in the original design as it has with some other process algebras
such as CCS.” [Ros98].
Buffers are a commonly used notion in the theory of computer science. Albeit
simple, the concept is crucial to the design of data processing and commu-
nication. Buffers essentially serve as memory, temporarily holding some data
while being transferred from one place to another, usually as part of some
distributed computation within a local or networked system. Such a transfer
may involve data being moved to or from an I/O device, or transmitting or
receiving data on a communication network:
The rest of this section adopts the following approach: first, the charac-
teristic behaviour of buffers is formally specified. This helps to make explicit
the defining properties of a buffer. A most simple buffer is then described to
offer such properties by design. This serves as a generic buffer specification
for other complicated systems to satisfy. The notion of refinement is intro-
duced as a means to check against process-oriented specifications. Finally a
piped communication system is presented as a case for demonstration, where
the system is only deemed to be a buffer if it proves to be a refinement of a
simple characteristic buffer.
Characteristic Behaviour
The above can be stated formally. The first property can be expressed
using traces as observations:
↓ c
m (tr ↓ c) ; a = c.m for some m ∈ comms(c)
(
a tr) ↓ c
tr ↓ c ; else
The second property insists that when the queue is empty the process
must allow for any message on the input. This property can’t be expressed
with traces anymore. Traces record which observations can happen, however,
144 M. Roggenbach, S. A. Shaikh and A. Cerone
failures(P ).
With the failures of a process at hand, we can express that a certain event,
say press, has to be possible after observing a certain trace, say
: press is
not an element of the refusal sets of the process ButtonOFF after observing
the trace
, formally:
(
, X) ∈ failures(ButtonOFF) =⇒ press ∈
/ X.
Div
In the context of failures, there is a process called Div that plays a special
role. We add it to our grammar as one further option
P :: = ...
| Div
though specifiers use it seldomly. Figure 3.3 shows the transition system
associated with it. As the only transition it has is labelled with τ , the only
observation one can make about Div is the empty trace, i.e., traces(Div) =
{
}. As the only state it has is unstable and has no outgoing transition,
it has no stable failures, i.e., failures(Div) = {}.
The failures of a process can either be obtained from the operational
semantics—as done above—or computed in a denotational way. We demon-
strate here that failures are powerful enough to distinguish between the inter-
nal and the external choice operator:
• In the case of internal choice, we simply take the union of the failures of
the constituent processes:
If the messages read by the buffer have not yet all appeared as output,
tr ↓ write < tr ↓ read, and hence the buffer is still not empty, then some
element of write.M is available for output:
ments. With traces we state that undesirable events should not happen, with
failures we formulate that desirable events could happen.
Up to now we have formulated in the semantic domains of traces and
failures what a buffer should do. Here, we give a Csp process which has the
desired properties.
BUFFER = BUFFER( )
It is one thing to claim that a process has certain properties. Yet, one
better proves that this is the case indeed:
(tr ↓ write) q
= (tr ↓ write) q
m
= (tr ↓ read )
m
= (tr
read .m) ↓ read
= tr ↓ read
failures(P Q)
= {(
, X) | (
, X) ∈ failures(P ) ∩ failures(Q)}
∪ {(s, X) | (s, X) ∈ failures(P ) ∪ failures(Q) ∧ s =
}
∪ {(
, X) | X ⊆ A ∧
∈ traces(P ) ∪ traces(Q)}
= {(
, X) | (
, X) ∈ failures(Q)}
∪ {(s, X) | . . . s =
}
∪ {}.
Refinement
P T Q traces(Q) ⊆ traces(P )
P P (reflexive)
P Q ∧ Q R =⇒ P R (transitive)
P Q ∧ Q P =⇒ P = Q (anti -symmetric)
150 M. Roggenbach, S. A. Shaikh and A. Cerone
As these laws can be proven to hold in all Csp standard models, we omit the
index indicating the specific model. Furthermore, refinement is compositional
such that it is preserved by all operations of Csp. This means for any Csp
context F (.) where a process can be substituted,
P Q =⇒ F (P ) F (Q) (substitution)
with x ∈ M, q ∈ M ∗ .
Similarly, in the case of the two element buffer B, we take B =
(Bw )w∈M ∗ as the vector of names. We define for the two element buffer
with the help of a vector of variables Y = (Yw )w∈M ∗ the following
system of equations:
Now, we are missing out on equations for Gw for |w| ≥ 3 : the two
element buffer does not prescribe any behaviour in the case that three
or more elements have been stored. These states are no reachable from
the initial state of an empty buffer. However, formally we are required
to provide equations, when we want to relate the BUF process with our
two element buffer. Here we choose:
Gw (Y ) = Div
Formulating our processes in the ‘right’ format for the fixpoint induction
rule involved
• finding a common index set,
• transforming process parameters to indices in order to formally obtain a
vector of process names,
152 M. Roggenbach, S. A. Shaikh and A. Cerone
(* length 0 *)
apply (cspF_unwind)
apply (cspF_hsf)+
(* length 1 *)
apply (cspF_unwind)
apply (cspF_hsf)+
apply (rule cspF_Int_choice_left1)
apply (rule cspF_decompo, auto)
(* length 2 *)
apply (cspF_unwind)
apply (cspF_hsf)+
apply (rule cspF_Int_choice_left2)
apply (simp)
done
Fig. 3.4 The proof from Example 38.9 as proof script in Csp-Prover
With these formulations, we are now prepared to carry out the proof:
The above proof also be carried out in Csp-Prover, cf. Fig. 3.4. Rule
cspF fp induct cpo ref right refers to fixec point induction. In the
case distinctions, (cspF unwind) represents the unfolding of the equa-
tions (i.e., going from the lhs of component function F to the rhs),
(cspF hsf)+ is a tactic that automatically applies a number of alge-
braic laws, however, sometimes one needs to be specific which algebraic
law shall be applied and to which argument (cspF Int choice left1—
chooses the first argument of the internal choice operator on the lhs of
an equation).
As refinement holds in all four cases, we know that BUF F B. Now
let us consider the three defining properties of a buffer in the context of
process B:
For the first defining property, we have: let tr ∈ traces(B). As
BUF F B we have tr ∈ traces(BUF ). For the traces of the BUF
process it holds that tr ↓ write ≤ tr ↓ read . Thus, the first defining
property holds for tr. The proofs for the second and third property are
analogous.
Thus, B has all the defining properties of a buffer.
154 M. Roggenbach, S. A. Shaikh and A. Cerone
A Communication System
i.e., the medium corrupts the transmitted message such that 1 is read
in but 0 is written out.
I.e., the first of the two reasons discussed above occurred.
MCOMM SYSTEM =
(MSNDR [| ToM |] MEDIUM ) [| FromM |] MRCVR
In this chapter we analyze the Children’s Puzzle with various tools for
Csp. The puzzle belongs to the lore of mathematical riddles. It appears to
be impossible to name its inventor. One reference is [BPFS].
The puzzle does not prescribe any ‘synchronisation’ between the steps.
Our above ‘snapshots’ “after Step 1” and “after Step 2” are possible in a
run, however, do not happen in every run. In particular with many children, a
system run can inlude a ‘configuration’ in which children have completed sev-
eral rounds (i.e., passed their candies and received a refill from the teacher),
while there are children who not yet have passed any candy. It is this lack of
synchronisation that makes it a challenge to analyse the puzzle.
Natural questions on the puzzle include:
channel c: {0..2}.{0..2}
Child(p,i) =
( c.(p+1)%3 ! (i/2)
-> c.p ? x -> Child(p, fill(i/2+x)))
[] ( c.p ? x
-> c.(p+1)%3 ! (i/2) -> Child(p, fill(i/2+x)))
Children = || p:{0..2} @
[ {| c.p, c.(p+1)%3 |} ] Child(p,2*p)
With a simulator such as the tool ProBe we can explore a single run of
one instance of the puzzle. Figure 3.7 shows a run of the puzzle in ProBe.
Here, the puzzle consists of three children who initially are holding zero, two,
and four candies, respectively. After choosing the three exchanges c.0.2,
c.1.0, and c.2.1, the children hold two, two, and four candies. Selecting
furthermore always the first choice offered, eventually, we reach a state in
which all three children hold four candies.
162 M. Roggenbach, S. A. Shaikh and A. Cerone
This result comes at high costs though: the proof needs to be carried out
interactively, i.e., the user enters proof commands, which the proof engine
then executes in order to gain a new proof state. Developing the proof script
published by Yoshinao Isobe and Roggenbach [IR08] took about one man
month. The final script consists of several thousand lines of proof commands.
Running the script takes about half an hour of computation time on a 2.5
GHz Intel Core 2 Duo processor.
We have seen: with simulation we can analyse a single run of a system.
With model checking we can verify a single system. With interactive theorem
we can verify a parameterised class of systems.
164 M. Roggenbach, S. A. Shaikh and A. Cerone
It is a long standing and still open research problem of how to link specifica-
tions written, e.g., in Csp with implementations written, e.g., in the program-
ming language C++. Here, ‘Invent & Verify’ and ‘Transformation’ are the
two standard approaches. In the first approach, the implementor ‘invents’ a
program and then establishes either by testing or by mathematical argument
that the implementation ‘fits’ to the specification. Testing approaches to Csp
are discussed, e.g., by Ana Cavalcanti and Temesghen Kahsai [CG07, KRS07].
The second approach, which we will follow here, ‘translates’ a given speci-
fication from a specification language into a programming language, in our
case from Csp into C++.
In the context of Csp, several techniques have been developed as link to a
programming language. They differ in methodology, preservation of seman-
tics, degree of automation, the supported language constructs, target lan-
guage, to name just a few criteria:
Child(0,x) =
(c1!x/2 -> d.1.x/2 -> c0?y -> Compute(0,x/2,y))
[] (c0?y -> c1!x/2 -> d.1.x/2 -> Compute(0,x/2,y))
Child(1,x) =
(c2!x/2 -> d.2.x/2 -> c1?y -> Compute(1,x/2,y))
[] (c1?y -> c2!x/2 -> d.2.x/2 -> Compute(1,x/2,y))
Child(2,x) =
(c0!x/2 -> d.0.x/2 -> c2?y -> Compute(2,x/2,y))
[] (c2?y -> c0!x/2 -> d.0.x/2 -> Compute(2,x/2,y))
else Child(p,4)
d.1.0, d.2.1, d.0.2, d.1.1, d.2.1, d.0.2, d.1.2, d.2.1, d.0.2, d.1.2, d.2.2, d.0.2
As expected, the system stabilizes after nine steps. The channels c0,
c1 and c2 are treated by CSP++ as internal events. There is a fixed
schedule selecting one possible execution path through the system.
Domain. The traces model observes the finite sequences of events that a
process can engage with. The empty observation
is always possible. If
there was an observation o =
a1 , a2 , . . . , ak−1 , ak , obviously prior to o is
was possible to observe o =
a1 , a2 , . . . , ak−1 . These considerations lead to
two healthiness conditions on trace observations: for all observations T it
holds that
T1 T = ∅ and T is prefix-closed, i.e., ∀t ∈ T.s ≤ t ⇒ s ∈ T.
Here, s ≤ t stands for s is a prefix of t.
In contrast to other process algebras, Csp treats termination of processes:
the process Skip does nothing but to terminate; after termination of P the
3 The Process Algebra CSP 169
Σ ∗ Σ ∗ ∪ {s | s ∈ Σ ∗ }.
Together with the two healthiness conditions, we obtain the Csp traces
domain as
T {T ⊆ Σ ∗ | T fulfills T1}.
traces(Stop) {
}
traces(Skip) {
,
}
Here, Csp uses the substitution [a/x] on the syntactic level in order to resolve
the binding of a to the variable x.
Csp internal choice is mapped to set union:
traces(P o9 Q) (traces(P ) ∩ Σ ∗ )
∪{s t | s
∈ traces(P ), t ∈ traces(Q)}
The conditional operator exhibits yet another Csp specialty. Csp assumes
that there is a logic that allows one to formulate conditions ϕ. This logic,
however, is never made explicit. When Csp is integrated with data, as, e.g.,
in CspM [Sca98] or in Csp-Casl [Rog06], this logic and its evaluation rules
are made explicit. Here, we formulate only:
traces(P ) if ϕ evaluates to true
traces(if ϕ then P else Q)
traces(Q) if ϕ evaluates to false
comes with proof obligations. Let us consider these proof obligations in the
simple case of the prefix operator:
traces(a → P ) { } ∪ { a s | s ∈ traces(P )}
∀s ∈ D, X ⊆ (Σ ∪ {}).(s, X) ∈ F.
∀(s, X) ∈ F, Y ⊆ Σ ∪ {}.
(∀a ∈ Y.s
a ∈
/ traces ⊥ (F )) =⇒ (s, X ∪ Y ) ∈ F.
failures ⊥ (a → P )
{(
, X) | X ⊆ Σ ∪ {}, a ∈/ X}
∪ {(
a s, X) | (s, X) ∈ failures ⊥ (P )}
divergences(a → P ) {
a t | t ∈ divergences(P )}
Here, R−1 (X) {a | ∃a ∈ X.a R a }. We read the failures clause as follows:
X is a refusal set of P [[R]] if its ‘reverse image’ R−1 (X) is refused by P .
For the sake of healthiness condition D2, we also include all refusals for any
divergent trace. Concerning the divergence clauses, we get: if s is a divergence
from P that does not end with a —encoded via s ∈ divergences(P ) ∩ Σ ∗ —
then we rename it via R∗ into s and obtain a divergence for P [[R]]. Note that
thanks to D3 we have that s
∈ D implies s ∈ D.
Over N , it is impossible to provide a general semantical clause that com-
putes the divergences of the process P \ X. The problem is that hiding intro-
duces a divergence in P \ X when P can perform an infinite consecutive
sequence of events in X. The difficulty is that over N we consider only finite
traces, not infinite ones. However, it is possible to provide a semantical clause
for the subclass of finitely branching processes. For further discussion of this
matter see, e.g., [Ros98].
Relation to the traces model T . The traces of the model T are related with
the traces of the model N , also the failures as defined in Sect. 3.2.3 are related
with the failures of the model N . Given a process P , we have
and
failures ⊥ (P ) = failures(P )
(3.7)
∪ {(s, X) | s ∈ divergences(P ), X ⊆ (Σ ∪ {})}
These connections between the models can be derived, e.g., from the oper-
ational semantics of Csp. As the operational models can be proven to coincide
with the denotational ones, it is justified to use these connections to establish
the following theorem:
Theorem 4 If divergences(P ) = ∅, then P N Q ⇒ P T Q.
Proof Let P N Q. As divergences(P ) = ∅, we obtain divergences(Q) = ∅.
Therefore, traces ⊥ (P ) = traces(P ) and traces ⊥ (Q) = traces(Q). From
failures ⊥ (Q) ⊆ failures ⊥ (P ) we derive that traces ⊥ (Q) ⊆ traces ⊥ (P ). Com-
bining these arguments leads to traces(Q) = traces ⊥ (Q) ⊆ traces ⊥ (P ) =
traces(P ).
Note that is it not possible to relax the precondition of Theorem 4. As Div
is the least refined process over N , we have, e.g., Div N a → Stop. However,
traces(a → Stop) = {
,
a} ⊆ {
} = traces(Div) i.e., Div T a → Stop.
3 The Process Algebra CSP 175
ATM0 T Stop,
i.e., the process does nothing and diverges immediately—as we record only
stable failures, Div has an empty failures component.
The process
RUN + +
Σ = (?x : Σ → RUN Σ ) Stop Skip
failures(Stop) {( , X) | X ⊆ Σ ∪ {}}.
failures(a → P ) {(
, X) | X ⊆ Σ ∪ {}, a ∈ / X}
∪ {(a s, X) | (s, X) ∈ failures(()P )}.
The reason for the difference is that we do not need to ‘close’ the failure set
for the sake of healthiness condition D2.
Hiding has an astonishing simple clause:
For traces, hiding on the syntactic level has a counterpart on the semantics:
\ X =
(
x t) \ X = t \ X (if x ∈ X)
(
y t) \ X =
y (t \ X) (if y ∈
/ X)
Reflection
One might wonder if it really is a good thing that there are these three
different and many more semantics for Csp. One can put this question into
an even wider context, as Rob van Glabbeek did in his classical account
[vG01], in which he studies the relationships between no less than 15 different
semantics for process calculi. And there are further more. Here, the question
arises how many semantics do we need, is the development of further semantic
models of process algebra ‘scientific nonsense’ / occupational therapy for
computer scientists?
The general observation concerning such semantics models is that their
development is driven by ‘necessities’: certain shortcomings of an existing
model are ‘patched’ by providing a new model. However, often this new model
comes at a ‘price’.
We illustrate this on the example of Csp. The traces model is fine when
one wants to study safety properties of systems. However, the traces model is
too weak to study liveness properties. Thus, when one wants to look, e.g., into
divergences, one needs a ‘refined’ view on processes. The failures/divergences
model provides such more fine grained view. However, this model runs into
problems with denotational semantics, e.g., it is impossible to provide a clause
for the hiding operator. This can be resolved by utilising the failures model,
however, this comes at the price that divergences can’t be studied in it,
though other liveness properties such as deadlocks can.
In the case of Csp, computer science has not been able to provide a single,
satisfactory model that could serve as semantical platform for all the analy-
sis methods one might be interested in. Thus, the pragmatic answer to the
above question is: one takes the ‘simplest’ model that allows one to apply
the method that delivers the analysis one is interested in. As there are clear
relationships between the models (see, e.g., the above theorems concerning
refinements, Theorems 4, 7, and 8), it is possible to combine results achieved
in different settings.
This situation is similar to the science of physics. When describing the
motion of macroscopic objects, from projectiles to parts of machinery, and
astronomical objects, classical mechanics is perfectly fine. However, when it
comes to aspects at small (atomic and subatomic) scales, quantum mechanics
is required. These two different theories are related. Most theories in classical
physics can be derived from quantum mechanics as an approximation valid
at large (macroscopic) scale.
180 M. Roggenbach, S. A. Shaikh and A. Cerone
Process algebras carry their name thanks to the rich set of algebraic laws that
allow one to transform processes, to refine processes, and to prove equality
between processes.
Csp has laws specific to certain models. Examples include:
• The traces model T treats internal choice and external choice in the same
way: P Q =T P Q.
This law does not hold in the failures/divergences model N and the stable
failures model F.
• In the stable failures model F one can never infer that a process is diver-
gence free: P div =F P.
This law does not hold in the failures/divergences model N .
The index on the equal sign indicates in which model the law holds.
There are also laws which express general properties of Csp. Here, one
usually omits the index at the equal sign. The following laws hold in all the
three standard models of Csp, namely T , N and F :
• Congruence laws. The various process equivalences = are congruences,
e.g., if Q = R then P Q = P R.
• Laws involving single operators. The choice operators are idempotent,
i.e., P P = P and P P = P, symmetric, associative; external choice
has Stop as its unit, i.e., P Stop = P.
• Interplay of different operators, e.g., distributivity laws. All Csp
operators distribute over internal choice, e.g., (P Q) \ X = (P \ X)
(Q \ X).
• Step laws. Each Csp operator has a step law. It gives the initial events
of the process formed by the Csp operator in terms of the initial events of
the constituent processes. As an example, we consider here the (relatively
simple) law of the external choice operator:
(? x : A → P (x)) (? x : B → Q(x)) =
? x : (A ∪ B) →
(if (x ∈ A ∩ B) then P (x) Q(x)
else if (x ∈ A) then P (x) else Q(x)).
where Ext(A,P,B,Q) (Step(A,P,B,Q) ) denotes the lhs (rhs) of the step law for
external choice. We consider the proof of (#2) only. Here, we compute the sets
failures(Ext(A,P,B,Q) ) and failures(Step(A,P,B,Q) ) by applying the semantic
clauses of the model F. After some simplifications we obtain:
failures(Ext(A,P,B,Q) ) =
{(
, X) | A ∩ X = ∅} ∪ {(
, X) | B ∩ X = ∅} ∪
{(
a t, X) | a ∈ A ∧ (t, X) ∈ failures(P (a))} ∪
{(
a t, X) | a ∈ B ∧ (t, X) ∈ failures(Q(a))} (#3)
failures(Step(A,P,B,Q) ) =
{(
, X) | (A ∪ B) ∩ X = ∅} ∪
{(
a t, X) | a ∈ A ∪ B ∧
if (a ∈ A ∩ B) then (t, X) ∈ failures(P (a)) ∪ failures(Q(a))
else if (a ∈ A) then (t, X) ∈ failures(P (a))
else (t, X) ∈ failures(Q(a))} (#4)
Using standard arguments on sets, one can show that the sets (#3) and
(#4) are indeed equal and that therefore the step law holds in F.
In contrast to this approach, one can mechanise such proofs, e.g., with
Csp-Prover. Figure 3.11 shows a proof-script in Csp-Prover proving the above
step law. The sets of failures of the both processes, i.e., (#3) and (#4), are
automatically derived in Csp-Prover, see the lines 9 and 12. This is a powerful
technique. Deriving the denotations of processes according to the semantical
clauses of a Csp model is a tedious but error prone and complex task—note
that the sets (#3) and (#4) are already simplified versions of the sets derived
from the semantical clauses. See the paper by Isobe and Roggenbach [IR07]
for a more detailed discussion of such proofs. Mistakes found in published
algebraic laws for Csp, see e.g., [IR06], demonstrate that presentations of
Csp models and axiom schemes will only be ‘complete’ once they have been
accompanied by mechanised theorem proving.
The above proofs concern the soundness of the laws. Yet another question
how many laws one actually needs, if the given laws characterise equality
in the chosen Csp model, i.e., if they are complete. Early approaches to
completeness restrict Csp to finite non-determinism over a finite alphabet
[Ros98]. For the stable failures model F, Isobe and Roggenbach give a com-
pleteness result for Csp with unbounded non-determinism over an alphabet
of arbitrary size using about 80 algebraic laws [IR06].
We now set out to address our questions concerning the semantics of recursive
equations stated in Sect. 3.2.2. We begin our excursion with a seemingly
simple example:
182 M. Roggenbach, S. A. Shaikh and A. Cerone
Fig. 3.11 A proof script in Csp-Prover for the step law of the external choice
P =a→P
Here, the behaviour of the process P on the left hand side is defined
using the behaviour of the process P on the right hand side. One reading
of such an equation is: we are interested in a denotation for P which
remains unchanged when applying the prefix function to it. In other
words: we are looking for a fixed point.
Denotational semantics works with at least two standard fixed point theo-
ries in order to deal with recursion: (i) partial orders in combination with
Tarski’s fixed point theorem and (ii) metric spaces in combination with
Banach’s fixed point theorem. Csp makes use of both approaches. In this
section, we study the above equation in the context of the partial order
approach.
We observe that the traces domain T together with set-inclusion ⊆ as
ordering relation forms a partial order with bottom element (T , ⊆, {
}) : set-
inclusion is reflexive, antisymmetric, and transitive; furthermore, {
} ⊆ T
for all T ∈ T as elements of T are required to be non-empty and prefix-closed.
Definition 2 (Upper bound, least upper bound) Let (P O, ≤) be a partial
order, let X ⊆ P O be a set of elements.
1. An element u ∈ P O is called an upper bound for X if for all x ∈ X . x ≤ u.
2. An element lub ∈ P O is called a least upper bound for X if it is an upper
bound for X and for all ub ∈ {u ∈ P O | ∀x ∈ X . x ≤ u} holds: lub ≤ ub.
In the context of the traces domain T , let
3 The Process Algebra CSP 183
f (lub((f n (⊥))n∈N ))
= lub((f n+1 (⊥))n∈N ) thanks to continuity
= lub((f n (⊥))n∈N ). adding the bottom element
Finally, we show that lub((f n (⊥))n∈N ) is the smallest fixed point of f . Let
x be a fixed point of f, i.e., f (x) = x. We know ⊥ ≤ x. Applying Theorem 4
to this yields: f n (⊥) ≤ f n (x) = x for all n ∈ N, i.e., x is an upper bound of
(f n (⊥))n∈N . Thus, lub((f n (⊥))n∈N ) ≤ x.
Note that the smallest fixed point of a continuous function f is unique.
Assume that u and v are both smallest fixed points of f . Then u ≤ v, as v a
the smallest fixed point. But also v ≤ u, as u is a smallest fixed point. With
antisymmetry, we obtain: u = v.
Using Theorem 10, we can study how to give semantics to recursive process
definitions:
traces M (a → P ) {
} ∪ {
a s | s ∈ traces M (P )}
traces M (n) M (n)
traces M (P ) = traces M (a → P )
= fa (traces M (P ))
186 M. Roggenbach, S. A. Shaikh and A. Cerone
Note that fixed points are not necessarily unique: the equation P = P
(with identity as its underlying function) has all elements of a semantic
domain, say of the traces domain T , as its solutions. Only by taking the
smallest one we make the solution unique, namely to be {
} over T .
The theory developed so far works for functions in one argument (i.e.,
action prefix) and one variable (i.e., one equation). In order to cater for more
complex situations, one needs to consider products of ω-complete partial
orders, continuous functions in several arguments, and the composition of
continuous functions. The subject of domain theory provides constructions
and solutions to these question of denotational semantics, see e.g., [Win93].
Without proof we quote results as presented in Roscoe’s book [Ros98]:
Theorem 11 (Ω-Completeness of domains and continuity of the semantic
functions)
• The model T is a cpo w.r.t. ⊆ as ordering relation and with [[Stop]]T as
bottom element.
The model F is a cpo w.r.t. ⊆ × ⊆ as ordering relation and with [[Div]]F
as bottom element.
If one restricts the alphabet Σ to be finite, the model N is a cpo w.r.t.
⊇ × ⊇ as ordering relation and [[Div]]N as bottom element.
• Over T and F, the semantic functions underlying action prefix, external
choice, internal choice, general parallel, sequential composition, renaming,
and hiding are continuous w.r.t. ⊆ and ⊆ × ⊆ as respective ordering
relations.
If one restricts the alphabet Σ to be finite, this holds also over N w.r.t.
⊇ × ⊇ as ordering relation. Here, the hiding operator over N is only
defined when applied to finitely non-deterministic processes.
Note that Roscoe works with directed sets rather than with ω-chains. How-
ever, as ω-chains are special directed sets, Roscoe’s results carry over to our
slightly simpler setting.
With this result we conclude: choosing the smallest fixed point guaranteed
by Kleene’s theorem gives semantics to all recursive process equations over
the models T and F, and also—under some restrictions—over the model N .
3 The Process Algebra CSP 187
This section provides analysis methods for general properties of parallel sys-
tems. We define what it means for a process to be deadlock free, livelock free,
or deterministic. For each of these properties we then present a characterisa-
tion in terms of Csp refinement. Full proofs are provided.
Livelock
divergences(Div) := Σ ∗
failures ⊥ (Div) := Σ ∗ × P(Σ )
Div represents an un-controllable process: it has all possible traces and can
refuse all events. Conditions D1 and D2 of the failures/divergences model
ensure that s ∈ divergences(P ) implies {t | s t ∈ divergences(P )} = Σ ∗
and {(t, X) | (s t, X) ∈ failures ⊥ (P )} = Σ ∗ × P(Σ ). This justifies the
definition:
Definition 5 (Livelock-freedom/divergence-freedom) A process P is said to
be livelock-free (divergence-free) if and only if divergences(P ) = ∅.
Theorem 12 (N -refinement preserves livelock-freedom) Let P and Q be pro-
cesses such that P is livelock-free and P N Q. Then Q is livelock-free.
Proof We show: if P N Q and Q has a livelock, then P has a livelock.
Let Q have a livelock. Then divergences(Q) = ∅. As P N Q, also
divergences(P ) = ∅.
The set of all livelock-free processes has a maximal element, namely the
process DivFΣ :
188 M. Roggenbach, S. A. Shaikh and A. Cerone
If the alphabet Σ is clear from the context we omit the index Σ and just
write DivF .
Theorem 13 (DivF is livelock-free) The process DivF is livelock-free.
Proof As neither Stop, nor Skip have any divergences, and the prefix operator
does not contribute to divergences, we obtain divergences(DivF ) = ∅.
Theorem 14 (DivFA is maximal among the livelock-free processes) Let P
be livelock free. Then DivF N P.
Proof Let DivF N P. As failures(Stop) = {(
, X) | X ⊆ Σ } and
failures(P Q) = failures(P ) ∪ failures(Q) we have that failures(DivF ) =
A∗ × P(Σ ). Thus, failures(P ) ⊆ failures(DivF ). Therefore, we must have
divergences(P ) ⊆ divergences(DivF ) = ∅, i.e., divergences(P ) = ∅. Thus, P
has a livelock.
The theorems of these section provide a sound and complete proof method
for livelock analysis:
Corollary 6 (Livelock analysis)
A process P is-livelock free if and only if DivF N P.
Deadlock
as its denotation in F, i.e., the process Stop can perform only the empty
trace, and after the empty trace the process Stop can refuse to engage in all
sets of events.
Stop denotes an immediate deadlock. In general, a process P is considered
to be deadlock free, if the process P after performing a trace s never becomes
equivalent to the process Stop. More formally:
Definition 7 (Deadlock-freedom) A process P is said to be deadlock-free if
and only if
∀s ∈ Σ ∗ .(s, Σ ) ∈
/ failures(P ).
3 The Process Algebra CSP 189
If the alphabet Σ is clear from the context we omit the index Σ and just
write DF .
Theorem 16 (DF is deadlock-free) The process DF is deadlock-free.
Proof We calculate the semantics of DF in the stable failures model F. The
process has all traces, as it can perform all events as well as Skip at any time:
traces(DF ) = Σ ∗ .
Determinism
1. s
a ∈ traces(P ) and
2. (s, {a}) ∈ failures(P ).
I.e., the process P is at the same time willing to engage in a and to refuse a.
We say that a process is deterministic if it is not non-deterministic.
Following an idea from Ranko Lazić, published by Bill Roscoe in [Ros03],
we express a check for determinism via refinement. Given a livelock free
process P, we construct two new processes Spec and G(P ) such that P is
deterministic if and only if Spec F G(P ) holds.
Let Σ be an alphabet of communications. We define two copies of Σ,
namely Σ.1 = {a.1 | a ∈ Σ} and Σ.2 = {a.1 | a ∈ Σ}. We define a process
Monitor over Σ.1 ∪ Σ.2 as
The process Monitor first offers all events in Σ.1. After it received such an
event a.1, it communicates its counterpart a.2 ∈ Σ.2 and behaves again like
Monitor.
Let P be a process over Σ. From P we construct a copy P.1 over Σ.1. To
this end, we rename all events a ∈ Σ to a.1 ∈ Σ.1. Analogously we construct
a copy P.2 over Σ.2:
P.1 = P [[a.1/a | a ∈ Σ]]
P.2 = P [[a.2/a | a ∈ Σ]]
With the help of these processes we define
After a trace of even length, it has all failures due to the process Stop.
After a trace of odd length, it can refuse termination, all elements of Σ.1,
and all elements of Σ.2 but one:
failures(Spec) =
{(s, X) | s ∈ traces(Spec), length(s) even, X ⊆ (Σ.1 ∪ Σ.2) }
∪ {(s, X) | s ∈ traces(Spec), length(s) odd,
∃a.2 ∈ Σ.2.X ⊆ (Σ.1 ∪ Σ.2 − {a.2}) }
failures(Q R)
= {(u, Y ∪ Z) | (u, Y ) ∈ failures(Q) ∧ (u, Z) ∈ failures(R)
∧ u ∈ traces(Q) ∩ traces(R)}
Next, we compute the failures for interleaving from the clause of general
parallel:
failures(Q ||| R)
= {(u, Y ∪ Z) | Y − {} = Z − {},
∃s, t.(s, Y ) ∈ failures(Q) ∧ (s, Z) ∈ failures(R)
∧ u ∈ s ||| t}
3 The Process Algebra CSP 193
As Spec has all failures after an even length trace—see above—we only
need to consider odd length traces in our proof.
“⇒” Let Spec G(P ). From the above considerations we know that this
can only be the case if failures((P.1 ||| P.2) Monitor ) ⊆ failures(Spec). Even
more precisely we know that the reason for the non-inclusion must have the
form (s, (Σ.1 ∪ Σ.2) ) where s is a trace of odd length.
According to Monitor, the last element of an odd length trace must end
with a communication in Σ.1. Thus, there exist s and a.1 such that s =
s
a.1 and s is an even length trace. Due to the trace semantics of Monitor
we know that s =
a1 .1, a1 .2, . . . , an .1, an .2 for some events a1 , . . . , an ∈
Σ, n ≥ 0. Let t =
a1 , . . . , an . Then t.1 ∈ traces(P.1) and t.2 ∈ traces(P.2).
Furthermore, we know that t.1
a.1 ∈ traces(P.1). Thus, we obtain t
a ∈
traces(P ).
As the failures of Monitor after an odd length trace can maximally have
(A.1 ∪ A.2 − {a.2}) as their refusal set, P.1 ||| P.2 must have contributed
the set {a.2} as a refusal after s. Thus, P.2 must have the failure (t.2, {a.2}).
Consequently P must have the failure (t, {a}).
Thus, P is non-deterministic.
“⇐” Let P be non-deterministic. Then there exist a trace s =
a1 , . . . , an
and a communication a such that s
a ∈ traces(P ) and (s, {a}) ∈
failures(P ). As P.1 and P.2 are obtained by P via bijective renaming, we
know that s.1
a.1 ∈ traces(P.1) and (s.2, {a.2}) ∈ failures(P.2). By con-
struction,
a1 .1, a1 .2, . . . , an .1, an .2
a.1 ∈ traces(P.1|||P.2). P.1 refuses all
the events from Σ.2. Thus, (s.1
a.1, {a.2}) ∈ failures(P.1). Consequently,
Obviously,
a1 .1, a1 .2, . . . , an .1, an .2
a.1 ∈ traces(M onitor) and it has
odd length. According to our above computation of the semantics for Monitor
holds:
This results in
This chapter introduced the process algebra Csp as means to model and
analyse concurrent systems.
Concerning learning Csp, cf. Sect. 3.2, the ATM example introduced the
syntax of the language. Based on the jet engine controller example, the seman-
tic concepts of Csp were sketched, namely its operational and denotational
semantics. Using the Buffer example, the need for extending observations
from traces to failures was demonstrated. Also, together with the Communi-
cation System example, the idea of refinement was introduced.
Utilising the Children’s Puzzle, cf. Sect. 3.3, the power of different tools
realising the methods part of Csp was discussed: with simulation one can
obtain results on a single run, with model checking one can analyse all runs
of a system, with theorem proving one can analyse a class of systems. Finally,
using tools such CSP++ it is possible to automatically translate Csp pro-
cesses into programs in a programming language.
The section on semantics and analysis, cf. Sect. 3.4, finally provides point-
ers to the more advanced theory of Csp: its denotational and axiomatic
semantics, and how to develop analysis methods.
Current research on Csp still concerns its foundations, see the above men-
tioned paper on “platonic Csp models” [Ros08]. There is also ongoing work
on making automatic verification more efficient and thus to make the for-
mal verification of concurrent system scalable, see, e.g., [AGR19]. Another
stream is, as for nearly all specification formalisms, the question of how
Csp specifications relate to implementations. Transformational approaches
include JCSP [Wel, WBM07] and CSP++ [Gar15, Gar05]—see Sect. 3.3.4.
Another paradigm is to systematically test from Csp specifications, see, e.g.,
[CG07, KRS07, KRS08]. The third stream of current research concerns Csp
extensions. One longstanding question is how to deal with data in the con-
text of Csp. CspM [Sca98] includes a functional programming language for
data description. CIRCUS, see, e.g., [OCW09], combines the Z formalism
with Csp, Csp-OZ [Fis97] provides a combination with Object-Z. Csp-Casl
[Rog06] uses the algebraic specification language Casl (see Chap. 4) for data
specification. Another longstanding topic is the extension of Csp by time.
Here, Schneider’s book [Sch00] presents an established and well worked-out
setting. Work by, e.g., Ouaknine and Worrel [OW03], however, demonstrates
that fundamental questions concerning timed Csp models are still open.
Other Csp extensions offer primitives that allow one to model hybrid sys-
tems [LLQ10], probabilistic systems [AHTG11], or to combine event based
and state based reasoning [ST05].
References
[BPFS] Tom Bohman, Oleg Pikhurko, Alan Frieze, and Danny Sleator. Puzzle 6: Uni-
form candy distribution. http://www.cs.cmu.edu/puzzle/puzzle6.html, Last
accessed: August 2021.
[BPS98] Bettina Buth, Jan Peleska, and Hui Shi. Combining methods for the livelock
analysis of a fault-tolerant system. In AMAST, LNCS 1548. Springer, 1998.
[CG07] Ana Cavalcanti and Marie-Claude Gaudel. Testing for refinement in CSP. In
9th International Conference on Formal Engineering Methods, LNCS 4789.
Springer, 2007.
[Fis97] Clemens Fischer. CSP-OZ: a combination of object-Z and CSP. In Formal meth-
ods for open object-based distributed systems. Chapman & Hall, 1997.
[Gar05] Bill Gardner. Converging CSP specifications and C++ programming via selec-
tive formalism. ACM Transactions on Embedded Computing Systems, 4(2),
2005.
[Gar15] Bill Gardner, 2015. http://www.uoguelph.ca/~gardnerw/csp++/, Last accessed
August 2021.
[GRS04] Andy Gimblett, Markus Roggenbach, and Bernd-Holger Schlingloff. Towards a
formal specification of an electronic payment system in CSP-CASL. In WADT,
LNCS 3423. Springer, 2004.
[HKRS09] Greg Holland, Temesghen Kahsai, Markus Roggenbach, and Bernd-Holger
Schlingloff. Towards formal testing of jet engine rolls-royce BR725. In Proc. 18th
Int. Conf on Concurrency, Specification and Programming, Krakow, Poland,
pages 217–229, 2009.
[Hoa85] Charles Antony Richard Hoare. Communicating Sequential Processes. Prentice
Hall, 1985.
[IMNR12] Yoshinao Isobe, Faron Moller, Hoang Nga Nguyen, and Markus Roggenbach.
Safety and line capacity in railways - an approach in timed CSP. In Integrated
Formal Methods, LNCS 7321. Springer, 2012.
[IR] Yoshinao Isobe and Markus Roggenbach. Webpage on CSP-Prover. http://
staff.aist.go.jp/y-isobe/CSP-Prover/CSP-Prover.html, Last accessed:
August 2021.
[IR05] Yoshinao Isobe and Markus Roggenbach. A generic theorem prover of CSP
refinement. In TACAS 2005, LNCS 3440. Springer, 2005.
[IR06] Yoshinao Isobe and Markus Roggenbach. A complete axiomatic semantics for
the CSP stable-failures model. In CONCUR 2006, LNCS 4137. Springer, 2006.
[IR07] Yoshinao Isobe and Markus Roggenbach. Proof principles of CSP - CSP-Prover
in practice. In Dynamics in Logistics. Springer, 2007.
[IR08] Yoshinao Isobe and Markus Roggenbach. CSP-Prover - a proof tool for the
verification of scalable concurrent systems. Japan Society for Software Science
and Technology, Computer Software, 25, 2008.
[IRG05] Yoshinao Isobe, Markus Roggenbach, and Stefan Gruner. Extending CSP-
Prover by deadlock-analysis: Towards the verification of systolic arrays. In
FOSE 2005, Japanese Lecture Notes Series 31. Kindai-kagaku-sha, 2005.
[KRS07] Temesghen Kahsai, Markus Roggenbach, and Bernd-Holger Schlingloff.
Specification-based testing for refinement. In SEFM 2007. IEEE Computer
Society, 2007.
[KRS08] Temesghen Kahsai, Markus Roggenbach, and Bernd-Holger Schlingloff.
Specification-based testing for software product lines. In SEFM 2008. IEEE
Computer Society, 2008.
[LLQ10] Jiang Liu, Jidong Lv, Zhao Quan, Naijun Zhan, Hengjun Zhao, Chaochen Zhou,
and Liang Zou. A calculus for Hybrid CSP. In Programming Languages and
Systems, LNCS 6461. Springer, 2010.
[Mil89] Robin Milner. Communication and concurrency. Prentice Hall, 1989.
[MK06] Jeff Magee and Jeff Kramer. Concurrency: State Models & Java Programs.
Wiley, 2nd edition, 2006.
3 The Process Algebra CSP 197
[MPW92] Robin Milner, Joachim Parrow, and David Walker. A calculus of mobile pro-
cesses, I. Inf. Comput., 100(1), 1992.
[OCW09] Marcel Oliveira, Ana Cavalcanti, and Jim Woodcock. A UTP semantics for
Circus. Formal Asp. Comput., 21(1-2), 2009.
[OW03] J. Ouaknine and J. Worrell. Timed CSP = closed timed ε-automata. Nordic
Journal of Computing, 10:1–35, 2003.
[PB99] Jan Peleska and Bettina Buth. Formal methods for the international space
station ISS. In Correct System Design, LNCS 1710. Springer, 1999.
[Rog06] Markus Roggenbach. CSP-CASL: A new integration of process algebra and
algebraic specification. Theoretical Computer Science, 354(1):42–71, 2006.
[Ros98] A.W. Roscoe. The theory and practice of concurrency. Prentice Hall, 1998.
[Ros03] A. W. Roscoe. On the expressive power of CSP refinement. Formal Aspects of
Computing, 17, 2003.
[Ros08] A. W. Roscoe. The three platonic models of divergence-strict CSP. In Theoret-
ical Aspects of Computing, LNCS 5160. Springer, 2008.
[Ros10] A.W. Roscoe. Understanding Concurrent Systems. Springer, 2010.
[Sca98] Bryan Scattergood. The Semantics and Implementation of Machine-Readable
CSP, 1998. DPhil thesis, University of Oxford.
[Sch00] Steve A. Schneider. Concurrent and Real-time Systems: the CSP Approach.
Wiley, 2000.
[SNW96] Vladimiro Sassone, Mogens Nielsen, and Glynn Winskel. Models for concur-
rency: Towards a classification. Theor. Comput. Sci., 170(1-2):297–348, 1996.
[ST05] Steve Schneider and Helen Treharne. CSP theorems for communicating B
machines. Formal Asp. Comput., 17(4):390–422, 2005.
[vG01] R.J. van Glabbeek. The linear time-branching time spectrum I – the semantics
of concrete, sequential processes. In Handbook of Process Algebra. Elsevier,
2001.
[WBM07] Peter Welch, Neil Brown, James Moores, Kevin Chalmers, and Bernhard Sputh.
Integrating and extending JCSP. In CPA 2007. IOS Press, 2007.
[Wel] Peter Welch. http://www.cs.kent.ac.uk/projects/ofa/jcsp/, Last accessed:
August 2021.
[Win93] Glynn Winskel. The formal semantics of programming languages: an introduc-
tion. MIT Press, 1993.
[Win02] Kirsten Winter. Model checking railway interlocking systems. Australian Com-
puter Science Communications, 24(1), 2002.
Part II
Methods
Chapter 4
Algebraic Specification in CASL
4.1 Introduction
Your aunt Erna has one of her generous days, promises to buy you a smart-
phone, and asks: “which phone do you want?” You explain to her what fea-
tures are important to you, but leave it to her to pick the phone—after all,
she is being generous enough. So, you might state that you want a specific
brand, you have ideas concerning the tech-spec of the cameras, e.g., how
many cameras there should be and and how many pixels they should have,
weight and size of the phone, as well as the battery life, etc.
Your smart-phone description can be seen as a typical algebraic specifica-
tion. Namely, rather than describing how the object of your desire shall be
Markus Roggenbach
Swansea University, Wales, United Kingdom
Liam O’Reilly
Swansea University, Wales, United Kingdom
built (exact camera part, which specific battery to put in, how the phone is
built internally in order to be light enough, etc.), you are speaking just about
the properties that the phone is supposed to have. In terms of algebraic spec-
ification, you are stating axioms that shall hold. Any phone that has these
properties, i.e., for which the stated axioms hold, would satisfy you. This is
typical for algebraic specification, which usually is classified as a ‘property-
oriented’ Formal Method, in contrast to ‘model-oriented’ methods—further
discussion on taxonomy can be found in Sect. 1.2.3. What you have done is to
narrow down the set of all smart-phones to a pool of acceptable ones. In terms
of algebraic specification, the ‘meaning’, i.e., semantics of your smart-phone
description, is the collection of all smart-phones which fulfill your wishes.
After studying the pool of acceptable smart-phones, you might discover
that it contains some you actually don’t like. In that case, you would start to
add further axioms to narrow things down. This is not without risk, however,
you might end up with an empty pool because your demands can’t be fulfilled.
In algebraic specification, in this case one speaks of an empty model class.
For simple specifications of this kind, natural language will suffice. How-
ever, for building complex technical systems, tool support is needed to analyze
various aspects of a specification, e.g., the model class of what one has speci-
fied. In this chapter we will study the algebraic specification language Casl,
which allows one to write logical axioms and comes with tool support for
parsing, static analysis, theorem proving, and testing—to name just a few.
As illustrated in the introduction to this book in Chap. 1, Formal Methods
can play many roles in the software life-cycle. For this chapter, we have chosen
some of the many ways that algebraic specification can facilitate software
engineering, namely how to formulate concise requirements, how to analyze
requirements for consistency, how to apply automated random testing for
quality assurance in an invent & verify software production process, and how
to use it to verify software designs.
This chapter will emphasise specification practice, where a naive under-
standing of logic will suffice. A discussion of the theoretical background
of the logic underlying Casl can be found in Sect. 2.4.3. Casl uses the
logic SubPCFOL= , i.e., we have a first-order logic (“FOL”) with subsort-
ing (“Sub”), partiality (“P”), sort generations constraints (“C”) and equality
(indicated by = ) available. In this chapter we will not consider subsorting.
We will look into the sublanguage PCFOL= of Casl.
This chapter is organised as follows. First, we introduce Casl syntax and
semantics; discuss how to use automated theorem proving to establish prop-
erties of specifications; and show how to test Java programs against Casl
specifications. Then—inspired by an industrial application of Formal Meth-
ods –we illustrate how Casl can be used to verify control programs. We
conclude this chapter by discussing some of the various specification struc-
turing mechanisms that Casl offers.
4 Algebraic Specification in CASL 203
4.2.1 Modelling
Casl Signatures
spec DatabaseSignature =
sorts Database, Name, Number
ops initial : Database;
lookUp : Database × Name →? Number ;
update : Database × Name × Number → Database;
delete : Database × Name → Database
pred isEmpty : Database
end
Casl specifications start with the keyword spec. They have a name, in
the example Database-Signature, which is separated with an equal sign
from the specification body. After the keyword sorts (or, equivalently, sort)
one declares sort symbols. After the keyword ops (or, equivalently, op), one
declares function symbols including their arity. For partial function symbols,
the arrow is decorated with a “?” in order to indicate partiality. After the
keyword pred (or, equivalently, preds) one declares predicate symbols and
their arity. It is optional to close a Casl specification with the keyword
end—see Appendix C for the Casl grammar.
4 Algebraic Specification in CASL 205
Casl Formulae
The next step in modelling is to give axioms in the form of PCFOL= formulae,
which define the interplay between the operation and predicate symbols.
spec OneSort =
sort s
end
Taking the operations initial and update as constructors, our axioms
systematically cover how the operations lookUp and delete and the pred-
icate isEmpty interact with them:
• In the state initial the database shall have no entries. Consequently,
observing this state with the lookUp function yields no result—
see %(non def initial)%. When there is at least one entry in the
database, we might obtain a result when observing it: Should the
most recent entry match the lookUp request, the number of the
entry is to be returned—see %(name found)%; otherwise, we have
to inspect the previous entries—see %(name not found)%.
• Deleting an entry in the initial state shall have no effect—see
%(delete initial)%. When the database has at least one entry, and
the most recent entry is for the name which we want to delete,
we take this entry away and look for further, earlier entries—see
%(delete found)%. If the most recent entry, however, was not for
the name to be deleted, the most recent entry is preserved and we
look for earlier entries—see %(name not found)%.
• Finally, only the initial database is empty—see %(def isEmpty)%.
In our setting, axioms in Casl are PCFOL= formulae. They are stated in
the Casl specification text after a bullet point “•”. Variables can be declared
in one go for several axioms, e.g., ∀ db : Database; name, name1, name2 :
Name; number : Number . However, it is equally possible to declare the vari-
ables for every axiom separately. For reference, axioms can be given a label,
e.g., %(name not found)%. In the Casl static semantics, the phrases deriv-
able from the non-terminal FORMULA of the Casl grammar yield PCFOL=
formulae.
4 Algebraic Specification in CASL 207
R {X | X ∈ S, X ∈
/ X}. (4.1)
208 M. Roggenbach, L. O’Reilly
Now, Mod (OneSort) can’t be a set: assume it was be a set; then S must
be a set too, as it is formed by rules from naive set theory (projection to
a component, union of two sets); but then R must be a set as well, as it is
again formed according to the rules of naive set theory (forming a new set
by restriction); as seen above, R is not a set; thus, Mod (OneSort) is not a
set. Thus, in general Mod (sp) is a class rather than a set.
Historical note. Bertrand Russell (1872–1970), the inventor of this paradox,
was a philosopher, mathematician and a global intellectual from an English,
aristocratic family, who happened to have been born in South Wales and
lived the last part of his life in Snowdonia, in North Wales, UK.
4.2.2 Validating
Using the Heterogeneous Tool Set Hets [MML07] and the auto-
mated theorem prover SPASS, we can prove that our specification
has all the intended properties—see Fig. 4.1: in the “Goals” column,
all of our intended properties are ticked with a “+”, indicating that
SPASS could derive them from the given axiomatic basis; the sub-
window in the right lower corner displays for the highlighted goal
deleting all entries leads to an empty database, which axioms of
the specification SPASS was using in order to establish this goal as a
theorem.
The tool Hets1 reports the proof status as follows: “A proved goal is indi-
cated by a “+”, a “-” indicates a disproved goal, a space denotes an open
goal, and a “x” denotes an inconsistent specification”.2 An open goal can
arise from the fact that first-order logic is undecidable; another reason can
1 Available at http://hets.eu.
2 See the HETS User Guide, available at https://sefm-book.github.io.
210 M. Roggenbach, L. O’Reilly
Fig. 4.1 Snapshot of Hets validating the database specification with the theorem prover
SPASS
be that neither the goal nor its negation is a consequence of the specifica-
tion. If a goal is a consequence of the specification, however, appears open in
SPASS this is usually for the reason that the search space that is too large:
the theorem prover SPASS could not cover in within the allotted time set by
the user or with the available memory.
The above specifications show that in Casl one can structure specifica-
tions, namely one can import named specifications and then extend them
after the keyword then. In UseCaseSetup we first import the specification
Database, which we then extend by entities that populate the sorts. For the
time being, we will use the Casl structuring constructs import and exten-
sions in a naive way. They can be flattened out as follows: an import can
be resolved by substituting the specification text for the name; the keyword
then can be removed by stitching specification parts together. In Sect. 4.4
we will discuss the Casl structuring language in detail.
More concisely, regarding the static and the model semantics of Casl, this
naive view results in:
• the signature of the above specification is the union of all symbols declared
in the various parts;
• the axioms of the specification are given by the union of all axioms stated
in the various parts;
• the model class of the specification consists of all models for the signature
in which the axioms hold.
4 Algebraic Specification in CASL 211
The annotation triggers tools to treat the axioms stated in sp as intended
consequences of sp, i.e., as theorems that shall be proven using the axioms
stated in sp.
Concerning the question of validating a specification, the fundamental
question is when to stop validating. Are eight axioms enough? Would twenty
axioms give a better assurance that the specification expresses what we want?
This question is still an open research topic.
We can, for example, consider an abstract property such as the commuta-
tivity of the update operation:
(hugo, 4711), (erna, 17) =
(erna, 17), (hugo, 4711)
As lists, they are different. However, they map the same numbers to the
names under lookUp.
A model where %(general update commutativity)% does hold is given
when the sort Database is represented by maps:
erna
→ 17,
hugo
→ 4711
As a map has unique keys with updates overwriting, we can give only
one representation, i.e., %(general update commutativity)% holds.
In order to prove consistency, one thus has to provide a model of the spec-
ification. For simple specifications, this can be done manually or by making
use of a so-called model finder such as Darwin. For complex specifications,
Lüth et al. have implemented a Casl consistency checker [LRS04], which is
based on a consistency calculus that allows one to reduce the question of
consistency for a complex specification to the question of consistency for a
simpler specification.
For our example, we first explicitly define an element of the model class:
name1 = name2 ⇒
lookUp(update(db, name1, number), name2) = number
4 Algebraic Specification in CASL 215
The above model M might have come as a surprise. All its carrier sets are
finite. The carrier set of Database indicates only if the database is empty, or
that something is stored for h, indicated by value h stored, etc. One would
expect a database to store actual data and not simply a flag indicating that
data has been stored.
However, up to now there have been no properties stated on what kind
of names or numbers the database shall deal with. Concerning the software
development process, the above database specification is still on the require-
ments level, i.e., many design decisions have still to be taken, e.g., the con-
crete data formats for the sorts Name and Number. This level of abstraction is
achieved by under-specification, i.e., the stated axioms allow ‘different’ imple-
mentations, including the intended one, but also not yet excluding “strange”
models such as M. As seen above, already such an under-specified, formal
requirement specification is useful: it can be validated to exhibit expected
properties, as demonstrated for the specification Database.
Proving that all the axioms hold in a model is a tedious, time consuming,
and error prone process. Thus, tool support would be worthwhile. In the
following we discuss how to use theorem proving for this task. To this end,
we (i) encode a (finite) model in Casl (up to isomorphism, see Sect. 2.3.1),
and (ii) prove that this model has the desired properties.
Given a Σ = (S, T F, P F, P ) and a Σ-model M for a signature with finite
carrier sets, we can represent M in a Casl specification spM as follows:
The above example makes use of the Casl free type construct. In general,
this so-called sort generation constraint is an abbreviation for some signature
declarations accompanied by higher order formulae. In our context, we use
the free type only as a useful abbreviations for elements of first-order logic,
e.g.,
free type Name ::= h | e
is a shorthand for
sort Name
ops h, e : Name
•¬h =e %(no confusion)%
• ∀ x : Name • x = h ∨ x = e %(no junk)%
i.e., it declares a sort name Name, it declares constants h and e of type Name,
ensures that the declared constants are pairwise different %(no confusion)%
and that the carrier set of Name includes only the interpretation of these
constants %(no junk)%. For more details, see Definition 18 in Chap. 2.
Another Casl element is the view specification. A view has a name,
in our case consistency, and links two specifications with each other, a
source specification, in our case UseCaseSetUp, and a target specification,
in our case MyModel. A view holds if each model of the target specification
is a model of the source specification. In the case that source and target
specification have different signatures, one considers the reduct of each model
of the target specification.
Thus, we have now seen two ways of producing proof obligations in Hets:
the Casl view and the Casl extension then %implies. It is up to the spec-
ifier which element to use. A view has the advantage that the properties
stated in the source specification can be used in the context of different ver-
ifications. In contrast, properties stated after a then %implies are part of
the specification to be verified.
The final new Casl element are comments to the specification text. They
start with %% and last to the end of the line.
Reflecting on the above model encoding algorithm, given a model M over
a signature Σ = (S, T F, P F, P ), by construction spM has the signature Σ =
(S, T F ∪ {x : s |x ∈ M(s), s ∈ S}, P F, P ), and M ∈ Mod(spM ), where M
is identical to M on the symbols from Σ and M (x : s) = x for x ∈ M(s),
s ∈ S. The consistency of spM can be proven with the consistency calculus
for Casl presented in [RS01]. Yet another approach to consistency can be
found in [CMM13].
218 M. Roggenbach, L. O’Reilly
ConGu [CLV10] is a tool that allows for automated random testing of Java
code from algebraic specifications via run-time monitoring. ConGu defines a
sublanguage of Casl, however, with a different concrete syntax.
In general, random testing is considered to be weak compared to more
involved testing approaches (see, e.g., Chap. 5). However, when guided by
axioms, as in ConGu, it turns out to be a powerful verification technique (as
understood in the context of Software Engineering, cf. Sect. 1.2.1). A similar
approach is also used by the tool JUnit-Quickcheck [HNSA16].
Testing Setup
When performing automated random testing using ConGu, the following four
components are needed:
refinement
Name is String
Number is String
Database is Database {
initial : --> Database
is Database () ;
update : Database name : Name number : Number --> Database
is void update ( String name , String number ) ;
lookup : Database name : Name - - >? Number
is String lookup ( String name ) ;
delete : Database name : Name --> Database
is void delete ( String name ) ;
contains : Database name : Name
is boolean contains ( String name ) ;
}
end refinement
The SUT can consist out of several classes. Here, these are the standard
String class and our Database implementation.
One possible implementation of our database could use a linked list to store
the entries (pairs of name and phone number). With a correct implementation
using the linked list approach one might obtain the following error-free output
from the random runner:
4 Algebraic Specification in CASL 221
Linked-Lists and Binary Search Trees are just two of the many data struc-
tures that can be used to implement a database. The above examples demon-
strate that there can be several different correct implementations for one
algebraic specification.
222 M. Roggenbach, L. O’Reilly
Finding Bugs
ConGu can find such a bug with random testing. In our experiments it
was detected after randomly executing about 10 tests. Below is a
typical error report:
Database before : Head -> Erwin :857 -> Hugo :293 -> null
Updating : Erwin to the number 413
Exception in thread " main "
runtime . exceptions . P o s t c o n d i t i o n E x c e p t i o n : Axiom :
( lookup ( update ( db , name1 , number ) , name2 ) = number )
if
( name1 = name2 ) ;
from Database
Context variables :
name1 : Name ;* = " Erwin "
name2 : Name ;* = " Erwin "
number : Number ;* = " 413 "
db : Database ;* = " Head -> Erwin :857 -> Hugo :293
-> null "
Context term nodes :
update ( db , name1 , number ) = " Head -> Erwin :413 ->
Erwin :857 -> Hugo :293 -> null "
When entering the specification into the ConGu system, the specifier might
make a typo such as forgetting a negation or adding one:
Context variables :
name1 : Name ;* = " Hugo "
name2 : Name ;* = " Hugo "
number : Number ;* = " 832 "
db : Database ;* = " Head -> Hugo :144 -> null "
Context term nodes :
update ( db , name1 , number ) = " Head -> Hugo :832 -> null "
lookup ( update ( db , name1 , number ) , name2 ) = " 832 "
lookup ( db , name2 ) = " 144 "
Both Casl and ConGu take the approach of so-called loose semantics—see
the definition under “Model semantics of Casl specifications” in Sect. 4.2.1.
This approach is discussed in Sect. 2.3.1 in the Chap. 2, “Logics for Software
224 M. Roggenbach, L. O’Reilly
Engineering”. A Java SUT represents one model in the class of all possible
models. It is said to be correct if it falls within the model class of the speci-
fication. The ConGu publications provide technically detailed discussions of
the link between the world of abstract data types and their implementation
in Java that justify the run-time monitoring approach taken. In Chap. 5 on
Testing, we will discuss a different approach for test generation from algebraic
specifications, where we detail how to relate specifications and programs.
Fig. 4.2 A Pelican crossing. R, A, and G represent red, amber and green lights, respec-
tively
The non visual indicator is active when the pedestrian green pictogram
is lit (non flashing).
226 M. Roggenbach, L. O’Reilly
It is clear that whilst the above are necessary safety conditions they are by
no means sufficient. In verification practice, finding the ‘right’ safety condi-
tions is an art. Risk analysis techniques can support the process of identifying
which safety conditions are most important.
After initialisation of the system’s state, the PLC runs in a non terminating
loop. This loop consists of three steps: First, the PLC reads Input, a set of
values; based on this Input and the PLC’s current State, the PLC computes
its next state State’ which also includes some Output’ values; finally, the
PLC writes Output’ and updates its state.
Ladder Logic, defined in the IEC standard 61131 [IEC03], is a graphi-
cal programming language for PLCs. It gets its name from the ladder like
appearance of its programs and is widely used, e.g., in train control systems.
From a mathematical point of view, Ladder Logic is a subset of Propositional
Logic. In Ladder Logic, Input, State and State’ are sets of Boolean variables,
where Output is a subset of State (and Output’ is a subset of State’).
In the context of PLCs programmed in Ladder Logic, there is a variety of
common initialisation procedures. One of these is to set all state variables to
false and run the program once.
spec TransitionRelation =
preds button, request, old sh, old sl, sh, sl, pg, pgf, pr, tg,
ta, tr, taf : ()
preds button’, request’, old sh’, old sl’, sh’, sl’, pg’, pgf ’, pr’,
tg’, ta’, tr’, taf ’ : ()
• old sh’ ⇔ sh
• old sl’ ⇔ sl
• sh’ ⇔ (old sh’ ∧ ¬ old sl’ ) ∨ (¬ old sh’ ∧ old sl’ )
• sl’ ⇔ (old sh’ ∧ ¬ old sl’ ) ∨ (¬ request ∧ button ∧ ¬ old sl’ )
228 M. Roggenbach, L. O’Reilly
• request’
⇔ (button ∧ ¬ old sh’ ) ∨ (button ∧ ¬ old sl’ )
∨ (request ∧ ¬ button ∧ ¬ old sh’ )
∨ (request ∧ ¬ button ∧ ¬ old sl’ )
• pg’ ⇔ old sh’ ∧ ¬ old sl’
• pgf ’ ⇔ old sh’ ∧ old sl’
• pr’ ⇔ ¬ old sh’
• tg’ ⇔ (¬ old sh’ ∧ ¬ old sl’ ) ∨ (¬ button ∧ ¬ request)
• ta’ ⇔ ¬ old sh’ ∧ old sl’
• tr’ ⇔ old sh’ ∧ ¬ old sl’
• taf ’ ⇔ old sh’ ∧ old sl’
end
suffix meaning
g light shows green
r light shows red
a light shows amber
gf light shows flashing
af light shows amber flashing
This axiom can be read as: if in current cycle of the PLC both state
variables old sh’ and old sl’ are true, then the traffic light will show
amber flashing in the next cycle.
4 Algebraic Specification in CASL 229
Our program abstracts from the question of how long a traffic light
shall stay green or red. In order to deal with time, PLCs offer special
boolean variables for setting a timer and for obtaining the information
that a fixed time interval has passed.
(n ≥ 0; mi > 0 and si are sort names for 1 ≤ i ≤ n; vi,j are variable names
for 1 ≤ i ≤ n, 1 ≤ j ≤ mi ; F is a formula in first-order logic) The equivalence
is universally quantified over the declared argument variables (which must
be distinct, and are the only free variables allowed in F ).
Analogously, after the keyword op one can write
The following theorem3 has been stated as rule (def1) in the consistency
calculus by Roggenbach and Schröder [RS01]:
Theorem 1 If BI is an operation or a predicate definition for a symbol which
is new over a specification sp, then the annotation def holds in
Proof We prove the theorem only for the case that BI is a predicate definition
as given in equivalence 4.3 for a predicate symbol p. The case of an operation
definition is analogous.
Let M be a model of sp. Define for each element e ∈ M (s1 )m1 × . . . ×
M (sn )mn a variable evaluation νe with νe (vi,j ) = e(i−1 mk )+j , i.e., the vari-
i−1
k=1
able vi,j obtains under νe the component with index ( k=1 mk ) + j from the
vector e. Define
• M (p)(e) = νe (F ) and
• M (x) = M (x) for symbols x = p.
M clearly is a model of sp then %def BI: by construction, equivalence 4.3
holds over M . Furthermore, there is no other model M of the specification
of sp then %def BI, which is identical with M on the symbols of sp: choosing
a value M (p)(e) different from M (p)(e) would falsify equivalence 4.3. Thus,
the extension is a definitional one.
One can associate an automaton with a ladder logic formula. This automaton
has interpretations of the set of propositional variables I ∪C as its states, i.e.,
the configurations of the PLC. In order to define the automaton’s transition
relation, we introduce paired valuations. Here, the function unprime deletes
the prime from a variable.
Definition 6 (Paired valuations) Given a finite set of input variables I, a
finite set of state variables C, and valuations μ, ν : (I ∪ C) → {0, 1} we define
the paired valuation μ ; ν : (I ∪ C ∪ I ∪ C ) → {0, 1} where
μ(x) if x ∈ I ∪ C
μ ; ν(x) =
ν(unprime(x)) if x ∈ I ∪ C .
The models M of our Casl specification are exactly these paired valuations
μ ; ν.
3Note that this theorem relies on the fact that Casl signatures do not include variables.
This is in contrast to signatures as introduced in Chap. 2.
232 M. Roggenbach, L. O’Reilly
With the associated automaton in mind, we can now formalise safety condi-
tions for our PLC as propositional formulae and make precise, what safety
verification shall mean.
We can manually check that this holds for the automaton depicted
in Fig. 4.3.
0
0
0000, tg, pr
1
1
0111, tg, pr
1 0
1 1
1 0
1 0
1111, tr, pg 1110, tr, pg
1 0
1 0
0001, taf, pgf 0000, taf, pgf
Fig. 4.3 The finite automaton associated with the Casl specification TransitionRela-
tion
4 Algebraic Specification in CASL 235
More formally, we define the verification problem for a ladder logic formula
ψ for a verification condition ϕ:
Definition 8 (The verification problem for ladder logic programs)
A(ψ) |= ϕ
spec TransistionsAreSafe = Ψ
then %implies
• ϕ ⇒ ϕ
end
236 M. Roggenbach, L. O’Reilly
Some safety conditions hold for the over approximation of the state space:
However, for other safety conditions, due to the over approximation of the
state space, inductive certification might fail:
4 Algebraic Specification in CASL 237
spec TransitionsAreSafeWithInvariant = Ψ
then %implies
• ϕ ∧ I ⇒ ϕ
end
In general, invariants are hard to find. They might arise from the appli-
cation domain (e.g., a Ladder Logic program reads from a sensor a value in
{0, 1, . . . , 5} and uses three boolean variables v2 v1 v0 to represent the binary
value of the read-in integer—i.e., the values 110 and 111 will never appear in
the reachable states) or be a property of the program itself: there is a rich
literature on automatic invariant detection of programs.
seen in Example 44.7 that the initial states are safe for vehicles. Thus, it
remains to show that safety for vehicles is preserved under the invariant.
spec TransitionsAreSafeUnderInvariant =
TransitionRelation
then %implies
• ¬ (¬ button ∧ ¬ request ∧ (sh ∨ sl ))
∧ ((tg ∧ ¬ ta ∧ ¬ tr ∧ ¬ taf ) ∨ (¬ tg ∧ ta ∧ ¬ tr ∧ ¬ taf )
∨ (¬ tg ∧ ¬ ta ∧ tr ∧ ¬ taf ) ∨ (¬ tg ∧ ¬ ta ∧ ¬ tr ∧ taf ))
⇒ (tg’ ∧ ¬ ta’ ∧ ¬ tr’ ∧ ¬ taf ’ )
∨ (¬ tg’ ∧ ta’ ∧ ¬ tr’ ∧ ¬ taf ’ )
∨ (¬ tg’ ∧ ¬ ta’ ∧ tr’ ∧ ¬ taf ’ )
∨ (¬ tg’ ∧ ¬ ta’ ∧ ¬ tr’ ∧ taf ’ )
%(safety is preserved for vehicles under an invariant)%
end
Using Hets, we can show that this property holds, i.e., safety holds also
for traffic lights.
Note that in the above example we carefully established first that the
invariant holds in all reachable states. Had we not done this, we might have
added a formula that restricts the reachable states. In that case, we could
have produced a false negative, i.e., we could have said that the system is
safe as we found it to be safe for a subset of the reachable states.
Programming in the small and programming in the large has been an estab-
lished topic since the mid 1970s. Paraphrasing DeRemer and Kron [DK76],
programming languages require primitives such as assignment, conditional,
loop for writing functions and procedures in a module (in the small). But
they also need a “module interconnection language” for knitting those mod-
ules together (in the large). Within Casl we already have used the then
construct in order to form larger specifications from smaller ones.
When choosing a programming language for a specific project, not only
the programming paradigm is important but also which standard libraries
and third party modules are available. The same holds for specification. The
specifier does not want to re-invent the wheel. Thus, a specification language
ought to support libraries and provide constructs to utilise library contents.
Casl has taken the idea of structured specifications further than any other
specification language, and is thus, exemplary. Beyond that, the Casl struc-
turing operators have been developed in such a way that any specification
language can re-use them—provided its semantics has been written in a
240 M. Roggenbach, L. O’Reilly
4.4.1 Extension
4 Available at https://github.com/spechub/Hets-lib.
5 Available at https://sefm-book.github.io.
242 M. Roggenbach, L. O’Reilly
Two disjoint sets are not ordered by set inclusion. That is, they are
incomparable. This is different for the natural numbers. There we have
the situation that any two natural numbers are in an ordering relation.
If this property holds of a partial order, one also speaks of a total order.
In total orders, it makes sense to speak about the min (max) of two
elements. It turns out that—given the extra axiom for total orders—the
definitions of inf (sup) and min (max) coincide:
spec TotalOrder =
PartialOrder
then ∀ x, y : Elem • x ≤ y ∨ y ≤ x
ops min, max : Elem × Elem → Elem
∀ x, y : Elem
• min(x, y) = x when x ≤ y else y
• max (x, y) = x when y ≤ x else y
then %implies
∀ x, y : Elem
• min(x, y) = inf (x, y) %(min=inf)%
• max (x, y) = sup(x, y) %(max=sup)%
end
4.4.2 Union
spec Relation =
sort Elem
pred ∼ : Elem × Elem
end
No integer is smaller than itself. Such relations are called irreflexive.
For integers it is also the case that its ordering relation < is transitive:
For integers it also holds that if a number is smaller than the other, the
reverse it never the case. Such relations are called ‘asymmetric’:
It turns out that our observation on the integers is a general one: when-
ever a relation is both irreflexive and transitive, it is asymmetric.
spec StrictOrder =
IrreflexiveRelation and TransitiveRelation
then %implies
AsymmetricRelation
end
Using Hets, we we can prove that all axioms stated in the specification
AsymmetricRelation hold.
In the above example, we observe that, e.g., the sort symbol Elem is
declared twice when taking the union, once in the specification Irreflex-
iveRelation and once in the specification TransitiveRelation. The
resulting signature of the union will have the symbol Elem only once. The
reason for this is that in Casl the signature of the union is obtained by the
ordinary union of the signatures (not their disjoint union). Thus all occur-
rences of a symbol in the specifications are interpreted uniformly (rather than
244 M. Roggenbach, L. O’Reilly
4.4.3 Renaming
spec List =
sort Elem
free type List ::= [] | :: (Elem; List)
then %def
op ++ : List × List → List
∀ L, M : List; e : Elem
4 Algebraic Specification in CASL 245
Having verified that the renaming produces what was expected (the
monoid axioms are now written using the signature elements from lists),
we can state that Lists are Monoids:
The reason why SPASS can’t prove the property is that SPASS is a first-
order theorem prover while the sort generation constraint from the free type
is a higher order formula. When Casl specifications are translated by Hets
into the language of SPASS, the higher order axioms of the free types are
omitted. Without the higher order axiom it is not possible to prove that Lists
are a monoid: the induction principles required are not available.
However, it is safe to add the required induction principles (which are for-
mulae in first-order logic) to the List specification: we know that the induc-
tion principles are a consequence of the sort generation constraint coming
with the free type.
246 M. Roggenbach, L. O’Reilly
The first thing to note is that the two inductions schemes that we
add in part 2 and in part 4 do not change the model class: they are
consequences of the free type that we used in order to specify the sort
List. However, SPASS is not capable of proving them, as SPASS is a
first-order prover. With these additional axioms in place, SPASS proves
the desired result that lists are monoids.
4 Algebraic Specification in CASL 247
The above example shows that ‘automated theorem proving’ might not be
as automated as one would like it to be. In theorem proving practice, it often
is the case that one needs to find suitable lemmas and with these pave the
way for the theorem prover. Nonetheless, the example also demonstrates that
the theorem prover is of great help: none of the base or step cases needed
to be manually proven—it was rather enough to state them. Thus, loads of
tedious steps were taken care of by the theorem prover. It was enough to
‘sketch’ the proof.
248 M. Roggenbach, L. O’Reilly
4.4.4 Libraries
6 Available at https://github.com/spechub/Hets-lib.
4 Algebraic Specification in CASL 249
See the Casl reference manual [Mos04] for a thorough discussion of instan-
tiation, including the general case of instantiating specifications with several
parameters.
4 Algebraic Specification in CASL 251
We need to map the sort symbol Elem from TotalOrder to the sort
symbol Nat from Nat, further the specification TotalOrder includes
the operation symbols inf and sup which—as proven in Example 45—
can be identified with min and max, resp.
We refrain from discharging the proof obligations arising from this
instantiation: using SPASS they could be proven inductively, following
the ideas discussed in Example 47.1.
Note, that again the “same name same thing” principle applies to this
specification: there are numerous elements declared and stated several
times in SortedListWithLengt.
When we now try to instantiate SortedListWithLengtNoNat
with the the specification Nat, we obtain the error message:
Symbols shared between actual parameter and body must be in formal param-
eter.
Here, we take the specification Nat itself as the specification with the
shared symbols. With this construction we can write the desired instan-
tiation:
spec SortedNatListWithLength =
SortedListWithLength
[Nat fit sort Elem
→ Nat, ops inf
→ min, sup
→ max ]
end
4.4.6 Hiding
The previously shown operators for structuring specifications share the prop-
erty that they do not change the expressivity of the specification language
used, i.e., for all specifications formed with these structuring operators, there
exists a specification without structuring operators which has the same model
class. This is not the case for the hiding operator. The hiding operator actu-
ally increases the expressivity of Casl, i.e., it allows to specify data types
that can’t be specified in Casl without hiding.
Hiding—keyword hide—removes symbols of a specification. Given a spec-
ification Sp, we write
Sp hide SY1 . . . , SYn
n ≥ 1, for obtaining a new specification, which is like Sp but with the symbols
SY1 to SYn removed. Note that sometimes more symbols than listed will be
removed in order to obtain a signature after hiding. Consider, for instance,
the following example:
spec Hugo =
sorts s, t
op o:s →t
end
spec MyDataType =
NewNat hide + , ∗
end
Utilising Hets we can obtain the Theory of MyDataType and see that
indeed MyDataType has the desired signature:
254 M. Roggenbach, L. O’Reilly
sort Nat
op 0 : Nat
op 1 : Nat
op square : Nat -> Nat
op suc : Nat -> Nat
Classical texts on algebraic specification include the books by Ehrig and Mahr
[EM85, EM90] as well as the edited volume by Astesiano, Kreowski, and
Krieg-Brückner [AKKB99]. The book by Loeckx, Ehrich and Wolf [LEW97]
provides an accessible discussion of concepts central to algebraic specification,
with a focus on questions of theoretical nature. Sannella and Tarlecki have
written probably the most comprehensive compendium on the subject [ST12].
The theory of institutions, which provides the accepted method of seman-
tics definition in algebraic specification, is discussed in the book by Dia-
conescu [Dia08] as well as in the book by Sannella and Tarlecki [ST12].
The Casl Reference Manual [Mos04] is the authoritative handbook on
Casl; the Casl User Manual [BM04] provides an example based overview
on the language. Mossakowski, Meader, and Lüttich provide a scientific dis-
cussion of their Hets tool in their publication [MML07]—though Hets dates
back to the early 2000s, it is still maintained and subject to further devel-
opments. The user interface of Hets represents structured specifications as
development graphs [MAH06].
Other algebraic specification languages include ASF-SDF [BHK89], Cafe-
OBJ [DF98], and Maude [CDE+07, Ölv17].
Some researchers, among them even a few who shaped the field, perceive
algebraic specification as a closed chapter in the history of science, coming as
a nicely wrapped-up parcel where all conceivable structural results have been
achieved and light has been shone into all corners. From our perspective, this
is a misconception and large parts of the landscape remain unexplored if only
seen from the right angle. In the following, we will point the reader to some
of these uncharted territories.
As for nearly all specification languages, the link between algebraic speci-
fication and modelling as well as programming could be stronger:
• In a formally based software development, a still open issue is how to
semantically combine an algebraic specification language and a behavioural
modelling language [RBKR20], or an algebraic specification language and
a programming language. The most obvious approach here would be to
‘transport’ the modelling or programming language into the realm of alge-
braic specification. To this end, one would capture the semantics of the
modelling or programming language as a so-called institution and provide
suitable mappings to express the semantical relations between modelling,
programming and specification.
256 M. Roggenbach, L. O’Reilly
References
[BGM91] Gilles Bernot, Marie Claude Gaudel, and Bruno Marre. Software testing based
on formal specifications: A theory and a tool. Softw. Eng. J., 6(6):387–405,
November 1991.
[BHK89] J.A. Bergstra, J. Heering, and P. Klint, editors. Algebraic Specification. ACM
Press, 1989.
[Bjø17] Dines Bjørner. Manifest domains: analysis and description. Formal Aspects of
Computing, 2017.
[BM04] Michel Bidoit and Peter D. Mosses. CASL User Manual – Introduction to
Using the Common Algebraic Specification Language. Springer, 2004.
[Bol06] William Bolton. Programmable Logic Controllers. Newnes, 2006.
[Bra12] Aaron R. Bradley. Understanding ic3. In Theory and Applications of Satisfi-
ability Testing – SAT 2012, pages 1–14. Springer, 2012.
[BT87] J.A. Bergstra and J.V. Tucker. Algebraic specifications of computable and
semicomputable data types. Theoretical Computer Science, 50(2):137 – 181,
1987.
[CDE+07] Manuel Clavel, Francisco Durán, Steven Eker, Patrick Lincoln, Narciso Martı́-
Oliet, José Meseguer, and Carolyn Talcott. All About Maude - a High-
performance Logical Framework: How to Specify, Program and Verify Systems
in Rewriting Logic. Springer, 2007.
[CLV10] Pedro Crispim, Antónia Lopes, and Vasco Thudichum Vasconcelos. Runtime
verification for generic classes with ConGu 2. In Formal Methods: Foundations
and Applications, LNCS 6527, pages 33–48. Springer, 2010.
[CMM13] Mihai Codescu, Till Mossakowski, and Christian Maeder. Checking conserva-
tivity with Hets. In Conference on Algebra and Coalgebra in Computer Sci-
ence, LNCS 8089. Springer, 2013.
[DF98] Răzvan Diaconescu and Kokichi Futatsugi. CafeOBJ Report: The Language,
Proof Techniques, and Methodologies for Object-Oriented Algebraic Specifica-
tion. World Scientific, 1998
[Dia08] Razvan Diaconescu. Institution-independent Model Theory. Birkhäuser Basel,
2008.
[DK76] Franklin L. DeRemer and Hans H. Kron. Programming-in-the-large versus
programming-in-the-small. In Programmiersprachen, pages 80–89. Springer,
1976.
[EM85] Hartmut Ehrig and Bernd Mahr. Fundamentals of Algebraic Specification 1.
Springer, 1985.
[EM90] Hartmut Ehrig and Bernd Mahr. Fundamentals of Algebraic Specification 2.
Springer, 1990.
[HNSA16] John Hughes, Ulf Norell, Nicholas Smallbone, and Thomas Arts. Find more
bugs with quickcheck! In Proceedings of the 11th International Workshop on
Automation of Software Test, pages 71–77. ACM, 2016.
[IEC03] IEC. Programmable Controllers - Part 3: Programming languages. Standard
61131-3, 2003.
[Jam10] Phillip James. SAT-based model checking and its applications to train control
software. Master’s thesis, Swansea University, 2010.
[JLM+13] Phillip James, Andy Lawrence, Faron Moller, Markus Roggenbach, Monika
Seisenberger, Anton Setzer, Karim Kanso, and Simon Chadwick. Verification
of solid state interlocking programs. In SEFM 2013 Collocated Workshops,
LNCS 8368, pages 253–268. Springer, 2013.
[JR10] Phillip James and Markus Roggenbach. Automatically verifying railway inter-
lockings using SAT-based model checking. In Proceedings of AVoCS’10. Elec-
tronic Communications of the EASST, 2010.
[KMR15] Alexander Knapp, Till Mossakowski, and Markus Roggenbach. Towards an
institutional framework for heterogeneous formal development in UML – A
position paper. In Software, Services, and Systems, LNCS 8950, pages 215–
230. Springer, 2015.
258 M. Roggenbach, L. O’Reilly
Imagine that you have a friend who is an engineer and a hobby pilot. She
invites you to a trip on her brand-new self designed airplane. When you look
puzzled, she tells you not to worry—although never tested, the whole plane
had been thoroughly simulated during development. With some reluctance,
you agree to join her on the maiden flight, so the two of you take off. In the
air, the left wing makes some funny noises. When you analyze the source,
you notice that the wing flaps are frequently deployed and undeployed. You
land and check the flap motors and cables, but cannot find any problem. So,
the problem must be in the control software. You wonder how to locate the
problem. Together with your friend, you set up a hardware-in-the-loop test
Bernd-Holger Schlingloff
Humboldt University and Fraunhofer FOKUS, Berlin, Germany
Markus Roggenbach
Swansea University, Wales, United Kingdom
environment, where the aircraft sensors (wind speed, angle of attack, and lift
coefficient) and actuators (flap motors) are connected to the software in a
simulation. Yet, all of your random simulation runs do not exhibit the motor
behaviour which you experienced while flying the plane. Thus, you begin to
think about systematic ways to construct test cases.
This chapter is concerned with the application of Formal Methods to soft-
ware and systems testing. For a long time, testing had been considered to
be an inherently informal activity: after a program was written by a team
of proficient programmers, the testers would have to sit down and do some
experiments with it in order to detect potential errors. Program design and
implementation was considered to be a superior activity which required high
skills and formal rigour, whereas testing was seen as an inferior activity which
was left to those who were not capable of writing good program code. With
ever increasing complexity, competition, and quality demands, this situation
has changed. Nowadays, often programming and bug fixing is considered to
be something which can be left to third parties, but testing of complex inter-
actions and making sure that the delivered software is free of faults is of
utmost importance. With this change of attitude, the need for formal rigour
in software testing began to rise. The term “software crisis” had been coined
in the late 1960s, when the cost of producing software exceeded that of buying
hardware. Today, we are facing a similar “software quality crisis”: For many
systems, the cost of verification and validation exceeds the cost of actual
programming by a large amount. Thus, improved and more efficient methods
are needed for guaranteeing that a program meets its specification.
One of the most common methods for quality assurance of computational
systems is testing. Often, it is stated that testing is just a substitute for formal
verification with the claim that “testing can be used to show the presence
of bugs, but never to show their absence” [Dij70]. However, this viewpoint is
not quite correct. Firstly, as we will show in Sect. 5.4 later on, in combination
with theorem proving, testing can very well be used to show the absence of
errors in a particular piece of code.
Secondly, each verification activity only considers a certain aspect of a
computational system. So far, no computational system exists for which all
constituent layers (application program, middleware, operating system, hard-
ware, and development tools) have been formally specified, let alone verified.
Thus, the verification of a particular component only shows the absence of
errors in that component, not in the complete system. As an example, even if
we have verified a particular sorting algorithm, we cannot be sure whether a
payroll program using that algorithm will issue the correct paychecks. Testing
considers a system within its environment; i.e., testing the sorting algorithm
within the payroll program can reveal all sorts of problems caused by the
interaction of components.
Thirdly, contrasting verification and testing per se is not adequate, because
the two techniques try to answer different questions. In formal verification,
an algorithm or program is shown to be correct with respect to a formal
specification; i.e., one mathematical object is compared to another one. In
5 Specification-Based Testing 261
For each of these quality measures and any given system, a value can be
determined via testing. Hence there are many variants of testing: functional
testing, performance testing, robustness testing, etc. The most important
quality criterion of software, however, is correctness, i.e., the absence of fail-
ure. Thus, in this chapter we only consider testing a computational system
for correctness.
262 B.-H. Schlingloff and M. Roggenbach
interchanged; for us, an error (occurring in the human mind) is more fundamental than a
fault (occurring in an artefact).
5 Specification-Based Testing 263
As we have seen in the previous chapters, there are two dimensions in the
formal specification of systems, which could be called space and time. Specifi-
cation formalisms such as algebraic specification or first-order logic are well-
suited to describe the structural aspects of a system. In contrast, process
algebras and temporal logics focus on the dynamic aspects, on the change of
the system’s state in time.
This section deals with the generation of tests for reactive systems from
state-based models and specification formalisms. In order to understand how
test cases can be generated from such models, we first present a method of
264 B.-H. Schlingloff and M. Roggenbach
modelling reactive systems with UML state machines. Then, we will discuss
different test generation algorithms and test coverage criteria.
This example is typical for a number of similar systems. Their main char-
acteristic is that they are stateful reactive systems. That is, the system can be
in any one of a number of states. It continuously reacts to stimuli from the
environment: In any state, given a certain input, it produces a designated
output and takes a transition into a new state. Many different formalisms
have been suggested for the modelling of stateful reactive systems, including
finite automata, process algebras (see Chap. 3 on CSP), Petri nets, and oth-
ers. Testing with CSP is discussed, e.g., by Cavalcanti and Hierons [CH13].
For this example, we will use UML2 state machines.
The Unified Modeling Language UML is a standardised, general-purpose
language for modelling all sorts of computational systems. It comprises a set
5 Specification-Based Testing 265
Note that the semantics of UML determines that ‘unexpected’ events are
skipped. That is, if the machine is, e.g., in state off and an up-event is
received, it just stays in this state and the event is discarded.
The model in Fig. 5.3 can be seen as a formalisation of the informal require-
ments given in Example 49. It describes the intended behaviour of the switch,
giving a precise meaning to phrases like ‘repeatedly’ or ‘desired mode’. Usu-
ally, a UML state machine is an abstraction of an actual target system (in
our case, a video camera recorder). Such an abstraction can be used in two
ways:
• for constructing the target system by a stepwise refinement process, and
• as a source for the generation of test cases for the target system.
The first of these uses is known as ‘model-based design’ (MBD), whereas
the second one has been called ‘model-based testing’ (MBT).2 In this chapter,
MBT is discussed.
2 Note that the use of the word ‘model’ significantly differs here from its use in logic.
In MBD/MBT, a model is defined to be a purposeful abstraction of some target system,
whereas in logic a model is a semantical structure for the evaluation of formulae.
268 B.-H. Schlingloff and M. Roggenbach
There are various notions of what a test case is. In the most general sense, a
test case is the description of a (single) experiment with the SUT. A test suite
is a set of test cases; it describes a cohesive set of experiments. Depending
on the aspect of a system under test that is to be considered, test cases can
have several forms—see Fig. 5.4, which is taken from a survey by one of the
authors [WS11].
For the time being, we restrict our attention to the testing of determinis-
tic reactive systems. Thus, in this section, we consider test cases which are
sequences. (Later on, for conformance testing of nondeterministic systems, we
will generate test cases which are trees. In Sect. 5.4, we will generate input
values as test cases for functional programs.) In the most general setting, a
test case for a reactive system is a sequence of events. Here, an event can be
any action from the tester, which serves as a stimulus for the SUT. Addition-
ally, an event could also be an observable reaction of the SUT: an expected
response from the SUT, an observable behaviour, a visible transition, state
or configuration, etc.
For our purposes, a test case is a finite path of input and output actions
in the state machine. In other words, a state machine is transformed into
a directed graph. In this graph, we consider finite paths from the initial
state. The labels on the transitions of such a path form a test case. The test
generator constructs a test suite for a predefined set of test goals. A test goal
could be, e.g., to reach a certain state or transition in the machine. A goal
is covered by a test suite if there is a test case in the suite such that the
goal is contained in the test case. Different test generators support different
coverage criteria; a detailed discussion can be found in Sect. 5.2.4 below. For
example, for the criterion “all-states” a test suite with only one test case is
sufficient:
{ (dn?, 100!, dn?, 010!, dn?, 001!) }.
The criterion “all-transitions” is still satisfied by a one-element test suite:
{ (dn?, 100!, dn?, 010!, dn?, 001!, dn?, 100!, up?, 000!) }.
If we require “decision coverage”, a test generator will yield a test suite where
all branches in the model are contained:
5 Specification-Based Testing 269
different behaviour for the carburettor when the car is under test or on the road.
270 B.-H. Schlingloff and M. Roggenbach
tester can never be sure whether the other path has been exercised. However,
this situation changes if certain assumptions about the SUT can be made.
We will discuss this so-called conformance testing in Sect. 5.3 below.
So far, we have derived different sets of test cases from a state machine model
of the SUT. The next step is to defined how the execution of a test case is to
be evaluated. In Sect. 5.3, we will assume that a test case yields the “pass”
verdict if and only if the observations described in the test case can be made
during the execution. Here, we will take the more general point of view of
specification-based testing. In this view, desired properties of the system under
test are formulated in a logical specification language. Whether the execution
of a test case at an SUT passes or fails is determined by this specification
and is independent of the way of how the test case has been generated.
An execution trace, or simply trace, is the sequence of events obtained by
executing a test case. In general, the test oracle is the part of the test system
which determines whether a trace satisfies the given properties or not. In
other words, the test oracle issues a test verdict for a given trace.
For example, we might want to check that “whenever the switch is pushed
up, the power will be turned off”, “The operating mode ‘play’ is reached
by repeatedly sliding the POWER switch down at most three times”, or
“whenever the VCR switch is pushed down, one of the lamps is lit until it is
slid up again”.
Such properties can be conveniently denoted in linear temporal logic (LTL,
cf. Chap. 2). In order to formalize the properties in LTL, we have to fix the
proposition alphabet P. Here, again, we have to consider which elements of
the SUT can be observed by the tester. One approach is to use the interfaces
“ENV2SUT” and “SUT2ENV” as the set of basic propositions. Thus, e.g.,
000! indicates that the VCR turns off, and 001! that it changes into play
mode. With these, the above properties can be written as follows.
(up? ⇒ 000!)
(dn? ⇒ (001! ∨ (dn? ⇒ (001! ∨ (dn? ⇒ 001!)))))
(dn? ⇒ (¬ 000! W up?))
In the last of these formulae, we are using an unless-operator rather than
an until, since we cannot guarantee that the generated test sequences always
end in the off-state.
The test oracle takes these formulae and checks whether they are satisfied
by the execution sequences which are obtained by running the tests on the
SUT. Subsequently, we give an algorithm for checking a test execution trace
5 Specification-Based Testing 271
In this basic form, with nested temporal formulae (e.g., (ϕ1 U (ϕ2 U ϕ3 ))))
the algorithm may traverse the given execution sequence several times. It
can be improved somewhat by separating the present- and future-part of ϕ
in each step and traversing σ only once. More precise, every LTL formula
ϕ can be written as a boolean combination of formulae ϕi and ψj , where
the ϕi do not contain temporal operators and thus can be evaluated in σ0 . If
this yields no result, then ψj can be evaluated recursively on σ (1) . Havelund
and Rosu [HR01] describe an efficient implementation of this idea with the
rewriting tool MAUDE.
The result of Algorithm 7 is not necessarily the same as the result of model
checking the formula with the state machine. Model checking determines
whether the formula is satisfied for all possible paths of the state machine. In
testing, we are evaluating the oracle formulae with actual runs of the SUT,
not with some abstract model.
272 B.-H. Schlingloff and M. Roggenbach
There are various ways how to generate test cases from UML state machines
or other formal models. Let us assume that the purpose of test generation is
to find a test suite where each state of the UML state machine appears at
least once. That is, we are trying to satisfy the “all-states” coverage criterion.
Thus, for each state we have to find a sequence of events which will trigger
transitions leading into that state. There are several ways of doing so: We can
employ a forward-directed search, starting with the initial configuration and
employing a depth-first or breadth-first search for the goal. Alternatively,
we can use a backward search, starting with the goal and stepwise going
backward in order to find the initial configuration. Dijkstra’s single-source
shortest path algorithm assigns for each node in a graph its distance from a
particular node via a greedy search. Such an assignment can be used in the
backward search: Instead of choosing any predecessor, we select one with a
minimal distance to the initial state. Of course, if a state is already covered,
it is not necessary to cover it twice. Therefore, we have to maintain a list of
covered test goals.
The pseudocode of this algorithm is given in Algorithm 8 on the next page.
In this code, length is a mapping (e.g., an array) from states to N0 ∪ ∞,
giving for each state s the length of the shortest path from the initial state
s0 to s. prev and trans are mappings from states to states and transitions,
respectively, giving for each state the previous state from which, and the
transition by which it is reached on the shortest path. In the first phase,
the algorithm calculates the values for length, prev and trans via greedy
breadth-first search. Then, in the second phase, the algorithm outputs the
test cases, starting with the path to the most distant state which has not
been covered.
Obviously, since in general a model may contain cycles, it may have
infinitely many runs. If there are finitely many states, then there is a finite
test suite which covers all of these states. However, potentially infinitely many
test cases could be derived from a cyclic model. In order to be able to exe-
cute the generated test suite within a finite amount of time, a finite subset
of all possible test cases must be selected. Model coverage criteria can help
to estimate to which extent the generated test suite reaches a certain testing
goal. Typical model coverage criteria for UML state machines or Finite State
Machine testing models are
• all-states: for each state of the state machine, there is a test case which
contains this state,
• all-transitions: the same for each transition of the state machine,
• all-events: the same for each event in the alphabet, which is used in at
least one transition,
5 Specification-Based Testing 273
TS ← ∅; U ← S; // Re-initializing U ;
while(U
= {s0 }) select s ∈ U such that length[s] is maximal
// for minimizing the number of test cases;
create new empty test sequence σ;
while (// (or, equivalently, prev[s]
= undef))s
= s0 remove s from U;
insert trans[s] at the front of σ TS ← TS ∪ σ;
return TS;
are specified output reactions which could never be produced during testing,
chances are high that something is wrong with the implementation. The all-
states and all-transitions criteria are related; clearly, if the state machine
is connected, than any test suite satisfying the all-transitions criterion also
satisfies the all-states criterion. In technical terms, all-transitions subsumes
all-states. Likewise, all-transitions subsumes all-events. In a state machine
with n states and m events, the all-transitions criterion can require up to m ∗
(n − 1) test cases. For practical purposes, besides the all-transitions criterion
often the depth-n criterion is used, were n is set to the diameter of the
model, i.e., the length of the longest run in which no state appears twice.
Alternatively, n can be set to the (estimated) diameter of the SUT. The
criterion all-n-transitions is quite extensive; for n ≥ 3 this criterion often
results in a huge test suite. Clearly, all-n-transitions subsumes depth-n, and
all-(n + 1)-transitions subsumes all-n-transitions.
Automated test generation algorithms strive to produce test suites sat-
isfying a certain coverage criterion. Therefore, the choice of the coverage
criterion has significant impact on the particular algorithm and the resulting
test suite. However, none of the above criteria uniquely defines a test suite.
For the criterion depth-n there is a unique minimal test suite, namely the set
of all runs of length n, plus the set of all maximal runs (which end in a state
from which there is no transition) of length smaller than n. This set can be
easily constructed via depth-first search.
For the other coverage criteria mentioned above, the existence of a minimal
test suite can not be guaranteed. For the actual execution of a test suite, its
size is an important figure. The size of a test suite can be measured in several
ways:
• the number of all events, i.e., the sum of the length’s of all test cases,
• the cardinality, i.e., the number of test cases in the test suite,
• the number of input events, or
• a combination of these measures.
At first glance the complexity of the execution of a test suite is determined
by the number of all events which occur in it. However, often it is a very costly
operation to reset the SUT after one test in order to run the next test; hence
it is advisable to minimize the number of test cases in the test suite. Likewise,
for manual test execution, the performance of an input action can be much
more expensive than the observation of output reactions; hence the number
of (manual) inputs must be minimized.
5 Specification-Based Testing 275
To answer this question, we assume for the moment the viewpoint that the
intended behaviour of an SUT is entirely defined by the specification. That
is, an implementation is correct for a specification if and only if it exhibits
all of the specified behaviour, and nothing else.
Having fixed a suitable definition of correctness, we can formulate two
fundamental properties a test suite should possess:
• each correct implementation should pass the test suite (Soundness), and
• each implementation which is not correct with respect to the specification
should fail (Exhaustiveness).
A test suite which is sound and exhaustive is called complete for a specifi-
cation.4 In other words, given an implementation im, specification sp and a
test suite ts which is complete for sp, im is correct for sp if and only if im
passes ts. We depict this so-called “validation triangle” in Fig. 5.5.
Each test suite ts induces an equivalence relation on the set of all imple-
mentations: im1 is ts-equivalent to im2 if im1 passes ts if and only if im2
passes T . Given a specification sp, im1 is testing-equivalent to im2 if for any
complete test suite ts for sp, im1 is ts-equivalent to im2 . Testing equivalence
gives a behavioral way to characterize the class of implementations which are
correct with respect to a given specification.
Yet, in order to make the definitions precise, we need to clarify what
the observable, specified behaviour of an implementation is. When should an
SUT “pass” or “fail” a test case? In the previous subsection, we defined model
4 Note that this convention differs slightly from the use of the terms in logic, where a cal-
culus is called sound if all provable statements are true, and complete if all true statements
are provable.
276 B.-H. Schlingloff and M. Roggenbach
coverage criteria for state machine testing models. That is, the specification
consists of a state machine, from which a test suite is derived. We assumed
that the observable behaviour is defined by the states and transition of the
specification. That is, we assumed that we can observe in which state of the
testing model the SUT currently is. A complete test suite would consist, e.g.,
of all sequences of states and transitions in the specification. A test case
passes, if the respective sequence is observable while running the SUT. This
assumption leads to a very strict correctness notion: Basically, here an SUT
is correct for a specification if and only if its behaviour can be described by
a state machine which is isomorphic to the specification, i.e., has the same
states and transitions. If the SUT itself is given as a state machine, then
it must be isomorphic to the specification. (Here, we disregard the case of
two ‘identical’ transitions connecting the same states with the same trigger,
guard and effect.)
However, the assumption of observability of all internal states of an SUT
may be too strong. We might, e.g., be only able to observe the transition
labels (trigger, guard and effect). In this case, a complete test suite checks
if implementation and specification are trace-equivalent, i.e., have the same
executions. A question which still has to be discussed in this setting is whether
we can observe silent transitions, which have no trigger and effect.
Or, we might be able to observe whether a trace is completed in the spec-
ification and/or the implementation. Yet another option is whether we can
observe that specification or implementation refuse to do certain actions at
some stage. This leads to yet another equivalence relation induced by the
notion of a complete test suite. There have been many different testing equiv-
alences defined and analyzed in the literature, e.g., [dNH83, Abr87, CH93].
The most general view on testing is that the SUT is a black box to which
a tester can send arbitrary inputs, and observe only the outputs produced as
a reaction. Thus, for UML, certain triggers are declared to be inputs from
the tester to the SUT, and certain actions are declared to be outputs to the
tester. On one hand, the tester can send an input to the SUT at any time,
but does not know how this input is processed, or whether it is processed at
all. On the other hand, the tester can observe the outputs of the SUT when
they are produced, but does not know whether the SUT will emit an output
or not. Alternatively, we might say that by a suitable timeout mechanism the
tester is also able to observe whether the SUT sends an output or not, i.e.,
whether the SUT is quiescent.
In his dissertation and subsequent work [Tre93, Tre96], Tretmans formal-
ized this approach in terms of Input-Output Transition Systems (IOTS).
Definition 2 (Input-Output Transition System, IOTS) An IOTS S is a struc-
ture S = (S, I, O, Δ, s0 ), where
• S is a countable, nonempty set of states,
• L = I ∪ O is a countable set of labels or observable actions, where i ∈ I is
an input and o ∈ O is an output to the transition system (I ∩ O = ∅),
5 Specification-Based Testing 277
The ioco relation can be used to define test sets for a given specification
and black-box implementation. As mentioned above on Sect. 5.2.2, we assume
that the specification is deterministic in the sense that for any s ∈ S and
a
a ∈ L there is at most one s such that s = ⇒ s . (Note that both sp abstract
and sp refined in the above example are deterministic.)
A test case for the IOTS S = (S, I, O, Δ, s0 ) is a finite tree, where the
leafs are labelled by {pass, fail}, and the non-leaf nodes are labelled by states
from S. Formally, a test case for S is a finite transition system T = (S T , O ∪
{δ}, I, ΔT , sT0 ) such that
1. for every s ∈ S T there is a unique finite path from sT0 to s (tree property),
2. there is a mapping ι : S T → (S ∪ {pass, f ail}) with ι(sT0 ) = s0 ,
oi
3. if ι(sT ) = s and out(s) = {o1 , . . . , on }, where s =
⇒ si , then sT has at least
o
n children sT1 , . . . , sTn such that sT −→ sTi and ι(sTi ) = si or ι(sTi ) = pass.
i
Clause (5) allows to send an input to the system under test from the test case,
which is foreseen by the specification. With clause (6), it is guaranteed that
the implementation may not deadlock in a situation where the specification
allows an output. This reflects the assumption that a non-reaction of the
system under test can be observed via a timeout-mechanism.
Informally, this test case sends a dn event to the SUT, checks whether
it produces the LED pattern 100, and then sends an up and checks for
000. If the SUT shows a wrong LED pattern or does not react at all,
the test fails
For executing such a tree test case with a black-box implementation, the
test harness can
• send an input to the implementation (according to Clause (5), there is at
most one possibility to do so),
282 B.-H. Schlingloff and M. Roggenbach
return T;
since we may cover each state on the cycle an arbitrary number of times.
The question arises, which number of test cases is ‘sufficient’ to establish
that an implementation im conforms to sp? We have remarked above, that
without any knowledge of the internal structure of the SUT, we can never be
sure that we have covered all relevant parts. However, there are reasonable
assumptions which can be made on this structure. One such assumption is
that the SUT can faithfully be represented by a finite IOTS. That is, for any
unknown system under test, there exists a (still unknown) finite IOTS which
exhibits the same behaviour. The length of the maximal path in which no
state is repeated is called the diameter of the IOTS. Thus, the basic testing
hypothesis is that each SUT can be represented by an IOTS which has a
finite diameter.
Another assumption which in some cases is reasonable is that the SUT is
deterministic, i.e., repeatedly given the same input sequence from the initial
state will drive the SUT through the same sequence of internal states and
transitions. An observation to be made about this is that if sp is finite and
acyclic, then only finitely many test cases can be derived from it. Based
on this observation, for deterministic implementations, test case selection
can be based on unwinding of the specification. In particular, Simao and
Petrenko [dSSP14] assume the following:
1. the implementation has at most as many states as the specification,
2. if in any state there is a conflict between an input and an output, then the
input is selected (so-called input-eagerness).
It is shown that under these assumptions, a finite and complete test suite for
ioco can be derived by unwinding the specification.
This lemma follows from the construction of Mim and the definition of the
evaluation algorithm eval termim and evalim . It relies on the fact that with
respect to undefined values, the algorithm reflects the semantics of terms and
predicates in Casl. Formally, Lemma 1 can be shown by inductions on t and
ψ. Intuitively, it states that im passes exactly those tests which hold in Mim .
Recall from Sect. 5.3 above that a test suite ts is called complete, if it
is sound and exhaustive. It is sound if each correct implementation passes,
and exhaustive if each incorrect implementation fails. Fundamental questions
in testing are whether complete test suites exist and how they can be con-
structed. Whether a finite complete test suite exists is an additional question.
In test generation from algebraic specifications, a test case is a ground
instance of a universally quantified specification formula. Let the ‘full’ test
suite ts full (sp) of specification sp be the set of all these ground instances.
Assuming that the set of ground terms is nonempty, we may ask: Does
ts full (sp) constitute a complete test suite?
Of course, the answer to this question depends on the type of formulae
which are allowed in the specification. It turns out that if we restrict our
attention to universally quantified specification formulae ∀x1 , . . . , xn ψ, where
ψ is quantifier-free, we can prove completeness of ts full (sp):
Theorem 1 im is correct w.r.t. sp, if and only if im passes ts full (sp).
Intuitively, this theorem holds since in term-generated models, a univer-
sally quantified formula ∀x1 , . . . , xn ψ(x1 , . . . , xn ) is equivalent to the (pos-
sibly infinite) set of formulae {ψ(t1 , . . . , tn ) | t1 , . . . , tn are ground terms}.
However, since the proof is not self-evident, we give a sketch.
Proof Soundness (“only if”) is more or less obvious, since it follows from
the instantiation principle of first-order logic (see Sect. 2.4.1): |= (∀x ψ(x) ⇒
ψ(t)). According to Definition 3 above, im is correct w.r.t. sp, if and only
if Mim |= Ax(sp). Assume Mim |= Ax(sp), and let T ∈ ts full (sp) be a
test case. We have to show that im passes T . We know that there exists
a formula ϕ = ∀x1 . . . xn ψ(x1 , . . . , xn ) ∈ Ax(sp), such that T is a ground
instance ψ(t1 , . . . , tn ) of ϕ. Since Mim |= Ax(sp), in particular it holds that
5 Specification-Based Testing 293
also be formulated as follows: “if ψ fails for some x ∈ Δ, then it must also
fail for some x ∈ δ”. If this hypothesis holds, then it is sufficient to test ψ(x)
for all x ∈ δ to find out whether or not ψ(x) holds for all x ∈ Δ.
To make the hypothesis effective, δ should be ‘much smaller’ than Δ. How-
ever, the choice of δ is not arbitrary, and the validity of the test hypothesis
must be shown by some other means than testing.
demanding for humans, or which have to be done over and over again. In
professional software testing, several activities have to be performed:
• Test planning: It must be determined what the scope of the testing
process is, which goals are targeted by the testing activities, and when
and where the testing should take place.
• Test design: Abstract test cases for the identified testing goals must be
described. These abstract test cases can be denoted in informal, semi-
formal, formal, or even executable notation.
• Test development: Test data must be assembled and/or selected from
an existing pool. Furthermore, abstract test cases and concrete test data
must be combined into executable test scripts.
• Test execution: The test cases must be executed, i.e., the SUT must be
connected to the test system, it must be started, stimuli must be sent to
the SUT, and responses of the SUT must be observed (and maybe logged).
• Test evaluation: For each test, it must be determined whether it has
passed or failed. If a test case has failed, appropriate development activities
must be triggered.
• Test assessment: It must be decided when testing is to be stopped, and
whether the determined goals have been reached.
• Test documentation: Test results must be documented and archived.
Often, specific formats for test documentation are prescribed here.
• Test lifecycle management: It must be planned how testing activities
integrate into the development process (code-first or test-first approach,
agile or phase-based testing, incremental or continuous testing processes,
etc.)
• Test management: Roles and responsibilities of people involved in the
testing must be assigned and administered.
• Test tool selection: It must be determined which software tools to use
for which testing tasks.
• Test tool administration: The selected tools must be procured, installed,
and maintained.
When it comes to test automation, most software engineers focus on auto-
mated test execution. However, all of the above activities can be supported
by appropriate tools, and can be automated to a certain extent. For example,
test planning can be supported by project management tools; test develop-
ment can be supported by automatic test data generators and automated
scripting engines; and test evaluation can be automated by an executable
test oracle, e.g., based on Algorithm 7 or Algorithm 10.
Popular testing tools can be classified into the following categories:
For each of these categories, dozens of tools are available, both com-
mercially and from academic providers. Specification-based testing tools are
mostly in the category “test design tools”. In fact, test generation from for-
mal specifications can be seen as a kind of automated test design. However,
the LTL monitoring approach described in Sect. 5.2.3 is an automated test
evaluation.
Model-based testing tools usually consist of two subcomponents:
(a) A graphical editor or modelling environment which allows to draw models
and check their syntax, and
(b) a test generator transforming the model into abstract test cases according
to certain quality criteria.
A typical test tool landscape including a model-based testing tool is
depicted in Fig. 5.6. Core components are shaded in grey, whereas report-
ing features are depicted in white.
Here, a requirements management tool is used to elicit, document, ana-
lyze and control the intended capabilities of a system. These requirements are
used as a basis for modelling the system; elements in the model are linked
to requirements and vice versa. This allows to trace the use of requirements
in the system’s development. The model can be executed in a suitable sim-
ulator, which allows to animate it and validate whether it conforms to the
expectations. The test generation component of the model-based testing tool
transforms the model into a test suite. It may contain a reporting component,
which measures model or requirements coverage and helps to trace require-
ments in the test suite. Results of test case generation are handed over to
298 B.-H. Schlingloff and M. Roggenbach
a test management system and a test execution engine. The test execution
engine is responsible for the connection of the testing system with the sys-
tem under test. It replaces abstract events by concrete signals, messages,
parameters or procedure calls, invokes the SUT with these concrete stimuli,
and records its responses. The test management system keeps track of which
tests have been executed with which results, and which requirements have
been tested. If a test case fails, then it files a ticket with an appropriate defect
tracking system. Optional features of the test management system are auto-
mated reporting of test goals, test plans, and test results; the test execution
engine may produce log-files of test execution and SUT test coverage.
An early technical paper on the systematics is the 1967 IBM white paper
“Evaluation of the Functional Testing of Control Programs” [Elm67], which
calls for a more scientific approach to software testing. One of the first books
dedicated especially to the topic of software testing are the proceedings of
the 1972 Chapel Hill Symposium on “Program Test Methods” [Het73].
In 1979, Glenford Myers described software testing as an ‘art’ [Mye79].
This still very readable book remarks that testing is different from debugging,
since it is addressing a different question (not where, but whether a program
contains errors). It is also different from verification, since the goal is to detect
errors, not to show their absence: “A successful test case is one that detects
an as-yet undiscovered error”. The main motivation of a tester therefore is
to find errors in a program, not to show or bring about its correctness. This
observation lead to a revival of research in the foundations of software testing.
Today, there is a wealth of textbooks available for software testing. Here, we
only mention the undergraduate text by Jorgensen [Jor95], the comprehensive
volume by Mathur [Mat08], the classic textbook by Beizer [Bei90], and the
introduction by Ammann and Offutt [AO08]. For the interested reader, it is
easy to find other literature which is maybe more adept to the personal taste.
There are also various curricula in testing, elaborated by the International
Software Testing Qualifications Board (ISTQB). These can be used to prepare
for a “certified tester” qualification [GVEB08, KL16].
The description of program control structures by state-transition systems
dates back to the 1950s [RS59]. The idea to use such formalisms also for
test generation appeared already in the 1970s. The main applications in
those years were in the field of testing the logic of integrated circuits and
telecommunication protocols. The main modelling paradigms were finite state
machines, Petri nets and specialized formalisms like the ITU-T Specification
and Description Language (SDL). In telecommunications, it is essential that
each communicating device conforms to the specified protocol. Thus, the
telecommunication standardisation industry was amongst the first to define
reference test suites and models for testing.
In the late 1990s it was understood that this approach can be effectively
used for practically all types of software, including operating systems, com-
pilers, data base management systems and others [Jor95]. Thus, the term
‘model-based testing’ was coined [AD97]. This new approach set the task
to seek more adequate modelling paradigms for the new classes of tar-
get systems. Thus, formalisms like the unified modelling language (UML)
and, later on, the UML testing profile (UTP) were defined [OMG13]. In
the mid-2000s, model-based testing became a hype both in academia and
industry. In 2004, the first workshop dedicated to model-based testing was
held in Barcelona [PPS15]. A graduate-level textbook on model-based test-
ing was composed from lectures at a Dagstuhl seminar [BJK+05]. Commer-
cial tools like Conformiq [Hui07], UniTesk [BKKP02], and RT-tester [Pel13]
were developed. Consequently, one of the first textbooks on practical model-
based testing was based on a tools approach [UL07]. A more scientific
300 B.-H. Schlingloff and M. Roggenbach
Within the last decade, specification-based testing, and its industrial variant
model-based testing, has become a well-established formal method which is
used in practical applications on a regular basis. However, the development
of the underlying theory is not yet finished. In particular, topics of ongoing
interest include
• the search for specification languages for test generation, which are more
abstract, yet easy to understand;
• the adaptation of algorithms and tools to deal with specification for-
malisms which are widely used in industry;
• more efficient methods for test generation in terms of fault detection capa-
bilities and test execution times;
• the increase of automation in model-based testing, e.g., to automatically
generate SUT adapters;
• the integration of specification-based testing with various other formal
methods such as static analysis and program verification; and
• the integration of test generation tools into continuous development envi-
ronments and application lifecycle management tool chains.
Even though the methods described in this chapter are regularly used for
industrial systems, there are several areas in which the theory still needs
to be developed. One such area is the testing of distributed and collabora-
tive systems. Consider, e.g., a group of (human or machine) agents working
together to achieve a common goal. Here, each agent can be modelled and
tested according to the methods described in this chapter. The environment
of one agent are all other agents, plus the context in which the whole group
is working. For testing the interaction between two agents, protocol testing
methods can be applied. However, elaborated methods for testing the emerg-
ing behaviour of the whole group are lacking.
The problem is made even more complex if the agents are adaptive and
change their behaviour over time. This may be the case, e.g., because they
5 Specification-Based Testing 301
References
[Tre08] Jan Tretmans. Model based testing with labelled transition systems. In Formal
Methods and Testing, pages 1–38. Springer, 2008.
[UL07] Mark Utting and Bruno Legeard. Practical Model-Based Testing: A Tools
Approach. Morgan Kaufmann, 2007.
[WS11] Stephan Weißleder and Bernd-Holger Schlingloff. Automatic model-based test
generation from uml state machines. In Model-Based Testing for Embedded
Systems. CRC Press, 2011.
[ZSM11] Justyna Zander, Ina Schieferdecker, and Pieter Mosterman, editors. Model-
Based Testing for Embedded Systems. CRC Press, 2011.
Part III
Application Domains
Chapter 6
Specification and Verification of
Normative Documents
Gerardo Schneider
Abstract This chapter is concerned with the formal specification and verifi-
cation of normative documents, that is, documents containing what is manda-
tory, permitted and prohibited. In computer science and software engineering,
these documents are usually referred as contracts. As the application domain
is quite vast, we give a high level description of a general approach to the
field, and we provide few motivating examples from different domains, after
clarifying on the notion of ‘contract’. We proceed then with the presentation
of the formal language CL and we show which kind of analysis may be done
on CL contracts, focusing mainly on the analysis of normative conflicts.
You got your new smart phone and decided to download as many free appli-
cations as possible. Since you do not have time nor patience, you simply click
on the ‘agree’ button of all the agreements without reading them. At the
end of the month when you got the bill for the use of Internet traffic, you
get a shock on the high bill. After a careful enquire you get to know that
one particular application was not free after all. You cancel it, but there is
a cancelation fee to be paid. Nothing can be done as you have ‘consciously
and willingly’ given your consent.
You travel to Brazil and you brought your smart phone with you. You
have agreed to a special offer with your provider on the price and roaming
policies when abroad, which stipulated among other things that you could
enjoy free Internet access up to 100 Mb after 20:00. You enjoy your life
drinking caipirinha, going to the beach, dancing samba, and uploading all
your nice photos to Facebook and writing comments about your day, doing it
at night benefiting from the offer of your phone provider. However, when you
Gerardo Schneider
University of Gothenburg, Sweden
come home and the first after-holidays bill comes, you cannot believe the 4
digits bill you get from your phone provider, mainly due to roaming abroad.
When asking for details you were told that the contract stipulated, among
other things: (i) Brazil did not qualify for the special offer; (ii) some days you
spent a bit more than 100 Mb, and the cost per additional Mb was 10 EUR.
After being told that, you spent hours going into the contract and you did
indeed find something about the above. It took you even more hours and the
help of a lawyer to check out all the conditions.
The above scenarios (both adaptations of real life cases) show the impor-
tance, for the bad more than good, of ‘contracts’.
Could the bad outcome be foreseen and prevented? Would it have been
possible to get a warning about the agreement not being valid in Brazil
automatically, or when the amount downloaded comes close to 100 Mb?
Now imagine that you are a lawyer and you need to modify existing con-
tracts, adding or deleting clauses for different clients. Though your work is
typically reviewed by you and colleagues to be sure they are correct and
without conflictive clauses, it happens from time to time that mistakes are
overlooked. After few years without any problem arising from a given con-
tract, you are suddenly in court trying to defend the impossible given that
your legal document is flawed. In case of contradictory clauses, which clause
should be taken into account? Is the contract suddenly declared void? Who
is liable? Would it be possible to have an intelligent editor to help lawyers
draft contracts allowing for the possibility to detect inconsistencies, conflic-
tive clauses, etc?
Though we will not be able to address and answer in detail all the above
questions, in what follows we present work addressing issues related to the
specification and analysis of contracts, or more generally of normative doc-
uments, that is, documents containing what is mandatory, permitted and
prohibited.
In next section we give a high level description of a general approach to the
field, and we provide few motivating examples from different domains, after
clarifying on the notion of ‘contract’. We proceed then with the presentation
of the formal language CL (Sect. 6.4), and we show in Sect. 6.5 which kind
of analysis may be done on CL contracts, focusing mainly on the analysis of
normative conflicts. We finish with a reflection on the content of the chapter,
suggestion for further reading, an extensive annotated bibliography, and a
brief description of current research trends.
Workflow Specifications
Legal Documents
5.1.10. Internet traffic may be measured by both Client and Provider by means
of Equipment and may take the two values high and normal.
OPERATIVE PART
7. CLIENT’S RESPONSIBILITIES AND DUTIES
7.1. The Client shall not:
7.1.1. supply false information to the Client Relations Department of the
Provider.
7.2. Whenever the Internet Traffic is high then the Client must pay [price] imme-
diately, or the Client must notify the Provider by sending an e-mail speci-
fying that he will pay later.
7.3. If the Client delays the payment as stipulated in 7.2, after notification he
must immediately lower the Internet traffic to the normal level, and pay
later twice (2 ∗ [price]).
[...]
8. CLIENT’S RIGHTS
8.1. The Client may choose to pay either: (i) each month; (ii) each three (3)
months; (iii) each six (6) months.
9. PROVIDER’S SERVICE
[...]
10. PROVIDER’S DUTIES
10.1 The Provider takes the obligation to return the personal data of the client
to the original status upon termination of the present Agreement, and after-
wards to delete and not use for any purpose any whole or part of it.
10.2 The Provider guarantees that the Client Relations Department, as part
of his administrative organisation, will be responsive to requests from the
Client or any other Department of the Provider, or the Provider itself
within a period less than two (2) hours during working hours or the day
after.
11. PROVIDER’S RIGHTS
11.1. The Provider takes the right to alter, delete, or use the personal data of the
Client only for statistics, monitoring and internal usage in the confidence of
the Provider.
11.2. Provider may, at its sole discretion, without notice or giving any reason or
incurring any liability for doing so:
11.2.2. suspend Internet Services immediately if Client is in breach of Clause 7.1;
13. TERMINATION
13.1. Without limiting the generality of any other Clause in this Agreement the
Client may terminate this Agreement immediately without any notice and
being vindicated of any of the Clause of the present Agreement if:
13.1.1 the Provider does not provide the Internet Service for seven (7) days con-
secutively.
13.2. The Provider is forbidden to terminate the present Agreement without pre-
vious written notification by normal post and by e-mail.
13.3. The Provider may terminate the present Agreement if:
13.3.1 any payment due from Client to Provider pursuant to this Agreement
remains unpaid for a period of fourteen (14) days;
16. GOVERNING LAW
[...]
312 G. Schneider
Terms of Service
2 In subsequent sections we will develop the concepts mentioned in the framework and
Note that the Runtime part of the framework is only valid for the case
of dealing with computer mediated transactions. The Static part is valid for
any kind of (legal) contract.
A full realisation of the framework presented above is a challenging task,
most of it is still ongoing research. In the rest of this chapter we will present
a small part of such long-term vision. We start by presenting the formal
language CL, as a candidate for the eCon in the framework.
We present here the formal language CL, designed with the aim to formalise,
at a certain level of abstraction, normative texts containing clauses determin-
ing the obligations, permissions and prohibitions of the involved parties. CL
is strongly influenced by dynamic, temporal, and deontic logic (cf. Sect. 2.5).
It is an action-based language meaning that the modalities are applied to
actions and not to state-of-affairs. In particular, it is possible to express
complex actions in the language by using operators for choice, sequence, con-
junction (concurrency) and the Kleene star (see Example 2). Besides, the
language allows to specify penalties (reparations) associated to the violation
of obligations and prohibitions.
6.4.1 Syntax
C := CO | CP |CF | C ∧ C | [β]C | | ⊥
CO := OC (α) | CO ⊕ CO
CP := P(α) | CP ⊕ CP
CF := FC (α)
α := 0 | 1 | a | α&α|α.α | α + α
β := 0 | 1 | a | β&β|β.β | β + β | β ∗
6.4.2 Semantics
A trace semantics usually gives us information about the traces (or sequences
of actions) that are valid, or accepted, by any formula (expression) of a logic
(formal language).
Originally, the trace semantics for CL was developed with the sole purpose
of being able to explain monitoring aspects. For that, it was defined over
infinite sequences of actions, and did not contain any information on whether
the action was mandatory, permitted, or prohibited, or none of the above.
However, it was realised later that in order to use the trace semantics for a
certain kind of analysis (namely conflict analysis), it should be modified so
that:
1. it contains deontic information (including permissions); and
2. it ‘accepts’ finite prefixes.
We present in what follows a trace semantics for CL which takes into account
the above two requirements.
For a contract with action alphabet Σ, we will introduce the deontic alpha-
bet Σd consisting of Oa , Pa and Fa for each action a ∈ Σ, in order to represent
which normative behaviour is enacted at a particular moment. Given a set
of concurrent actions α, we will write Oα to represent {Oa | a ∈ α}.
Given a CL contract C with action alphabet Σ, the semantics will be
expressed in the form σ, σd C, where σ is a finite trace of sets of concur-
rent actions in Σ and σd is a finite trace consisting on sets of sets (needed
to distinguish choices from conjunction) of deontic information in Σd . The
statement σ, σd C is said to be well-formed if length(σ) = length(σd ); in
what follows we will consider only well-formed semantic statements.
Intuitively, a well-formed statement σ, σd C will correspond to the state-
ment that action sequence σ is possible under (will not break) contract C,
with σd being the deontic statements enforced from the contract.
Example 56 shows some traces for two different contracts.
C = [a]O(b) ∧ [b]F(b).
The contract
C = F(c) ∧ [1](O(a) ∧ F(b))
stipulates that it is forbidden to perform action c and that after
the execution of any action, there is an obligation to perform an
318 G. Schneider
Note that the presentation of the traces σ and σd suggests that both traces
are paired position-wise as they have the same length. Though this is true
to some extent, it might help to ‘read’ the traces in the following way: first
consider the first element of the σd trace, then the first of the σ trace, and
successively. That is, in the first contract given in Example 56, we should read
the whole judgment as explained in what follows. At the beginning there is no
normative constraint (first element of the trace σd being {∅}). Then after a
is executed (first element of the σ trace being {a}) we have that the contract
stipulates an obligation of executing action b (second element of the trace
σd being {{Ob }}). We then have that b is executed (second element of the σ
trace being {b}), which is in accordance with the corresponding obligation at
that moment in σd .
In Example 56.1 below we show a trace for a contract containing the obli-
gation of a choice. The choice is expressed at the trace level by having a set
containing a set with the normative concepts affected by the choice (in this
case, 2 obligations).
C = [a]O(b + c) ∧ [b]F(b).
σ = {a}, {b}
and σd = {∅}, {{Ob , Oc }}
we have that σ, σd C .
Basic conditions: Figure 6.3 shows at line (6.1) that empty traces satisfy
any contract.
Done, Break: The simplest definitions are those of the trivially satisfiable
contract , and the unsatisfiable contract ⊥. In the case of ⊥, only an
empty sequence will not have yet broken the contract, while in the case of
, any sequence of actions satisfies the contract (whenever no obligation,
prohibition, or permission is present on the trace). See Fig. 6.3 line (6.2).
Conjunctions: For the conjunction of two contracts, the action trace must
satisfy both contracts and the deontic traces are combined point-wise, as
shown in Fig. 6.3 line (6.3).
Exclusive disjunction: Figure 6.3 line (6.4) displays the case for the dis-
junction, which is similar to conjunction. Note that the rule is valid only
for C1 and C2 being both of the form CO or CP . In the rest of this chapter
320 G. Schneider
Why are there so many semantics for CL? There are practical reasons to
have different semantics. As we have already discussed, the trace semantics
is useful for monitoring purposes, and for certain kind of analysis where a full
(Kripke) semantics is not needed, as for the detection of normative conflicts.
The encoding into the μ-calculus (or in general into another logic) is use-
ful to study expressiveness of the language, and to get a way to semantically
prove things about the language by using the proof engine (or model-based
approach) of the target logic (μ-calculus in this case). Given the non-standard
combination of deontic, dynamic and temporal operators with regular expres-
sions over actions, the semantics is in general non-compositional and thus
rewriting rules are given so CL expressions are preprocessed before giving
the encoding.
The Kripke semantics is the semantics of the language as it unambiguously
gives the meaning of each CL expression not by means of interpreting it into
another logic or formal language, but rather by using the standard world
semantics used in modal logics. Many of the ‘properties’ of the language are
somehow forced in the semantic definition, making it impossible to derive
many of the well known paradoxes inherited from the normative deontic
notions. This semantics is thus very complicated and not easy to understand
6 Specification and Verification of Normative Documents 321
Conflicts in normative texts comes in four different flavours. The first two are
when at a given moment the same action is under the scope of two opposite
deontic modalities. This happens when one is being obliged and forbidden to
perform the same action (e.g., O(a) ∧ F(a)), and when one is being permitted
and forbidden to perform the same action (e.g., P(a) ∧ F(a)). In the former
we would end up in a situation where whatever is performed will violate the
contract. The latter case does not necessarily correspond to a real conflict
but rather a potential one: if the permission is exercised then a conflict will
occur.
The remaining two kinds of conflicts occur when certain modalities are
applied to two mutually exclusive actions generating real or potential norma-
tive conflicts. This happens when obligations are applied to mutually exclu-
sive actions (e.g., O(a) ∧ O(b) with a#b), and similarly with permissions and
obligations (e.g., P(a) ∧ O(b) with a#b). Note that we have not included as
potentially conflictive the case of permissions of mutually exclusive actions.
Whether this is indeed a case to be considered or not is a philosophical
question. In any case this case could be added to our analysis without incon-
venience.
Example 57 shows the importance of the (temporal) relation between sen-
tences, and the vulnerability of abstraction in modelling and specification.
Let us come back to our main aim, that is to detect normative conflicts on
CL contracts. Example 58 shows the connection between traces and conflicts.
6 Specification and Verification of Normative Documents 323
[a]O(b) ∧ [b]F(b)
with allowed actions a and b. It is clear that both traces σ1 = {a}, {b}
C = [a]O(b + c) ∧ [b]F(b).
We can show that C is not conflict-free (i.e., there is at least one conflict)
since {a, b}, {b}
, {∅}, {{Ob , Oc }, {Fb }}
C, and there are D, D ⊆
σd (1) such that D and D are in conflict. To see this, let us take D =
324 G. Schneider
α& /α& = if α& ⊆ α& , otherwise 0
(0; α)/α& =0
(1; α)/α& =α
(α; α )/α& = (α/α& ); α
(α + α )/α& = α/α& + α /α&
Here are some examples for the tail operator.
• (a; b)/a = b
• ((a; b) + (a; c))/a = b + c.
f : CL × A& → CL
f (, ϕ) =
f (⊥, ϕ) = ⊥
f (C1 ∧ C2 , ϕ) = f (C1 , ϕ) ∧ f (C2 , ϕ)
⎧
⎪
⎪
if (f (C1 , ϕ) = ∧ f (C2 , ϕ) = ⊥)∨
⎪
⎨ (f (C1 , ϕ) = ⊥ ∧ f (C2 , ϕ) = )
f (C1 ⊕ C2 , ϕ) = ⊥ if (f (C1 , ϕ) = f (C2 , ϕ) = )∨
⎪
⎪
⎪
⎩ (f (C1 , ϕ) = f (C2 , ϕ) = ⊥)
f (C1 , ϕ) ⊕ f (C2 , ϕ) otherwise
C if α& ⊆ ϕ
f ([α& ]C, ϕ) =
otherwise
C if α& ϕ
f ([α& ]C, ϕ) =
otherwise
C if (α; α )/ϕ = 0
f ([α; α ]C, ϕ) =
[(α; α )/ϕ]C otherwise
f ([α + α ]C, ϕ) = f ([α]C, ϕ) ∧ f ([α ]C, ϕ)
f ([β; β ]C, ϕ) = f ([β][β ]C, ϕ)
f ([β + β ]C, ϕ) = f ([β]C ∧ [β ]C, ϕ)
f ([β ∗ ]C, ϕ) = f (C ∧ [β][β ∗ ]C, ϕ)
if α& ⊆ ϕ
f (OC (α& ), ϕ) =
C otherwise
f (OC (α; α ), ϕ) =
⎧(OC (α) ∧ [α]OC (α ), ϕ)
f
⎨ if f (O⊥ (α), ϕ) = or f (O⊥ (α ), ϕ) =
f (OC (α + α ), ϕ) = C if f (O⊥ (α), ϕ) = ⊥ and f (O⊥ (α ), ϕ) = ⊥
⎩ /ϕ)
CO (α + α otherwise
C if α& ⊆ ϕ
f (FC (α& ), ϕ) =
otherwise
f (FC (α; α ), ϕ) = f ([α]FC (α ), ϕ)
f (FC (α + α ), ϕ) = f (FC (α) ∧ FC (α ))
f (P(α& ), ϕ) =
f (P(α · α ), ϕ) = f (P(α) ∧ [α]P(α ), ϕ)
f (P(α + α ), ϕ) = f (P(α) ∧ P(α ), ϕ)
The algorithm for computing the residual function is not very complex,
but it has a lot of cases and small subtleties making it difficult to understand.
So, instead of explaining it in detail we rather give an illustrative example
on a simple CL formula on how it works (see Example 60).
326 G. Schneider
f (([a]O(b)), a) ∧ f ([b]F(b)), a)
By applying the definition of f again to the first conjunct, we get:
f (([a]O(b)), a) = O(b)
as it matches the first occurrence of f ([α& ]C, ϕ). Continuing now with
the second conjunct (same part of the definition applies), we get:
f ([b]F(b)), a) =
We thus have that:
The residual function f is just auxiliary; the automaton is built using the
construction function fc shown in Fig. 6.5 This functions takes as argument
the initial state of the automaton s0 (where l(s0 ) = C). Besides the residual
function f , fc uses function fd (shown in Fig. 6.6) that adds all the relevant
deontic information to each state (we take α& to be equal to a1 & . . . &an ).
Note that we have omitted the case for ⊕ in the deontic labelling function
description. In practice, two different automata are created for each one of
the choices, and the analysis proceeds as usual. Also note that there is no
explicit labelling function for F (α + α ) and P (α + α ), since these cases are
reduced to conjunction.
We will not give a detailed reading of the main and auxiliary algorithms,
but rather provide examples to get a feeling on how they work.
Example 61 provides a discussion on the automaton construction for con-
tract C [a]O(b) ∧ [b]F(b).
The main algorithm takes a contract written in CL and decides whether the
given contract may reach a state of conflict. Once the automaton was gener-
ated from the contract as explained above, the conflict detection algorithm
simply consists of a standard forward or backward reachability analysis look-
ing for states containing conflicts. This analysis is based on a fixed-point
computation as usually done for model checking.3
We will not prove the correctness and completeness of the algorithm in detail,
but we will show the essential steps to do so. We first need to prove the
following auxiliary results: (i) the traces accepted by the automaton coincide
with those ‘accepted’ by the contract in CL (according to the trace semantics);
(ii) a contract C in CL is conflict-free if and only if the generated automaton
A(C) is conflict-free. The first part is stated as follows.
Lemma 1 Given a CL contract C, the automaton A(C) accepts all and only
those traces σ that satisfy the contract:
The proof is based on a long and tedious induction on the structure of the
formula, proving that fc (and the auxiliary functions f and fd ) are complete
and correct.
Note that our algorithm checks that no state contains a conflict rather than
checking all possible satisfying runs. In order to prove that this is correct we
need to prove that we generate only and all the reachable states.
3In this book, we do not explain how model checking algorithms for temporal logics work;
we refer the reader to any standard book on the topic, e.g, [CGP99].
330 G. Schneider
Figure 6.8 shows a sample of the input file to the framework, containing part
of the description of what an airline ground crew should do before flights
leave (more on CNL later in this section).
The system is summarised in Fig. 6.9, where arrows represent the flow of
information between processing stages. (For space considerations the picture
is shown in 2 columns with the understanding that the flow continues from
the bottom of the left figure to the up right part of the right figure.)
from the user, but it does demand a knowledge of the CNL syntax and
the set of allowed verbs.
2. The CNL version of the contract in AnaCon text format (Fig. 6.8) is then
passed to the AnaCon tool, which begins processing the file.
3. The clauses in the contract are translated into their CL equivalents using
GF. This translation is achieved by parsing the CNL clauses into abstract
syntax trees, and then re-linearising these trees using the CL concrete
syntax.
4. From the resulting CL clauses, a dictionary of actions is extracted. Each
action is then automatically renamed to improve legibility of the resulting
formulae, and a dictionary file is written. The list of mutually exclusive
actions from the CNL contract is verified to make sure that each individual
action actually does appear in the contract.
5. Using the renamed CL clauses from the previous step and the list of mutu-
ally exclusive actions, an XML representation of the contract is prepared
for input into the CLAN tool.
6. This XML contract is then passed for analysis to CLAN via its command-
line interface, which checks whether the contract contains normative con-
flicts. If no such conflicts are found, the user is notified of the success. If
CLAN does detect any potential conflicts, the counter-example trace it
provides is linearised back into CNL using the GF translator in the oppo-
site direction. The dictionary file is used to re-instate the original action
names.
7. The user must then find where the counter-example arises in the original
contract. This last step must again be carried out manually, by following
the CNL trace and comparing with the original contract.
We have seen the contract language CL and the conflict detection tool
CLAN; in what follows we will briefly describe the two missing components
of AnaCon, namely our CNL and GF.
affected by the richness of the parent natural language and the specific for-
malism in which the CNL is defined [WAB+10].
Among other applications, CNLs are useful when considering human-
machine interactions which aim for an algorithmic treatment of language.
One must answer the following questions when designing a CNL [WAB+10]:
We can now build more complex sentences by adding modalities for obli-
gations, permissions and prohibitions. For instance, if we take the action “the
ground crew opens the desk”, then the different modalities may be written in
one of the following ways:
{the ground crew} must open {the desk}
• Obligation: {the ground crew} shall open {the desk}
{the ground crew} is required to open {the desk}
{the ground crew} may open {the desk}
• Permission: it is optional for {the ground crew} to open {the desk}
{the ground crew} must not open {the desk}
• Prohibition:
{the ground crew} shall not open {the desk}
In the case of obligations and prohibitions, the user can specify a repara-
tion clause which must be hold if the contract is violated. In the CNL the
reparation is introduced with comma and the keyword otherwise after the
main action. For example:
Here we can have an arbitrarily long list of clauses, which are applied in the
order in which they are written. The last clause is not followed by otherwise,
which indicates that its reparation is ⊥.
Even though the structure of the CNL version is noticeably less natural,
it is sufficient for our purposes to be merely close enough to English as to be
understood by any non-technical person.
6 Specification and Verification of Normative Documents 335
AnaCon has been applied to the two of the motivating examples presented
in Sect. 6.2.2 (Examples 53 and 54). In both cases the process started by
first manually translating the document in natural language into our CNL.
AnaCon was then applied and many conflicts were detected. A careful anal-
ysis of the first counter-examples gave an idea on whether the problem was
at the original document (a real conflict), or at the CNL (due to a wrong
modelling). At the beginning most of the conflicts detected were due to a
wrong modelling, so after few iterations to get a good CNL, the conflicts
336 G. Schneider
that occurred where due to ambiguities in the way the original documents
were written.
We briefly present in what follows a summary of the result of applying
AnaCon to Example 53. (A full description of the case studies is reported in
[ACS13].) We start by showing the modelling and re-writing process of the
example. Let us consider two clauses from the specification and show their
equivalent CNL representations.
Original: The ground crew is obliged to open the check-in desk and request the
passenger manifest from the airline two hours before the flight leaves.
CNL:
i f { t h e f l i g h t } l e a v e s { i n two h o u r s } then
{ t h e ground crew } must open { t h e check−i n d e s k } and
{ t h e ground crew } must r e q u e s t { t h e p a s s e n g e r m a n i f e s t from
the a i r l i n e }
CNL:
i f { t h e f l i g h t } l e a v e s { i n two h o u r s } then each o f
− { t h e ground crew } must open { t h e check−i n d e s k }
and { t h e ground crew } must r e q u e s t
{ t h e p a s s e n g e r m a n i f e s t from t h e a i r l i n e }
− i f { t h e ground crew } c l o s e s { t h e check−i n d e s k } then
each o f
− { t h e ground crew } must send { l u g g a g e i n f o r m a t i o n t o
airline}
− { t h e ground crew } must not i s s u e { b o a r d i n g p a s s }
− { t h e ground crew } must not r e o p e n { t h e check−i n d e s k }
When processed with AnaCon, the first conflicting state reported was reached
after a single action:
1 c o u n t e r example found
Clause :
( ( (O( a7&b2 ) ) ( Oa3 ) ) ˆ ( ( ( Oa2 ) ( Ob1 ) ) ˆ ( ( [ a7 ] ( ( O( a6 . ( b4 . ( a8 . a5 )
) ) ) ( Ob7 ) ) ) ˆ ( ( ( F( b5 ) ( Oa3 ) ) ˆ ( ( ( Ob6 ) ( Oa3 ) ) ˆ ( ( [ b6 ] ( Oa9 ) ) ˆ ( (
[ b6 ] ( Fa1 ) ) ˆ ( [ b6 ] ( Fa4 ) ) ) ) ) ) ) ) )
Trace :
1 . t h e f l i g h t l e a v e i n two h o u r s
each o f
− { t h e ground crew } must send { t h e l u g g a g e i n f o r m a t i o n
to the a i r l i n e }
− { t h e ground crew } must not i s s u e { b o a r d i n g p a s s }
− { t h e ground crew } must not r e o p e n { t h e check−i n d e s k }
In order to perform model checking of contracts we have to: (i) get a Kripke
structure (or a special kind of automaton, usually a Büchi automaton) of the
contract; (ii) write what we want to prove on a property language (usually
some kind of temporal logic); and (iii) encode everything on an existing model
checker (or develop an ad hoc model checker for our specific language, proving
that it is indeed possible).
There is no ad hoc model checker for CL. However, it is possible to provide
a rather involved encoding into existing model checkers, and perform model
checking of CL contracts by following these steps:
1. Model the conventional contract (in natural language) as a CL expression.
2. Translate the CL specification into Cμ (a variant of the μ-calculus).
6 Specification and Verification of Normative Documents 339
Section 6.5 is based on [KPS08, FPS09a]. See [PPS07] for more details about
model checking CL contracts (cf. Sect. 6.5.4).
Dı́az et al. introduced the formal graphical language C-O Diagrams,
extending CL among other things with real-time constraints (see [DCMS14]
for an extended and updated version) [MCDS10]. Camilleri et al. [CPS14]
presented a CNL for C-O Diagrams following a similar approach as the one
presented in this chapter for CL.
This idea of using a CNL as a natural language-like interface for a formal
system is not new. In particular, see the Attempto controlled natural language
[FKK08], which has played an influential role in the development of the area.
Initial work showing the feasibility to relate CL and a CNL has been imple-
mented in the tool AnaCon [ACS13, ACS12]. A more detailed description of
this framework as well as its application to the two case studies appearing in
this chapter (cf. Examples 53 and 54) appears in [ACS13, MRS11].
More recently, Camilleri et al. have defined a new CNL for C-O Diagrams
and developed a proof-of-concept web-based tool to transform normative doc-
uments in natural language into a formal representation. That way it is pos-
sible to perform syntactic and semantic queries, the latter via a translation
into UPPAAL timed automata [CGS16, CS17, CHS18, Cam17].
For more details on the Grammatical Framework, see [Ran11].
This chapter has focused on CL and related tools. The area is, however,
quite broad and it is difficult to give an exhaustive list of related work. In what
concerns the formalisation of normative concepts in general using deontic
logic and other formalisms, see for instance publications appearing in the
series of conferences DEON [Deo19], Jurix [AR19] and ICAIL [ICA19], and
in the Journal of Artificial Intelligence and Law [Jou19]. For examples of the
use of CNL for other formal contracts languages see, for instance, [AGP16,
CCP16, ACP18]. See also papers appearing in the CNL workshops [DWK18].
References
[ACP18] Shaun Azzopardi, Christian Colombo, and Gordon J. Pace. A controlled nat-
ural language for financial services compliance checking. In CNL’18, volume
304 of Frontiers in Artificial Intelligence and Applications, pages 11–20. IOS
Press, 2018.
[ACS12] Krasimir Angelov, John J. Camilleri, and Gerardo Schneider. AnaCon. http://
www.cse.chalmers.se/~gersch/anacon, Jan 2012.
[ACS13] Krasimir Angelov, John J. Camilleri, and Gerardo Schneider. A framework
for conflict analysis of normative texts written in controlled natural language.
Journal of Logic and Algebraic Programming, 82(5-7):216–240, July-October
2013.
[AGP16] Shaun Azzopardi, Albert Gatt, and Gordon J. Pace. Reasoning about partial
contracts. In JURIX’16, volume 294 of Frontiers in Artificial Intelligence and
Applications, pages 23–32. IOS Press, 2016.
[AR19] Michal Araszkiewicz and Vı́ctor Rodrı́guez-Doncel, editors. The 32nd Annual
Conference on Legal Knowledge and Information Systems. IOS Press, 2019.
[BCC+03] Lilian Burdy, Yoonsik Cheon, David R. Cok, Michael D. Ernst, Joseph Kiniry,
Gary T. Leavens, K. Rustan M. Leino, and Erik Poll. An overview of JML tools
and applications. In FMICS’03, volume 80 of ENTCS, pages 75–91, 2003.
342 G. Schneider
[Cam17] John J. Camilleri. Contracts and Computation: Formal Modelling and Analy-
sis for Normative Natural Language. PhD thesis, Department of Computer Sci-
ence and Engineering, University of Gothenburg, Gothenburg, Sweden, 2017.
[CCP16] Aaron Calafato, Christian Colombo, and Gordon J. Pace. A controlled natural
language for tax fraud detection. In CNL’16, LNCS 9767, pages 1–12. Springer,
2016.
[CGP99] Edmund M. Clarke, Orna Grumberg, and Doron A. Peled. Model checking.
The MIT Press, 1999.
[CGS16] John J. Camilleri, Normunds Gruzitis, and Gerardo Schneider. Extracting For-
mal Models from Normative Texts. In NLDB’16, LNCS 9612, pages 403–408.
Springer, 2016.
[CHS18] John J. Camilleri, Mohammad Reza Haghshenas, and Gerardo Schneider. A
Web-Based Tool for Analysing Normative Documents in English. In SAC-
SVT’18, pages 1865–1872. ACM, 2018.
[CPS14] John J. Camilleri, Gabrielle Paganelli, and Gerardo Schneider. A CNL for
contract-oriented diagrams. In CNL’14, volume 8625 of LNCS, pages 135–146.
Springer, 2014.
[CS17] John J. Camilleri and Gerardo Schneider. Modelling and analysis of normative
documents. Journal of Logical and Algebraic Methods in Programming, 91:33–
59, October 2017.
[DCMS14] Gregorio Dı́az, M. Emilia Cambronero, Enrique Martı́nez, and Gerardo Schnei-
der. Specification and Verification of Normative texts using C-O Diagrams.
IEEE Transactions on Software Engineering, 40(8):795–817, 2014.
[Deo19] DeonticLogic.org. http://deonticlogic.org/, 2019.
[DWK18] Brian Davis, Adam Z. Wyner, and Maria Keet, editors. 6th International
Workshop on Controlled Natural Language (CNL’16), volume 304 of Fron-
tiers in Artificial Intelligence and Applications. IOS Press, 2018.
[ebx] ebXML: Electronic Business using eXtensible Markup Language. www.ebxml.
org.
[FKK08] Norbert E. Fuchs, Kaarel Kaljurand, and Tobias Kuhn. Attempto Controlled
English for Knowledge Representation. In Reasoning Web, volume 5224 of
Lecture Notes in Computer Science, pages 104–124. Springer, 2008.
[FPS09a] Stephen Fenech, Gordon J. Pace, and Gerardo Schneider. Automatic Conflict
Detection on Contracts. In ICTAC’09, LNCS 5684, pages 200–214. Springer,
2009.
[FPS09c] Stephen Fenech, Gordon J. Pace, and Gerardo Schneider. Clan: A tool for
contract analysis and conflict discovery. In ATVA’09, LNCS 5799, pages 90–
96. Springer, 2009.
[ICA19] 17th international conference on artificial intelligence and law. http://www.
iaail.org/, 2019.
[Jou19] Journal of Artificial Intelligence and Law, 2019.
[KPS08] Marcel Kyas, Cristian Prisacariu, and Gerardo Schneider. Run-time monitor-
ing of electronic contracts. In ATVA’08, volume 5311 of LNCS, pages 397–407.
Springer, October 2008.
[Log13] Francesco Logozzo. Practical specification and verification with code contracts.
In HILT’13, pages 7–8. ACM, 2013.
[MCDS10] Enrique Martinez, Emilia Cambronero, Gregorio Diaz, and Gerardo Schneider.
A Model for Visual Specification of e-Contracts. In IEEE SCC’10, pages 1–8.
IEEE Computer Society, 2010.
[Mey86] Bertrand Meyer. Design by contract. Technical Report TR-EI-12/CO, Inter-
active Software Engineering Inc., 1986.
[MRS11] Seyed M. Montazeri, Nivir Roy, and Gerardo Schneider. From Contracts in
Structured English to CL Specifications. In FLACOS’11, volume 68 of EPTCS,
pages 55–69, 2011.
6 Specification and Verification of Normative Documents 343
[PPS07] Gordon J. Pace, Cristian Prisacariu, and Gerardo Schneider. Model checking
contracts –a case study. In ATVA’07, LNCS 4762, pages 82–97. Springer, 2007.
[Pri10] Cristian Prisacariu. A Dynamic Deontic Logic over Synchronous Actions. PhD
thesis, Department of Informatics, University of Oslo, December 2010.
[PS07] Cristian Prisacariu and Gerardo Schneider. A formal language for electronic
contracts. In FMOODS’07, LNCS 4468, pages 174–189. Springer, 2007.
[PS09a] Gordon J. Pace and Gerardo Schneider. Challenges in the specification of full
contracts. In Integrated Formal Methods (iFM’09), LNCS 5423, pages 292–306,
2009.
[PS09b] Cristian Prisacariu and Gerardo Schneider. CL: An Action-based Logic for
Reasoning about Contracts. In WOLLIC’09, LNCS 5514, pages 335–349.
Springer, 2009.
[PS12] Cristian Prisacariu and Gerardo Schneider. A dynamic deontic logic for com-
plex contracts. Journal of Logic and Algebraic Programming, 81(4):458–490,
2012.
[Ran09] Aarne Ranta. The GF resource grammar library. Linguistic Issues in Language
Technology, 2(2), December 2009.
[Ran11] Aarne Ranta. Grammatical Framework: Programming with Multilingual
Grammars. CSLI Publications, 2011.
[WAB+10] Adam Wyner, Krasimir Angelov, Guntis Barzdins, Danica Damljanovic, Brian
Davis, Norbert Fuchs, Stefan Hoefler, Ken Jones, Kaarel Kaljurand, Tobias
Kuhn, Martin Luts, Jonathan Pool, Mike Rosner, Rolf Schwitter, and John
Sowa. On controlled natural languages: properties and prospects. In CNL’09,
volume 5972 of LNCS/LNAI, pages 281–289. Springer, 2010.
[wsg] Web Services Agreement Specification (WS-Agreement). https://www.ogf.
org/documents/GFD.107.pdf.
[wsl] WSLA: Web Service Level Agreements. https://dominoweb.draco.res.ibm.
com/cdedb79080f59ee285256c5900654839.html.
Chapter 7
Formal Methods for
Human-Computer Interaction
Antonio Cerone
You are back home from work, tired and hungry. Your partner welcomes you
announcing that a nice cake is coming out of the oven soon and, this time,
‘properly baked’. You sniff the air and perceive a light burning smell. You
then recall that last time the cake did not properly rise, probably because
the oven was kept open for too long while inserting the cake and thus the
Antonio Cerone
Nazarbayev University, Nur-Sultan, Kazakhstan
initial baking temperature was not high enough. Your partner is announcing
that this time there won’t be any problems with rising because
1. during the oven pre-heating phase, the temperature was set 20 degrees
higher than the temperature indicated in the cake recipe,
2. when such higher temperature was reached, the oven was opened and the
cake inserted (supposedly the opening of the oven would have decreased
the temperature 20 degrees down, to the one indicated in the recipe), and
3. after closing the oven the temperature setting was immediately lowered to
the value indicated in the recipe.
However, the burning smell you perceive is now getting stronger, clearly show-
ing that something went wrong in performing the three-step algorithm above,
which supposedly implement our ‘baking task’. Your partner swears that the
increase of 20 degrees is not too much, because it is a widely tested sug-
gestion from a cooking internet forum and it is confirmed by many positive
comments. Can you explain what went wrong? Well, there was some kind of
cognitive error during the task execution. But which error exactly?
Normally, cognitive errors occur when a mental process aiming at opti-
mising the execution of a task causes instead the failure of the task itself.
The existence of a cognitive cause in human errors started to be understood
already at the beginning of last century, when Mach stated: “knowledge and
error flow from the same mental sources, only success can tell the one from
the other” [Mac05]. But it took till the 1990s to understand that “correct
performance and systematic errors are two sides of the same coin” [Rea90].
In our cake baking example, the three-step algorithm that implements the
task is in principle correct, but the mental processes used to carry out the task
may lead to a cognitive error. In fact, it is the human cognitive processing that
does not perform the algorithm correctly, thus causing the error to emerge.
Here, the key design point is that we cannot expect human behaviour to adapt
to a specific algorithm when performing a task. It is instead the algorithm
that must realise the task by taking human performance into account.
In the rest of this section we will briefly review the research trends and
milestones in Formal Methods for HCI (Sect. 7.1.1) and state what we mean
for user (Sect. 7.1.1) and operator (Sect. 7.1.1). Section 7.2 introduces the
structure of human memory and its main cognitive processes and, in par-
ticular, short-term memory (STM), including alternative CSP-based mod-
els (Sect. 7.2.1), and long-term memory (LTM) and its further structuring
(Sect. 7.2.2). Section 7.3 illustrates how to formally model human behaviour
while Sect. 7.4 shows how to combine the model of the human component
and the model of the interface to produce the overall model of the interac-
tive system. Finally, Sect. 7.5 addresses the formal verification of the overall
interactive system model and delves into the formal analysis of soundness and
completeness of cognitive psychology theories; in Example 69.2 of Sect. 7.5.1
we will also reveal what cognitive error caused the cake to burn and why the
algorithm used by your partner caused such an error to emerge.
7 Formal Methods for Human-Computer Interaction 347
7.1.1 Background
The systematic analysis of human errors in interactive systems has its roots
in Human Reliability Assessment (HRA) techniques [Kir90], which mostly
emerged in the 1980s. However, these first attempts in the safety assessment
of interactive systems were typically based on ad hoc techniques [Lev95],
with no efforts to incorporate a representation of human cognitive processes.
within the model of the interaction.
During the 1980s and 1990s, the increasing use of formal methods led
to more objective analysis techniques [Dix91] that resulted, on the one
hand, in the notion of cognitively plausible user behaviour, based on for-
mal assumptions to bind the way users act driven by cognitive processes
[BBD00] and, on the other hand, in the formal description of expected effec-
tive operator behaviour [PBP97] and the formal analysis of errors performed
by the operator as reported by accident analysis [Joh97]. Thus, research
in the formal analysis of interactive systems branched into two separate
directions: the analysis of cognitive errors of users involved in everyday-life
[Cer11, CB04, CE07, RCB08] and work-related [MRO+15, RCBB14] inter-
active tasks, and the analysis of skilled operator’s behaviour in tradition-
ally critical domains, such as transportation, chemical and nuclear plants,
health and defence [CCL08, CLC05, De 15, MPF+16, SBBW09]. The dif-
ferent interaction contexts of a user, who applies attention very selectively
and acts mainly under automatic control [Cer11, NS86], and an operator,
who deals with high cognitive load and whose attentional mechanisms risk to
be overloaded due to coping with Stimulus Rich Reactive Interfaces (SRRIs)
[SBBW09], have led to the development of distinct approaches, keeping sep-
arate these two research directions. However, users have sometimes to deal
with decision points or unexpected situations, which require a ‘reactivation’ of
their attentional mechanisms, and operators must sometime resort to automa-
tisms to reduce attentional and cognitive loads.
In this chapter we propose a modelling approach [Cer16] that unifies these
two contexts of human behaviour, which were traditionally considered sepa-
rately in previous literature, namely
• user, i.e., a human who performs everyday activities in a fairly automatic
way, and
• operator, i.e., a human who performs deliberate tasks making large use
of attention explicitly.
User
User refers to ordinary people carrying out everyday activities, such as baking
a cake, driving a car, using a smartphone, interacting with an ATM, etc.
During such activities, users perform tasks that are initially triggered by
348 A. Cerone
specific goals, and then normally proceed in a fairly automatic way until the
goal is accomplished.
As an example of everyday activity let us consider the natural language
description of the user interaction with an ATM in Example 65 [Cer11, Cer16].
Notice that there is .no specific order among the basic activities. The user
performs a specific basic activity depending on the observed state of the
interface associated with that activity. Normally, some ordering is driven by
the specific interface with which the user interacts. If we consider the general
ATM description in Example 36 from Chap. 3, we notice that all ATMs will
deliver the cash only after the user has inserted the card and entered the pin.
And, obviously, the card can only be returned after being inserted. Specific
ATMs impose further orderings, between card insertion and pin entering as
well as between card return and cash delivery. However, if you approach
the ATM to start an interaction and notice some cash already delivered,
and supposedly forgotten by the previous user, ...you definitely collect it!
(independently of whether you give it to the bank or you keep it.) Thus
the basic activity of collecting cash may even be the first to occur while
performing the task.
Although the task described in Example 65 requires some practice or
training, during which the novice user performs deliberate actions, then,
after repeated interactions, sufficient knowledge, skill and familiarity will be
acquired, thus allowing the user to perform the task in a fairly automatic
way. For example, an expert user will automatically insert the card in the
right slot when the interface appears in the normal ready state, which the
user is familiar with (whatever such a state looks like), and without any need
to look for the appropriate slot (which is automatically reached by the hand
movement). Such an acquired automatic behaviour allows the user to per-
form the task efficiently and quickly. However automatic behaviour is also
the context in which typical cognitive errors analysed in previous research
are most likely to occur as we will see in Sect. 7.5.1.
7 Formal Methods for Human-Computer Interaction 349
Operator
Similarly,
• The purpose of the operator of a nuclear plant control room is to ensure
the safe functioning of the plant. This purpose results in the monitoring
of all system readout, searching for readout configurations that may be
indicators of anomalies: goals are deliberately set in order to check specific
readout configurations but also, in a more holistic way, by considering
configurations which are not normally associated with anomalies and set
new subgoals to further investigate them.
• The purpose of the operator of a machine of an industrial plant is to fol-
low standard and specific operating procedures while using the machine.
The operator must make deliberate choices depending on the perceived
situation and consequently set goals that are consistent with the operat-
ing procedures. Furthermore, since operating procedures refer to generic
situations and are by no means exhaustive, the operator’s choices are not
made among a predefined set of possibilities, but normally require a global
assessment of the current situation.
We can conclude that an operator cannot automatically act in response to
observations, but has to globally assess the observed situation and make
informed, deliberate decisions on whether to act and what to do. Goals are
thus established throughout the process according to the purpose of the task.
environment, and three main kinds of human memory, in order to store infor-
mation:
– sensory memory, where information perceived through the senses persists
for a very short time,
– short-term memory (LTM), also called working memory, which has a
limited capacity and where the information that is needed for processing
activities is temporarily stored with rapid access and rapid decay, and
– long-term memory (LTM), which has a virtually unlimited capacity
and where information is organised in structured ways, with slow access
but little or no decay [DFAB04].
A usual practice to keep information in memory is rehearsal. In particular,
maintenance rehearsal allows us to extend the time during which information
is kept in STM, whereas elaborative rehearsal allows us to transfer information
from STM to LTM.
The limited capacity of short-term memory has been measured using exper-
iments in which the subjects had to recall items presented in sequence. By
presenting sequences of digits, Miller [Mil56] found that the average person
can remember 7 ± 2 digits. However, when digits are grouped in chunks, as it
happens when we memorise phone numbers, it is actually possible to remem-
ber larger numbers of digits. Therefore, Miller’s 7±2 rule applies to chunks of
information and the ability to form chunks can increase people’s STM actual
capacity.
The limited capacity of short-term memory requires the presence of a
mechanism to empty it when the stored information is no longer needed.
When we produce a chunk, the information concerning the chunk compo-
nents is removed from STM. For example, when we chunk digits, only the
representation of the chunk stays in STM, while the component digits are
removed and can no longer be directly remembered as separate digits. Gen-
erally, every time a task is completed, there may be a subconscious removal
of information from STM, a process called closure: the information used to
complete the task is likely to be removed from STM, since it is no longer
needed.
We can use CSP to define a general STM model as shown in Example 67.
STMempty = STM7;
STM7 = store -> STM6 []
delay -> STMempty []
closure -> delay -> STMempty;
STM6 = store -> STM5 [] remove -> STM7 []
delay -> STMempty []
closure -> delay -> STMempty;
...
STM2 = store -> STM1 [] remove -> STM3 []
delay -> STMempty []
closure -> delay -> STMempty;
STM1 = store -> STM0 [] remove -> STM2 []
delay -> STMempty []
closure -> delay -> STMempty;
STM0 = store -> STMmanagement []
remove -> STM1 []
delay -> STMempty []
closure -> delay -> STMempty;
STMmanagement = overloadedSTM -> delay -> STMempty;
Notice that this memory model does not include the representation of the
actual pieces of information that can be stored in STM. Information con-
tents need to be represented by further CSP processes, one for every possible
piece of information to define the two possible information states, stored and
not stored. These further processes must synchronise with the CSP process
in Example 67, thus resulting in a complex model, which is not easy to under-
stand and manage and has limited scalability.
In order to develop a more intuitive, manageable and scalable model,
we consider the CSP extension implemented in the Process Analysis Toolkit
(PAT) [PAT19]. In particular, PAT provides integer variables and arrays as
7 Formal Methods for Human-Computer Interaction 353
syntactic sugar to define system states, without any need to explicitly rep-
resent such states as additional synchronising processes. Processes can be
then enabled by guards, which check the current values of variables, while
events are annotated with performed assignments to variables and, more in
general, with any statement block of a sequential program. Notice that the
statement block is an atomic action, i.e. it is executed until the end without
any interruption or interleaving. However, annotated events cannot synchro-
nise with events of other processes, i.e., the parallel composition operator
treats annotated events in the same way as the interleaving operator. PAT
also supports the definition of constants, either singulnnand or as part of an
enumeration, which associates consecutive integer numbers starting from 0
to the enumerated constants. For example
#define low 0;
#define medium 1;
#define high 2;
are three declarations of constants, which can be globally introduced in an
alternative way as the enumeration
enum {low, medium, high};
The most obvious array implementation of STM would use each position
of the array to store a piece of information. Thus the size of the array would
represent the STM maximum capacity. However, the retrieval of information
from STM would require to go through all elements of the array. Instead, we
consider the implementation in Example 67.1.
var stmSize = M;
var stm[InfoNumber];
By default all positions of the array are initialised to 0. The storage of
information Info in the STM is performed by the occurrence of event
store which is enabled by guard stmSize < M , which ensure that the
STM is not full, and results in setting the Info-th position of array
354 A. Cerone
example, while we are learning to drive, ride a bike, play a musical instru-
ment or even when we are learning to do apparently trivial things, such as
tying a shoelace, we consciously retrieve a large number of facts from the
semantic memory and store a lot of information into STM. Skill acquisition
typically occurs through repetition and practice and consists in the creation
in procedural memory of rules and procedures (proceduralisation), which can
be then unconsciously used in an automatic way with limited involvement of
declarative memory and STM.
In this section we present how to model the human components using PAT.
Input and output occur in humans through senses and the motor system. In
this chapter we give a general representation of input channels in term of
perceptions, with little or no details about the specific senses involved in the
perception, but with a strong emphasis on the semantics of the perception in
terms of its potential cognitive effects. For instance, if the user of a vending
machine perceives that the requested product has been delivered, the empha-
sis is on the fact that the perception of the product being delivered induces
the user to collect it and not on whether the user has seen or rather heard the
product coming out of the machine. We represent output channels in term of
actions. Actions are performed in response to perceptions.
In Example 65 of Sect. 7.1.1 we can identify a number of perceptions and
actions, which we describe in Example 65.1
Actions:
We have seen in Sect. 7.2.2 that skill acquisition results in the creation in
procedural memory of the appropriate rules to automatically perform the
task, thus reducing the accesses to declarative memory and the use of the
STM, and, as a result, optimising the task performance. Inspired by Norman
and Shallice [NS86], we consider two levels of cognitive control:
• automatic control is a fast processing activity that requires little or no
attention and is carried out outside awareness with no conscious effort
implicitly, using rules and procedures stored in the procedural memory,
and
• deliberate control is a processing activity triggered and focussed by
attention and carried out under the intentional control of the individual,
who makes explicit use of facts and experiences stored in the declarative
memory and is aware and conscious of the effort required in doing so.
For example, let us consider the process of learning to drive
Perceptions are briefly stored in sensory memory and only relevant percep-
tions are transfered to STM using attention, a selective processing activity
that aims to focus on one aspect of the environment while ignoring others.
We can see this focussing activity as the transfer of the selected perception
from sensory memory to STM.
For both users and operators the top-level task can be decomposed in
a hierarchy of goals and tasks until reaching basic activities, which do not
require further decomposition and can be performed by executing a single
action.
In our model of cognitive behaviour we consider a set Π of perceptions, a
set Σ of actions, a set Γ of goals, a set Ξ of purposes, and a set Δ of pieces of
cognitive information. The information that can be processed by the human
memory is given by the set
Θ = Π ∪ Σ ∪ Γ ∪ Ξ ∪ Δ.
goal(info)
goal(cashC)
ST M = {goal(cashC)}
Example 65.3 illustrates how to use PAT to define the infrastructure to model
the closure phenomenon for the ATM task described in Example 65.2. The
task aims at achieving the goal of withdrawing cash (getCashGoal).
var stmGoal = [ 0 ];
var stm[N];
var stmSize;
var perc[N];
The storage of goal in STM is modelled by the one position array
stmGoal. The content of this position is initialised to 0. Arrays stm
and perc implement the STM non-goal contents and the perceptions
available in the environment, respectively.
The closure controls the removal of the achieved goal and the removal of
non-goal information in order to free memory space for further processing
towards the achievement of other goals. Example 65.4 illustrates how to use
PAT to model the removal of goal getCashGoal for the ATM task.
Example 65.5 illustrates how to use PAT to model the removal of the non-
goal information for the ATM task.
cell = cell + 1;
}
} -> eact -> Closure();
Process FlashOut clears the contents of the non-goal part of the STM
(array stm). In fact, the storage of goal in STM is separately imple-
mented by array stmGoal to ensure that closure does not remove goals
other that the achieved one.
Example 65.6 illustrates how to use PAT to initialise the task with the
appropriate goal for the ATM task.
Each basic activity info1 ↑ perc =⇒ act ↓ info2 is defined by one choice of
the Task process. The choice is a process guarded by
• condition perc[P] == 1, if perc
= none, where P is the position of array
perc that implements perception perc,
• condition stmSize > n, if n+1 is the number of pieces of information in
info1 , and one condition stm[I] == 1, for each piece of information i ∈
info1 , if info1
= none, where I is the position of array stm that implements
i, and
• condition stmSize < M-n, where M is the maximum capacity of STM, if n
is the cardinality of info2 \info1 .
The first event of the process implements action act. Annotated actions store
and retrieve contain the assignments described in Example 67.1
Process User is the parallel composition of the three processes defined in
Examples 65.4 and 65.7
Notice that the use of events eact and eba forces the closure to occur
between the action performance and the storage of information in STM. In
this way, the same basic activity that causes closure and removal of a goal or
subgoal may also store a new goal or information in STM.
In Sect. 7.4 we will see how to combine this user model with an interface
model. Then, in Sect. 7.5.1 we will show how to use model checking to formally
verify properties of such an overall system.
In deliberate control, the role of the goal is not only to determine when
closure should occur but also to drive the task: we act deliberately to achieve
goals. Thus basic activities are not only driven by perceptions and non-goal
information stored in STM, but also by one specific goal stored in STM. A
typical case of deliberate behaviour is problem solving, in which the task goal
is normally reached through a series of steps involving the establishing of
subgoals. Achieving the subgoal takes the operator somehow closer to the
task goal until this can be achieved directly. This process is illustrated in
Example 71.
Actions:
Cognitive information:
boxM oved the fact that the box has been moved with its contents;
boxEmptied the fact that the box is empty;
boxM ovedEmpty the fact that the box has been moved without
its contents.
The first condition means that the goal in STM is the same as the one in the
basic activity apart from some additional purposes. In fact, on the one hand,
a specific purpose ξ ∈ Ξ does not prevent goals for less specific purposes to
be used, since they will still get closer to the goal for purpose ξ, on the other
hand, goals for more specific purposes should not be used, since they might
take far away from the goal for purpose ξ. The performance of the basic
activity and the closure are the same as in the case of automatic control.
The automatic behaviour described in Example 71 is formalised in Exam-
ple 71.2
goal(boxM oved)
goal(boxEmptied).
ST M = {goal(boxM oved)}
Example 71.3 shows the usage of STM while performing the task modelled in
Example 71.2 with a heavy box.
7 Formal Methods for Human-Computer Interaction 367
Example 71.4 illustrates how to use PAT to model the closure phenomenon
for the task described in Example 71.3.
var stmGoal = [ 0 , 0 ];
var stm[N];
var stmSize;
var perc[N];
var info[N];
Closure() = ba-> (
[stmGoal[boxMovedGoal] == 1 &&
(info[boxMoved] == 1 || stm[BoxMoved])]
achieveBoxMoved {info[BoxMoved] = 0;
stmGoal[BoxMoved] = 0;
stmSize--;} -> FlashOut() []
[stmGoal[boxEmptiedGoal] == 1 &&
(info[boxEmptied] == 1 || stm[BoxEmptied])]
achieveBoxMoved {info[BoxEmptied] = 0;
stmGoal[BoxEmptied] = 0;
stmSize--;} -> FlashOut() []
eact -> Closure() );
Goals() =
[stmSize < M && stmGoal[BoxMovedGoal] == 0]
move {stmGoal[BoxMovedGoal] = 1;
stmSize++} -> Goals() []
[stmGoal[BoxMovedGoal] == 1] ba -> eba -> Goals() []
[stmSize < M && stmGoal[BoxEmptiedGoal] == 0]
move {stmGoal[BoxEmptiedGoal] = 1;
stmSize++} -> Goals() []
[stmGoal[BoxEmptiedGoal] == 1] ba -> eba -> Goals();
Array info implements the possibility that the information associated with
the goal achievement is a new piece of information stored in STM by the basic
7 Formal Methods for Human-Computer Interaction 369
activity. Thus not only the position of the stmGoal array corresponding to the
achieved goal is changed to 0 but also the same position of array info. This
is followed by the execution of process FlashOut, which clears the contents
of the non-goal part of STM (array stm).
Example 71.5 illustrates how to model Example 71.2 in PAT:
for each piece of information i ∈ info2 , the possibility that the information
i is associated with the goal achievement is implemented by the assignment
info[I] = 1, where I is the position of array info that implements i.
Example 65.9 illustrates how to use PAT to define the infrastructure and
model the closure phenomenon for the ATM task described in Example 65.8.
Closure() = ba-> (
[stmGoal[getCashGoal] == 1] cashC ->
achieveGetCash {stmGoal[getCashGoal] = 0;
stmSize--;} -> FlashOut() []
[stmGoal[getStatGoal] == 1] cashC ->
achieveGetCash {stmGoal[getStatGoal] = 0;
stmSize--;} -> FlashOut() []
eact -> Closure() );
Goals() =
[stmSize < M && stmGoal[getCashGoal] == 0 &&
stm[Interaction] == 0] getCash {stmGoal[getCashGoal] = 1;
stmSize++} -> Goals() []
[stmGoal[getCashGoal] == 1] ba -> eba -> Goals() []
[stmSize < M && stmGoal[getStatGoal] == 0 &&
374 A. Cerone
With respect to Example 65.4, processes Closure and Goals have the addi-
tional choice for the new goal. Moreover, guards in process Goals also include
a condition on the absence of interaction from STM: initially there is no
goal in STM and the role of process Goals is to establish one goal non deter-
ministically, when the user in not interacting with the ATM.
Example 65.10 illustrates how to use PAT to model the basic activities for
the ATM task described in Example 65.8.
represented by the perception provided to the user. The first event of the
choice to be performed is the synchronisation event that models the inter-
action of the human (events CardI, PinE, CashS, StatS, CashC, StatC and
CardC in Example 65.11). Each synchronisation event is followed by the ‘local’
interface event that modifies the interface state by assigning 0 to the source
state and 1 to the target state. These local events my be split to increase
the readability of the model, as it happens in the last choice of the ATMold
process in Example 65.11.
In order to keep the synchronisation event and the associated interface
events as an one atomic action, we use the atomic process construct available
in PAT. The atomic keyword associates higher priority with a process: if the
process has an enabled event, the event will execute before any events from
non atomic processes. Moreover, the sequence of statements of the atomic
process is executed as one single step, with no interleaving with other pro-
cesses.
The ATM interface modelled in Example 65.11 was very common in the
past. However, it was observed that delivering cash or statement before
returning the card sometimes caused the user error of forgetting the card.
This error is due to the fact that once the goal of collecting the cash or the
statement is achieved, STM may be flashed out by the closure phenomenon
thus losing some information, possibly including the reference to the action
to collect the card. The discovery of this error led to the development of
a new ATM interface that returns the card before delivering cash or state-
ment. In terms of interface model this means that the user’s selection of a
transaction, although it results in the same user perception of seeing the
card returned, should determine two distinct state transitions depending on
whether the user selects ‘cash withdrawal’ or ‘statement printing’. The new
state will then produce the appropriate perception at a later stage.
In general, when dealing with a fairly complex behaviour, possibly result-
ing from the parallel composition of several subsystems, it is necessary to
consider internal system states, which do not present themselves as human
perceptions. Therefore, in addition to the perc array to implement percep-
tion, we also use an array state to implement internal states.
Example 65.12 models the new ATM interface.
ATMnew() =
atomic{ [perc[CardR] == 1] cardI ->
readCard {perc[CardR] = 0;
perc[PinR] = 1} -> ATMnew() } []
atomic{ [perc[PinR] == 1] pinE ->
readPin {perc[PinR] = 0;
7 Formal Methods for Human-Computer Interaction 377
Section 7.2 illustrated various kinds of memory, which play different roles in
processing information. Then in Sects. 7.3.3 and 7.3.4 we described automatic
and deliberate behaviour, respectively, and provided a formal notation (and
its implementation in PAT) to model basic activities under these two forms of
cognitive control. If we wish to associate the location of the rules that model
basic activities with distinct parts of the human memory, we can imagine that
they are stored in LTM and, more specifically, that automatic basic activities
are stored in procedural memory and deliberate basic activities are stored in
semantic memory.
We have also mentioned that information may be transferred from sensory
memory to STM through attention while facts and knowledge may be trans-
ferred from semantic memory to STM. We must add that information may
flow from STM to LTM, first to episodic memory, and then produce changes
to semantic and procedural memory. In fact, automatic and deliberated basic
activities are created through a long-term learning process. In general, users
make large use of deliberate activities while learning a task and, during the
learning process, they create automatic rules in procedural memory to replace
the less efficient rules in semantic memory. However, although automatic con-
trol is efficient and requires less STM usage than deliberate control, it may
result inappropriate in some situation. In such a case, experiential knowledge
378 A. Cerone
already stored in the LTM may be used to solve the situation. Norman and
Shallice [NS86] propose the existence of a Supervisory Attentional System
(SAS), sometimes also called Supervisory Activating System, which becomes
active whenever none of the automatic tasks are appropriate. The activation
of the SAS is triggered by perceptions that are assessed as danger, novelty,
requiring decision or are the source of strong feelings such as temptation and
anger. The SAS is an additional mechanism to switch from automatic to
deliberate control.
In Sect. 7.3.6 we described how to model the switching from automatic
to deliberate control due to a required decision. Now we consider how such
switching may occur due to the user’s assessment of perceptions as the result
of acquired experiential knowledge. Example 65.13 extends Example 65.9 with
the infrastructure for representing factual and experiential knowledge and the
mechanisms to assess perception and produce an appropriate response based
on experiential knowledge.
Closure() = ba-> (
[response == normal && stmGoal[getCashGoal] == 1]
cashC ->
achieveGetCash {stmGoal[getCashGoal] = 0;
stmSize--;} -> FlashOut() []
[response == normal && stmGoal[getStatGoal] == 1]
cashC ->
achieveGetCash {stmGoal[getStatGoal] = 0;
stmSize--;} -> FlashOut() []
eact -> Closure() );
FlashOut() = ...
Goals() = ...
ExpectNew() = ba ->
( eba -> ExpectNew() []
cashS -> eba ->
( [perc[CardO] == 1]
cardExpectMet -> ExpectNew() []
[perc[CashO] == 1]
cardExpectFailed -> ExpectNew() ) []
statS -> eba -> ( [perc[CardO] == 1]
cardExpectMet -> ExpectNew() []
[perc[StatO] == 1]
cardExpectFailed -> ExpectNew() )
);
);
The above model caters for two different user expectations. The
first one is ExpectOld, where a user used to interact with the old
ATM expects to see the cash or statement delivered after selecting
‘cash withdrawal’ or ‘statement printing’; such expectations are not met
(cashExpectMet or statExpectMet, respectively) if the card is returned
instead. The second one is ExpectNew, where a user used to interact
with the new ATM expects to see the card returned after selecting
380 A. Cerone
Until now we have considered the following components of the overall system:
– the user’s behaviour
User() = Closure() || Goals() || Task();
consisting of the infrastructure for STM (process Closure) and goals (pro-
cess Goals) and the human task process Task (see Examples 65.7, 71.5,
65.10 and 65.15),
– the interface or system (see Examples 65.11 and 65.11), and
– the user’s experiential constraints (see Example 65.14).
However, as illustrated in Example 65.16 there are further aspects of the
environment that influence the interaction and thus ought to be part of the
modelled overall system:
• the initial interface/system state,
• the availability of resources, and
• the user’s knowledge.
382 A. Cerone
Resources() = HasCard();
Knowledge() = KnowsPin();
From an analytical point of view we focus on two aspect: overall system verifi-
cation and task failure analysis. First, in Sect. 7.5.1 we illustrate how to verify
whether the design of the interface and the other environment components
addresses cognitive aspects of human behaviour such as closure phenom-
ena and user expectations that trigger the SAS to activate attention (overal
system verification). Then, in Sect. 7.5.2, we consider patterns of behaviour
featuring persistent operator errors may lead to a task failure.
#assert SystemOldUserNew() |=
[] ( cashS -> ( ! cardI U cashC ) );
#assert SystemOldUserNew() |=
[] ( statS -> ( ! cardI U statC ) );
7 Formal Methods for Human-Computer Interaction 385
#assert SystemNewUserOld() |=
[] ( cashS -> ( ! cardI U cashC ) );
#assert SystemNewUserOld() |=
[] ( statS -> ( ! cardI U statC ) );
#assert SystemOldUserOld() |=
[] ( cashS -> ( ! cardI U cashC ) );
#assert SystemOldUserOld() |=
[] ( statS -> ( ! cardI U statC ) );
#assert SystemOldUserNew() |=
[] ( readCard -> ( ! cardI U cardC ) );
#assert SystemNewUserOld() |=
[] ( readCard -> ( ! cardI U cardC ) );
#assert SystemOldUserOld() |=
[] ( readCard -> ( ! cardI U cardC ) );
The PAT model checker shows that the safety property is valid with
the new ATM (SystemNewUserNew and SystemNewUserOld) and not
with the old ATM (SystemOldUserOld and SystemOldUserOld), inde-
pendently of the user experience. The counterexample captures possible
post-completion errors in using the old design of the ATM and shows
that such errors cannot occur in the new design of the ATM.
We can now understand what cognitive error caused the cake of Example 65
to burn and why the algorithm used by your partner caused such an error to
emerge. This is illustrated in Example 69.2.
The purpose of the operator’s behaviour is to prevent the system from reach-
ing a failure state. In this case the unwanted result of the interaction is the
task failure. Although it is acceptable that the operator makes errors, since
recovery from errors is always possible, if this recovery does not occur and
the operator persists in making errors, then the system will eventually reach
a failure state.
Applied psychology uses experiments, natural observation and other data
gathering instruments to identify and categorise the operator’s patterns of
behaviour that may lead to a task failure. The goal of this kind of studies
is to capture all possible patterns of behaviour that may lead to a task fail-
ure in order to design system controls, support tools, environment settings
and working schedules that prevent operators from entering such dangerous
patterns of behaviour.
Formal methods can support applied psychology by verifying whether
the decomposition of a task failure into patterns of behaviour is sound
and complete. The task failure F and its empirically defined decomposition
D = {P1 , . . . Pn } into patterns of behaviour can be formalised in LTL. The
decomposition D is
– sound if each of the Pi is sufficient to cause the task failure F , and
– complete if one of the Pi is necessary to cause the task failure F .
388 A. Cerone
Then model checking can be used to verify the soundness of the decomposition
(P ⇒ F )
P ∈D
than the book by Dix et al. The third draws on sound computer science
principles, with a strong formal methods flavour. It uses state machines and
graph theory as a powerful and insightful way to analyse and design bet-
ter interfaces and examines specific designs and creative solutions to design
problems
Looking more specifically at modelling cognition, historical but still actual
works are by Newell and Simon [NS72], Card et al. [CEB78]. In a later work
Card, Moran and Newel [CMN83] introduced a somehow formal notation,
which inspired, on the one hand, the development of a plethora of cognitive
architectures over the last 40 years and, on the other hand, the use of formal
methods in HCI.
Kotseruba and Tsotsos published a broad overview of these last 40 years of
cognitive architectures [KT18], featuring 84 cognitive architectures and map-
ping them according to perception modality, implemented mechanisms of
attention, memory organisation, types of learning, action selection and prac-
tical applications. A similar, but less comprehensive survey by Samsonovich
[Sam10] collects the descriptions of 26 cognitive architectures submitted by
the respective authors. Finally, Laird et al. [LLR17] focus on three among the
most known cognitive architectures, ACT-R, Soar and Sigma, and compare
them based on their structural organisation and approaches to model core
cognitive abilities.
In 1991 two nice surveys on the first formal approaches in HCI were com-
piled by Haan, van der Veer and van Vliet [GdHvV91], based on a psychology
perspective, and by Dix [Dix91], based on a computer science perspective.
Although the scientific community working on the use of formal methods in
HCI is quite small, there have been a number of significant results over the last
20 years. Such results mainly appear in the proceedings of the international
workshops on on Formal Methods for Interactive Systems (FMIS), which run
from 2006, though not every year, and in journal special issues associated
with such workshop. Some of these special issues and other papers in the
area appeared in the journal Formal Aspects of Computing. Two important
collection of works on formal methods approaches to HCI have been recently
edited by Weyers, Bowen, Dix and Palanque [WBDP17] and by Oulasvirta,
Kristensson, Bi and Howes [OKBH18].
with user experience, whereby the user expects some challenges in order to
test personal skills and knowledge, enjoy the interaction and avoid boredom.
Usability is also strictly related to critical nonfunctional properties such as
safety [CCL08] and security [CE07]. Such relationship is actually two ways.
On one side improving usability increases safety and/or security [CCL08]. On
the other side introducing mechanisms to increase safety and/or security may
reduce usability, and as a result, may lead to an unexpected global decrease
in safety [IBCB91] and/or security [CE07]. Investigating such complex rela-
tionships is an important research direction.
In the real world humans frequently have to deal with operating environ-
ments that
1. continuously produce, change and invalidate human expectations as part
of an evolutionary learning process [Cer16, IBCB91],
2. deploy constraining social contexts [IBCB91] and cultural differences
[Hei07], and
3. provide a large amount of stimuli, which are perceived through several
modalities at the same time and interpreted and combined according to
temporal and contextual constraints (multimodal interaction) [CFG07].
The formal approach proposed in this chapter as well as all approaches that
aim at applying formal methods to generic HCI problems presuppose that
1. expectation are a priori constraints rather than part of a learning process,
2. cognitive behavior depends on a specific social and cultural context, and
3. human cognition and actions are directly triggered by isolated perceptions.
Therefore, it is important to
1. define cognitive mechanisms that build
• expectations in semantic memory out of experience stored in episodic
memory, and
• procedures in procedural memory out of knowledge stored in semantic
memory,
thus mimicking the information flow from STM first to episodic memory
and then to LTM (see Sect. 7.4.1),
2. enable multiple, interacting instantiations of cognitive architectures as part
of a complex sociotechnical system, and
3. define, at the cognitive architecture level, mechanisms for the fusion of
multiple modalities.
These objectives may not be easily accomplished using formal notations with
limited data structures such as CSP, even in the extended form provided by
PAT. A more sophisticated modelling language with extensive data struc-
tures, possibly featuring an object-oriented paradigm, is needed. With this
aim in mind the Maude rewrite system [Ö17] has been proposed as a possible
candidate [Cer18, BMO19]. Furthermore, the definition of the Behavioural
392 A. Cerone
References
8.1 Introduction
Let’s start with a fairy tale. “In days of yore and in times and tides long gone
before there dwelt in a certain town of Persia two brothers one named Kasim
and the other Ali Baba.”1
Markus Roggenbach
Swansea University, Wales, United Kingdom
Siraj Ahmed Shaikh
Coventry University, Coventry, United Kingdom
Hoang Nga Nguyen
Coventry University, Coventry, United Kingdom
1 See https://www.pitt.edu/~dash/alibaba.html#burton for the full text of this story.
“Open Sesame!”, shouts Ali Baba in this famous tale of Ali Baba and the
Forty Thieves from the Arabian Nights, where these are the magic words that
open the treasure cave. As the tale goes, Ali Baba follows a group of forty
thieves to the cave where they hide their loot, and he overhears the magic
words, which are key to opening the cave. Later, Kasim, Ali Baba’s brother,
also gets the magic words as he overhears him to say “Open Sesame” to get
into the cave. In his haste and excitement over the riches, Kasim ends up
forgetting the magic words to get out of the cave once he is in.
Kasim meets his fate and gets killed in the cave by the thieves once they
find him. Ali Baba ends up getting rich and happy eventually. The moral of
the story is that effective key management is key to security and safety! And
of course greed does not serve one well.
Three important security principles emerge from the story:
– First, challenge and response is used to open the cave door. Only the one
who can say the magic words can enter or leave the cave. This is a simple
example of a challenge response protocol, where the challenge is the door
only opens in response to a magic word (password), and the valid response
is the password “Open Sesame!”.
– Secondly, eavesdropping is always a possibility, as it was for Ali Baba and
Kasim.
– Thirdly, the perfect cryptography assumption is made, i.e., the cave can’t be
fooled. There is no other way to open the door but to say “Open Sesame!”.
This chapter introduces an important application of Formal Methods:
the design and verification of security protocols. Such protocols are used to
provide properties such as authentication, confidentiality, integrity or non-
repudiation.
Security protocols underpin a number of common technologies in everyday
use. An electronic purse, cf. Example 9, is one application where all financial
transactions are conducted over a protocol with desired security properties.
Similarly, electronic voting, cf. Example 14, relies on security protocols to
ensure, e.g., secrecy of the vote, i.e., only the voter knows who they voted,
and privacy of voters, i.e., if they have participated in the election or not.
Among the many formalisms suitable to address the challenge of security
protocol verification, we choose the process algebra Csp as the underlying
formalism for this chapter, see Chap. 3 for a thorough introduction to Csp; an
understanding of the syntax as provided in Sect. 3.2.1 and the traces model as
provided in Sect. 3.2.2 would suffice for this chapter. As distributed systems,
security protocols belong to the natural remit of process algebra. Over the
years, in particular the Csp community has made significant contributions to
the verification of security protocols and has developed a rich set of analysis
methods, cf. Sect. 8.7.1.
Section 8.2 introduces the reader to the basic principles of security. Sec-
tion 8.3 introduces the Needham-Schroeder authentication protocol, discusses
why it fails to provide authentication, and presents the Needham-Schroeder-
8 Formal Verification of Security Protocols 397
Lowe protocol, which corrects the discussed flaw. In Sect. 8.4, we introduce
the Csp approach of how to formally model authentication and security pro-
tocols in general. Such models open the possibility to rigorously reason and
prove protocols with respect to desired properties. Section 8.5 applies model
checking to the Needham-Schroeder authentication protocol and shows how
a counter example trace is automatically found. It also provides a correct-
ness result for the Needham-Schroeder-Lowe protocol under the assumption
that an attacker uses a limited number of reasoning steps only. In contrast,
Sect. 8.6 utilises the so-called Rank-Function Theorem to give a manual cor-
rectness proof of the Needham-Schroeder-Lowe protocol, without making any
assumptions w.r.t. the number of an attacker’s reasoning steps.
This section lays out some fundamental principles: these are basica notations
of cryptography, cf. Sect. 8.2.1, security principles, cf. Sect. 8.2.2, and security
protocols, cf. Sect. 8.2.3.
8.2.1 Cryptography
The term cryptography is derived from the Greek word kryptos, meaning hid-
den. A related notion cryptanalysis is to do with analysing hidden information
with intent to uncover it. Both cryptography and cryptanalysis are branches
of cryptology, which is the science of hiding. The purpose of cryptography is
to hide the content of a message so that it is not revealed to everyone. This
is made possible by converting the message from its original form, known as
plaintext, to a distorted incomprehensible form known as ciphertext. The pro-
cess of converting plaintext to ciphertext is called encryption and the process
of converting ciphertext back to plaintext is called decryption. Encryption
and decryption operations are implemented in the form of algorithms known
as cryptographic algorithms or cryptosystems, where plaintext (or ciphertext)
and encryption (or decryption) keys are parameters. Most cryptosystems are
based on assumptions that certain problems such as, e.g., factorisation of
numbers, are hard problems in terms of complexity theory. We denote a
ciphertext produced as a result of encrypting a plaintext message m using
an encryption key k as {m}k .
A ciphertext {m}k shall ensure that only those possessing key k are able to
decrypt the ciphertext and access m in plaintext form. In practice ciphertexts
may be open to manipulation, as the legacy of the Data Encryption Standard ,
or DES, reminds us. DES was introduced in the 1970s as an encryption algo-
rithm; as of late 1990s it has been considered to be vulnerable to brute-force
398 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
This allows any entity to send private messages to A without the need for
sharing a key between them.
Another useful application of public key cryptography is to allow for sign-
ing messages, i.e., a message m is encrypted with A’s private key as
{m}skA . This could only be decrypted using A’s public key pk A , where
This allows any entity A to sign a message, where anyone can verify that
the message originated from A.
Closely following [CLRS09], we provide an example of a public key cryp-
tosystem.
(i) A → B : m
This simply denotes that in the i th step of a protocol entity A sends a mes-
sage m destined for entity B. We use A, B and C throughout the chapter as
participant entities. Message can consist of several parts which are concate-
nated. We write message concatenation with a ’.’, e.g., m1 .m2 is a message
consisting of two messages m1 and m2 . In order to avoid brackets, we use the
convention that concatenation is a left-associative operator.
A security protocol is a communication protocol that provides assurance
on security. To this end, such a protocol may use cryptography as a building
block towards achieving one or more security principles; note however that
cryptography alone may not suffice to achieve a principle.
Note, that this notation does not take care of actions that a partic-
ipant is performing after receiving a message, e.g., the activity “upon
receipt B decrypts this message” is abstracted from.
402 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
Some authors consider more powerful intruder models, where the intruder
has more capabilities, in particular w.r.t. the perfect encryption assump-
tion. For instance, Schneider [Sch02] demonstrates how the intruder could
be allowed to manipulate composition of messages through the exclusive-or
function. Compared to the Dolev-Yao model, the intruder is therefore given
further capability to interfere with protocol messages.
are no guarantees to the initiator with whom the responder is running the
protocol with. This is the weakest of the authentication guarantees suggested
by Lowe. Some protocols may serve this guarantee from a responder to an
initiator, in which case we speak of aliveness as well.
On the other hand the strongest of Lowe’s guarantees is presented below.
Definition 2 (Injective agreement) We say that a protocol guarantees to an
initiator A injective agreement with a responder B on a set of data items ds
if, whenever A (acting as initiator) completes a run of the protocol, appar-
ently with responder B, then B has previously been running the protocol,
apparently with A, and B was acting as responder in his run, and the two
agents agreed on the data values corresponding to all the variables in ds, and
each such run of A corresponds to a unique run of B.
Injective agreement ensures that both protocol participants are engaged
in the same run with each other, every time the protocol is run. Additionally,
every run provides explicit agreement on any parameters of the protocol.
Essentially, this serves for mutual authentication between A and B.
Strong guarantees such as injective agreement above require some mech-
anism to ensure uniqueness of protocol runs. To ensure that a response is
fresh, and not a replay from a previous run of the protocol between some A
and B, a random value is often used, referred to as a nonce. At the start of
every run, A would generate a fresh nonce NA and include it in the challenge
it sends to B. Upon receipt of a response from B, A would check for the
value of the nonce to ensure it is the same. This provides A with a guarantee
that B has engaged in this fresh run of the protocol. This is important where
protocols are designed to run several times; in such a situation the attacker
could replay an older message and use it to deceive a participant.
For the purposes of this chapter, we consider nonces as arbitrary values
for single use. We assume that nonces are
– fresh every time they are generated;
– unpredictable such that no participant can determine the value of a nonce
yet to appear; and
– not able to reveal the identity of the participant that produced the nonce.
For protocol implementation nonces are typically realised as randomly gener-
ated numbers. How to realise random number generators, and how to prove
that they match the criteria listed above, is beyond the scope of this chapter.
One of the first authentication protocols was presented by Needham and
Schroeder [NS78] in 1978. It became the basis for the well-known Kerberos
protocol widely used in a range of applications including imap, POP, SMTP,
FTP, SSH and Microsoft applications.
8 Formal Verification of Security Protocols 405
In 1995, Lowe presented a man in the middle attack on the N-S proto-
col [Low95]. Such an attack allows an attacker to impersonate one partici-
pant in a session with another and serves to demonstrate the subtleties of
designing such protocols.
The first run of the protocol shows A initiating an honest run with
I with a fresh nonce NA . Before I responds, it initiates a second run
of the protocol with B, pretending to be A, and forwards NA to B by
encrypting it with pk B . B responds to the request by encrypting NA
and a fresh nonce NB , and encrypting it with A’s public key pk A . At
this stage, B believes that it is taking part in a run with A, whereas A
believes that it is taking part in a run with I ; note that NB is of the
form that does not convey to A the identity of the entity that generated
the nonce.
For B to be assured that it communicates with A, it waits for the
final message of the protocol. To mislead B, I relays the response from
B onwards to A in response to the earlier run of the protocol. A finds
the message as expected and returns NB encrypted with pk I , which I is
able to decrypt. I encrypts it with pk B to send it onwards to B as part
of the final message of the second run. As a result of this, B is misled
to believe that it has just completed a protocol run with A.
Lowe’s attack shows that the protocol fails on injective agreement
between A and B. Injective agreement insists that the responder B has
to be running the protocol with A, which has shown to be not the case.
For the intruder to complete the last step (2.3) of the manipulated
run, it needs A to decrypt B ’s nonce. Hence the attack cannot be fulfilled
without A’s engagement. Therefore, despite of the attack, A’s aliveness
is guaranteed to B.
The attack demonstrates how the protocol fails to achieve the goal of
mutual authentication between the two participants.
Lowe [Low95] presents a modification to the original protocol, aptly known
as the Needham-Schroeder-Lowe protocol (short: N-S-L protocol), to address
the flaw demonstrated in Example 75.1
CM |= ϕ =⇒ AM |= ϕ.
The message space of a protocol is the set of all messages that can appear
in any run of the protocol. This space usually has a structure. In general,
one considers the following sets: U denotes a set of protocol participants that
may run it, N is a set of all nonces and K is a set of all cryptographic keys
that can be used by participants. Thus the set of all atoms A is defined as
A ::= U | N | K
8 Formal Verification of Security Protocols 409
There are three cases: messages can be atoms, messages can be encrypted
under some key, and messages can be paired.
x∈X P (x)
B = receive.B?a?{n.a}pkB →
send.B.a!{n.NB }pka →
receive.B.a?{NB }pkB → Stop
8 Formal Verification of Security Protocols 411
Here, n and a are variables. Both a and n are bound when B receives
its first message. The question mark before the a indicates that a is
a variable. The Csp process B is only prepared to receive messages if
both occurrences of a in receive.B?a?{n.a}pkB have the same value. In
receive.B.a?{NB }pkB we write a ‘?’ in front of {NB }pkB , though the
process B is only willing to receive this specific value and no binding to
a variable takes place.
Note that each message in the protocol corresponds in Csp to one
send and one receive action in different processes.
We model a ‘secure’ Network as a process that receives messages,
passes them on to the intended receiver, and then starts over again:
send.A.B
send.A.I
A receive.A.B
receive.A.I receive.I.A
receive.I.B
Network send.I.A
send.B.A send.I.B
send.B.I
B receive.B.A
receive.B.I
This modelling makes use of Csp pattern matching: a process is only will-
ing to receive those messages that match the specified pattern. This abstracts
from implementation details such as first receiving a message, then decrypting
and analysing it, before possibly rejecting it.
Recall that the Dolev-Yao model allows an intruder to block, replay, spoof
and manipulate messages that appear on any public communication channel.
A generates relation can be used to characterise the message manipulation
that the intruder is capable of. Figure 8.2 presents the rules that define this
relation.
Fig. 8.2 Rules for generating messages using the ⊆ P(M) × M relation
In step (1.1) of the protocol run in Eample 75.1, the intruder receives
the message {NA .A}pkI . This increases the intruder’s knowledge to a
set denoted as IK as follows:
Compared with the setting of Example 75.3, now the intruder process
replaces the network component.
The process NET has many traces including the one from the man
in the middle attack demonstrated in Example 75.1:
Example 75.6 shows that taking the traces of a security protocol as they
are can make it difficult to analyse the protocol for authentication. In such
circumstances, one often ‘enriches’ such model of a system in order to indicate
particular behaviours of interest. In the next section we will use ‘signal events’
to indicate what stage of the protocol a participant has reached through a
protocol run.
To make explicit the role of protocol participants, signal events are defined
[SBS09] as a structure to indicate the status of a participant. This technique
is known as instrumentation. In instrumentation, signal events are added to a
process in order to allow for more fine grained observations. When one makes
use of instrumentation, it is important to check that the chosen instrumen-
tation does not alter the original behaviour, i.e., after instrumentation, all
original behaviours must remain possible, and no new behaviours are added.
For the purpose of analysis in this chapter, we use a set S of signals:
B = receive.B?a?{n.a}pkB →
Running.B.a.n →
send.B.a!{n.NB }pka →
receive.B.a.{NB }pkB →
Commit.B.a.NB → Stop
∀tr .tr b
≤ tr =⇒ a ∈ tr
agreement if for P extended with signals, where A will only commit once
with NA , the following holds:
The first step in making our Csp specification of a security protocol machine
readable is to represent its message space (cf. Sect. 8.4.2). To this end, CspM
offers syntax to describe the Csp alphabet in form of a functional program-
ming language. This includes (among many other features) the possibility
to define (recursive) data types, provides a built-in generic type for forming
sequences, supports set comprehension, and allows one to define functions
using pattern matching.
Using CspM , we can represent the message space of Example 75.2 as
follows:
MSG3_CONT = { Enc.pkb.(Sq.<Nonce.nb>) |
pkb <- PKEY, nb <- NONCE }
MSG3_BODY = { (Msg3, c) | c <- MSG3_CONT }
{NA , A}pkB
Enc.pkb.(Sq.<Nonce.na, User.a>)
8 Formal Verification of Security Protocols 421
Note the symbols < and >, which are used as sequence constructors in
CspM . The variables pkb, na, and a are bound to the following specific
values
i.e., pkb can be any public key, na can be any nonce, and a can be any
user. Finally, this set of messages is wrapped up as
Similar constructions are applied to the messages in the second and third
steps. Finally, we construct sets MSG CONT and MSG BODY, that contain
all possible message contents and message bodies respectively.
This message space is a finite one. This is due to the finiteness of the
domains we start with, and due to using only constructions that, given
finite sets as parameters, result in a finite set.
User_A =
[] b : diff(USER,{A}) @
send.A.b.(Msg1, Enc.pk(b).(Sq.<Nonce.NA, User.A>))
-> [] nb : NONCE @
recv.A.b.(Msg2, Enc.PKA.(Sq.<Nonce.NA, Nonce.nb>))
-> send.A.b.(Msg3, Enc.pk(b).(Sq.<Nonce.nb>))
-> STOP
...
Network = send?a?b?m -> recv.b.a.m -> Network
System =
(User_A ||| User_B) [| {|send, recv|} |] Network
422 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
The process User A directly encodes the three steps in which partici-
pant A is engaged in, where the choice operators are restricted to finite
sets, ensuring finite branching.
The system composition with parallel operators uses the CspM con-
struct {|send, recv|}, which denotes the set of all events that can be
communicated over the channels send and recv.
In our first encoding of the intruder, see Eq. 8.3, the intruder process was
parameterised over the set of facts known in a particular state. Thus, there
is an exponential number of states, as there are 2|Fact| subsets. Inspired by
the Casper tool, we represent the facts by having |Fact| many processes that
are running in parallel. Each of these can be in two states, i.e., we still have
an exponentiell size of states. However, by using parallel composition, we
play to the strength of model checking in FDR. The intruder has some initial
knowledge IK.
Key.SKI, Nonce.NI,
User.A, User.B, User.I}
Intruder(K) =
|| F : Fact @ [KnownAlpha(F)]
if member(F,K) then Known(F) else Unknown(F)
The replicated alphabetised parallel || F:Fact @ [KnownAlpha(F)]
creates |Fact| many processes. These processes take either the form
Known(F) or Unknown(F). This state depends whether the fact F belongs
to the set K. The processes are synchronised over sets KnownAlpha(F).
Section B.1 provides a concise definition of the replicated operator in
particular of the synchronisation sets between the processes.
KnownAlpha(F) =
Union({
{ send.x.y.(Msg1,F) | x <- USER, y <- USER,
member(F, MSG1_CONT)},
...
{ recv.x.y.(Msg3,F) | x <- USER, y <- USER,
member(F, MSG3_CONT)},
{ infer.F.r |
r <- rules_match_head(F,Deduction_Rules) },
{ infer.rule_head(r).r |
r <- rules_contain_body(F,Deduction_Rules) }
})
...
Encryption_Deduction_Rules =
Union({Msg1_Encryption_Deduction_Rules,
Msg2_Encryption_Deduction_Rules,
Msg3_Encryption_Deduction_Rules})
Msg1_Decryption_Deduction_Rules =
{ (Nonce.n ,
{Enc.k.(Sq.<Nonce.n, User.u>), Key.sk(k)}) |
k<-PKEY, n <- NONCE, u <- USER }
...
Decryption_Deduction_Rules =
Union({Msg1_Decryption_Deduction_Rules,
Msg2_Decryption_Deduction_Rules,
Msg3_Decryption_Deduction_Rules})
Deduction_Rules =
Union({Encryption_Deduction_Rules,
Decryption_Deduction_Rules})
The rules are formed along the three message types. The set of
Deduction Rules is the union of all these rules.
Note that we only encode encryption with a public key and decryp-
tion with a secret key, i.e., we realise Eq. 8.1, but ignore Eq. 8.2.
8 Formal Verification of Security Protocols 425
In the chosen encoding approach, there are |Fact| many processes. These
processes are either in the Known state or in the Unknown state, representing
the current intruder’s knowledge. Every message that the intruder listens
to on the network potentially increases this knowledge, i.e., the state of a
process changes from Unknown to Known or remains as Known. Furthermore,
the intruder can apply inference rules. This is encoded via a synchronisation
between processes in state Known: provided the intruder knows all facts in
the condition, the process encoding the fact stated in the rule’s conclusion
can change from Unknown to Known. The intruder can send those messages
which are known.
rule_head((f,_)) = f
rule_body((_,bs)) = bs
There are four functions that decompose rules: to return a rule’s head
or body, and to obtain rules matching a given head or body. Here, the
“ ” is a wildcard symbol, that acts as a placeholder for any value in the
appropriate domain.
Unknown(F) =
(member(F, MSG1_CONT) &
[] x : diff(USER, {I}),
y : USER @ send.x.y.(Msg1,F) -> Known(F))
[] ... []
([] r : rules_match_head(F,Deduction_Rules) @
infer.F.r -> Known(F))
Known(F) =
(member(F, MSG1_CONT) &
(([] x : USER, y : USER @
426 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
Building over the message space, the protocol participants and the intruder
encoded in CspM , it becomes straightforward to compose the overall system.
Having encoded the system under consideration, the next step is to encode
the security property we are interested in.
8 Formal Verification of Security Protocols 427
Note that over an alphabet with two elements {e, d}, any trace that
fulfills e precedes d needs to begin with e: suppose a trace t would
start with d, then the property would not hold for the first element of
t. When a trace has e as its first element, it will fulfill the property e
precedes d regardless of what follows.
The encoding of aliveness and injective agreement in CspM follows
Definitions 5 and 6. The external choice operator in the process encoding
aliveness allows to choose any participant as a partner.
InjectiveAgreement(a,b,na) =
Precedes(running.b.a.na, commit.a.b.na)
Having now encoded both the system and the security properties in CspM ,
we can set up the model checking:
The model checker confirms that both refinements hold, i.e., with
Aliveness(A,B) and Aliveness(B,A). Thus, we have an automated
proof for the claim that the N-S protocol offers aliveness.
However, setting up model checking for injective agreement leads to
a violation of the refinement:
to be seen by the intruder. The idea is that message of rank 1 can be ‘freely
circulated’ and won’t give the intruder any knowledge that could be used to
compromise security. In a protocol run the intruder’s knowledge shall remain
of rank 1.
So, for example, the identities of protocol participants are always assumed
to be known by all participants. Hence we can assign them rank 1: ρ(U) 1.
Public keys are always known and hence are assigned rank 1. Private keys of
honest users however are assumed to be never compromised, hence they have
rank 0. Naturally, the intruder knows its own private key, thus it gets rank
1. For the N-S-L protocol, this would mean:
0 ; k = skA ∨ k = skB
ρ(k)
1 ; otherwise
ρ(c.m) ρ(m).
The rank of a set S is the rank of the element in the set with the lowest rank:
The rank of a sequence tr is the rank of the element in the sequence with the
lowest rank:
ρ(tr) min{ρ(s) | s in tr}.
We define min{} 1, i.e., it is the maximum value that a rank function can
take.
A process P maintains ρ if it does not introduce a message of rank 0
after receiving messages of rank 1 only, i.e., it never ‘leaks a secret’. More
formally:
Definition 7 (Maintains rank)
P maintains ρ
⇔
∀tr ∈ traces(P ).ρ(tr receive) = 1 =⇒ ρ(tr (send ∪ S)) = 1
8 Formal Verification of Security Protocols 431
where P is a process and ρ is a rank function. The channels receive and send
are seen here as sets of events that can be communicated over them. The
function restrict denoted by projects an arbitrary trace to a trace containing
only elements that belong to a given set A. It is defined as follows:
a
(tr A) if a ∈ A
A
; ( a
tr) A
tr A if a ∈
/A
In order to state the main result of this chapter, we generalise the precedes
predicate from pairs of events to pairs of event sets.
Definition 8 (R precedes T) Let R and T be some disjoint sets of events.
∀b ∈ T, tr .tr b
≤ tr =⇒ ∃a ∈ R.a ∈ tr
P [| R |] Stop
The process Stop does not engage in any event. The synchronous parallel
operator [| R |] says that events in the set R need to be synchronised, i.e., they
can happen only if both processes are willing to engage in them. Therefore
as long as events are not from R any event in which P [| R |] Stop engages
is coming from P . If P wants to engage in an event from R, it is blocked
by Stop. The above construction ‘preserves’ all traces of P up until the first
appearance of an event from R.
Network restriction and precedes predicates are closely related:
Theorem 2 (Linking “precedes” with network restriction) With the nota-
tions as above it holds that
R. We have to show that tr does not contain an event from T . Assume, that
tr contains some event b from T . Then there exists tr b
≤ tr. Then, by
assumption, there must occur some a ∈ R in tr . Contradiction to tr R =
.
“⇐” Let tr ∈ traces(P ). Assume that R precedes T does not hold for
tr. Then there exists some tr b
≤ tr with b ∈ T such that for all
a ∈ R it holds that a does not occur in tr . As tr b
≤ tr, we have
tr b
∈ traces(P )—this holds as the Csp traces semantics is prefix closed.
Then tr b
∈ traces(P [| R |] Stop). However, tr b
T =
, as b ∈ T.
Contradiction.
Theorem 2 provides a general strategy for security properties that can be
characterised by a precedes predicate. Consider the network NET restricted
by a particular set R, i.e., the process NET [| R |] Stop; if this process has no
traces in which events from T occur, the protocol is correct; otherwise it is
not correct.
The following theorem, originally stated in [Sch98a], turns this idea into
an effective proof method for security protocol analysis. It essentially reduces
the analysis for the precedes predicate to the analysis of the maintains rank
property.
For the formulation of this theorem, we—like in our protocol encoding in
CspM for the sake of model checking—distinguish between the user name,
e.g., A, B, I ∈ U, and the Csp process User i that says how user i behaves in
the context of the protocol.
Theorem 3 (Rank Function Theorem) Consider the following network:
where
• U is a finite set of user names,
• S̄ is some finite set of channel names for signal events,
• User i is a process that describes how participant i behaves, where
– User i can send messages on channel send.i,
– User i can receive messages on channel receive.i,
– User i can report progress to the environment by sending signals on
channel signal.i,
– the alphabet of User i is a subset of
and
• the Intruder process is given by
8 Formal Verification of Security Protocols 433
satisfying
(R1) ∀m ∈ Init.ρ(m) = 1
(R2) ∀S ⊆ M, m ∈ M.(∀m ∈ S.ρ(m ) = 1 ∧ S m) =⇒ ρ(m) = 1
(R3) ∀t ∈ T.ρ(t) = 0
(R4) ∀i ∈ U.User i [| R |] Stop maintains ρ
In this section we focus on proving that the N-S-L protocol provides injective
agreement. We will also briefly discuss where the proof fails in the case of the
N-S protocol.
First, let’s take a look at the instrumented N-S-L protocol. Here, we con-
sider only the Csp specifications for participants A and B, as instrumentation
does neither change the intruder process nor the network composition. We
instrument the protocol for proving B authenticating A using nonce NB as a
challenge. This means by Definition 6 that we aim to prove that the protocol
satisfies the two properties:
• Running.A.B.NB precedes Commit.B.A.NB and
• nonce NB is used only once.
The Rank Function Theorem can be utilised to check the precedes property.
That nonce NB is used only once is a consequence of our assumptions on
nonces, cf. Sect. 8.3.
B = receive.B?a?{n.a}pkB →
send.B.a!{B.n.NB }pka →
receive.B.a?{NB }pkB →
Commit.B.a.NB → Stop
Rather than using the instrumented processes A and B from Example 76.1
directly for our analysis, we are replacing them with different processes that
are better suited for the analysis. In Example 76.2 for process A we are using
a semantically equivalent process, and for process B we are using a refined
process B̂, i.e., B̂ has less behaviours.
where
436 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
B̂ receive.B.A?{n.A}pkB →
send.B.A!{B.n.NB }pkA →
receive.B.A?{NB }pkB →
Commit.B.A.NB → Stop
ρ(U) 1
0 ; if k ∈ {skA , skB }
ρ(K)
1 ; otherwise
0 ; if n = NB
ρ(N )
1 ; otherwise
8 Formal Verification of Security Protocols 437
1 ; if b = A, m ∈ B. N .NB
ρ({m}pkb )
ρ(m) ; otherwise
0 ; if b = A, m ∈ {B. N .NB }pkA
ρ({m}skb )
ρ(m) ; otherwise
0 ; if s = Commit.B.A.NB ;
ρ(S)
1 ; otherwise
ρ(m1 .m2 ) = min{ρ(m1 ), ρ(m2 )}
The specific rationale behind this definition is as follows:
• The protocol participants are all expected to be known, so that any
participant can initiate communication with any other. Hence rank
1 is assigned to all values in U.
• We assume that all secret keys of honest users remain private. Hence
rank 0 is assigned to them. The intruder knows its own secret key,
thus ρ(skA ) = 1. All public keys have rank 1.
• As nonce NB is used for authentication, it is assigned rank 0. For the
chosen guarantee, all other nonces can be assigned rank 1.
• When in dialog with participant A, in its second step participant B
circulates the message {B.NA .NB }pkA , thus we assign such messages
rank 1 and explicitly set the decryption of these messages to rank 0.
The rank of all other messages depends on their contents only.
• Theorem 2 requires signals in set T to be of rank 0: consequently
we assign ρ(Commit.B.A.NB ) = 0; all other signals can be freely
circulated and hence assigned rank 1.
• In order to deal with the pairing function, we say that a pair of
messages has rank 0 when one of the messages involved has rank 0.
One can prove by induction on the message structure that the target
domain of ρ is indeed {0, 1}.
Checking for R1
Checking for R2
1. m ∈ S then S m
2. S m and S k then S {m}k
3. S {m}pkb and S skb then S m
4. S m1 .m2 then S m1 and S m2
5. S m1 and S m2 then S m1 .m2
When deriving messages using these rules, we count the application of one
rule as one step. This allows us to check property R2 by induction on the
length of the derivation.
Checking for R3
The only event in set T is the signal event Commit.B.A.NB , which has rank
0. Thus, the condition is satisfied.
(stop-law)
Stop [| R |] Stop = Stop
(input-law)
(output-law)
send.x.y.m
→ P [| R |] Stop
Stop ; if send.x.y.m ∈ R
=
send.x.y.m → (P [| R |] Stop) ; otherwise
(signal-law)
Stop ; if s ∈ R
(s → P ) [| R |] Stop =
s → (P [| R |] Stop) ; otherwise
(distr-law)
Checking for R4
In order to check for condition R4, there are two calculi that support dis-
charging this proof obligation. The first calculus deals with network restric-
tion: given a process involving a restriction operator, this calculus allows us
to derive an equivalent Csp process without restriction operator. The second
calculus supports us in checking if a Csp process maintains rank. It reduces
the proof obligation “maintains rank” over a ‘complex’ process to a proof
obligation over a simpler process and the checking of some side conditions.
Thanks to these two calculi, it is often possible to discharge proof obligation
R4 in an, admittedly lengthy, however rather mechanical way.
440 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
Figure 8.3 collects a number of algebraic laws that hold for restriction (over
the Csp traces model T ). Chapter 3 discusses how to develop and prove such
Csp laws. Furthermore, the following theorem holds:
Theorem 4 (Restriction with disjoint event set) If R ∩ α(P ) = ∅ then
P [| R |] Stop = P, where α(P ) denotes the alphabet of process P .
Applying the calculus provided by these laws, and also taking Theorem 4
into account, we compute restriction free processes associated with the pro-
cesses describing the behaviour of participants A and B under restriction:
The processes Ā(b, n) are generic in two variables, namely in the user
name b ∈ {B, I} and in the nonce n ∈ {NA , NB , NI }. We consider two
cases:
Case 1: b = B and n = NB .
= (send.A.B!{NA .A}pkB →
receive.A.B?{B.NA .NB }pkA →
Running.A.B.NB →
send.A.B!{NB }pkB → Stop) [| Running.A.B.NB |] Stop
= send.A.B!{NA .A}pkB →
receive.A.B?{B.NA .NB }pkA → Stop
A [| Running.A.B.NB |] Stop
= (send.A.B!{NA .A}pkB →
receive.A.B?{B.NA .NB }pkA → Stop)
(b=B∨n=NB Ā(b, n))
ρ(
receive) = 1 ⇒ ρ(
(send ∪ S)) = 1
⇔ ρ(
) = 1 ⇒ ρ(
) = 1
⇔⇒
⇔
(stop-rule)
Stop maintains ρ
P maintains ρ, ρ(m) = 1
(output-rule)
send.x.y.m → P maintains ρ
P maintains ρ, ρ(data) = 1
(signal-rule)
event.data → P maintains ρ
Here, event ∈ Running.U.U ∪ Commit.U .U .
∀j ∈ J.Pj maintains ρ
(choice-rule)
j∈J Pj maintains ρ
Thus,
ρ(tr receive) = 1 ⇒ ρ(tr (send ∪ S) = 1
⇔ ρ(tr receive) = 1 ⇒ ρ(tr (send ∪ S) = 1
⇔ P maintains ρ.
P maintains ρ holds as it is a premise of the rule.
(signal-rule) Analogously to the (output-rule).
(input rule) Let tr ∈ traces(receive.x?y?p → P (y, p),
Case 1: If tr =
, then the claim holds, see the proof for the stop rule.
Case 2: If tr =
, then there exists some tr ∈ traces(P ) such that
tr = receive.x.y.m tr for some y and m. Let ∀y, m ∈ M.ρ(m) = 1 ⇒
(P (y, m) maintains ρ.
Case 2.1: If ρ(m) = 0, then ρ(receive.x.y.m tr ) receive = 0 and the
implication holds as the premise is wrong.
8 Formal Verification of Security Protocols 443
According to the rule’s premise, P (y, m) maintains ρ holds for all y and m
with ρ(m) = 1.
ρ({b.NA .n}pkA )
= min{ρ(b), ρ(NA ), ρ(n)}
= min{1, 1, 1}
= 1.
A [| Running.A.B.NB |] Stop
maintains ρ (choice-rule).
B̂ = receive.B.A?{n.A}pkB →
send.B.A!{B.n.NB }pkA →
receive.B.A?{NB }pkB →
Commit.B.A.NB → Stop
1. ρ({NB }) = ρ(NB ) = 0.
Thus, Q1 receive.B.A?{NB }pkB → Commit.B.A.NB → Stop
maintains ρ (input-rule).
2. ρ({B.n.NB }pkA ) = 1 for all n ∈ N .
As Q1 maintains ρ, also Q2 (n) send.B.A!{B.n.NB }pkA → Q1
maintains ρ for all n ∈ N (output-rule).
3. As Q2 (n) maintains ρ for all n ∈ N , receive.B.A?{n.A}pkB → Q3 (n)
maintains ρ (input-rule).
Overall, this analysis shows that B̂ maintains ρ.
Concerning the process algebra Csp, the book “The Modelling and Anal-
ysis of Security Protocols: The Csp Approach” [RSG+00] provides a good
overview on the techniques that one can apply to protocol analysis in the
context of Csp.
When model checking security protocols with FDR, the informal specifi-
cation needs to be converted into an appropriate script that FDR takes as an
input. In order to assist in the generation of such machine-readable script,
Gavin Lowe [Low97a] has developed a specialist tool, Compiler for the Analy-
sis of Security Protocols, better known as Casper, to convert informal protocol
specification into a script that can be processed by FDR.
The insight gained into the design of a protocol due to rank functions
analysis is invaluable. Constructing a rank function, however, is not always
trivial and remains arduous. Heuristic approaches to constructing rank func-
tions assist in the manual process of verification [SBS06]. This still leaves the
448 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
This chapter has demonstrated the use of the Dolev-Yao intruder model. An
area of further research aims to extend the boundaries of this model and to
incorporate further properties of existing cryptographic primitives and handle
new primitives. This is critical if protocols with real-world complexity are to
be analysed for even more sophisticated attacks. The rank functions approach
has been extended to analyse protocols relying on algebraic properties of
exclusive-or (XOR) primitives used to combine messages [Sch02], and for
protocols making use of the Diffie-Hellman scheme [DS07a].
Handling security properties other than authentication is also of interest.
Some work in this area has dealt with anonymity [SS96], perfect forward
secrecy [DS05], non-repudiation [Sch98a] and temporal aspects of security
properties [ES00]; as new properties permanently emerge there is an ongoing
need to address these new properties.
Another area of research belongs to emerging scenarios for security pro-
tocols operating in pervasive environments, where location and attribute
authentication properties, along with nodes with limited processing abilities,
are modelled for.
One example of this can be found in RFID technology as is used, e.g., in
supply chains. RFID tags have limited computational capabilities and power
supply. Thus, RFID technology relies on specific protocols. For many of these
protocols it is not known if they achieve the desired security services, while
for many of them attacks have been demonstrated [VDR08]. Manik Lal Das
et al. give an analysis of an RFID authentication scheme in the context of
the internet of things [DKM20].
Another example are Industrial Internet of Things (IIoT) edge security
challenges, e.g., when it comes to data integrity. An attacker might alter
data from sensors, thus let automation and decision making come to wrong
conclusions or degrade network performance. As IIoT networking and devices
are heterogenous and resource-constrained, deploying standard security pro-
tocols is challenging. Thus, many IIoT networks are operating unprotected.
Developing and analysing suitable protocols is an ongoing research topic, see,
e.g., [CGBK20]. Yet another topic is how to guarantee security in heteroge-
nous settings, when IIoT networks consists of edge nodes running various
different protocols.
450 Markus Roggenbach, Siraj Ahmed Shaikh, and Hoang Nga Nguyen
References
[CGBK20] Karanjeet Choudhary, Gurjot Singh Gaba, Ismail Butun, and Pardeep Kumar.
MAKE-IT - A lightweight mutual authentication and key exchange protocol
for industrial internet of things. Sensors, 20(18):5166, 2020.
[CK11] Véronique Cortier and Steve Kremer, editors. Formal Models and Techniques
for Analyzing Security Protocols. IOS Press, 2011.
[CLN09] Cas J. F. Cremers, Pascal Lafourcade, and Philippe Nadeau. Comparing state
spaces in automatic security protocol analysis. In Formal to Practical Security,
LNCS 5458. Springer, 2009.
[CLRS09] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.
Introduction to Algorithms. The MIT Press, 2009.
[DKM20] Manik Lal Das, Pardeep Kumar, and Andrew Martin. Secure and privacy-
preserving RFID authentication scheme for internet of things applications.
Wirel. Pers. Commun., 110(1):339–353, 2020.
[DS05] Rob Delicata and Steve A. Schneider. Temporal rank functions for forward
secrecy. In 18th IEEE Computer Security Foundations Workshop. IEEE Com-
puter Society, 2005.
[DS07a] Rob Delicata and Steve Schneider. An algebraic approach to the verification
of a class of Diffie-Hellman protocols. International Journal of Information
Security, 6(2-3):183–196, 2007.
[DS07b] Christos K. Dimitriadis and Siraj A. Shaikh. A biometric authentication pro-
tocol for 3G mobile systems: Modelled and validated using CSP and rank
functions. International Journal of Network Security, 5(1), 2007.
[DY83] D. Dolev and A. Yao. On the security of public key protocols. IEEE Trans.
Inf. Theor., 29(2):198–208, 1983.
[ES00] Neil Evans and Steve Schneider. Analysing time dependent security properties
in CSP using PVS. In ESORICS, LNCS 1895. Springer, 2000.
[ES05] Neil Evans and Steve A. Schneider. Verifying security protocols with PVS:
widening the rank function approach. J. Log. Algebr. Program., 64(2):253–
284, 2005.
[Gol03] D. Gollmann. Authentication by correspondence. IEEE Journal on Selected
Areas in Communications, 21(1):88–95, 2003.
[Hea00] James Heather. Using rank functions to verify authentication protocols. PhD
thesis, Royal Holloway University of London, 2000.
[HS02] James Heather and Steve Schneider. Equal to the task? In ESORICS, LNCS
2502. Springer, 2002.
[HS05] James Heather and Steve Schneider. A decision procedure for the existence of
a rank function. Journal of Computer Security, 13(2):317–344, 2005.
[HS06] James Heather and Steve Schneider. To infinity and beyond or, avoiding the
infinite in security protocol analysis. In ACM Symposium on Applied Com-
puting, pages 346–353. ACM, 2006.
[Laz99] Ranko S. Lazić. A semantic study of data independence with applications to
model checking, 1999. PhD thesis. University of Oxford.
[Low95] Gavin Lowe. An attack on the Needham-Schroeder public-key authentication
protocol. Information Processing Letters, 56(3):131–133, 1995.
[Low97a] Gavin Lowe. Casper: A compiler for the analysis of security protocols. In Com-
puter Security Foundations Workshop. IEEE, 1997.
[Low97b] Gavin Lowe. A hierarchy of authentication specifications. In Computer Secu-
rity Foundations Workshop. IEEE, 1997.
[NR06] Long H. Nguyen and Andrew W. Roscoe. Efficient group authentication pro-
tocol based on human interaction. IACR Cryptol. ePrint Arch., 2006.
8 Formal Verification of Security Protocols 451
[NS78] Roger M. Needham and Michael D. Schroeder. Using encryption for authen-
tication in large networks of computers. Communications of the ACM,
21(12):993–999, 1978.
[RSG+00] P.Y.A. Ryan, S.A. Schneider, M.H. Goldsmith, G. Lowe, and A.W. Roscoe.
The Modelling and Analysis of Security Protocols: The CSP Approach.
Addison-Wesley, 2000.
[SBS06] Siraj A. Shaikh, Vicky J. Bush, and Steve A. Schneider. A heuristic for con-
structing rank functions to verify authentication protocols. In Preproceedings
of the 3rd International Verification Workshop at IJCAR 2006, pages 112–
127, 2006.
[SBS09] Siraj A. Shaikh, Vicky J. Bush, and Steve A. Schneider. Specifying authen-
tication using signal events in CSP. Computers & Security, 28(5):310–324,
2009.
[SC14] Spyridon Samonas and David Coss. The CIA strikes back: Redefining confi-
dentiality, integrity and availability in security. Journal of Information System
Security, 2014.
[Sch98a] Steve A. Schneider. Formal analysis of a non-repudiation protocol. In CSFW,
pages 54–65, 1998.
[Sch98b] Steve A. Schneider. Verifying authentication protocols in CSP. IEEE Trans.
Software Eng., 24(9):741–758, 1998.
[Sch02] Steve Schneider. Verifying authentication protocol implementations. In Formal
Methods for Open Object-Based Distributed Systems. Kluwer, 2002.
[SD06] Siraj A. Shaikh and Christos K. Dimitriadis. Analysing a biometric authen-
tication protocol for 3G mobile systems using CSP and rank functions. In
Security in Pervasive Computing, LNCS 3934, pages 211–226. Springer, 2006.
[SS96] Steve Schneider and Abraham Sidiropoulos. CSP and anonymity. In
ESORICS, LNCS 1146. Springer, 1996.
[VDR08] Ton Van Deursen and Sasa Radomirovic. Attacks on RFID protocols. Cryp-
tology ePrint Archive, 2008.
Part IV
Wrapping up
Chapter 9
Origins and Development
of Formal Methods
John V. Tucker
Let us look at early software and ask, how it was made and who for? Two
domains are well known: scientific software and business software—both were
pioneering, large scale and critically important to their users. Science and
business had a profound effect on the early development and adoption of
computing technologies, though what was computed was already computed
long before electronic computers and software emerged and changed the scale,
speed and cost of computation.
The initial development of programming was largely shaped by the need to
make computations for scientific, engineering and business applications. An
important feature of applications in numerical calculations and simulations
in science and engineering that is easily taken for granted is that the prob-
lems, theoretical models, algorithms and data are mathematically precise and
John V. Tucker
Swansea University, Wales, United Kingdom
Among the responses to the crisis was the idea of making the whole pro-
cess of software development more “scientific”, governed by theoretically
well-founded concepts and methods. A metaphor and an aspiration was the
contemporary standards of engineering design, with its mathematical mod-
els, experimental discipline and professional regulation, as in civil engineer-
ing. Enter a new conception of software engineering whose Formal Methods
were to provide new standards of understanding, rigour and accountability in
design and implementation. Today, we can organise Formal Methods through
their systematic methodologies for design and validation, techniques for for-
mally modelling systems, software tools for exploring the models, and mathe-
matical theories about the models. In addition to this technical organisation,
Formal Methods can also be organised by their use in different application
domains. Here my emphasis is on original formal modelling techniques and
mathematical theories.
1 An account of the conference and copies of the proceedings are available at http://
homepages.cs.ncl.ac.uk/brian.randell/NATO.
9 Origins and Development of Formal Methods 457
9.2 Logic
theories were created around the new problems in computing: excellent exam-
ples are the theories of abstract data types and process algebra.
The case for mathematical logic as a theoretical science that is fundamental
to the future of computing was made eloquently by John McCarthy (1927–
2011) in a 1963 paper that has elements of a manifesto [McC63]:
“It is reasonable to hope that the relationship between computation and mathe-
matical logic will be as fruitful in the next century as that between analysis and
physics in the last. The development of this relationship demands a concern for
both applications and for mathematical elegance.”
Over fifty years later the fruitful relationship is thriving and is recog-
nised in computer science and beyond. Very advanced theories about data,
programming, specification, verification have been created—clearly estab-
lishing the connections envisioned by McCarthy. So, today, logical methods
are advanced and commonplace. Their origins and nature require explain-
ing to young computer scientists who encounter them as tools. In science,
there are few more dramatic examples of the fundamental importance of
research guided by the curiosity of individuals—rather than by the directed
programmes of companies, organisations and funding bodies—than the legacy
of logic to computer science.
What is a program? What does a program do? Formal Methods for developing
programs begin with the problem of defining programming languages. This
requires methods for defining
(i) the syntax of the language, i.e., spelling out the properties of texts that
qualify as legal programs of the language; and
(ii) the semantics of the language, i.e., giving a description of what con-
structs mean or what constructs do.
Formal Methods often make precise informal methods but in the case of
programming and programming languages there were few informal methods.
Early languages of the 1950s, like Fortran for scientific computation, and
the later Cobol for commercial data processing, established the practicality
and financial value of high-level machine-independent languages.2 But their
features were simple and, being close to machine architectures, their informal
descriptions were adequate for users and implementors. The need for more
expressive high-level languages presented problems. An early success was the
definition of the syntax of Algol 60 using mathematical models of grammars
[Nau+60, Nau62]. The method used was to become known as BNF notation,
2 By 1954 the cost of programming was becoming comparable with the cost of computer
installations, which was a prime motivation for IBM’s development of Fortran [Bac98].
9 Origins and Development of Formal Methods 459
sometimes named after its creators John Backus (1924–2007) and Peter Naur
(1928–2016).
The definition of syntax took up some important ideas from linguistics
from the 1950s, where the search for a mathematical analysis of what is com-
mon to natural languages led to the formal grammars of Noam Chomsky
[Cho56, Cho59] and his four-level hierarchy. The BNF notation corresponded
exactly with Chomsky’s context-free grammars. The mathematical analysis
of languages defined by grammars was taken over by computer scientists,
motivated by parsing and translating programming languages. Its generality
enabled its applications to grow widely. The resulting formal language theory
was one of the first new scientific theories to be made by computer scientists.
It found its place in the computer science curriculum in the 1960s, symbolised
by the celebrated classic by Ullman and Hopcroft [UH69].3 The technical ori-
gins of Formal Methods for the syntax of natural and computer languages lie
in mathematical logic, especially computability and automata theory where
decision problems were a central topic and rewriting rules for strings of sym-
bols were well known as models of computation. Thus, the works of Alan
Turing and Emil Post (1897–1954) are an influence on theory-making from
the very beginning: see Greibach [Gre89] for an account of the development
of formal language theory.
The definition of the semantics of programming languages has proved to be
a much harder problem than that of syntax. One needs definitive explanations
for what programming constructs do in order to understand the implications
of choices in the design of languages, and the consequences for the programs
that may be written in them. A semantics is needed as a reference standard,
to guarantee the portability of programs and to reason about what programs
do.
Most programming languages are large and accommodate lots of features
that are thought to be useful in some way. This criterion of ‘usefulness’ varies
a great deal. Variants of features to allow programmers lots of choice add to
the size, and the interaction between features add to the semantic complex-
ity. Thus, semantic definitions of whole languages are awkward and are rarely
achieved completely in a formal way. However, the semantical analysis of lan-
guages that are focussed on a small number of programming constructs has
proved to be very useful—modelling constructs and their interaction in a
controlled environment, as it were. For example, simple languages contain-
ing just a few constructs can be perpetual sources of insights.4 Over many
years, these studies have led to ambitious attempts to find systematic meth-
ods for cataloging and predicting the semantic consequences of choosing con-
structs for programming languages. However, the basic approaches to defining
3 The following decade saw a rich harvest of textbooks on processing syntax, six by Ullman,
formally the meaning of a programming language have been settled since the
1970s.
First, there are operational semantics, where the constructs are explained
using mathematical models of their execution. A natural form of operational
semantics defines an abstract machine and explains the behaviour of con-
structs in terms of changes of states of the machine. Operational semantics
aligns with interpreters. An important historical example are the Formal
Methods developed to define the semantics of the language PL/1 at the IBM
Vienna Laboratories. The PL/1 language was an important commercial devel-
opment for IBM, complementing the convergence of IBM users’ software and
machines represented by OS/360. PL/1—like OS/360—was a huge challenge
to the state of the art of its day. Starting in 1963, the language was developed
in New York and Hursley, UK. The task of providing a complete and precise
specification of the new language was given to Vienna in 1967, and led to
remarkable advances in our knowledge of programming languages, through
the work of many first-rate computer scientists (e.g., the contributions of
Hans Bekić (1936–1982) and Peter Lucas (1935–2015), see [BJ84]). Their
methods resulted in the Vienna Definition Language for the specification of
languages [Luc81].
Secondly, there are denotational semantics, where the constructs are
interpreted abstractly as so-called denotations, normally using mathemati-
cal objects of some kind. In a first attempt at this denotational approach,
Christoper Strachey (1916–1975) and Robert Milne made a huge effort to
develop such a mathematically styled semantics for languages. An early
important example of the application of the approach is Peter Mosses’s
semantics for Algol 60 [Mos74]. The mathematical ideas needed led to a new
semantic framework for computation called domain theory. This was based
upon modelling the approximation of information using orderings on sets; it
was proposed by Dana Scott (1932-) and developed by him and many oth-
ers into a large, comprehensive and technically deep mathematical subject.
Domains of many kinds were created and proved to be suited for defining
the semantics of functional languages where recursion is pre-eminent. Deno-
tational semantics also involve abstract meta-languages for the purpose of
description and translation between languages.
Thirdly, there are axiomatic semantics, where the behaviour of constructs
are specified by axioms. Axiomatic semantics defines the meaning of con-
structs by means of the logical formulae that correctly describe input-output
behaviours, or even the logical formulae that can be proven in some logic
designed around the language. Axiomatic semantics focus on what a pro-
grammer can know and reason about the behaviour of his or her programs.
An important development was the attempt by Robert Floyd (1936–2001)
to provide rules for reasoning on the input/output behaviour of flow charts
and Algol fragments [Flo67]. In these early investigations, the behaviour of a
program was described in terms of expressions of the form
{P }S{Q},
9 Origins and Development of Formal Methods 461
not essential, for a method for defining programming languages. In the case
of Floyd-Hoare logic for while programs, the semantics the proof system
is actually talking about was surprising [BT84a], for example, it was non-
deterministic.
The relationship between the three different methods of defining semantics
was addressed early on—e.g., by the former Vienna Lab computer scientist
Peter Lauer in [Lau71]—but the links between the semantics of programs
and the formal systems for reasoning were weak and error prone. For exam-
ple, a decade later, Jaco de Bakker (1939–2012) made a monumental study
of operational and denotational programming language semantics and their
soundness and completeness with respect to Floyd-Hoare logics in [Bak80].
Again the theory was limited to computation on the natural numbers. Later
the theory was generalised in [TZ88] to include abstract data types using an
assertion language that was a weak second-order language, and a lot of new
computability theory for abstract algebraic structures [TZ02].
The late 1960s saw the beginnings of an intense period of thinking
about the nature of programming and programs that sought concepts and
techniques that were independent of particular programming languages.
New methods for developing data representations and developing algorithms
focussed on a rigorous understanding of program structure and properties,
and became a loosely defined paradigm called structured programming. For
a classic example, in 1968, Edsger Dijkstra pointed out that the use of the
goto statement in programs complicated massively their logic, was a bar-
rier to their comprehension and should be avoided [Dij68c]. Throughout the
1970s, increasingly sophisticated views of programming and programs grew
into the new field of programming methodology, which was perfect for encour-
aging the growth of formal modelling and design methods. For example,
in the method of stepwise refinement an abstractly formulated specification
and algorithm are transformed via many steps into a concrete specification
and program, each transformation step preserving the correctness of the new
specification and program. This method of developing provably correct pro-
grams was promoted by Edsger Dijkstra [Dij76]. The abstract formulations
used novel computational concepts such as non-determinism in control and
assignments, concurrency, and abstract data type specifications to make high-
level descriptions of programs, and turned to the languages of mathematical
logic to formalise them. For example, a formal theory of program refinement
employing infinitary language and logic was worked out by Back [Bac80].
Many interesting new developments and breakthroughs in Formal Methods
have their roots in the scientific, curiosity-driven research and development we
have mentioned. For example, the specification languages and their associated
methodologies are intended to describe and analyse systems independently
of—and at a higher level of abstraction than is possible with—programming
languages. An early example is the Vienna Development Method (VDM),
which originates in the IBM Vienna Laboratory work on Formal Methods
and the exercise of developing a compiler—the Vienna Definition Language.
9 Origins and Development of Formal Methods 463
The purpose of computing is to create and process data. Of all the concepts
and theories to be found in Formal Methods to date, perhaps the simplest
and most widely applicable is the theory of abstract data types. The informal
programming idea of an abstract data type is based upon this:
This informal notion can be found in Barbara Liskov and Steve Zilles 1974
article [LZ74].5 Liskov saw in abstract data types a fundamental abstrac-
tion that could be applied pretty much anywhere and would contribute to
the methodologies emerging in structured programming; more importantly
the abstraction could be implemented and a bridge formed between com-
putational structures and operations. Liskov designed CLU to be the first
working programming language to provide such support for data abstraction
[LSR+77, LAT+78]. Liskov’s thinking about abstract data types is focussed
by the construct of the cluster which, in turn, is inspired by the concepts of
5 Along with suggestions about encapsulation, polymorphism, static type checking and
exception handling!
464 John V. Tucker
modularity + encapsulation.
These two concepts derive from David Parnas’ hugely influential ideas of
information hiding and encapsulation, with their emphasis on interfaces
separating modules, and specifications and their implementations [Par72a,
Par72b, Par01].
Encapsulation means that the programmer in CLU can access data only
via the operations listed in the header of a cluster, and is ignorant of the
choices involved in data representations. This raises the question what, and
how, does the programmer know about the operations? The answer is by
giving axioms that specify the properties of the operations. Steve Zilles had
presented this idea using axioms that were equations in a workshop organised
by Liskov in 1973, where he defined a data type of sets. This is the start of the
emphasis on the algebraic properties of data types [Zil74, LZ75]. The notion
was designed to improve the design of programming languages—as in Liskov’s
CLU. It helped shape the development of modular constructs such as objects
and classes, e.g., in the languages C++ [Str80] and Eiffel [Mey91, Mey88].
But it did much more. It led to a deep mathematical theory, new methods
for specification and verification, and contributed spinouts seemingly removed
form abstract data types.
Soon abstract data types became a new field of research in programming
theory, as the Workshop in Abstract Data Types (WADT), begun and ini-
tially sustained in Germany from 1982, and the 1983 bibliography [KL83]
and bear witness.
The formal theory of data types developed quickly but rather messily.
The idea of abstract data type was taken up more formally by John Guttag
in his 1975 PhD (e.g., in [Gut75, Gut77]), and by others who we will meet
later. Guttag studied under Jim J Horning (1942–2013) and took some ini-
tial and independent steps toward a making a theory out of Zillies’s simple
idea [GH78]. As it developed it introduced a number of mathematical ideas
into software engineering: universal algebra, initial algebras, final algebras,
axiomatic specifications based on equations, term rewriting, and algebraic
categories. Most of these ideas needed considerable adaption or extension:
an important example is the use of many sorted structures—a topic barely
known in algebra. Experienced computer scientists, mainly at IBM Yorktown
Heights, began an ambitious research programme on Formal Methods for
data: Joseph Goguen (1941–2006), Jim Thatcher, Eric Wagner, Jesse Wright
formed what they called the ADJ Group and wrote about many of the basic
ideas needed for a fully formal theory of data in a long series of some 18 papers
[Gog89, GTW78, Wag01], though Goguen left the group to pursue other col-
laborations. Most of their work is unified by the fundamental notion of ini-
tiality, and the problems of specifying abstract data types using axioms made
of equations. The theory was elegant and very robust, and encouraged the
emergence of specification as an independent subject in software engineering.
Mathematically, the theory of abstract data types grew in scope and
sophistication. For example, Guttag and others had noted the relevance of
9 Origins and Development of Formal Methods 465
empty stack and so is not defined. Such partial functions cause difficulties
when working with equations and term rewriting; they are especially disliked
by theoreticians captivated by beauty of the algebraic methods applied to
total functions. Making partial operations total is an option, e.g., the idea of
introducing data to flag errors, but one that is not always attractive math-
ematically. As abstract data types and specification methods expanded in
the 1980s, issues of partiality could not be ignored. A good impression of the
variety of treatments of partiality that were becoming available can be gained
from Peter Mosses’s [Mos93], who was later to take on the task of manag-
ing the definition of Casl where decisions on partial semantics were needed.
Monographs [Bur86] and [Rei87] on partiality appeared in the decade. New
treatments continue to be developed such as [HW99], and the iconoclastic
but surprisingly practical and algebraically sound 1/0 = 0 of [BT07].
The theory of institutions was created by Joseph Goguen and Rod Burstall
with the aim of capturing the essence of the idea of a logical system and its
role in Formal Methods. The use of logical calculi was burgeoning and the
concept aimed to abstract away and become independent of the underlying
logical system; it did this by focussing on axioms for satisfaction. Institutions
could also describe the structuring of specifications, their parameterization
and refinement, and proof calculi. Institutions see the light of day through
the algebraic specification language CLEAR [BG80] and more independently
in [GB84]; Goguen and Burstall’s polished account appears only 12 years
later in [GB92]. A interesting reflection/celebration of institutions and related
attempts is [Dia12]. Institutions offer a general form of template for language
design, comparison and translation, albeit one that is very abstract. They
have been applied to modelling languages like UML and ontology languages
like OWL, and to create new languages for both such as the distributed ontol-
ogy, modelling and specification Language DOL [Mos17]. Specification as a
fundamental concept and as a subject in its own right was advanced by work
involving abstract data types. Unsurprisingly in view of the universal impor-
tance of data types, several areas in computer science first tasted Formal
Methods through abstract data types or benefitted from ideas and methods
spun out of its research. It was out of this research community came the first
use of Formal Methods for testing by Marie-Claude Gaudel (1946-) and her
coworkers in e.g., [BCF+86, Gau95].
The design of better language constructs was a motivation for abstract
data types, and the initial concerns with abstraction, modularity, reuse, and
verification have proved to be timeless and very general. Inherent in thinking
about data abstraction are ideas of genericity. With a background in abstract
data types, David Musser (who had worked with John Guttag), Deepak
Kapur (who had worked with Barbara Liskov) and Alex Stepanov proposed
a language Tecton [KMS82] for generic programming in 1982. Stepanov went
on to design of the standard template library (STL) for C++, i.e., the C++
standard collection classes, which has been influential in the evolution of C++
and other languages. Generic programming is a programming paradigm based
9 Origins and Development of Formal Methods 467
that focuses on finding the most abstract formulations of algorithms and then
implementing efficient generic representations of them; it leads to libraries
of re-usable domain-specific software. Much of these language developments
took place in industrial labs, starting with the General Electric Research
Center, New York.
Like grammars and automata, abstract data types are timeless scientific
ideas.
Despite the fact that logic is fundamentally about reasoning and logic was
so influential in computing, reasoning about programs was slow to gather
momentum and remained remote from practical software development. The
mathematical logician and computer pioneer Alan Turing applied logic in his
theoretical and practical work and, in particular, addressed the logical nature
of program correctness in an interesting report on checking a large routine
in 1949, see [MJ84]. In 1960, John McCarthy drew attention to proving cor-
rectness [McC62]: “Primarily, we would like to be able to prove that given
procedures solve given problems” and, indeed:
“Instead of debugging a program, one should prove that it meets its specification,
and this proof should be checked by a computer program. For this to be possible,
formal systems are required in which it is easy to write proofs.”
Earlier, we noted the rise of such formal systems for program correctness
after Floyd and Hoare in the late 1960s, motivated by the needs of users of
programs.
The development of reasoning about programs has followed three paths.
First, there was the development of logics to model and specify computational
properties, such as program equivalence and correctness. To add to the selec-
tion of first-order and second-order logics mentioned, temporal logics were
proposed by Burstall [Bur74] and Kröger [Krö77, Krö87]; and, earlier, in a
particularly influential 1977 article about properties arising in sequential and,
especially, concurrent programming, Amir Pnueli (1941–2009) applied linear
temporal logic (LTL) [Pnu77].
The second path is the formulation of special methodologies and languages
for constructing correct programs. One example is design-by-contract, associ-
ated with Bertrand Meyer’s language Eiffel. In this object-oriented language,
software components are given verifiable interface specifications, which are
styled contracts; these specifications augment abstract data types with pre-
conditions, postconditions and invariants. Another example is Cliff Jones’ rely
guarantee methods for designing concurrent programs, originating in [Jon81].
Rely guarantee methods are designed to augment Floyd-Hoare triples to con-
trol information about the environment of a parallel program. The method
468 John V. Tucker
cially known as Nqthm, was begun in 1971 and over four decades accom-
plished a number of important verifications including a microprocessor [Hun85]
and a stack of different levels of software abstraction [Moo89]; the later indus-
trial strength version ACL2 provided verifications of floating point for AMD
processor implementations [MLK96]. PVS appeared in 1992 but is one of a
long line of theorem provers built and/or developed at SRI, starting with
Jovial in the 1970s [EGM+79]. The aim of PVS is provide a general working
environment for system development using Formal Methods, in which large
formalizations and proofs are at home. Thus, PVS combines a strong specifi-
cation language and proof checker, supported by all sorts of tools and libraries
relevant to different application areas. The progress of PVS was influenced
by work for NASA and is now very widely used [ORS+95, Cal98].
Theorem provers based on quite different logics have also proved success-
ful. An intuitionistic logic created in 1972 to model mathematical statements
and constructive reasoning by Per Martin-Löf (1942-) based on types is the
basis for many theorem provers and programming languages. Robert Consta-
ble developed Nuprl, first released in 1984 [Con86], and others based upon
dependent type theories and functional programming have followed, such as
Coq [BC04] and Agda [BDN09]. The use of types goes back to logic and
Bertrand Russell (1872–1970)—see [Con10].
Model checkers seek to find when a formula ϕ is satisfiable in a model. The
verification technique is particularly suited to concurrency where formulae
in temporal logic can express properties such as mutual exclusion, absence
of deadlock, and absence of starvation, and their validity tested in a state
transition graph, called a Kripke structure. For such concurrency problems,
linear temporal logic (LTL) was applied by Amir Pnueli; the logic contained
operators F (sometimes) and G (always), augmented with X (next-time) and
U (until) and the program proofs were deductions in the logic. In 1981 the
value and efficiency of satisfiability was established by Edmund M Clarke and
Allen Emerson [CE81] and, independently, by Jean-Pierre Queille and Joseph
Sifakis [QS82] who showed how to use model checking to verify finite state
concurrent systems using temporal logic specifications. For example, Clarke
and Emerson used computation tree logic (CTL) with temporal operators A
(for all futures) or E (for some future) followed by one of F (sometimes), G
(always), X (next-time), and U (until). Personal accounts of the beginnings
of model checking are [Cla08] by Clarke and [Eme08] by Emerson. For an
introduction to temporal logic methods see the monograph [DGL16].
The role of logic is to express properties of programs in logical languages
and to establish rules for deducing new properties from old. To make a pro-
gram logic, such as a Floyd-Hoare logic, typically there are two languages
and sets of rules—the language of specifications and the language of pro-
grams. It is possible to combine specifications and programs into a single
formal calculus, and there are plenty of formal systems that seem to possess
such unity. Given that the calculi are intended for reasoning about programs,
the complicating factor is what is meant by programs. In such calculi using
470 John V. Tucker
9.6 Concurrency
Concurrency in computing refers to the idea that two or more processes exist,
that they are taking place at the same time and communicating with one
another. The phenomenon is ubiquitous in modern software, but it can take
on many forms and leads to very complicated behaviour. Analysing, and to
some extent taming, the logical complexity of concurrency has been another
significant achievement of Formal Methods over the past 50 years.
Early on concurrency was found to be fundamental in the design of oper-
ating systems, where in the simplest of machines many processes need to be
running at the same time, monitoring and managing the machine’s resources,
computations, input-output, and peripherals. Until quite recently, there was
one processor that had to schedule all instructions so as to create and main-
tain an approximation to simultaneous operation. The solution was to break
up the different processes and interleave their instructions—the processor
speed being so great that for all practical purposes the effect would be simul-
taneous operation. This technique later became known as the arbitrary inter-
leaving of processes.
The problems that arose from this necessary concurrency in operating sys-
tems required computer scientists to isolate the phenomenon and to create
special constructs such as Dijkstra’s semaphore for the THE multiprogram-
ming system [Dij63, Dij68a, Dij68b]. The topic was soon central to research in
programming methodology. Programming concurrency led to all sorts of spe-
cial algorithmic constructs and reasoning techniques initially to extend the
Formal Methods that had bedded down for sequential languages. An impor-
tant paper extending Floyd-Hoare style verification to parallel programs is
[OG76]. But parallelism also demanded a substantial rethink of how we spec-
ify semantics. Gordon Plotkin’s introduction of the method of what became
called structural operational semantics (SOS) in 1980 [Plo04a, Plo04b] is
something of a milestone, evident in his elegant semantics for the concurrent
9 Origins and Development of Formal Methods 471
The idea of a process calculus led Tony Hoare to re-analyse the ideas of
his Csp language [Hoa78] and create a new calculus called (for a period)
Theoretical Csp.
These calculus approaches took off with new energy and in all sorts of
new directions. The sharpness of the mathematical tools uncovered a wide
spectrum of semantics for concurrent processes. The relationship between
processes, especially their equivalence, emerged as a fundamental but very
complex topic. There were many ways of viewing processes and their equiva-
lence in formal calculi, for the world has many systems. Milner’s longstanding
interest [Mil70, Mil71a, Mil71b] in the idea of a process simulating another
was a basic idea of CCS. In contrast, Hoare’s Csp compared processes by
notions of refinement.
In the emerging process theory, notions of system equivalence soon mul-
tiplied taking many subtly different forms [Gla96]. David Park (1935–1990)
introduced a technical notion into process theory called bisimulation [Par81].
Ideas of bisimulation focus on when two systems can each simulate the oper-
ation of the other. Bisimulation in concurrency also took on many forms and,
indeed unsurprisingly, bisimulation notions suitably generalised were found
to have wide relevance [Rog00]. Bisimulation stimulated interest in apply-
ing and developing new semantic frameworks for computation, such as game
semantics [Cur03] and coalgebraic methods [San11, SR11].6
De Bakker and Zucker took the process notion and created a new theory
of process specification based on metric space methods for the solution of
equations [BZ82]. They were inspired technically by Maurice Nivat’s lectures
on formal languages based on infinite strings [Niv79] where the languages
were defined using fixed points provided by the Banach contraction theorem.
The metric space theory of processes expanded providing an alternate theory
of nondetermisitic processes [BR92].
An important advancement of the nascent theory was to refine further
the fundamental issues that the principle demanded, non-determinsim and
sequencing. A pure form of process theory called Algebra of Communicating
Processes (ACP) was created by Jan Bergstra and Jan Willem Klop in 1982.
They viewed processes algebraically and axiomatically: a process algebra was
a structure that satisfied the axioms of ACP, and a process was simply an
element of a process algebra! In particular, the axioms of ACP were equations
that defined how operators made new processes from old. The equations made
ACP subject to all sorts of algebraic constructions such as initial algebras,
inverse limits etc. Thus, ACP took an independent direction, inspired by the
world of abstract data types and rewriting. Interestingly, ACP was developed
along the way of solving a problem in de Bakker-Zucker process theory (on
fixed points of so called non-guarded equations). It was Bergstra and Klop
who first coined the term process algebra in this first publication [BK82]. The
term later came to cover all work at this level of abstraction. Their theory was
6 Just as studies of recursive definitions of higher types in programming languages led to
the semantic framework of domain theory.
9 Origins and Development of Formal Methods 473
reducing risks and so to determine when 00-55 would apply. The standards have been
9 Origins and Development of Formal Methods 475
safety critical computing in general are the Formal Methods for hybrid sys-
tems.
Safety critical software engineering needs to grow as automation deepens
its hold on our work places, infrastructure, homes and environment, and soft-
ware is desired that is smart in making anticipations. But human safety is
not merely a matter of exact specifications that are correctly implemented.
Human safety is dependent on good design that understands the human in
the context.
Security. Lastly, with our capabilities and our appetite to connect together
software devices come deep worries about security. These worries are affecting
much software engineering as the need to identify and work on vulnerabilities
on legacy and new software becomes commonplace. Access control, broadly
conceived, is an important area for security models that codify security poli-
cies. For a system or network they specify who or what are allowed to access
the system and which objects they are allowed to access. Access problems
are encountered in the design of early operating systems, of course. The
1973 mathematical model that Bell and Padula designed for military appli-
cations was particularly influential that was developed and deployed in many
security applications [BLaP73, BLaP76]. However, John McLeans’s formal
analysis [McL87], some 14 years later, revealed technical problems with the
revised several times subsequently and the explicit requirement for Formal Methods has
been removed.
476 John V. Tucker
9.8 In Conclusion
found what they needed in small neglected corners of logic and algebra. The
theory-makers were driven to speculate and experiment with ideas, sometimes
behind and sometimes in front of the technologies of the day. It started with
the specification of programming languages—syntax and semantics. As our
understanding grew, languages developed alongside Formal Methods. Soft-
ware tools of all kinds demand languages for descriptions. That digital com-
putation is in its nature logical and algebraic was understood early on—it
is clear in Turing’s view of computation. That logical and algebraic theories
could be so expanded and refined to embrace practical large scale hardware
and software design, and the immense and diverse world of users, is a remark-
able scientific achievement, one that is ongoing and is at the heart of research
and development of Formal Methods.
However, from the beginning, the speed of innovation in software and
hardware has been remarkable—as any history of computer science since
the 1950s makes clear. This relentless development generates productivity
for users, profit for innovators, and challenges for regulators. It has certainly
outstripped the complex and patient development of the underlying science of
software engineering, e.g., in safety and especially security. Formal Methods
have come a long way and have mastered many theoretical and practical
problems of enormous complexity and significance. They are the foundations
for an enduring science of computing.
On a personal note, I thank Markus Roggenbach for his invitation and
encouragement to write this account of the origins and early development of
formal Formal Methods for software engineering. I have benefitted from infor-
mation and advice from Antonio Cerone, Magne Haveraaen, Faron Moller,
Bernd-Holger Schlingloff, Harold Thimbleby, and Henry Tucker. I find myself
a witness to many of the technical innovations that make up the story so far.
I know that this first hand experience has led to bias toward some achieve-
ments and to neglect of others, but hopefully I—and certainly others—will
have opportunities to correct my shortcomings. This survey has been shaped
by the themes of this textbook, and the extensive Formal Methods archives
in Swansea University’s History of Computing Collection. As my efforts here
suggests, deeper histories will be needed as the subject matures, our under-
standing grows, and breakthroughs mount up.
References
[Apt81] Krzysztof Apt, Ten years of Hoare’s logic: A survey – Part I, ACM Transactions
on Programming Languages and Systems, 3 (4) (1981), 431–483.
[Apt83] Krzysztof Apt, Ten years of Hoare’s logic: A survey – Part II: Nondeterminism,
Theoretical Computer Science, 28 (1-2) 1983, 83–109.
[ASM80] Jean-Raymond Abrial, Stephen A Schuman, and Bertrand Meyer, A specifica-
tion language, in A M Macnaghten and R M McKeag (editors), On the Con-
struction of Programs, Cambridge University Press, 1980.
[Bac80] Ralph-Johan Back, Correctness Preserving Program Refinements: Proof The-
ory and Applications, Mathematical Centre Tracts 131, Mathematical Centre,
Amsterdam, 1980.
[Bac98] John Backus, The history of Fortran I, II, and III, IEEE Annals of the History
of Computing, 20 (1998) (4), 68–78.
[Bae05] Jos C.M. Baeten, A brief history of process algebra, Theoretical Computer Sci-
ence, 335 (2-3) (2005), 131–146.
[Bak80] Jaco de Bakker, Mathematical Theory of Program Correctness, Prentice-Hall
International Series in Computer Science, 1980.
[BB96] Jos C.M. Baeten and Jan A. Bergstra, Discrete time process algebra, Formal
Aspects of Computing, 8 (1996) (2), 188–208.
[BBR10] Jos C M Baeten, T. Basten, and M.A. Reniers, Process Algebra: Equational The-
ories of Communicating Processes, Cambridge Tracts in Theoretical Computer
Science 50, Cambridge University Press, 2010.
[BBS92] Jos C M Baeten, Jan A Bergstra, and Scott A. Smolka, Axiomatising proba-
bilistic processes: ACP with generative probabilities, in CONCUR 92, Lecture
Notes in Computer Science 630, Springer, 1992, 472–485.
[BBS95] Jos C M Baeten, Jan A Bergstra, and Scott A. Smolka, Axiomatizing probabilis-
tic processes: ACP with generative probabilities, Information and Computation,
121(1995) (2), 234–254.
[BC04] Yves Bertot and Pierre Castéran, Interactive Theorem Proving and Program
Development. Coq art: The Calculus of Inductive Constructions, Texts in The-
oretical Computer Science: an EATCS series, Springer, 2004.
[BCF+86] L. Bouge, N.Choquet, L. Fribourg, and M.-C. Gaudel. Test set generation from
algebraic specifications using logic programming. Journal of Systems and Soft-
ware, 6 (4) (1986) 343–360.
[BD02] Manfred Broy and Ernst Denert (editors), Software Pioneers: Contributions to
Software Engineering, Springer-Verlag, 2002.
[BDN09] Ana Bove, Peter Dybjer and Ulf Norell, A Brief Overview of Agda – A Functional
Language with Dependent Types, in Stefan Berghofer, Tobias Nipkow, Christian
Urban and Makarius Wenzel (editors), Theorem Proving in Higher Order Logics,
Lecture Notes in Computer Science 5674, Springer-Verlag, 2009, 73–78.
[Bek71] Hans Bekić, Towards a mathematical theory of processes, Technical Report TR
25.125, IBM Laboratory Vienna, 1971. Reprinted in [BJ84].
[Bel05] D. Elliott Bell, Looking back at the Bell-La Padula model, ACSAC ’05 Pro-
ceedings of the 21st Annual Computer Security Applications Conference, IEEE
Computer Society, 2005, 337–351.
[BG80] Rod Burstall and Joseph Goguen. The semantics of Clear, a specification lan-
guage. In Dines Bjørner (editor), Abstract Software Specification – 1979 Copen-
hagen Winter School, Lecture Notes in Computer Science 86, Springer, 1980,
292–332.
[BH92] Dines Bjørner, Anne Elisabeth Haxthausen, Klaus Havelund, Formal, model-
oriented software development methods: From VDM to ProCoS and from RAISE
to LaCoS, Future Generation Computer Systems 7 (2-3) (1992), 111–138.
[BH14] Anya Helene Bagge and Magne Haveraaen, Specification of generic APIs, or: why
algebraic may be better than pre/post, in High integrity language technology
2014, ACM, 2014, 71–80.
9 Origins and Development of Formal Methods 479
[BHK89] Jan A Bergstra, Jan Heering, and Paul Klint (editors), Algebraic Specification,
ACM Press/Addison-Wesley, 1989.
[BJ82] Dines Bjørner and Cliff Jones, Formal Specification and Software Development,
Prentice Hall International, 1982.
[BJ84] Hans Bekić and Cliff Jones (editors), Programming Languages and Their Defini-
tion: H. Bekić (1936–1982), Lecture Notes in Computer Science 177, Springer,
1984.
[BJR96] Grady Booch, Ivar Jacobson and James Rumbaugh, The Unified Modeling
Language for Object-Oriented Development Documentation Set Version 0.91.
Addendum UML Update, Rational Software Corporation, 1996.
[BK82] Jan A Bergstra and Jan Willem Klop, Fixed point semantics in process algebra.
Technical Report IW 208, Mathematical Centre, Amsterdam, 1982.
[BK84] Jan A Bergstra and Jan Willem Klop, Process algebra for synchronous commu-
nication. Information and Control 60 (1-3) (1984), 109–137.
[BKM95] Robert S.Boyer, Matt Kaufmann, Joseph S Moore, The Boyer-Moore theo-
rem prover and its interactive enhancement, Computers and Mathematics with
Applications, 29 (2) (1995), 27–62.
[BLaP73] D. Elliott Bell and Leonard J. LaPadula, Secure computer systems: Vol. I math-
ematical foundations, Vol. II mathematical model, Vol III refinement of the
mathematical model. Technical Report MTR-2547 (three volumes), Mitre Cor-
poration, Bedford, MA, 1973.
[BLaP76] D. Elliott Bell and Leonard J. LaPadula, Secure computer system: Unified expo-
sition and Multics interpretation. Technical Report ESD-TR-75-306, Mitre Cor-
poration, Bedford, MA, 1976.
[BLS05] Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte, The Spec# program-
ming system: an overview, in Gilles Barthe, Lilian Burdy, Marieke Huisman,
Jean-Louis Lanet, and Traian Muntean (editors), Construction and Analysis
of Safe, Secure and Interoperable Smart Devices, Lecture Notes in Computer
Science 3362, Springer-Verlag, 2005, 49–69.
[BPS01] Jan A Bergstra, Alban Ponse and Scott A Smolka, Handbook of Process Algebra,
Elsevier 2001.
[BR92] Jaco de Bakker and Jan Rutten (editors), Ten Years of Concurrency Semantics.
Selected Papers of the Amsterdam Concurrency Group, World Scientific, 1992.
[Bro75] Fred Brooks, The Mythical Man-Month: Essays on Software Engineering, Addi-
son Wesley, 1975. Republished 1995.
[Bro87] Fred Brooks, No Silver Bullet – Essence and Accidents of Software Engineering,
IEEE Computer, 20 (1987) (4), 10–19.
[BT82a] Jan A Bergstra and John V Tucker, The completeness of the algebraic specifi-
cation methods for data types, Information and Control, 54 (1982), 186–200.
[BT82b] Jan A Bergstra and John V Tucker, Expressiveness and the completeness of
Hoare’s logic, Journal of Computer and System Sciences, 25 (3) (1982), 267–
284.
[BT84a] J A Bergstra and John V Tucker, The axiomatic semantics of programs based
on Hoare’s logic, Acta Informatica, 21 (1984), 293–320.
[BT84b] J A Bergstra and John V Tucker, Hoare’s logic for programming languages with
two data types, Theoretical Computer Science, 28 (1984) 215–221.
[BT87] Jan A Bergstra and John V Tucker, Algebraic specifications of computable and
semicomputable data types, Theoretical Computer Science, 50 (1987), 137–181.
[BT95] Jan A Bergstra and John V Tucker, Equational specifications, complete term
rewriting systems, and computable and semicomputable algebras, Journal of
ACM, 42 (1995), 1194–1230.
[BT07] Jan A Bergstra and John V Tucker, The rational numbers as an abstract data
type, Journal of the ACM, 54 (2), (2007), Article 7.
[Bur74] Rod BurstalI, Program proving as hand simulation with a little induction, in
Information Processing ’74, 308-312. North-Holland, 1974.
480 John V. Tucker
[Gut77] John V Guttag, Abstract data types and the development of data structures,
Communications of the ACM, 20 (6) (1977), 396–404.
[Har87] David Harel, Statecharts: a visual formalism for complex systems, Science of
Computer Programming, 8 (3) (1987), 231–274.
[Hav00] Magne Haveraaen, Case study on algebraic software methodologies for scientific
computing, Scientific Programming 8 (4) (2000), 261–273.
[Hen88] Matthew Hennessy, Algebraic Theory of Processes, MIT Press, 1988.
[HJ89] C A R Hoare and Cliff B. Jones, Essays in Computing Science, Prentice Hall
International, 1989.
[Hoa69] C A R Hoare, An axiomatic basis for computer programming, Communications
of the ACM, 12 (10) (1969), 576–580, 583.
[Hoa78] C A R Hoare, Communicating Sequential Processes, Communications of the
ACM, 21 (8) (1978), 666–677.
[Hoa85] C A R Hoare, Communicating Sequential Processes, Prentice-Hall, 1985.
[Hol97] Gerard Holzmann, The model checker SPIN, IEEE Transactions on Software
Engineering 23 (5) (1997), 279–295.
[Hol04] Gerard Holzmann, The SPIN Model Checker: Primer and Reference Manual,
Addison-Wesley, 2004.
[Hun85] Warren A Hunt, Jr, FM8501: A Verified Microprocessor, PhD Thesis, University
of Texas at Austin, 1985.
[HW73] C A R Hoare and N Wirth, An axiomatic definition of the programming language
Pascal, Acta Informatica, 2 (4) (1973), 335–355.
[HW99] Magne Haveraaen and Eric G. Wagner, Guarded algebras: disguising partial-
ity so you won’t know whether it’s there, in (editors), in Didier Bert, Chris-
tine Choppy and Peter D. Mosses, Recent Trends in Algebraic Development
Techniques, Lecture Notes in Computer Science 1827, Springer-Verlag, 1999,
182–200.
[Jon80] Cliff Jones, Software Development: A Rigorous Approach, Prentice Hall Inter-
national, 1980.
[Jon81] Cliff Jones, Development Methods for Computer Programs including a Notion of
Interference. PhD Thesis, Oxford University, 1981. Published as: Programming
Research Group, Technical Monograph 25.
[Jon90] Cliff Jones, Systematic Software Development using VDM, Prentice Hall 1990.
[Jon01] Cliff Jones, The Transition from VDL to VDM, Journal of Universal Computer
Science, 7 (8) (2001), 631–640.
[Jon03] Cliff Jones, The early search for tractable ways of reasoning about programs,
IEEE Annals of the History of Computing, 25 (2) (2003), 26–49.
[Jon13] Capers Jones, The Technical and Social History of Software Engineering, Addi-
son Wesley, 2013.
[GB84] Joseph A Goguen and Rod Burstall, Introducing institutions, in Edward Clarke
and Dexter Kozen (editors), Logics of Programming Workshop, Lecture Notes
in Computer Science 164, Springer, 1984, 221–256.
[GB92] Joseph A Goguen and Rod Burstall, Institutions: Abstract model theory for
specification and programming, Journal of the Association for Computing
Machinery, 39 (1) (1992), 95–146.
[GJS90] Alessandro Giacalone, Chi-chang Jou, and Scott A Smolka, Algebraic reasoning
for probabilistic concurrent systems, in Manfred Broy and Cliff Jones (editors),
Proceedings of IFIP Technical Committee 2 Working Conference on Program-
ming Concepts and Methods, North Holland, 1990, 443–458.
[GM82] Joseph A Goguen and Jose Meseguer, Security policies and security models,
in Proceedings 1982 Symposium on Security and Privacy, Oakland, CA, IEEE
Computer Society, 1982, 11–20.
[GM84] Joseph A Goguen and Jose Meseguer, Inference control and unwinding, in Pro-
ceedings 1984 Symposium on Security and Privacy, Oakland, CA, IEEE Com-
puter Society, 1984, 75–86.
9 Origins and Development of Formal Methods 483
[GM14] Jan F Groote and M.R.Mousavi, Modeling and analysis of communicating sys-
tems, The MIT Press, 2014.
[Gog89] Joseph A Goguen, Memories of ADJ, Bulletin of the EATCS, No. 36, October
1989, 96–102. Also Current Trends in Theoretical Computer Science: Essays
and Tutorials, World Scientific (1993), 76–81.
[Gor00] Michael Gordon, From LCF to HOL: a short history, in Gordon Plotkin, Colin
P Stirling, and Mads Tofte (editors), Proof, Language, and Interaction, MIT
Press, 2000, 169–185.
[Gor18] Michael Gordon, The unforeseen evolution of theorem proving in ARM processor
verification. Talk at Swansea University, 28th April 2015. http://www.cl.cam.
ac.uk/archive/mjcg/SwanseaTalk. Retrieved February 2018.
[Gre89] Sheila A Greibach, Formal languages: origins and directions, IEEE Annals of
the History of Computing, 3 (1) (1998), 14–41.
[Gri78] David Gries (editor), Programming Methodology. A Collection of Articles by
Members of IFIP WG 2.3, Springer, 1978.
[GTW78] Joseph A Goguen, Jim W Thatcher, and Eric G Wagner. An initial algebra
approach to the specification, correctness, and implementation of abstract data
types. In R T Yeh (editor) Current Trends in Programming Methodology. IV:
Data Structuring, Prentice-Hall, 1978, 80–149.
[HUW14] John Harrison, Josef Urban and Freek Wiedijk, History of interactive theorem
proving, in Dov M. Gabbay, Jörg H Siekmann, and John Woods Handbook of
the History of Logic. Volume 9: Computational Logic, North-Holland, 2014,
135–214.
[Kam77] Sam Kamin, Limits of the “algebraic” specification of abstract data types, ACM
SIGPLAN Notices, 12 (10) (1977), 37–42.
[KL83] B Kutzler and F Lichtenberger, Bibliography on Abstract Data Types, Lecture
Notes in Computer Science 68, Springer, 1983.
[KM14] Bakhadyr Khoussainov and Alexei Miasnikov, Finitely presented expansions of
groups, semigroups, and algebras, Transactions American Mathematical Society,
366 (2014), 1455–1474.
[KMS82] Deepak Kapur, David R Musser, and Alex A Stepanov, Tecton: A language for
manipulating generic objects, in J. Staunstrup (editor), Program Specification,
Lecture Notes in Computer Science 134, Springer-Verlag, 1982, 402–414.
[Krö77] Fred Kröger, LAR: A logic of algorithmic reasoning, Acta Informatica 8 (3)
(1977), 243–266.
[Krö87] Fred Kröger, Temporal Logic of Programs, EATCS Monographs in Theoretical
Computer Science 8, Springer-Verlag, 1987.
[Lam94] Leslie Lamport, The temporal logic of actions, ACM Transactions on Program-
ming Languages and Systems 16 (3) (1994), 872–923.
[Lan81] Carl Landwehr, Formal models for computer security, ACM Computing Surveys,
13 (3) (1981), 247–278.
[LAT+78] Barbara Liskov, Russell Atkinson, Toby Bloom, J. Eliot Moss, J. Craig Schaf-
fert, Robert Scheifler, and Alan Snyder, CLU Reference Manual, Computation
Structures Group Memo 161, MIT Laboratory for Computer Science, Cam-
bridge, MA, July 1978.
[Lau71] Peter Lauer, Consistent Formal Theories of the Semantics of Programming
Languages, PhD Thesis, Queen’s University of Belfast, 1971. Published as TR
25.121, IBM Lab. Vienna.
[LEW96] Jacques Loeckx, Hans-Dieter Ehrich, Markus Wolf, Specification of Abstract
Data Types: Mathematical Foundations and Practical Applications, John Wiley
and Sons, 1996.
[LG86] Barbara Liskov and John V Guttag, Abstraction and Specification in Program
Development, MIT Press and McGraw Hill, 1986.
[Low95] Gavin Lowe, Probabilistic and prioritized models of timed CSP. Theoretical
Computer Science, 138 (1995), 315–352.
484 John V. Tucker
[Low96] Gavin Lowe, Breaking and fixing the Needham-Schroeder public-key protocol
using FDR. Software - Concepts and Tools, 17:93–102, 1996.
[LSR+77] Barbara Liskov, Alan Snyder, Russell Atkinson, and J. Craig Schaffert, Abstrac-
tion mechanisms in CLU, Communications of the ACM, 20:8, 1977, 564–576.
[Luc70] Peter Lucas, On the semantics of programming languages and software devices,
in Randall Rustin (editor), Formal Semantics of Programming Languages,
Courant Computer Science Symposium 2, Prentice Hall, 1970, 52–57.
[Luc81] Peter Lucas, Formal Semantics of Programming Languages: VDL, IBM Journal
of Research and Development 25 (5) (1981), 549–561.
[LZ74] Barbara Liskov and Stephen Zilles, Programming with abstract data types,
ACM Sigplan Conference on Very High Level Languages, April 1974, 50–59.
[LZ75] Barbara Liskov and Stephen Zilles, Specification techniques for data abstrac-
tions, in IEEE Transactions on Software Engineering, 1 (1975), 7–19.
[MC80] Carver A. Mead and Lynn Conway, Introduction to VLSI Systems, Addison-
Wesley, 1980.
[McC62] John McCarthy, Towards a mathematical science of computation, in Cicely M
Popplewell (editor), Information Processing 1962, Proceedings of IFIP Congress
62, Munich, Germany, August 27 - September 1, 1962. North-Holland, 1962, 21–
28.
[McC63] John McCarthy, A basis for a mathematical theory of computation, in P Braffort
and D Hirshberg (editors), Computer Programming and Formal Systems, North-
Holland, 1963, 33–69.
[McL87] John Mclean, Reasoning about security models, 1987 IEEE Symposium on
Security and Privacy, Oakland, CA, IEEE Computer Society, 1987, 123–131.
[Mey88] Bertrand Meyer, Object-Oriented Software Construction, Prentice Hall, 1988.
[Mey91] Bertrand Meyer, Eiffel: The language, Prentice Hall, 1991.
[Mey92] Bertrand Meyer, Applying “Design by Contract”, IEEE Computer, 25 (10) 1992,
40–51.
[Mil70] Robin Milner, A Formal Notion of Simulation Between Programs, Memo 14,
Computers and Logic Research Group, University College of Swansea, UK, 1970.
[Mil71a] Robin Milner, Program Simulation: An Extended Formal Notion, Memo 15,
Computers and Logic Research Group, University College of Swansea, UK, 1971.
[Mil71b] Robin Milner, An Algebraic Definition of Simulation Between Programs, Stan-
ford Computer Science Report No. STAN-CS-71-205, 1971.
[Mil80] Robin Milner, A Calculus of Communicating Systems, Lecture Notes in Com-
puter Science 92, Springer-Verlag, 1980.
[Mil89] Robin Milner, Communication and Concurrency, Prentice Hall, 1989.
[Mil03] Robin Milner, Interview with Martin Berger at the University of Sussex, http://
users.sussex.ac.uk/~mfb21/interviews/milner. Retrieved March 2019.
[MJ84] F L Morris and Cliff B Jones, An early program proof by Alan Turing, Annals
of the History of Computing, 6 (2) (1984), 139–143.
[MLK96] J Strother Moore, Tom Lynch and Matt Kaufmann, A mechanically checked
proof of the correctness of the kernel of the AMD5K 86 floating-point division
algorithm, IEEE Transactions on Computers 47 (9) (1998), 913–926.
[MLP79] R A Millo, R J Lipton, and A J Perlis, Social processes and proofs of theorems
and programs, Communications of the ACM, 22 (5) (1979), 271–280.
[MMS+96] Carroll Morgan, Annabelle McIver, Karen Seidel and J. W. Sanders,
Refinement-oriented probability for CSP, Formal Aspects of Computing, 8 (6)
(1996) 617–647.
[Moo89] J Strother Moore, A mechanically verified language implementation, Journal of
Automated Reasoning, 5 (4) (1989), 461–492.
[Mos74] Peter D Mosses, The mathematical semantics of Algol 60, Oxford University
Programming Research Group Technical Report 12, 1974.
9 Origins and Development of Formal Methods 485
[Mos93] Peter D. Mosses. The use of sorts in algebraic data type specification, in Michel
Bidoit and Christine Choppy (editors), Recent Trends in Data Type Specifica-
tion, Lecture Notes in Computer Science 655, Springer-Verlag, 1993, 66–91.
[Mos04] Peter D Mosses (editor), CASL Reference Manual. The Complete Documenta-
tion of the Common Algebraic Specification Language, Lecture Notes in Com-
puter Science 2960, Springer-Verlag, 2004.
[Mos17] Till Mossakowski, The Distributed Ontology, Model and Specification Language
DOL, in Phillip James and Markus Roggenbach (editors), Recent Trends in
Algebraic Development Techniques, Lecture Notes in Computer Science 10644,
Springer-Verlag, 2017.
[Mor81] Thomas P Moran, The Command Language Grammar: A representation for the
user interface of interactive computer systems, International Journal of Man-
Machine Studies 15 (1) (1981), 3–50.
[MP67] John McCarthy and J Painter, Correctness of a compiler for arithmetic expres-
sions, Jacob T Schwartz (editor), Proceedings of Symposia in Applied Mathe-
matics 19. Mathematical Aspects of Computer Science, American Mathematical
Society, 1967, 33–41.
[MPW92] Robin Milner, Joachim Parrow and David Walker, A calculus of mobile pro-
cesses, Information and Computation, 100 (1) (1992), 1–40.
[MS76a] Robert Milne and Christopher Strachey, A Theory of Programming Language
Semantics. Part A: Indices and Appendices, Fundamental Concepts and Math-
ematical Foundations, Chapman and Hall, 1976.
[MS76b] Robert Milne and Christopher Strachey, A Theory of Programming Language
Semantics. Part B: Standard Semantics, Store Semantics and Stack Semantics,
Chapman and Hall, 1976.
[MS13] Faron Moller and Georg Struth, Modelling Computing Systems: Mathematics
for Computer Science, Springer, 2013.
[MT90a] Kevin McEvoy and John V Tucker, Theoretical foundations of hardware design,
in Kevin McEvoy and John V Tucker (editors), Theoretical Foundations of VLSI
Design, Cambridge Tracts in Theoretical Computer Science 10, Cambridge UP,
1990, 1–62.
[MT90b] Faron Moller and Chris Tofts, A temporal calculus of communicating systems,
In Jos C. M. Baeten and Jan Willem Klop (editors), CONCUR 90, Theories of
Concurrency: Unification and Extension, Lecture Notes in Computer Science
458. Springer-Verlag, 1990, 401–415.
[MT92] Karl Meinke and John V Tucker, Universal algebra, in S. Abramsky, D. Gabbay
and T Maibaum (editors) Handbook of Logic in Computer Science. Volume I:
Mathematical Structures, Oxford University Press, 1992, 189–411.
[Nau+60] Peter Naur et al. Report on the Algorithmic Language ALGOL60, Communi-
cations of the ACM, 3 (5) (1960), 299–314.
[Nau62] Peter Naur (editor), Revised Report on Algorithmic Language ALGOL 60, Com-
munications of the ACM, i, No. I, (1962), 1–23.
[Nau66] Peter Naur, Proof of algorithms by general snapshots, BIT 6 (1966), 310–316.
[Niv79] Maurice Nivat, Infinite words, infinite trees, infinite computations, in J W de
Bakker and J van Leeuwen (editors), Foundations of Computer Science III,
Mathematical Centre Tracts 109, 1979, 3–52.
[NR69] Peter Naur and Brian Randell (editors), Software Engineering: Report of a
conference sponsored by the NATO Science Committee, Garmisch, Germany,
7-11 October, 1968, Brussels, Scientific Affairs Division, NATO (1969), 231pp.
[NR85] Maurice Nivat and John Reynolds (editors), Algebraic Methods in Semantics,
Cambridge University Press, 1985.
[NS78] Roger Needham and Michael Schroeder, Using encryption for authentication in
large networks of computers, Communications of the ACM, 21(12) 1978, 993–
999.
486 John V. Tucker
[OG76] Susan Owicki and David Gries, An axiomatic proof technique for parallel pro-
grams I, Acta Informatica 6 (4) (1976), 319–340.
[OPW+17] R Oliveira, P Palanque, B Weyers, J Bowen, A Dix, State of the art on formal
methods for interactive systems, in B Weyers, J Bowen, A Dix, P Palanque
(editors) The Handbook of Formal Methods in Human-Computer Interaction,
Human–Computer Interaction Series. Springer, Cham, 2017.
[ORS92] Sam Owre, John Rushby and Natarajan Shankar, PVS: A Prototype Verification
System, in Deepak Kapur (editor), 11th International Conference on Automated
Deduction (CADE) Lecture Notes in Artificial Intelligence 607, Springer-Verlag,
1992, 748–752.
[ORS+95] S. Owre, J.Rushby, N. Shankar, and F.von Henke. Formal verification for fault-
tolerant architectures: Prolegomena to the design of PVS, IEEE Transactions
on Software Engineering, 21(2) (1995), 107–125.
[Par69] David Parnas, On the use of transition diagrams in the design of a user Interface
for an interactive computer system, Proceedings 24th National ACM Conference
(1969), 379–385.
[Par72a] David Parnas, A technique for software module specification with examples,
Communications of the ACM, 15 (5) (1972), 330–336.
[Par72b] David Parnas, On the criteria to be used in decomposing systems into modules,
Communications of the ACM, 15 (12)(1972), 1053–58.
[Par81] David Park, Concurrency and automata on infinite sequences, in Peter Deussen
(editor), Theoretical Computer science, Lecture Notes in Computer Science 104,
Springer, 1981, 167–183.
[Par01] David Parnas, Software Fundamentals – Collected Papers by David L Parnas,
Daniel M.Hoffman and David M Weiss (editors), Addison-Wesley, 2001.
[Plo83] Gordon D. Plotkin, An operational semantics for CSP, in D Bjørner (editor),
Proceedings IFIP TC2 Working Conference: Formal Description of Program-
ming Concepts II, North-Holland, 1983, 199–223.
[Plo04a] Gordon D. Plotkin, The origins of structural operational semantics, Journal of
Logic and Algebraic Programming, 60-61, (2004), 3–15.
[Plo04b] Gordon D. Plotkin, A structural approach to operational semantics, DAIMI
FN-19, Computer Science Department, Aarhus University, 1981. Also: Journal
of Logic and Algebraic Programming, 60-61, (2004), 17–139.
[Pnu77] Amir Pnueli, The temporal logic of programs, Proceedings of the 18th Annual
Symposium on Foundations of Computer Science, IEEE 1977, 46–57.
[Pos94] Emil L. Post, Degrees of recursive unsolvability. Preliminary report, in Martin
Davis (editor), Solvability, Provability, Definability: The Collected Works of
Emil L. Post. Birkhäuser, Boston, Basel, Berlin, 1994, 549–550.
[QS82] J.-P. Queille and Josef Sifakis, Specification and verification of concurrent sys-
tems in CESAR. In: Symposium on Programming. Lecture Notes in Computer
Science, vol. 137, Springer, 1982, 337–351.
[RB69] Brian Randell and John N. Buxton (editors), Software Engineering Techniques:
Report of a conference sponsored by the NATO Science Committee, Rome, Italy,
27-31 October, 1969, Brussels, Scientific Affairs Division, NATO (1970), 164pp.
[RBH+01] Willem-Paul de Roever, Frank de Boer, Ulrich Hannemann, Jozef Hooman,
Yassine Lakhnech, Mannes Poel, and Job Zwiers, Concurrency Verification:
Introduction to Compositional and Noncompositional Methods, Cambridge Uni-
versity Press, 2001.
[Rei81] Phyllis Reisner, Formal grammar and human factors design of an interactive
graphics system, IEEE Transactions on Software Engineering, 7 (2) (1981),
229–240.
[Rei87] Horst Reichel, Initial Computability Algebraic Specifications, and Partial Alge-
bras, Clarendon Press, 1987.
[Rog00] Markus Roggenbach, Mila Majster-Cederbaum, Towards a unified view of bisim-
ulation: a comparative study. Theoretical Computer Science, 238 (2000), 81–130.
9 Origins and Development of Formal Methods 487
A brief postponement
Brings the most distant goal within reach.
B. Brecht
Challenge
Readers would recognise these influences over the many examples of appli-
cations spread across the preceding chapters. Such trends only add to the
challenge of software engineering, as they bring increased complexity in
requirements and specification, added layers of abstraction for design, and
the potential for subtle errors at the implementation stage. The message of
this book is clear: Formal Methods are a step in the direction of address-
ing the software engineering challenge. Evidence suggests that they offer a
clear beneficial impact on quality of the software produced, and time and
cost incurred in the process [WLBF09]. A mathematical underpinning of the
engineering process allows for explicit requirements to be expressed, precise
specifications to be derived, critical properties proved using some form of
theorem-proving or model checking, and the final outcome to be compre-
hensively tested. At each stage, Formal Methods allow for ambiguity to be
addressed and rigour applied to provide some assurance in the final prod-
uct. Undoubtedly, successful adoption depends on the application of Formal
Methods only at a selected stage of the engineering process, so as to provide
assurance where it is most needed and avoid additional cost where possible.
Contribution
The 2020 white paper “Rooting Formal Methods within Higher Education
Curricula for Computer Science and Software Engineering” [CRD+ 20] makes
the following propositions:
• Current software engineering practices fail to deliver dependable software.
• Formal methods are capable of improving this situation, and are beneficial and
cost-effective for mainstream software development.
• Education in formal methods is key to progress things.
• Education in formal methods needs to be transformed.
With this textbook we hope to have helped improving this situation. In par-
ticular, we argue that Formal Methods have come out of the niche of safety
critical applications, and that it is reasonable to apply them also in main-
stream software development.
For the academic teacher, our book offers an example driven approach
for teaching the subject. It puts an emphasis on the application of Formal
Methods, while still preserving mathematical rigour. The book describes a
selected set of Formal Methods in one integrated setting.
For students of software engineering, the book offers an accessible account
to understand what Formal Methods are about. Studying this book should
enable them to apply various Formal Methods to concrete software engineering
492 Authors’ Conclusion
References
CRD+ 20 Antonio Cerone, Markus Roggenbach, James Davenport, Casey
Denner, Marie Farrell, Magne Haveraaen, Faron Moller, Philipp
Koerner, Sebastian Krings, Peter Ölveczky, Bernd-Holger Schlin-
gloff, Nikolay Shilov, and Rustam Zhumagambetov. Rooting
formal methods within higher education curricula for computer
science and software engineering—A White Paper, 2020.
https://arxiv.org/abs/2010.05708.
Dij72 Edsger Dijkstra. The humble programmer. Communications of
the ACM, 15(10):859–866, 1972.
Dix10 Alan Dix. Human-computer interaction: A stable discipline, a
nascent science, and the growth of the long tail. Interacting
with Computers, 22(1):13–27, 2010.
JMO06 Magne Jorgensen and Kjetil Molokken-Ostvold. How large are
software cost overruns? A review of the 1994 chaos report.
Information and Software Technology, 48(4):297–301, 2006.
Neu06 Peter Neumann. Risks of untrustworthiness. In 22nd Annual
Computer Security Applications Conference. IEEE Computer
Society, 2006.
NR69 Peter Naur and Brian Randell, editors. Software Engineering:
Report of a conference sponsored by the NATO Science Com-
mittee. NATO Scientific Affairs Division, Brussels, 1969.
Sat01 M. Satyanarayanan. Pervasive computing: vision and chal-
lenges. IEEE Personal Communications, 8(4):10–17, 2001.
WLBF09 Jim Woodcock, Peter Gorm Larsen, Juan Bicarregui, and John S.
Fitzgerald. Formal methods: Practice and experience. ACM
Computing Surveys, 41(4), 2009.
Appendix A
Syntax of the Logics in this Book
Here, we give an overview of the syntax of the various logics and formalisms
used in this book. Moreover, we provide examples for each formalism.
The symbol “” stands for “equal by definition” or “is defined as”.
Syntax
Abbreviations
Examples
Syntax
Abbreviations
• ¬ϕ (ϕ ⇒ ⊥) (negation)
• ¬⊥ (verum)
• (ϕ ∨ ψ) (¬ϕ ⇒ ψ) (disjunction)
• (ϕ ∧ ψ) ¬(¬ϕ ∨ ¬ψ) (conjunction)
• (ϕ ⇔ ψ) ((ϕ ⇒ ψ) ∧ (ψ ⇒ ϕ)) (equivalence)
• ⊕ ψ) (ϕ ⇔ ¬ψ)
(ϕ (exclusive-or)
• (ϕ1 , . . . , ϕn ) i≤n (ϕi ∧ j≤n,j=i ¬ϕj ) (choice)
• ϕi ( i≤n−1 ϕi ∨ ϕn ), if n > 0, and i≤0 ϕi ⊥
i≤n
• j≤n,j=i ϕj ( j≤n−1,j=i ϕj ∧ ϕn ), if i = n, and j=j ϕj
Example formulae
• ((⊥ ⇒ ⊥) ⇒ ⊥)
• (p ⇒ (p ∨ q))
• (motor 59kW ⇒ ¬gearshift automatic)
Syntax
Abbreviation
Example formulae
Syntax
Example formulae
• ((a = b) ∧ (b = c) ⇒ (a = c))
• f (x) = x2 + 2 ∗ x + 1
• ∀x∃y (y = f (x))
• ∃x∃y (¬(x = y) ∧ ∀z(z = x ∨ z = y))
Many-sorted F OL=
Syntax
Example formulae
Syntax
Example formulae
√ √
• ∀x : real . x > 0 (where
√ · : real →? real )
• ∀x : real . (x >√0 ⇒ x > 0)
• ∀x : real . (def x ⇔ x ≥ 0)
• ∀s : String. (¬isEmpty(rest(s)) ⇒ def first(rest(s)))
• ∀s : String. ∀c : Char . (isEmpty(s) ⇒ ¬(first(s) = c))
Syntax
Abbreviation
Example formulae
Modal Logic
Syntax
M LP ::= P | ⊥ | (M LP ⇒ M LP ) | M LP
Abbreviation
Example formulae
• p
• (p ⇒ p)
• ( cloudy ⇒ cloudy)
Multimodal logic
Syntax
Abbreviation
Example formulae
• ab[a] p
• (ap ⇒ b p)
• (isHobby ⇒ (int isHome ∧ ext isClub))
498 A Syntax of the Logics in this Book
Deontic logic
Syntax
Abbreviations
Example formulae
Syntax
LTL has besides the modal next-operator ‘’ the binary until-operator ‘ U ’.
LTLP ::= P LP | (LTLP ⇒ LTLP ) | LTLP | (LTLP U LTLP )
Abbreviations
• ϕ ( U ϕ) (eventually- or sometime-operator)
• ϕ ¬¬ ϕ (globally- or always-operator)
Example formulae
• ( sleeping ⇒ sleeping)
• ((ϕ ⇒ ϕ) ⇒ (ϕ ⇒ ϕ)
• ((ψ ∨ ϕ ∧ (ϕ U ψ)) ⇒ (ϕ U ψ))
• phil0 eating
Appendix B
Language Definition of CSP
B.1 Syntax
B.1.1 Processes
The Csp syntax is given by the following grammar, which is defined relatively
to an alphabet of events Σ and a set of process names PN . After the %% we
list the name of the process and give its representation in CspM .
P, Q ::= Stop %% deadlock process STOP
| Skip %% terminating process SKIP
| Div %% diverging process
| N %% process name N
| a→P %% action prefix a -> P
| ?x : A → P %% prefix choice
| c.a → P %% channel communication c.a -> P
| c?x → P %% channel input c?x -> P
| c!a → P %% channel output c!a -> P
| P Q %% external choice P [] Q
| P Q %% internal choice P |~| Q
| if cond then P else Q %% conditional if cond then P
else Q
| cond & P %% guarded process cond & P
| P o9 Q %% sequential composition P; Q
| P Q %% interrupt P /\ Q
| P [| A |] Q %% general parallel P [|A|] Q
| P [A B]Q %% alphabetised parallel P [A||B] Q
| P ||| Q %% interleaving P ||| Q
| P Q %% synchronous parallel P [| Events |] Q
| P \A %% hiding P \ A
| P [[R]] %% renaming
| i∈I Pi %% replicated external choice []i:I@P(i)
| j∈J Pj %% replicated internal choice |~|j:J@P(j)
| |||i∈I Pi %% replicated interleaving |||i:I@P(i)
| [| A |] i∈I Pi %% replicated general parallel [|A|]i:I@P(i)
| i∈I (Ai , Pi ) %% replicated alphabetised ||i:I@[A(i)]P(i)
where
• a ∈ Σ,
• N ∈ PN ,
• c is a channel, a ∈ T (c)—the type of c—and events(c) ⊆ Σ (cf. Sect.
3.2.1),
• cond is a condition in a logic of choice (not determined by Csp),
• A, B ⊆ Σ,
• R ⊆ Σ × Σ such that for all a ∈ Σ there exists a ∈ Σ with (a, a ) ∈ R,
• I is a finite index set, (Pi )i∈I is a family of processes, (Ai )i∈I is a family
of sets with Ai ⊆ Σ for all i ∈ I,
• J is a non-empty index set, (Pj )j∈J is a family of processes.
The CspM column has been left blank in several cases:
• To the best of our knowledge, the prefix choice operator ?x : A → P has no
counterpart in CspM (though in case of a finite set A it can be simulated
via replicated external choice).
• Renaming is written in CspM as
P [[a <- b]]
where a and b are events. CspM offers a rich comprehension syntax for
expressing complex renaming—see, e.g., the FDR user manual or th book
A.W. Roscoe, The theory and practice of concurrency, Prentice Hall, 1998,
for a documentation of this syntax.
• The CspM process CHAOS is similar to Div, however, can’t terminate as it
is defined as
Note that—in order to keep the language manageable in the context of a brief
introduction—we refrain from introducing a number of Csp constructs such
as multi channels (allowing multiple data transfers in a single event), linked
parallel, untimed timeout etc.
N =P
B.2 Semantics
Csp static semantics concerns aspects of the language such as the scope of
variables, the relation between synchronisation sets and process alphabets,
and that process names have a unique definition.
Csp distinguishes between two kinds of variables, which we call static and
dynamic. Static variables are bound by replicated operators, and by process
names occurring on the lhs of an equation; they are not affected by process
termination. Dynamic variables are bound by prefix choice and channel input;
their binding lasts up to process termination.
Synchroniation sets and processes in alphabetised parallel are related as
follows:
• The process P [ A B ] Q is wellformed if the alphabet of P is a subset of
A and the alphabet of Q is a subset of B.
• The process i∈I (Ai , Pi ) is wellformed, if for all i ∈ I, the alphabet of Pi
is a subset of Ai .
A system of equations is wellformed, if there is exactly one equation for
each occurring process name.
• i∈I (Ai , Pi ) Pk [ Ak i∈I\{k} Ai ] i∈I\{k} (Ai , Pi ) (for k ∈ I)
where i∈{} (Ai , Pi ) Skip.
The choice to set i∈{} (Ai , Pi ) Skip is in accordance with the FDR
documentation and also agrees with Csp algebraic laws. However, FDR
operation is different. It appears to be i∈{} (Ai , Pi ) RUN ext Skip(A),
where
Note that prefix choice and replicated internal choice are part of the core
language rather than syntactic sugar. Both these operators allow for infinite
branching in Csp.
The definitions presented subsequently closely follow the book A.W. Roscoe,
The theory and practice of concurrency, Prentice Hall, 1998.
For ease of presentation, we assume the following implicit typing for the
labels of transitions:
• a ∈ Σ—i.e., a is an element of the alphabet.
• b ∈ Σ ∪ {}—i.e., b stands for an observable event.
• x ∈ Σ ∪ {τ }—i.e., x stands for a non-terminating event.
Furthermore, we add the state Ω representing a process after termination.
This special state helps to treat termination in the case of the parallel oper-
ator. Note that the semantics has the property that the state Ω can only be
reached by transitions labelled with .
• Stop—deadlock process.
This process has no firing rule.
• Skip—successfully terminating process.
Skip −→ Ω
• Div—diverging process.
τ
Div −→ Div
• N —process name.
τ if there is an equation N = P
N −→ P
• a → P —action prefix.
a
(a → P ) −→ P
• ?x : A → P —prefix choice.
a a∈A
(?x : A → P ) −→ P [a/x]
• P Q—external choice.
b b
P −→ P Q −→ Q
b b
P Q −→ P P Q −→ Q
τ τ
P −→ P Q −→ Q
τ τ
P Q −→ P Q P Q −→ P Q
• P Q—internal choice.
τ τ
P Q −→ P P Q −→ Q
504 B Language Definition of CSP
Ω [| A |] Ω −→ Ω
• P \ A—hiding.
a x
P −→ P P −→ P
τ a∈A x x∈
/A
P \ A −→ P \ A P \ A −→ P \ A
P −→ P
P \ A −→ Ω
B.4 Denotational Semantics 505
• P [[R]]—relational renaming.
a τ
P −→ P P −→ P
c ifaRc τ
P [[R]] −→ P [[R]] P [[R]] −→ P [[R]]
P −→ P
P [[R]] −→ Ω
• j∈J Pj —replicated internal choice.
τ k∈J
j∈J Pj −→ Pk
– The process RUN With Skip Σ = (?x : Σ → RUN With Skip Σ ) Skip
is the least refined process.
Semantic Clauses
[| A |] {}
[| A |] x t2 ∅
[| A |] y t2 {y u | u ∈ [| A |] t2 }
x t1 [| A |] ∅
x t1 [| A |] x t2 {x u | u ∈ t1 [| A |] t2 }
x t1 [| A |] x t2 ∅
x t1 [| A |] y t2 {y u | u ∈ x t1 [| A |] t2 }
y t1 [| A |] {y u | u ∈ t1 [| A |] }
y t1 [| A |] x t2 {y u | u ∈ t1 [| A |] x t2 }
y t1 [| A |] y t2 {y u | u ∈ t1 [| A |] y t2 }
∪ {y u | u ∈ y t1 [| A |] t2 }
where x, x ∈ A ∪ {}, y, y ∈
/ A ∪ {}, and x = x .
∗
• Given a trace t ∈ Σ and a set A ⊆ Σ, (t \ A) is inductively defined by:
\ A
t\A if x ∈ A
(x t) \ A
x (t \ A) otherwise
– (, ) ∈ R∗
– (, ) ∈ R∗
– (a, b) ∈ R ∧ (t, t ) ∈ R∗ =⇒ (a t, b t ) ∈ R∗
traces⊥ (F ) {s | ∃X ⊆ Σ ∗ . (s, X) ∈ F }
Semantic Clauses
In some cases, e.g., for the external choice operator, the expressions deter-
mining the function failures⊥ ( ) utilise the function divergences( ). In spite
of this, we always first present the function computing the failures followed
by the presentation of the function computing the divergences.
The definition of the renaming operator applies the inverse of a binary
relation R to a set X:
As in N it is in general not possible to give the correct value for the hiding
operator, we do not give a clause for it. We refrain from giving a semantic
clause for the interrupt operator in N .
failures⊥ (P Q)
{(, X) | (, X) ∈
failures⊥ (P ) ∩ failures⊥ (Q)}
∪ {(t, X) | t = ∧
((t, X) ∈ failures⊥ (P ) ∨
(t, X) ∈ failures⊥ (Q))}
∪ {(, X) | X ⊆ Σ ∧
( ∈ divergences(P ) ∨
∈ divergences(Q))}
∪ {(, X) | X ⊆ Σ ∧
( ∈ traces⊥ (P ) ∨
∈ traces⊥ (Q))}
divergences(P Q) divergences(P ) ∪ divergences(Q)
failures⊥ (P Q) failures⊥ (P ) ∪ failures⊥ (Q)
divergences(P Q) divergences(P ) ∪ divergences(Q)
⎧
⎨ failures⊥ (P ) ; cond
failures⊥ (if cond then P else Q) evaluates to true
⎩
⎧ failures⊥ (Q) ; otherwise
⎨ divergences(P ) ; cond
divergences(if cond then P else Q) evaluates to true
⎩
divergences(Q) ; otherwise
510 B Language Definition of CSP
failures⊥ (P o9 Q) {(s, X) | s ∈ Σ ∗ ∧
(s, X ∪ {}) ∈ failures⊥ (P )}
∪ {(s t, X) | s ∈ traces⊥ (P ) ∧
(t, X) ∈ failures⊥ (Q)}
∪ {(s, X) | s ∈ divergences(P o9 Q) ∧
X ⊆ Σ}
divergences(P 9 Q) divergences(P )
o
∪ {s t | s ∈ traces⊥ (P ) ∧
t ∈ divergences(Q)}
failures⊥ (P [| A |] Q) {(u, Y ∪ Z) | Y, Z ⊆ Σ ∧
Y \(A ∪ {}) = Z\(A ∪ {}) ∧
∃s, t ∈ Σ ∗ . u ∈ (s [| A |] t) ∧
(s, Y ) ∈ failures⊥ (P ) ∧
(t, Z) ∈ failures⊥ (Q)}
∪ {(u, Y ) | u ∈ divergences(P [| A |] Q) ∧ Y ⊆ Σ ∗ }
divergences(P [| A |] Q) {u v | v ∈ Σ ∗ ∧
∃s ∈ traces⊥ (P ), t ∈ traces⊥ (Q).
u ∈ (s [| A |] t) ∩ Σ ∗ ∧
(s ∈ divergences(P ) ∨
t ∈ divergences(Q))}
failures⊥ (P [[R]]) {(s , X) | ∃s.sR∗ s ∧
(s, R−1 (X)) ∈ failures⊥ (P )}
∪ {(s, X) | s ∈ divergences(P [[R]]) ∧
X ⊆ Σ}
divergences(P [[R]]) {s t | ∃s ∈ divergences(P ) ∩ Σ ∗ .
s R∗ s ∧ t ∈ Σ ∗ }
failures⊥ (j∈J Pj ) failures⊥ (Pj )
j∈J
divergences(j∈J Pj ) j∈J divergences(Pj )
B.4 Denotational Semantics 511
.
• Refinement:
Semantic Clauses
Together, the functions traces( ) and failures( ) map Csp processes to obser-
vations in the stable failures domain F. These functions are defined relatively
512 B Language Definition of CSP
Again, we refrain from giving a semantic clause for the interrupt operator
in F.
traces(Stop) {}
failures(Stop) {(, X) | X ⊆ Σ }
traces(Skip) {, }
failures(Skip) {(, X) | X ⊆ Σ}
∪ {(, X) | X ⊆ Σ }
traces(Div) {}
failures(Div) {}
traces(N ) Mtraces (N )
failures(N ) Mfailures (N )
traces(a → P ) {}
∪ {a s | s ∈ traces(P )}
failures(a → P ) {(, X) | a ∈ / X}
∪ {(a t , X) | (t , X) ∈ failures(P )}
traces(?x : A → P ) {}
∪ {a s | a ∈ A ∧
s ∈ traces(P [a/x])}
failures(?x : A → P ) {(, X) | A ∩ X = ∅}
∪ {(a t , X) | a ∈ A ∧
(t , X) ∈ failures(P [a/x])}
traces(P Q) traces(P ) ∪ traces(Q)
failures(P Q) {(, X) | (, X) ∈
failures(P ) ∩ failures(Q)}
∪ {(t, X) | t = ∧
(t, X) ∈ failures(P ) ∪ failures(Q)}
∪ {(, X) | X ⊆ Σ ∧
∈ traces(P ) ∪ traces(Q)}
traces(P Q) traces(P ) ∪ traces(Q)
failures(P Q) failures(P ) ∪ failures(Q)
B.4 Denotational Semantics 513
traces(P ) ; cond evaluates to true
traces(if cond then P else Q)
traces(Q) ; otherwise
failures(P ) ; cond evaluates to true
failures(if cond then P else Q)
failures(Q) ; otherwise
traces(P o9 Q) (traces(P ) ∩ Σ ∗ )
∪ {s t | s ∈ traces(P ) ∧ t ∈ traces(Q)}
failures(P o9 Q) {(t1 , X) | t1 ∈ Σ ∗ ∧ (t1 , X ∪ {}) ∈ failures(P )}
∪ {(t1 t2 , X) | t1 ∈ traces(P )∧
(t2 , X) ∈ failures(Q)}
traces(P [| A |] Q) {s [| A |] t | s ∈ traces(P ) ∧ t ∈ traces(Q)}
failures(P [| A |] Q) {(u, Y ∪ Z) | Y \ (A ∪ {}) = Z \ (A ∪ {})∧
∃t1 , t2 . u ∈ t1 [| A |] t2 ∧
(t1 , Y ) ∈ failures(P ) ∧ (t2 , Z) ∈ failures(Q)}
traces(P \ A) {s \ A | s ∈ traces(P )}
failures(P \ A) {(t \ A, Y ) | (t, Y ∪ A) ∈ failures(P )}
traces(P [[R]]) {t | ∃s ∈ traces(P ) : sR∗ t}
failures(P [[R]]) {(t, X) | ∃t . (t , t) ∈ R∗ ∧
(t , R−1 (X)) ∈ failures(P )}
traces(j∈J Pj ) j∈J traces(Pj )
failures(j∈J Pj ) j∈J failures(Pj )
Appendix C
Concrete CASL Syntax
In this appendix we provide a grammar for the concrete syntax of the dis-
cussed sublanguage of Casl. The grammar of the full language can be found
in Peter D. Mosses, Casl Reference Manual, Springer, 2004. We take the
freedom to resolve some chain rules, to add a start symbol, to simply the
grammar of terms as well as the lexical syntax. However, overall our presen-
tation follows closely the one of the Casl reference manual. We also use the
following conventions established in the Casl context:
• Nonterminal symbols are written as uppercase words, possibly hyphenated,
e.g., SORT, BASIC-SPEC.
• Terminal symbols are written as either:
C.1 Specifications
C.3 Formulae
| false
| not FORMULA
| FORMULA "/\" ... "/\" FORMULA
| FORMULA "\/" ... "\/" FORMULA
| FORMULA "=>" FORMULA
| FORMULA if FORMULA
| FORMULA "<=>" FORMULA
| QUANTIFIER VAR-DECL ";"...";" VAR-DECL "." FORMULA
| "(" FORMULA ")"
| ...
QUANTIFIER ::= forall | exists
| ...
TERM ::= OP-NAME
| OP-NAME "(" TERM ","..."," TERM ")"
VAR ::= WORD
A Boolean values, 54
Abstraction, 408 Bottom element, 168
completeness, 408 Byzantine agreement, 2
data abstraction, 408
data abstraction in CSP, 408 C
soundness, 408 Car configurator, 51
Accessibility relation, 94 Carrier set, 84
Advanced Encryption Standard, 398 Casl
Agile development, 15 consistent specification, 213
ANACON, 330–333, 335 extension annotation
Arity, 71 %cons, 229
Casl function symbol, 204 %def , 229
Casl predicate symbol, 204 %implies, 211
Artificial intelligence, 40 formula, 206
Asymmetric, 70 free type, 217
Attack, 402 generic specification, 249
Attention, 347, 356, 357 instantiation, 250
Supervisory Attentional System (SAS), parametrization, 249
378 loose specification, 207
Authentication model class of a specification, 207
aliveness, 403, 417, 427 model encoding, 215
by correspondence, 403 model semantics, 207
challenge-response mechanism, 403 non-empty carrier set, 207
injective agreement, 404, 418, 427 signature, 204
of an entity, 400 specification, 204
of data, 400 static semantics, 207
signal event Commit, 415 structured specification, 240
signal event Running, 415 extension, 241
Automaton, 9 hiding, 252
Availability, 400 library, 248
Axiomatic semantics, 9 renaming, 244
union, 242
B view, 217
Backus-Naur-form, 6, 53, 458 Categorical, 63
Bisimulation, 472 Characteristics of concurrent systems, 158
B method, 35 Chisholm’s paradox, 100
L N
Ladder Logic, 227 Natural deduction, 60
Least upper bound, 182 Needham-Schroeder-Lowe protocol, 406
Legal documents, 310 Needham-Schroeder protocol, 405, 476
Liveness property, 146 Nonce, 404
Logic, 49, 50, 457, 458, 467 Nondeterminism, 269
deontic logic, 96 Normative documents. see contractNP-
Floyd-Hoare logics, 461 completeness, 58
modal logic, 92, 457
multimodal logic, 94 O
PCFOL= , 202 Occam programming language, 4
propositional logic, 51 ω-chain, 183
second-order logic, 78 ω-complete partial order (CPO), 183
SubPCFOL= , 202 Operating system verification, 33
temporal logic, 101, 457 Operational semantics, 9, 133
Temporal Logic of Actions (TLA), 470 Operator, 349
boolean operator, 54
M dual operator, 94
Machine learning, 40 logical operator, 51
Man in the middle attack, 402 temporal operator, 102
on Needham-Schroeder protocol, 405 Optimal asymmetric encryption padding,
Message concatenation, 401 399
Message encryption, 397 Order
Message space, 408 lexicographic order, 82
atoms, 408 linear order, 76
cryptographic keys, 408 partial order, 70
finite set, 420 total order, 76
message encryption, 409
message pairing, 409 P
nonces, 408 Partiality, 85, 465
participants, 408 Partial order, 70, 168
Method, 10, 50 Pelican Crossing, 224
Modal logic, 92 Perfect encryption assumption, 398
Model Plaintext, 397
first-order model, 73 Possible world, 93
Index 523
Tool qualification, 22 V
Total order, 76 Validation, 15
Trace, 270, 277 Validation relation, 54, 74, 95
quiescent trace, 278 Validity, 55, 63
Trace equivalence, 276 Valuation, 73
Tracing of modelling decisions, 141 Variable
Transition system, 473 bound variable, 73
Transitivity, 70 free variable, 73
True concurrency semantics, 123
individual variable, 72
Type, 83
variable valuation, 73
argument type, 83
Verification, 15
result type, 83
Vienna Development Method (VDM), 462
U V-model, 13
Universe of discourse, 73
Unless, 270
Until, 102, 270 W
Upper bound, 182 Waterfall model, 13
User, 347 Workflow specification, 309