25
1 Functional Requirements: Formal Structural Requirements Why Formal? – Revisiting SADT RML/Telos Essentials A Formalization of RML/Telos A Survey of Formal Methods

1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

1

Functional Requirements:

Formal Structural Requirements

•Why Formal? –Revisiting SADT

•RML/Telos Essentials

•A Formalization of RML/Telos

•A Survey of Formal Methods

Page 2: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

2

Page 3: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

3

RML/TelosEssentials

[S. G

reenspan, J. M

ylopoulos and A. Borgida, A. O

n formal requirements modeling

languages: RML revisited, 16th Int. Conf. on Software Eng. pp135

-147. 1994.

In p

hilo

sophy, onto

logy is the stu

dy o

f being

or existe

nce. It seeks to d

escribe o

r posit the

basic cate

goriesand relationships o

f being o

r existe

nce to d

efine e

ntitiesand types o

f entities

within its fra

mework

. Onto

logy can b

e said to stu

dy conceptions o

f re

ality.

http://e

n.w

ikipedia.o

rg/w

iki/Onto

logy

What does object-orientation mean?

Page 4: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

4

RML/TelosEssentials

?

cf. Liar’s paradox;

Russell’s paradox:

Ais an elem

ent of M

if and only if Ais not an elem

ent of A

is M

an element of itself?

[A. Church, Theory of Types, 1940.]

Page 5: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

5

Uniform treatment of attributes and associations

Page 6: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

6

?

Page 7: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

7

RML/Telos–Assertion Class

AssertionClass IsTreatedWith with

arguments p: Patients

t: Treatments

necessary cond1: Available (treatment = t, at = p.location)

cond2: Recom

mended (treatment = t, disease = p.diagnosis)

end IsTreatedWith

AssertionClass Available with

arguments treatment: Treatments

at: Nursing-Hom

eend Available

AssertionClass ReceiveChemotherapy isAIsTreatedWith with

arguments p: CancerPatients

t: CancerDrugs

What could be instances?

Page 8: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

8

RML/Telos–MetaClass

MetaClassActivityClasswith

input: EntityClass

output: EntityClass

control: EntityClass

part: ActivityClass

end ActivityClass

ActivityClassAdm

itPatientswith

input

: Person

output

: Patient

control: M

edicalDoctor

part

getBasicInfo: Interview (whom = person)

place: AssignRoom(toW

hom= person)

getConsult: ScheduleVisit(visitor = doc, visitee= patient)

assess: takeVitalSigns(visitee= patient)

Page 9: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

9

RML/Telos–Temporal Primitives

ActivityClassAdm

itPatientswith

… part

getBasicInfo: Interview (whom = person)

place: AssignRoom(toW

hom= person)

getConsult: ScheduleVisit(visitor = doc, visitee= patient)

assess: takeVitalSigns(visitee= patient)

constraints getBasicInfofollowedByplace

place overlaps getConsult

Tem

porally-related

overlaps

followedBy

nonOverlapping

earlier

later

occurs-during

costarts

cofinishes

*see the a

xio

matization

late

r on

Page 10: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

10

A Formalization of RML/Telos

[S. G

reenspan, J. M

ylopoulos and A. Borgida, A. “A Requirements Modeling Language and Its Logic,”

In M. Brodieand J. Mylopoulos (eds), O

n K

nowledge B

ase M

anagem

ent Syste

ms, Springer-Verlag. 1986. pp 471 -502. ]

Page 11: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

11

Formal Semantics

�formal = syntax = gram

mar

=> reasoning, consistency checking, derive new facts

-deductive reasoning

-abductivereasoning

-approximate reasoning

-analogical reasoning

-qualitative reasoning

-probabilistic reasoning

-…

�semantics: meaning

-Denotationalsem

antics,

-Tarskiansemantics,

-Kripke’spossible world sem

antics,

-Hoare’s partial correctness sem

antics

-…

Can be in the form of

-semantic integrity constraints/assertions, rules)

�pro

of th

eory

/axiom

aticsfor deriving new statements from

old

�m

odel th

eory

/sem

anticsfor making sense of them

Page 12: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

12

Logic: Brief Review

�connectives:

^, & logical conjunction

logical disjunction

→,

material implication(im

plies; if .. Then)

↔,

material equivalence

(if and only if; iff)

¬, ˜logical negation

�quantifiers: universal quantifier

existential quantifier

�modality: ne

cessity

possibility

�meta logical properties

semantic consequence

syntactic consequence

logical consistency: two statem

ents are consistent

if and only if their conjunction is not a contradiction

�fo

rmal languagefor expressing statem

ents

�m

odel th

eory

/sem

anticsfor making sense of them

�pro

of th

eory

/axiom

aticsfor deriving new statements from

old

