Metodi formali per il software

Formal Methods in software development
a.a.2016/2017
Prof.Anna Labella
7/28/2017
1
Operational semantics

Meaning of program phrases defined in
terms of the steps of computation they
can take during program execution
7/28/2017
2
The metaphore of abstract
machine
An automaton is given by a (finite) set of
states S; an initial state s0 and (one or
more) terminal one
 Transitions labeled via a finite alphabet 
 A transition law : S x   S

Arbib, Michael A. (1969). Theories of Abstract Automata- Prentice Hall
7/28/2017
3
The metaphore of abstract
machine
Automata are characterized through the
“accepted” language
 i.e. through the possible sequences of
elements from the alphabet going from
the initial state to the terminal state

7/28/2017
4
Finite State Automata
7/28/2017
5
Finite State Automata
1€

1€
Coffee machine A1:
tea
coffee

Coffee machine A2:
1€
1€
1€
tea
coffee

Are the two machines ”the same”?
7/28/2017
6
The algebra of languages
<P(*), , , , Ø, *, , {}>
* is the free monoid generated by the alphabet
P(*) is a boolean algebra, but also a domain
It is a monoid w.r.t. concatenation  (Frobenius product)
7/28/2017
7
The free monoid generated by A
7/28/2017
8
Exercises
Let us take A = {1}, what is A* ?
7/28/2017
9
Exercises
Let us take A = {1}, what is A* ?
Which of coding we get?
7/28/2017
10
Boolean algebra
<P(*), , , , Ø, *>
7/28/2017
11
Frobenius product

Frobenius product distributes over sum (union)
7/28/2017
12
The algebra of languages
We are able to define iteration on P(*)
7/28/2017
13
Regular expressions
Formulas build from +, . and *, starting
from 0, 1 and elements of ∑
Example : a* + a . b*
7/28/2017
14
Right linear grammars
• Let us have also non terminal ( not belonging to ∑)
symbols
• A right linear grammar is a set of rewriting rules,
where single non terminal elements are rewritten into
linear polinomial expressions where elements of the
alphabet are left coefficients
Example:
S → aS also written S → aS | ε or S= aS + 1
S→ε
7/28/2017
15
Theorems
•
Languages accepted by finite states automata
correspond to regular expressions
•
Regular expressions are generated by right linear
grammars, which are continuous operators on P(*)
•
The language associated with a right linear grammar
is the minimal solution of a recursive equations
system
•
We can extend the result to context free grammars
16
7/28/2017
(push down automata)
Examples
Let us take the automaton
a
It accepts the language a*
defined by the grammar X = a X | 
or via the recursive equation x = ax+1
as its minimal solution (Tarski’s theorem)
7/28/2017
17
More generally
The recursive equation
x = ax+b
defines a continuous function P(*)  P(*)
and has a*b as its minimal solution (Tarski’s theorem)
7/28/2017
18
Exercises
7/28/2017
19
We can take more general grammars
grammar
equations system
Minimal solution
X∞ = a*ba*
Y∞ = 0
7/28/2017
20