Specifications en Langage Z Chapitre 7. Langage Z (Zed) Jean Raymond Abrial Annees 70 Oxford...

Post on 04-Apr-2015

105 views 0 download

Transcript of Specifications en Langage Z Chapitre 7. Langage Z (Zed) Jean Raymond Abrial Annees 70 Oxford...

Specifications en Langage Z

Chapitre 7

Langage Z (Zed)

Jean Raymond Abrial Annees 70 Oxford University Base sur les ensembles et les relations Largement utilise dans la communaute

‘’methodes formelles’’, EULangage B Annees 90 Z + Concepts OO Ligne de metro a Paris

Specifier en Z

Formuler specs en termes abstraits Ensembles/ relations, sans souci de

representation/ programmation What vs How Conception independante du langage

Ensembles en Z

Types de donnes usuels (sans souci de representation)

Types de donnees definis par l’usager CITIZEN DRIVER LICENCE_NUMBER REPLY = yes | No STATUS = InUse | Free | OnHold | OutOfOrder LIGHTS = Green | Orange | Red

Ensembles en Z

MAGHREB = TN | DZ | MA | MU | LY homeland: MAGHREB homeland = TN

Power Sets

}}.,,{},,}{,{},,{},{},{},{{{},

},,{

cbacbcabacba

cbaS

P(S)

Power Sets

};,{Pr{};Pr

).(Pr

LYDZoducersOiloducersOIL

MAGHREBPoducersOil

..Pr

..Pr

..Pr

..Pr

}.,{Pr

wrongoducersOilDZ

wrongoducersOilEG

falseoducersOilTN

trueoducersOilDZ

LYDZoducersOil

i: integer; i=10; 5<i<15 vrai 15<i<25 faux i = ‘’hello world’’ illegal

Cardinalite

.2)(#

.1}Pr{#

.2Pr#

.1{{}}#

.0}{#

.0{}#

#SSP

oducersOil

oducersOil

a

Structure d’Une Specification en Z

Schemas en Z

Operations sur les Schemas

Substitutions

Conjonction

Delta et Chi

Disjonction

Symboles d’Entrée/ Sortie

Entrée: ? Sortie: !

Relations en Z

Ensemble des Relations de X vers Y:

Declaration d’Une relation de X vers Y:

X={0,1} Y={a,b} XxY = {(0,a),(0,b),(1,a),(1,b)} P(XxY)= R est deterministe: chaque element de

X a au plus une image. R est totale: chaque element de X a au

moins une image.

}

)},1(),,1(),,0(),,0{(

)},,1(),,0(),,0)}{(,1(),,0(),,0{(

)},1(),,1(),,0{()},,1(),,1(),,0{(

)},,1(),,0{()},,1(),,0{(

)},,1(),,0{()},,1(),,0{(

)},,1(),,1{()},,0(),,0{(

)},,1{()},,1{()},,0{()},,0{(

{},

{)(

)}.,1(),,1(),,0(),,0{(}.,{}.1,0{

baba

ababba

baabab

baab

bbaa

baba

baba

YXP

babaYXbaYX

Fonctions en Z

Relations Deterministes:

Relations Deterministes et Totales:

Exemple de Specification en Z

Gestion d’une bibliotheque Gestion des ressources bibliographiques Gestion des acquisitions Gestion des suppressions (pertes, etc) Gestion des emprunts Gestion des abonnes

Types de donnees

Donnees a maintenir

Livres que nous possedons Livres disponibles a l’emprunt Nombre par livre Emprunts Ensemble des abonnes

Declaration de l’espace

m: ensembles des abonnes, t: date courante, k: possessions de la bibliotheque r: emprunts s: livres disponibles a l’emprunt

Espace d’etats et Invariants

))((:

:

:

:

)(:

DATEBOOKPPERSONr

naturalBOOKs

naturalBOOKk

DATEt

PERSONPm

Initialisation

DATEtoday

Library

:?

}|{}),{('

}|)0,{('

}|)0,{('

?'

{}'

PERSONppr

BOOKbbs

BOOKbbk

todayt

m

Acquisition d’un Livre

Acquisition

BOOKb

Library

:?

)()(':?

1?)(?)('

)()(':?

1?)(?)('

',','

bsbsbb

bsbs

bkbkbb

bkbk

rrttmm

Abonnement

Personne presentee est deja abonnee. Elle ne l’est pas.

Abonnement Normal

dejaAbonnenormalmsg

PERSONa

Library

|:!

:?

rrkksstt

normalmsg

amm

ma

',',','

!

?}{'

?

Abonnement Exceptionnel

dejaAbonnenormalmsg

PERSONa

Library

|:!

:?

dejaAbonnemsg

ma

!

?

Abonnement

Abonnement = AbonnementNormal AbonnementExceptionnel

Emprunt

Variables d’entrée: abonne a?, livre b? Variables de sortie: msg! Cas:

a? n’est pas abonne b? n’est pas disponible Emprunt normal

NonAbonne

malEmpruntNorsponiblelivreNonDinonAbonnemsg

BOOKb

PERSONa

Library

||:!

:?

:?

nonAbonnemsg

ma

!

?

NonDisponible

malEmpruntNorsponiblelivreNonDinonAbonnemsg

BOOKb

PERSONa

Library

||:!

:?

:?

sponiblelivreNonDimsg

bs

!

0?)(

EmpruntNormal

malEmpruntNorsponiblelivreNonDinonAbonnemsg

BOOKb

PERSONa

Library

||:!

:?

:?

)()(':?)},?,{(?)(?)('

)()(':?,1?)(?)('

',','

!

0?)(

?

araraatbarar

bsbsbbbsbs

kkttmm

malEmpruntNormsg

bs

ma

Emprunt

Emprunt = NonAbonne livreNonDisponible EmpruntNormal

Elimination d’un Livre

Je ne possede pas le livre Je l’ai perdu J’en dispose.

Abonnement Exceptionnel

dejaAbonnenormalmsg

PERSONa

Library

|:!

:?

dejaAbonnemsg

ma

!

?

Abonnement Exceptionnel

dejaAbonnenormalmsg

PERSONa

Library

|:!

:?

dejaAbonnemsg

ma

!

?

Acquisition d’un Livre

r: PERSON BOOK q: PERSON P(BOOK) PERSON = {P1, P2, P3, P4} BOOK = {B1, B2, B3} r = {(P1,B1),(P1,B3),(P3,B1),(P3,B2)} q ={ (p1 , {b1,b3}), (p2 , {}),

(p3 , {b1,b2}), (p4 , {})}.

Quelle est la relation q qui correspond a la meme situation

Initialisation

Abonnement a la bibliotheque

Forme sophistiquee d’abonnement

Ajouter un livre

Minuit

Liste d’Emprunt