[H. G

effner, http://www.tecn.upf.es/~hgeffner/html/cursos/slides/logica.pdf]

For more, see www.voronkov.com/slides/brics01.ps (Ι(A) ╞Ι(B))

Every

derivable form

ula

is v

alid

.

Every

valid

form

ula

is d

erivable.

Page 13: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

13

Formal Semantics of RML/Telos

�Basic Predicates

�IN (i, C, s): predicate asserting that token I is an instance ofclass C

E.g., IN (John, Child, 1997)

IN (John, Student, 2004)

�IS-A (C1, C

2): time-independent predicate asserting that class C

1is a subclass of

class C2.

E.g., IS-A (Child, Person)

IS-A (Student, Person)

�PROPDEF (C, a): time-independent function which gives the class to which

the value of attribute a for instances of class C must belong

(definitional property function)

E.g., PROPDEF (Person, age) => PersonAgeValue

where Class PersonAgeValue

= 0..200

PROPDEF (Child, age) => ChildAgeValue

where Class ChildAgeValue

= 1..17

Page 14: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

14

Formal Semantics of RML/Telos

�Som

e Axiom

s

�Partial Order IS-A Constraint

�reflexive (C, C):

E.g., IS-A (Person, Person)

IS-A (Child, Child)

�anti-symmetric: (C1≠C2) ∧IS-A (C1, C

2) ↔

~ IS-A (C2, C

1)E.g., IS-A (Child, Person) →

~ IS-A (Child, Person)

�transitive: IS-A (C1, C

2) ∧IS-A (C2, C

3) →

IS-A (C1, C

3)

E.g., IS-A (ChildStudent, Child) ∧IS-A (Child, Person)

→IS-A (ChildStudent, Person)

�What are the subclasses of class C?

�What are the superclassesof class C?

�Are classes C

1and C2related to each other?

�What inconsistencies are there?

E.g., IS-A (C2, C

3) IS-A (C1, C

2) IS-A (C3, C

1)

Page 15: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

15

Formal Semantics of RML/Telos

�Axiom

s

�Extensional IS-A Constraint

�IN (I, C1, s) ∧IS-A (C1, C

2) →

IN (I, C2, s)

Each instance of a class is in its superclass

�IN (Cathy, Child, 2004) ∧IS-A (Child, Person) →

IN (cathy, Person, 2004)?

�IN (Maria, Person, 2004) ∧IS-A (Child, Person) →

IN (Maria, Child, 2004)?

�IN (Chris, Child, 2004) ∧IS-A (Child, Person) →

IN (Chris, Person, 2005)?

�IN (Person, PersonClass, 1996) ∧IN (John, Person, 2004)

→IN (John, PersonClass, 2004)?

Page 16: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

16

Formal Semantics of RML/Telos

�Axiom

s

�IntensionalIS-A Constraint

�PROPDEF (C2, a) = A2∧IS-A (C1, C

2)∃ ∃∃∃A1[PROPDEF (C1, a) = A1∧IS-A (A1, A2)]

Inherited attributes have more specialized ranges

�PROPDEF (Person, age) = PersonAge

Value ∧IS-A (Child, Person)

∃ ∃∃∃A1[ PROPDEF (Child, age) = A1∧IS-A (A1, PersonAgeValue)

Show both valid theorems and invalid theorems using UML class diagrams,

for both associations and attributes

Uniform treatment of attributes and associations

Page 17: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

17

Formal Semantics of RML/Telos

�More definitions

�PROPVAL (k,, p, s): function which gives the value of the attribute p of element

k at time s (the factual property function)

�$: a special constant used to denote the null value

�necessary (p) =d

ef[PROPDEF (x, p) = y ∧y ≠$] →

[IN (z, x, now) →PROPVAL (z, p, now) ≠$]

�Initially (p) =def [PROPDEF (x, p) = y ∧y ≠$] →

[OCCURS (z, x, now, t) →PROPDEF (z, p, now) ≠$]

assume that OCCURS has been defined using m

eet (late

r)

Page 18: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

18

Formal Semantics of RML/Telos

�Basic Predicates –in Set Theory?

Page 19: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

19

RML/Telos–Axiomatization of Temporal Primitives

[J. Allen and G. Ferguson, “Actions and Events in Tem

poral Logic,”Journal of Logic and Com

putation, 1994]

Page 20: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

20

RML/Telos–Axiomatization of Temporal Primitives

Page 21: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

21

A Brief Survey of Formal Methods

How Much Formality?: How do FMs differ?

Adapted from

[http://www.cs.toronto.edu/~sme/CSC2106S/slides/11-how-much-formality.pdf]

�Mathematical Foundation

Logic

first order predicate logic -e.g. RML

temporal logic -e.g. Albert II, SCR, KAOS

multi-valued logic –e.g. Xchek

Other

algebraic languages -e.g. Larch

set theory -e.g. Z

�Ontology

Fixed

states, events, actions -e.g. SCR

entities, activities, assertions -e.g. RML

Extensible

meta language for defining new concepts -e.g. Telos

�Treatment of Time

State/event models

time as a discrete sequence of events -e.g. SCR

time as quantified intervals -e.g. KAOS

Time as a first class object

meta-level class to represent time -e.g. Telos

Page 22: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

22

Three Different Traditions

�Formal SpecificationLanguages

Grew out of work on program

verification

Spawned many general purpose specification languages

Suitable for specifying the behavior of program

units

Key technologies: Type checking, Theorem

proving

�Reactive System Modeling

Grew out of a need to capture dynam

ic models of system behavior

�Focus is on reactive system

s (e.g. real-time, embedded control

system

s) support reasoning about safety, liveness

�provide a precise requirements specification language

Key technologies: Consistency checking, Model checking

�Formal Conceptual Modeling

Grew out of a concern for capturing real-world knowledge in RE

Focus is on modeling domain entities, activities, agents, assertions

provide a formal ontology for domain modeling

use first order predicate logic as the underlying formalism

�Key technologies: inference engines, default reasoning, KBS-shellsApplicability to RE is poor

No abstraction or structuring

closely tied to program

sem

antics

Examples: Larch, Z, VDM, …

Applicability to RE is good

modeling languages were

developed specifically for RE

Examples: Statecharts, RSML,

Parnas-tables, SCR, …

Applicability to RE is excellent

modeling schemes capture key

reqs concepts

Examples: Reqs Apprentice, RML,

Telos, The NFR Framework,

Albert II, i*

[http://www.cs.york.ac.uk/hise/safety-critical-archive/2002/0171.html]

M MMM, Prog

Prog

Prog

Prog|= S SSS; Gs,S SSS, D DDD|= R RRR; (G GGG

s sss,R RRR, D DDD|= G GGG) V (G GGGs sss, ,,,R RRR, D DDD|~ G GGG); (G GGG|= ¬P PPP) V (G GGG|~ ¬P PPP)

Page 23: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

23

Formal SpecificationLanguages

�Three basic flavors:

Operational -specification is executable abstraction of the implem

entation

good for rapid prototyping

e.g., Lisp, Prolog, Smalltalk

State-based -views a program as a (large) data structures whose state

can be altered by procedure calls

using pre/post-conditions to specify the effect of procedures

e.g., VDM, Z

Algebraic -views a program as a set of abstract data structures with a setof operations…

…operations are defined declaratively by giving a set of axiom

se.g., Larch, CLEAR, O

BJ

�Developed for specifying programs

Program

s are formal, m

an-made objects

can be modeled precisely in terms of input-output behavior

But in RE we’re more concerned with:

real-world concepts, stakeholders, goals, loosely define problems, environm

ents

So these languages are NOT appropriate for RE

but people fail to realize that requirements specification ≠program specification

Page 24: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

24

Reactive System Modeling

�Modeling how a system should behave

Model the environm

ent as a state machine

Model the system

as a state machine

Model safety, liveness properties of the machine as temporal logic assertions

Check whether the properties hold of the system interacting with its environm

ent

Examples:

Statecharts

Harel’s notation for modeling large system

sAdds parallelism, decom

position and conditional transitions to STDs

RSML (Requirements State Machine Language) [Heimdahl & Leveson]

Adds tabular specification of com

plex conditions to Statecharts

A7e approach

Major project led by Parnasto formalize A7e aircraft requirements spec

Uses tables to specify transition relations & outputs

SCR (Software Cost Reduction) [Heitmeyer et. al.]

Extends the A7e approach to include dictionaries & support tables

Page 25: 1 Functional Requirements: Formal Structural Requirementschung/SYSM6309/rml.pdf · Focus is on modeling domain entities, activities, agents, assertions ... Algebraic -views a program

25

Formal Conceptual Modeling

�General approach

model the world beyond functional specifications

a specification is prescriptive, concentrating on desired properties of the machine

but we also need to capture an understanding of the applicationdomain

hence build models of hum

ans’knowledge/beliefs about the world

make use of abstraction & refinem

ent as structuring primitives

Examples:

RML (Requirements Modeling Language) [Greenspan & Mylopoulos, early-1980s]

First m

ajor attempt to use knowledge representation techniques in RE

Essentially an object oriented language, with classes for activities, entities and assertions

Uses First Order Predicate Language as an underlying reasoningengine

Telos Extends RML by creating a fully extensible ontology

Meta-level classes define the ontology (the basic set is built in)

The NFR Framework

�The first visual modeling of NFRsas softgoalsand softgoalsatisficing

�Albert II [Dubois & duBois, mid-1990s]

Models a set of interacting agents that perform actions that change their state

Uses an object-oriented real-time temporal logic for reasoning

�i*

[Yu et al]