an executable formal semantics for sdl-2000 andreas prinz dresearch gmbh berlin

20
An Executable Formal An Executable Formal Semantics for SDL-2000 Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

Upload: jody-west

Post on 22-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

An Executable Formal Semantics An Executable Formal Semantics for SDL-2000for SDL-2000

Andreas Prinz

DResearch GmbH Berlin

Page 2: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

2

SAM 2000, Col de Porte

© DResearch GmbH

ContentsContents

• SDL-2000 Formal Description– static part– dynamic part

• SDL-2000 Formal Implementation

• Conclusion

Page 3: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

3

SAM 2000, Col de Porte

© DResearch GmbH

Formality: Static PartFormality: Static Part

language part

Abstract Syntax

transformations (e.g. RPC)conditions (e.g. types)

formalisation

Concrete Syntax BNF

BNF

Rewriting

PC1

Page 4: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

4

SAM 2000, Col de Porte

© DResearch GmbH

Example: Concrete SyntaxExample: Concrete Syntax

state s;

input a;

output b,c;

nextstate s;

endstate;

<output> ::=

output <output body>

<output body> ::=

<signal identifier>

{, <signal identifier>}*

Page 5: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

5

SAM 2000, Col de Porte

© DResearch GmbH

Example: Abstract SyntaxExample: Abstract SyntaxState-node(Name(s),

Input-node(Identifier(a),

Transition(

Output-node(Identifier(b)),

Output-node(Identifier(c)),

Nextstate-node(Name(s))

) ) )

Output-node :: Signal-identifier

Signal-identifier = Identifier

Page 6: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

6

SAM 2000, Col de Porte

© DResearch GmbH

Example: TransformationsExample: TransformationsIf several <signal identifier>s are specified in an <output body>, this is derived syntax for specifying a sequence of <output>s in the same order as specified in the original <output body>.

< <output>(<output body>(< o > // r) ) > provided r empty

=>

< <output>(<output body>(< o >) ),

<output>(<output body>(r) ) >

Page 7: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

7

SAM 2000, Col de Porte

© DResearch GmbH

Example: ConditionsExample: ConditionsThe <signal identifier> in an <output body> must denote a <signal definition>.

o <output body>:

o.s-<signal identifier>.refersto <signal definition>

o Output-node:

o.s-Signal-identifier.refersto

Signal-definition

Page 8: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

8

SAM 2000, Col de Porte

© DResearch GmbH

Example: MappingExample: Mapping

<output>(<output body>(< id >))

=>

Output-node(Mapping(id))

Page 9: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

9

SAM 2000, Col de Porte

© DResearch GmbH

Formality: Dynamic PartFormality: Dynamic PartAbstract Syntax

databehaviourstructure

initialisation

compilation

data interface

SDL Abstract Machine (SAM)

ASM

primitivesconnectionsstructure

Page 10: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

10

SAM 2000, Col de Porte

© DResearch GmbH

Example: SAMExample: SAM

Link_Moduleif Self.from.queue<>empty then

let S=Self.from.queue.head in

if Applicable(Self,S) then

DELETE(S,Self.from)

INSERT(S,Delay(Self),Self.to)

Self.last_time:=Delay(Self)

where

Applicable(Self,S)= ...

Delay(Self)=max(now+Self.delay,Self.last_time)

Page 11: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

11

SAM 2000, Col de Porte

© DResearch GmbH

Example: InitialisationExample: InitialisationInit_Agent_Moduleif mode(Self)=initial then

mode(Self):= starting

CREATEVARIABLES(Self.ref.Variable-definition)

do forall a:Self.ref.Agent

extend Agent with ag

ref(ag):= a, mode(ag):= initial

Mod(ag):= Init_Agent_Module

else

CREATECHANNELS(Self.ref.Channel-definition)

Mod(Self):= Execute_Module

Page 12: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

12

SAM 2000, Col de Porte

© DResearch GmbH

Example: CompilationExample: Compilation

l1: STATENODE( {<a, l2>})

l2: OUTPUT(b) => l3l3: OUTPUT(c) => l4l4: SKIP => l1

Page 13: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

13

SAM 2000, Col de Porte

© DResearch GmbH

ImplementationImplementationtools used: lex, yacc, kimwitu, make, workbench

lexical structure sdl.l

concrete syntax sdl.y, sdl_cs.k

abstract syntax sdl_as.k

transformations sdl_trans.k

conditions sdl_cond.k

mapping CS -> AS sdl_map.k

compilation sdl_compile.k

ASM parts sdl.asm

Page 14: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

14

SAM 2000, Col de Porte

© DResearch GmbH

ConclusionsConclusions• ASM very well suited for SDL semantics

• difficult to cover the whole language

• flexible use of different techniques in dynamic semantics

• executability of the semantics

• implementation already for a restricted version of SDL

Page 15: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

An Executable Formal Semantics An Executable Formal Semantics for SDL-2000for SDL-2000

Dr. A. Prinz

DResearch GmbH Berlin

Page 16: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

16

SAM 2000, Col de Porte

© DResearch GmbH

Abstract State MachinesAbstract State Machines• general

– state transitions– introduced by Gurevich– based on mathematics

• states

• transitions

• programs

• concurrency/time

Y. Gurevich. Evolving Algebra 1993: Lipari GuideIn E. Börger, editor, Specification and Validation Methods; Oxford University Press 1995

Y. Gurevich.ASM Guide 97CSE Technical Report, University of Michigan-Ann Arbor, 1997

Page 17: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

17

SAM 2000, Col de Porte

© DResearch GmbH

Abstract State MachinesAbstract State Machines• general• states

– algebras– sets,functions– domains– reserve elements

• transitions• programs• concurrency/time

state

element

domain

function

boolean

function

vocabulary

0-ary function

1-ary predicate

function name

predicate name

Page 18: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

18

SAM 2000, Col de Porte

© DResearch GmbH

Abstract State MachinesAbstract State Machines• general

• state

• transitions– locations, updates– firing of updates– runs

• programs

• concurrency/time

Account(Jill):= 1000000

Account(Jack):= 0

Jill.Account:= 1000000

Jack.Account:= 0

Page 19: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

19

SAM 2000, Col de Porte

© DResearch GmbH

Abstract State MachinesAbstract State Machines• general• states• transitions• programs

• concurrency/time

know(s):= know(s)+SDL do forall s: Student

– do-forall

choose s: Student

focus(Self):= s

– choose

if strike then

else

– if-then-else

extend Flyer by f

– extend

Page 20: An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin

20

SAM 2000, Col de Porte

© DResearch GmbH

Abstract State MachinesAbstract State Machines• general• states• transitions• programs• concurrency/time

– agents– Mod, Self– partially ordered runs– now

ag1

ag4

ag3

ag2

Mod(agX)

View(agX,S)

S

M1

M2

M3