View
223
Download
2
Tags:
Embed Size (px)
Citation preview
3
Formal Methods
Specification and verification methods Have formal (mathematical) semantics
unambiguous facilitate proofs of correctness
In use since late 1970smore popular in Europe than USstill only a niche market
4
Types of Formal Methods
Model-theoretic VDM, Z
Algebraic ACT One, Larch , OBJ
Concurrent processes CCS, CSP, Petri Nets
Finite State Machines Esterel, Statecharts
Hybrid LOTOS, SDL
5
Model-theoretic Methods
Vienna Development Method (VDM) invented at IBM Vienna lab in late 1970s used for compilers (Denmark, Germany) and for
information processing (England)
Z Invented by Jean-Raymond Abrial (France) Developed by Programming Research Group (PRG)
at Oxford Used at IBM Hursley in mid 1980s
6
Foundations of Z
Model theoretic methodabstract model is constructedproperties of the model are proven
Set theory (and other discrete math) First order predicate calculus Schema calculus provides incrementality
7
Predicate Logic Variables ranging over arbitrary sets Predicates: assertions about variables Operators:
conjunction: A B disjunction: A B negation: A implication: A B
Quantifiers universal: x: T R(…x…) existential: x: T R(…x…)
9
Functions and Relations
element mapping: x y domain, range: dom(R), ran(R) overriding: R S partial function: x y
10
Sequences
definition: <>, <a, b> concatenation: <a, b> <x, y> length: #S functions:
head(S) first elementtail(S) all but the first elementlast(S) last elementfront(S) all but the last element
11
Schema Operators
conjunction: S T disjunction: S T hiding: S \ (v1, …, vn) hiding: S \ T overriding: S T
12
Names
Variables input: name?output: name!postcondition: name'
Schemachanges state: Nameconstant state: Name
16
Examples
known = { Mark, Cheryl, Eric, Paul }
birthday = { Mark April 7,Cheryl July 9,Eric July 14,Paul April 30 }
21
Deriving Properties
known' = dom birthday'= dom ( birthday
{name? date?} )= dom birthday dom
{name? date?}= dom birthday { name? }= known { name? }
24
Symbol Table [Hayes 87]
Describes a relation between symbols and values
Illustrates use of schema operators
31
Overriding Definitions
Introduce a new symbol table for each level of scope
Need to override the previous definitions of symbols:
{ s v } { s w } Need to introduce a distributed override
operator for sequences of symbol tables
32
Block-Structured Symbol Tables
BST seq ST
/ : seq ST ST
/ <> = Ø
/ ( s < t > ) = (/ s ) t
bst0 < >
34
Z Method
1. Introduce basic sets2. Define an abstract state in terms of sets,
functions, relations, sequences, etc.3. Specify the initial state4. Define pre- and post-conditions of
operations5. State and prove theorems