Presentation is loading. Please wait.

Presentation is loading. Please wait.

Generic Language Technology (2IS15) Dynamic Semantics

Similar presentations


Presentation on theme: "Generic Language Technology (2IS15) Dynamic Semantics"— Presentation transcript:

1 Generic Language Technology (2IS15) Dynamic Semantics
dr. Suzana Andova

2 Dynamic Semantics Definition of a (programming) language involves:
abstract syntax, so-called signature concrete syntax: textual syntax graphical syntax semantics: static semantics dynamic semantics / Faculteit Wiskunde en Informatica

3 Dynamic Semantics Semantics represents the intended meaning of a language and language constructs Semantics is a means to represent our understanding of a model/program (what is does) and To communicate our understanding to other entities To understand what happens in a computer/machine when a program/model is executed / Faculteit Wiskunde en Informatica

4 Dynamic Semantics Not any language is suitable for description of dynamic semantics Dynamic semantics ideally is described in a formal language (formal semantics) because: ambiguities and inconsistencies can be detected in a (modeling) language which appears to be pretty “ok” this is the basis for analysis, validation and verification, but also implementation / Faculteit Wiskunde en Informatica

5 Dynamic Semantics in practice
Hardly any modeling language used in industry has formal sematics The semantics of languages is often defined by translation or interpretation Languages evolve and more ambiguities are introduced / Faculteit Wiskunde en Informatica

6 Dynamic Semantics in practice
(domain) model (DS) Language (implementation) engine / Faculteit Wiskunde en Informatica

7 Dynamic Semantics in practice
? Ambiguous representation and miscommunication different understandings of models (domain) model a c b d e start-start (DS) Language (implementation) engine how many execution sequences one can think of?  “total” representation required! / Faculteit Wiskunde en Informatica

8 Dynamic Semantics in practice
Model to implementation inconsistency - SW constructs do not use semantics, only syntax Code is manually added in the parts generated Cognitive feedback Gap between Modeling and Model/Implementation Debugging no possibility to transfer results of execution/debugging back to the original model Lack of Early Design correctness analysis (domain) model (DS) Language (implementation) engine / Faculteit Wiskunde en Informatica

9 Dynamic Semantics in practice
simulation model perform. ana. model test model transformations (DSL) model Transformation from one env to another - Semantic transformation gap - Model transformation correctness reasoning (DS) Language (implementation) engine / Faculteit Wiskunde en Informatica

10 Dynamic Semantics in practice
? (DSL) model 1 (DS) Language (implementation) engine1 simulation model perform. ana. test transformations (DSL) model 2 (DS) Language (implementation) engine2 simulation model perform. ana. test transformations Multi-disciplinary project - Semantic gap between models / Faculteit Wiskunde en Informatica

11 Describing Dynamic Semantics
(Reference) Implementation - Model/program is executed - Conclusions about the behaviour based on observations Translational - Select target language(s) - Model based in most of the cases Interpretation Formal semantics - structural operational semantics (SOS, MSOS) - denotational semantics - axiomatic - algebraic - game semantics - … (DSL) model (DS) Language (implementation) engine / Faculteit Wiskunde en Informatica

12 Describing Dynamic Semantics
(Reference) Implementation - Model/program is executed - Conclusions about the behaviour based on observations - if the code is complex (as usual) no behavioural analysis (DSL) model (DS) Language (implementation) engine / Faculteit Wiskunde en Informatica

13 Describing Dynamic Semantics
(DSL) model (DSL) Language (implementation) engine Model Target language formal semantics direct translation (properties preservation?) Translational semantics - Model based - Ad-hoc Syntactic mapping - No semantical mapping -> no ambiguities detection - No support for language evolution - Inconsistency and Properties preservation? - Traceability/reverse mapping

14 Describing Dynamic Semantics
(DSL) model (DSL) Language (implementation) engine Model Target language formal semantics direct translation Translational semantics - Ad-hoc Semantical mapping - No semantical mapping -> no ambiguities detection - No support for language evolution - Inconsistency and Properties preservation? - Traceability/reverse mapping

15 Describing Dynamic Semantics
(domain) model Target model translation for free! correct by construction! DSL formal semantics formal semantics Target language (implementation) engine engine design decision?

16 Describing Dynamic Semantics
Formal semantics structural operational semantics (SOS, MSOS) describes the execution of the program on some (very) abstract machine (G. Plotkin) Denotational semantics: mathematical definition of input/output relation of the program by induction on its syntactic structure (D. Scott, C. Strachey) Axiomatic semantics formalization of special properties of the program by logical formulae (assertions and proof rules; R. Floyd, T. Hoare) - algebraic - event structures - …. / Faculteit Wiskunde en Informatica

17 / Faculteit Wiskunde en Informatica

