– 7 – 2017-05-29 – main –
Softwaretechnik / Software-Engineering
Lecture 7: Formal Methods for Requirements Engineering
2017-05-29
- Prof. Dr. Andreas Podelski, Dr. Bernd Westphal
Albert-Ludwigs-Universität Freiburg, Germany
Lecture 7: Formal Methods for Requirements Engineering 2017-05-29 - - PowerPoint PPT Presentation
Softwaretechnik / Software-Engineering Lecture 7: Formal Methods for Requirements Engineering 2017-05-29 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universitt Freiburg, Germany 7 2017-05-29 main Topic Area
– 7 – 2017-05-29 – main –
2017-05-29
Albert-Ludwigs-Universität Freiburg, Germany
– 7 – 2017-05-29 – Sblockcontent –
2/49
VL 6 . . . VL 7 . . . VL 8 . . . VL 9 . . .
– 7 – 2017-05-29 – main –
3/49
– 6 – 2017-05-22 – Sreana –
23/41 Focus
current desired innovation
Analysis Technique
situation situation consequences Analysis of existing data and documents Observation Questionning with closed
structured
Interview Modelling Experiments Prototyping Participative development
(Ludewig and Lichter, 2013)
– 7 – 2017-05-29 – Sblockcontent –
4/49
VL 6 . . . VL 7 . . . VL 8 . . . VL 9 . . .
– 7 – 2017-05-29 – main –
5/49
– 6 – 2017-05-22 – Sttwytt –
39/41
testing, delivery, re-use, re-implementation.
Note: vague vs. abstract.
– 7 – 2017-05-29 – Sblockcontent –
6/49
VL 6 . . . VL 7 . . . VL 8 . . . VL 9 . . .
– 7 – 2017-05-29 – Scontent –
7/49
Logic
– 7 – 2017-05-29 – main –
8/49
– 7 – 2017-05-29 – Scoreet –
9/49
T r1 r2 r3 c1 × × − c2 × − ∗ c3 − × ∗ a1 × − − a2 − × −
– 7 – 2017-05-29 – Scoreet –
10/49
T: decision table r1 · · · rn c1 description of condition c1 v1,1 · · · v1,n . . . . . . . . . ... . . . cm description of condition cm vm,1 · · · vm,n a1 description of action a1 w1,1 · · · w1,n . . . . . . . . . ... . . . ak description of action ak wk,1 · · · wk,n
– 7 – 2017-05-29 – Scoreet –
10/49
T: decision table r1 · · · rn c1 description of condition c1 v1,1 · · · v1,n . . . . . . . . . ... . . . cm description of condition cm vm,1 · · · vm,n a1 description of action a1 w1,1 · · · w1,n . . . . . . . . . ... . . . ak description of action ak wk,1 · · · wk,n
(w1,i, . . . , wk,i) is called effect of ri.
– 7 – 2017-05-29 – Scoreet –
11/49
Each rule r ∈ {r1, . . . , rn} of table T
T: decision table r1 · · · rn c1 description of condition c1 v1,1 · · · v1,n . . . . . . . . . ... . . . cm description of condition cm vm,1 · · · vm,n a1 description of action a1 w1,1 · · · w1,n . . . . . . . . . ... . . . ak description of action ak wk,1 · · · wk,n
is assigned to a propositional logical formula F(r) over signature C ˙ ∪ A as follows:
F(r) := F(v1, c1) ∧ · · · ∧ F(vm, cm)
∧ F(w1, a1) ∧ · · · ∧ F(wk, ak)
where F(v, x) = x , if v = × ¬x , if v = − true , if v = ∗
– 7 – 2017-05-29 – Scoreet –
12/49 F(r) := F(v1, c1) ∧ · · · ∧ F(vm, cm) ∧ F(v1, a1) ∧ · · · ∧ F(vk, ak)
F (v, x) = x , if v = × ¬x , if v = − true , if v = ∗
T r1 r2 r3 c1 × × − c2 × − ∗ c3 − × ∗ a1 × − − a2 − × −
– 7 – 2017-05-29 – main –
13/49
– 7 – 2017-05-29 – Setasspec –
14/49
We can use decision tables to model (describe or prescribe) the behaviour of software! Example: Ventilation system of lecture hall 101-0-026.
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
and whether (we intend to) start ventilation of stop ventilation.
σ(b) := true, if button pressed now and σ(b) := false, if button not pressed now. σ(go) := true, we plan to start ventilation and σ(go) := false, we plan to stop ventilation.
As usual, we write σ | = ϕ iff ϕ evaluates to true under σ (and σ | = ϕ otherwise).
thus, given σ, we have either σ | = F(r) or σ | = F(r).
We say, σ is allowed by decision table T if and only if there exists a rule r in T such that σ | = F(r).
– 7 – 2017-05-29 – Setasspec –
15/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
F(r1) = b ∧ off ∧ ¬on ∧ go ∧ ¬stop F(r2) = b ∧ ¬off ∧ on ∧ ¬go ∧ stop F(r3) = ¬b ∧ true ∧ true ∧ ¬go ∧ ¬stop (i) Assume: button pressed, ventilation off, we (only) plan to start the ventilation.
– 7 – 2017-05-29 – Setasspec –
15/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
F(r1) = b ∧ off ∧ ¬on ∧ go ∧ ¬stop F(r2) = b ∧ ¬off ∧ on ∧ ¬go ∧ stop F(r3) = ¬b ∧ true ∧ true ∧ ¬go ∧ ¬stop (i) Assume: button pressed, ventilation off, we (only) plan to start the ventilation.
Yes! (Because σ1 | = F(r1)) (ii) Assume: button pressed, ventilation on, we (only) plan to stop the ventilation.
= F(r2)) (iii) Assume: button not pressed, ventilation on, we (only) plan to stop the ventilation.
– 7 – 2017-05-29 – Setasspec –
16/49
Needs!
need 1 need 2 need 3 ...Solution! Customer Developer
announcement
(Lastenheft)
→
...e
Customer Developer
(Pflichtenheft)
→
spec 1 spec 2a spec 2b ...§
...e
Customer Developer
software contract
(incl. Pflichtenheft)
→
Needs! Developer Customer
software delivery
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
– 7 – 2017-05-29 – Setasspec –
16/49
Needs!
need 1 need 2 need 3 ...Solution! Customer Developer
announcement
(Lastenheft)
→
...e
Customer Developer
(Pflichtenheft)
→
spec 1 spec 2a spec 2b ...§
...e
Customer Developer
software contract
(incl. Pflichtenheft)
→
Needs! Developer Customer
software delivery
T1: cash a cheque r1 r2 else c1 credit limit exceeded? × × c2 payment history ok? × − c3
− ∗ a1 cash cheque × − × a2 do not cash cheque − × − a3
× − −
(Balzert, 2009)
– 7 – 2017-05-29 – Setasspec –
16/49
Needs!
need 1 need 2 need 3 ...Solution! Customer Developer
announcement
(Lastenheft)
→
...e
Customer Developer
(Pflichtenheft)
→
spec 1 spec 2a spec 2b ...§
...e
Customer Developer
software contract
(incl. Pflichtenheft)
→
Needs! Developer Customer
software delivery
T1: cash a cheque r1 r2 else c1 credit limit exceeded? × × c2 payment history ok? × − c3
− ∗ a1 cash cheque × − × a2 do not cash cheque − × − a3
× − −
(Balzert, 2009)
– 6 – 2016-05-12 – Sre –
12/37
A requirements specification should be
— it correctly represents the wishes/needs of the customer,
— all requirements (existing in somebody’s head, or a document, or ...) should be present,
— things which are not relevant to the project should not be constrained,
— each requirement is compatible with all other requirements; otherwise the requirements are not realisable,
— a requirements specification does not constrain the realisation more than necessary,
— the sources of requirements are documented, requirements are uniquely identifiable,
— the final product can objectively be checked for satisfying a requirement.
which is usually only in the customer’s head. → is is difficult to be sure of correctness and completeness.
It’s not unusual that even the customer does not precisely know...!
For example, the customer may not be aware of contradictions due to technical limitations.
– 7 – 2017-05-29 – Setasspec –
17/49
... so, off to “ ‘technological paradise’ where [...] everything happens according to the blueprints”.
(Kopetz, 2011; Lovins and Lovins, 2001)
– 7 – 2017-05-29 – main –
18/49
– 7 – 2017-05-29 – Setana –
19/49
– 6 – 2016-05-12 – Sre –
12/37
A requirements specification should be
— it correctly represents the wishes/needs of the customer,
— all requirements (existing in somebody’s head, or a document, or ...) should be present,
— things which are not relevant to the project should not be constrained,
— each requirement is compatible with all other requirements; otherwise the requirements are not realisable,
— a requirements specification does not constrain the realisation more than necessary,
— the sources of requirements are documented, requirements are uniquely identifiable,
— the final product can objectively be checked for satisfying a requirement.
which is usually only in the customer’s head. → is is difficult to be sure of correctness and completeness.
It’s not unusual that even the customer does not precisely know...!
For example, the customer may not be aware of contradictions due to technical limitations.
– 7 – 2017-05-29 – Setana –
20/49
disjunction of all rules’ premises is a tautology, i.e. if | =
Fpre(r).
– 7 – 2017-05-29 – Setana –
21/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
Recall:
F(r1) = c1 ∧ c2 ∧ ¬c3 ∧ a1 ∧ ¬a2 F(r2) = c1 ∧ ¬c2 ∧ c3 ∧ ¬a1 ∧ a2 F(r3) = ¬c1 ∧ true ∧ true ∧ ¬a1 ∧ ¬a2
Fpre(r1) ∨ Fpre(r2) ∨ Fpre(r3) = (c1 ∧ c2 ∧ ¬c3) ∨ (c1 ∧ ¬c2 ∧ c3) ∨ (¬c1 ∧ true ∧ true) is not a tautology.
– 7 – 2017-05-29 – Setana –
22/49
Needs!
need 1 need 2 need 3 ...Solution! Customer Developer
announcement
(Lastenheft)
→
...e
Customer Developer
(Pflichtenheft)
→
spec 1 spec 2a spec 2b ...§
...e
Customer Developer
software contract
(incl. Pflichtenheft)
→
Needs! Developer Customer
software delivery
If there are no misunderstandings, then we did discuss all cases.
– 7 – 2017-05-29 – Setana –
23/49
T: decision table r1 · · · rn else c1 description of condition c1 v1,1 · · · v1,n . . . . . . . . . ... . . . cm description of condition cm vm,1 · · · vm,n a1 description of action a1 w1,1 · · · w1,n w1,e . . . . . . . . . ... . . . . . . ak description of action ak wk,1 · · · wk,n wk,e
F(else) := ¬
– 7 – 2017-05-29 – Setana –
24/49
A rule r ∈ T is called useless (or: redundant) if and only if there is another (different) rule r′ ∈ T
i.e. if ∃ r′ = r ∈ T • | = (Fpre(r) = ⇒ Fpre(r′)) ∧ (Feff (r) ⇐ ⇒ Feff (r′)). r is called subsumed by r′.
– 7 – 2017-05-29 – Setana –
25/49
T: room ventilation r1 r2 r3 r4 b button pressed? × × − −
ventilation off? × − ∗ −
ventilation on? − × ∗ × go start ventilation × − − − stop stop ventilation − × − −
yielding an easier usable specification.
– 7 – 2017-05-29 – Setana –
25/49
T: room ventilation r1 r2 r3 r4 b button pressed? × × − −
ventilation off? × − ∗ −
ventilation on? − × ∗ × go start ventilation × − − − stop stop ventilation − × − −
yielding an easier usable specification.
– 6 – 2016-05-12 – Sre –
13/37
The representation and form of a requirements specification should be:
not unnecessarily complicated — all affected people should be able to understand the requirements specification,
the requirements specification should not introduce new unclarities or rooms for interpretation (→ testable, objective),
creating and maintaining the requirements specification should be easy and should not need unnecessary effort,
storage of and access to the requirements specification should not need significant effort.
Note: Once again, it’s about compromises.
may not be easily understandable by every affected person. → provide redundant explanations.
→ value low access effort higher, a requirements specification document is much more often read than changed or written (and most changes require reading beforehand).
– 7 – 2017-05-29 – Setana –
26/49
A decision table T is called deterministic if and only if the premises of all rules are pairwise disjoint, i.e. if ∀ r1 = r2 ∈ T• | = ¬(Fpre(r1) ∧ Fpre(r2)). Otherwise, T is called non-deterministic.
– 7 – 2017-05-29 – Setana –
27/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
Yes.
– 7 – 2017-05-29 – Setana –
28/49 Tabstr : room ventilation r1 r2 r3 b button pressed? × × − go start ventilation × − − stop stop ventilation − × −
No. By the way...
under certain conditions (which I will specify later), and
under certain conditions (which I will specify later).
We in particular state that we do not (under any condition) want to see on and off executed together, and that we do not (under any condition) see go or stop without button pressed.
– 7 – 2017-05-29 – Scontent –
29/49
Logic
– 7 – 2017-05-29 – main –
30/49
– 7 – 2017-05-29 – Setconflax –
31/49
Example:
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × −
then σ | = on ∧ off and σ | = ¬on ∧ ¬off never happen in reality for any observation σ.
(T “does not know” that on and off can be opposites in the real-world).
Then T would be relative complete (relative to the domain knowledge that on/off are opposites).
Bottom-line:
we may also want to represent relations between actions/conditions in the real-world (→ domain model (Bjørner, 2006)).
– 7 – 2017-05-29 – Setconflax –
32/49
Intuition: a conflict axiom characterises all those cases, i.e. all those combinations of condition values which ‘cannot happen’ — according to our understanding of the domain.
Example:
“on models an opposite of off , neither can both be satisfied nor both non-satisfied at a time”
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × − ¬[(on ∧ off ) ∨ (¬on ∧ ¬off )]
– 7 – 2017-05-29 – Setconflax –
33/49 “Airbus A320-200 overran runway at Warsaw Okecie Intl. Airport on 14 Sep. 1993.”
T r1 r2 r3 else splq spoilers requested × × − thrq thrust-reverse requested − − × lgsw at least 6.3 tons weight on each landing gear strut × ∗ × spd wheels turning faster than 133 km/h ∗ × ∗ spl enable spoilers × × − − thr enable thrust-reverse − − × −
Idea: if conditions lgsw and spd not satisfied, then aircraft is in the air.
14 Sep. 1993:
"Flight 29041129" by Anynobody - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Flight_29041129.png#/media/File:Flight_29041129.png "Lufthansa Flight 2904 crash site Siecinski" by Mariusz Siecinski - http://www.airliners.net/photo/Lufthansa/Airbus-A320-211/0265541/L/. Licensed under GFDL via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Lufthansa_Flight_2904_crash_site_Siecinski.jpg
– 7 – 2017-05-29 – Setconflax –
34/49
A decision table T is called complete wrt. conflict axiom ϕconfl if and only if the disjunction of all rules’ premises and the conflict axiom is a tautology, i.e. if | = ϕconfl ∨
Fpre(r).
Fits intuition: ϕconfl = false means we don’t exclude any states from consideration.
– 7 – 2017-05-29 – Setconflax –
35/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation − × − ¬[(on ∧ off ) ∨ (¬on ∧ ¬off )]
then σ | = on ∧ off is possible in reality (e.g. due to sensor failures). Decision table T does not tell us what to do in that case!
– 7 – 2017-05-29 – Setconflax –
36/49
A rule r ∈ T is called vacuous wrt. conflict axiom ϕconfl if and only if the premise of r implies the conflict axiom, i.e. if | = Fpre(r) → ϕconfl.
Example:
T: room ventilation r1 r2 r3 r4 b button pressed? × × − ×
ventilation off? × − ∗ ×
ventilation on? − × ∗ × go start ventilation × − − − stop stop ventilation − × − × ¬[(on ∧ off ) ∨ (¬on ∧ ¬off )]
– 7 – 2017-05-29 – Scontent –
37/49
Logic
– 7 – 2017-05-29 – main –
38/49
– 7 – 2017-05-29 – Setconflrel –
39/49
metric relation ⊆ (A × A).
(i) Rule r is called consistent with conflict relation if and only if there are no conflicting actions in its effect, i.e. if | = Feff (r) →
(a1,a2)∈ ¬(a1 ∧ a2).
(ii) T is called consistent with iff all rules r ∈ T are consistent with .
– 7 – 2017-05-29 – Setconflrel –
40/49
T: room ventilation r1 r2 r3 b button pressed? × × −
ventilation off? × − ∗
ventilation on? − × ∗ go start ventilation × − − stop stop ventilation × × − ¬[(on ∧ off ) ∨ (¬on ∧ ¬off )]
“actions stop and go are not supposed to be executed at the same time”
as well as in requirements in general — are not always as obvious as in the toy examples given here! (would be too easy...)
– 7 – 2017-05-29 – Scontent –
41/49
Logic
– 7 – 2017-05-29 – main –
42/49
– 7 – 2017-05-29 – Setcoll –
43/49
and σ be a model of an observation of C and A. Then Fcoll(T) :=
a ↔
r∈T,r(a)=× Fpre(r)
is called the collecting semantics of T.
– 7 – 2017-05-29 – Setcoll –
43/49
and σ be a model of an observation of C and A. Then Fcoll(T) :=
a ↔
r∈T,r(a)=× Fpre(r)
is called the collecting semantics of T.
= Fcoll(T). That is, if exactly all actions of all enabled rules are planned/exexcuted.
– 7 – 2017-05-29 – Setcoll –
43/49
and σ be a model of an observation of C and A. Then Fcoll(T) :=
a ↔
r∈T,r(a)=× Fpre(r)
is called the collecting semantics of T.
= Fcoll(T). That is, if exactly all actions of all enabled rules are planned/exexcuted. Example:
T: room ventilation r1 r2 r3 r4 b button pressed? × × − ×
ventilation off? × − ∗ ∗
ventilation on? − × ∗ ∗ go start ventilation × − − − stop stop ventilation − × − − blnk blink button − − − × ¬[(on ∧ off ) ∨ (¬on ∧ ¬off )]
– 7 – 2017-05-29 – Setcoll –
44/49
Decision table T is called consistent with conflict relation in the collecting se- mantics (under conflict axiom ϕconfl) if and only if there are no conflicting actions in the effect of jointly enabled transitions, i.e. if | = Fcoll(T) ∧ ϕconfl →
(a1,a2)∈ ¬(a1 ∧ a2).
– 7 – 2017-05-29 – main –
45/49
– 7 – 2017-05-29 – Setdisc –
46/49
“Es ist aussichtslos, den Klienten mit formalen Darstellungen zu kommen; [...]”
(“It is futile to approach clients with formal representations”) (Ludewig and Lichter, 2013)
T: room ventilation r1 r2 else b button pressed? × ×...
Developer Customer
here, just check and update if needed
WAT?!
Precise/objective: whoever reads it whenever to whomever, the meaning will not change.
(formalising all requirements is in most cases not possible),
– 7 – 2017-05-29 – Sttwytt –
47/49
requirements specification language with
describe their understanding of requirements. Customers may need translations/explanation!
can be used to analyse requirements. The discussed DT properties are decidable, there can be automatic analysis tools.
Note: wrong assumptions can have serious consequences.
– 7 – 2017-05-29 – main –
48/49
– 7 – 2017-05-29 – main –
49/49 Balzert, H. (2009). Lehrbuch der Softwaretechnik: Basiskonzepte und Requirements Engineering. Spektrum, 3rd edition. Bjørner, D. (2006). Software Engineering, Vol. 3: Domains, Requirements and Software Design. Springer-Verlag. Kopetz, H. (2011). What I learned from Brian. In Jones, C. B. et al., editors, Dependable and Historic Computing, volume 6875 of LNCS. Springer. Lovins, A. B. and Lovins, L. H. (2001). Brittle Power - Energy Strategy for National Security. Rocky Mountain Institute. Ludewig, J. and Lichter, H. (2013). Software Engineering. dpunkt.verlag, 3. edition. Wikipedia (2015). Lufthansa flight 2904. id 646105486, Feb., 7th, 2015.