210 likes | 345 Views
An Executable Formal Semantics for SDL-2000. Andreas Prinz DResearch GmbH Berlin. Contents. SDL-2000 Formal Description static part dynamic part SDL-2000 Formal Implementation Conclusion. Concrete Syntax. BNF. Rewriting. PC1. Formality: Static Part. language part. formalisation.
E N D
An Executable Formal Semantics for SDL-2000 Andreas Prinz DResearch GmbH Berlin
Contents • SDL-2000 Formal Description • static part • dynamic part • SDL-2000 Formal Implementation • Conclusion
Concrete Syntax BNF Rewriting PC1 Formality: Static Part language part formalisation transformations (e.g. RPC) conditions (e.g. types) Abstract Syntax BNF
Example: Concrete Syntax state s; input a; output b,c; nextstate s; endstate; <output> ::= output <output body> <output body> ::= <signal identifier> {, <signal identifier>}*
Example: Abstract Syntax State-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
Example: Transformations If 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) ) >
Example: Conditions The <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
Example: Mapping <output>(<output body>(< id >)) => Output-node(Mapping(id))
Abstract Syntax structure behaviour data compilation initialisation structure connections primitives SDL Abstract Machine (SAM) ASM Formality: Dynamic Part data interface
Example: SAM Link_Module if 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)
Example: Initialisation Init_Agent_Module if 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
Example: Compilation l1: STATENODE( {<a, l2>}) l2: OUTPUT(b) => l3 l3: OUTPUT(c) => l4 l4: SKIP => l1
Implementation tools 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
Conclusions • 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
An Executable Formal Semantics for SDL-2000 Dr. A. Prinz DResearch GmbH Berlin
Abstract 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
Abstract State Machines state element domain function boolean function vocabulary 0-ary function 1-ary predicate function name predicate name • general • states • algebras • sets,functions • domains • reserve elements • transitions • programs • concurrency/time
Abstract State Machines Jill.Account:= 1000000 Jack.Account:= 0 Account(Jill):= 1000000 Account(Jack):= 0 • general • state • transitions • locations, updates • firing of updates • runs • programs • concurrency/time
if strike then else extend Flyer by f do forall s: Student • do-forall • choose choose s: Student focus(Self):= s • if-then-else • extend Abstract State Machines • general • states • transitions • programs • concurrency/time know(s):= know(s)+SDL
Abstract State Machines ag2 • general • states • transitions • programs • concurrency/time • agents • Mod, Self • partially ordered runs • now ag1 M1 M2 ag3 M3 ag4 Mod(agX) S View(agX,S)