18 Dynamic Semantics Operational semantics: describes computation of the program on some (very) abstract machine (G. Plotkin) Denotational semantics: mathematical definition of input/output relation of the program by induction on its syntactic structure (D. Scott, C. Strachey) Axiomatic semantics: formalization of special properties of the program by logical formulae (assertions and proof rules; R. Floyd, T. Hoare) / Faculteit Wiskunde en Informatica

19 Dynamic Semantics . In practice, the design of complex software systems usually involves various types of domain specific (modeling) languages that cover different design aspects of the same system. / Faculteit Wiskunde en Informatica

20 Dynamic Semantics Integers and Strings can occur as values during
module Values signature Integer > VALUE StrCon > VALUE "nil-value" -> VALUE Integers and Strings can occur as values during execution nil-value denotes error values / Faculteit Wiskunde en Informatica

21 Dynamic Semantics Value environment Use Table again to get a mapping
module Value-environments signature Table[[PICO-ID, VALUE]] -> VENV Use Table again to get a mapping from PICO-ID to VALUE Call it VENV: this represents the Run-item values of variables (heap) / Faculteit Wiskunde en Informatica

22 Dynamic Semantics Pico-interpreter module Pico-interpreter signature
evp(PROGRAM) > VENV evd(DECLS) > VENV evits({ID-TYPE ","}*) > VENV evs({STATEMENT ";"}*, VENV) -> VENV evst(STATEMENT, VENV) > VENV eve(EXP, VENV) > VALUE / Faculteit Wiskunde en Informatica

23 Dynamic Semantics Pico-interpreter Evaluate a program
equations [Ev1] evp(program(Decls, Series)) = evs(Series, evd(Decls)) Evaluate the statements Evaluate the declarations / Faculteit Wiskunde en Informatica

24 Dynamic Semantics Pico-interpreter
[Ev2] evd(decls(Id-type*)) = evits(Id-type*) [Ev3] evits(id-type(Id:natural), Id-type*) = store(evits(Id-type*),Id,0) [Ev4] evits(id-type(Id:string), Id-type*) = store(evits(Id-type*), Id,””) [Ev5] evits() = [] / Faculteit Wiskunde en Informatica

25 Dynamic Semantics Pico-interpreter [Ev6] Venv' := evst(Stat, Venv),
Venv'' := evs(Stat*, Venv') ======================= evs(Stat ; Stat*, Venv) = Venv'' [Ev7] evs( , Venv) = Venv [Ev8] evst(assign(Id, Exp), Venv) = update(Id, eve(Exp, Venv), Venv) / Faculteit Wiskunde en Informatica

26 Dynamic Semantics Pico-interpreter [Ev9] eve(Exp, Venv) != 0
================== evst(if(Exp, Series1, Series2), Venv) = evs(Series1, Venv) [Ev10] eve(Exp, Venv) == 0 evs(Series2, Venv) / Faculteit Wiskunde en Informatica

27 Dynamic Semantics Pico-interpreter [Ev11] eve(Exp, Venv) == 0
================== evst(while(Exp, Series), Venv) = Venv [Ev12] eve(Exp, Venv) != 0, Venv' := evs(Series, Venv) ======================== evst(while(Exp, Series), Venv) = evst(while(Exp, Series), Venv') / Faculteit Wiskunde en Informatica

28 Dynamic Semantics Pico-interpreter
[Ev13] eve(Id, Venv) = lookup(Venv, Id) [Ev14] eve(Nat-con, Venv) = Nat-con [Ev15] eve(Str-con, Venv) = Str-con [Ev16] Nat1 := eve(Exp1, Venv), Nat2 := eve(Exp2, Venv) ======================= eve(plus(Exp1, Exp2), Venv) = Nat1 + Nat2 / Faculteit Wiskunde en Informatica

29 Dynamic Semantics Pico-interpreter [Ev17] Nat1 := eve(Exp1, Venv),
======================== eve(min(Exp1 , Exp2), Venv) = Nat1 - Nat2 [Ev18] Str1 := eve(Exp1, Venv), Str2 := eve(Exp2, Venv) ======================= eve(conc(Exp1, Exp2), Venv) = Str1 || Str2 [default] eve(Exp,Venv) = nil-value / Faculteit Wiskunde en Informatica

30 Dynamic Semantics Pico-interpreter reduces to The term evp( )
begin declare input : natural, output : natural, repnr: natural, rep: natural; input := 14; output := 1; while input - 1 do rep := output; repnr := input; while repnr - 1 do output := output + rep; repnr := repnr - 1 od; input := input - 1 od end reduces to The term [<input,1>, <repnr,1>, <output, >, <rep, >] / Faculteit Wiskunde en Informatica

31 Dynamic Semantics / Faculteit Wiskunde en Informatica


Download ppt "Generic Language Technology (2IS15) Dynamic Semantics"

Similar presentations


Ads by Google