component based semantics
play

Component-Based Semantics Peter D. Mosses Swansea University - PowerPoint PPT Presentation

Component-Based Semantics Peter D. Mosses Swansea University (emeritus) TU Delft (visitor) IFIP WG 2.2 Meeting, Bordeaux, September 2017 Component-based semantics Aims encourage language developers to use formal semantics Means


  1. Component-Based Semantics Peter D. Mosses Swansea University (emeritus) TU Delft (visitor) IFIP WG 2.2 Meeting, Bordeaux, September 2017

  2. Component-based semantics Aims ‣ encourage language developers to use formal semantics Means ‣ modularity ‣ reusable components ‣ tool support

  3. Related work ‣ Action Semantics ‣ ASM: Abstract State Machines ‣ PLT Redex / Racket Racket s docs packages download ‣ 𝕃 -framework ‣ ‣ PL AN C OMP S project, collaborators: Neil Sculthorpe Thomas van 
 Binsbergen

  4. Component-based semantics Components are fundamental constructs (‘funcons’) ‣ defined operationally, e.g.: scope ( ρ : envs , X : ) T ) : ) T ρ 1 / ρ 0 ` X ! X 0 ρ 0 ` scope ( ρ 1 , X ) ! scope ( ρ 1 , X 0 ) scope ( ρ 1 , V ) V

  5. Component-based semantics Translation of language constructs to funcons ‣ e.g. (Caml Light) : E : expr ::= · · · | value-defs in expr | · · · eval [ [ E : expr ] ] : ⇒ values · · · eval [ [ VD in E ] ] = scope ( decl [ [ VD ] ] , eval [ [ E ] ]) · · · VD : value-defs ::= · · · decl [ [ VD : value-defs ] ] : ⇒ envs · · ·

  6. Funcons: Characteristics ‣ correspond to fundamental programming concepts ‣ language- independent ‣ have fixed behaviour ‣ new ones can be added

  7. Funcons: Foundations Modular SOS (MSOS) ‣ Proc. MFCS , 1999; J.LAP , 2004 Implicitly-Modular SOS (I-MSOS) ‣ Proc. SOS , 2008 (with M.New) Value-computation specifications, bisimulation congruence format ‣ Proc. FoSSaCS , 2013 (with M.Churchill) Signatures with strictness annotations ‣ Trans. AOSD , 2015 (with M.Churchill, N.Sculthorpe, P.Torrini)

  8. Funcons: Foundations Structural operational semantics (SOS) ρ 0 ` h D, σ i ! h D 0 , σ 0 i ρ 0 ` h scope ( D, X ) , σ i ! h scope ( D 0 , X ) , σ 0 i ρ 1 / ρ 0 ` h X, σ i ! h X 0 , σ 0 i ρ 0 ` h scope ( ρ 1 , X ) , σ i ! h scope ( ρ 1 , X 0 ) , σ 0 i ρ 0 ` h scope ( ρ 1 , V ) , σ i ! h V, σ i

  9. Funcons: Foundations Implicitly-Modular SOS (I-MSOS) D ! D 0 scope ( D, X ) ! scope ( D 0 , X ) ρ 1 / ρ 0 ` X ! X 0 ρ 0 ` scope ( ρ 1 , X ) ! scope ( ρ 1 , X 0 ) scope ( ρ 1 , V ) ! V

  10. Funcons: Foundations Value-computation specifications, bisimulation congruence format D ! D 0 scope ( D, X ) ! scope ( D 0 , X ) ρ 1 / ρ 0 ` X ! X 0 ρ 0 ` scope ( ρ 1 , X ) ! scope ( ρ 1 , X 0 ) scope ( ρ 1 , V ) V

  11. Funcons: Foundations Signatures with strictness annotations scope ( ρ : envs , X : ) T ) : ) T ρ 1 / ρ 0 ` X ! X 0 ρ 0 ` scope ( ρ 1 , X ) ! scope ( ρ 1 , X 0 ) scope ( ρ 1 , V ) V

  12. Funcons: Values Universe ‣ algebraic data types: booleans, lists, tuples, … ‣ built-in types: numbers, sets, maps, types, … ‣ none : no-value – represents the lack of an ordinary value Types ‣ Boolean algebra: union, intersection, complement, S <: T

  13. Funcons: Computations Control flow ‣ sequencing, interleaving, choosing, iterating, … Data flow ‣ giving, binding, storing, interacting, generating, … ‣ throwing / handling, delimited continuations …

  14. Funcons: Abstractions Values encapsulating computations ‣ thunks, functions, procedures, methods, patterns, … ‣ open, closures ‣ forcing, applying, composing, …

  15. Funcon descriptions of programming concepts — Examples —

  16. Examples of funcon descriptions Operand evaluation order Funcon and (B 1 : booleans, B 2 : booleans) : booleans ‣ interleaved: and (B 1 , B 2 ) ‣ sequential: and ( left-to-right (B 1 , B 2 )) ‣ explicit: give (B 2 , and (B 1 , given )) ‣ conditional: if-then-else (B 1 , B 2 , false )

  17. Examples of funcon descriptions Unbounded and bounded arithmetic Funcon integer-add (N 1 : integers, N 2 : integers) : integers 
 integer-subtract (N 1 : integers, N 2 : integers) : integers 
 … Funcon short-integer (N: integers) : bounded-integers(…,…) ‣ short-integer ( integer-add (N 1 , N 2 )) 
 short-integer ( integer-subtract (N 1 , N 2 )) 
 …

  18. Examples of funcon descriptions Partial arithmetic operations Funcon integer-divide (N 1 : integers, N 2 : integers) : 
 integers|no-value Funcon definitely (V: T|no-value) : ⇒ T 
 Rule definitely (V: values) ↝ V 
 Rule definitely (none) ↝ fail ‣ integer-add (1, definitely ( integer-divide (N 1 , N 2 )))

  19. Examples of funcon descriptions Declarations compute environments Type envs ↝ maps(ids, values|no-value) Funcon bind (I: ids, V: values) : envs 
 bound (I: ids) : ⇒ values 
 scope ( ρ : envs, X: ⇒ T) : ⇒ T ‣ local declaration: scope ( bind (I, E), … bound (I)…)

  20. Examples of funcon descriptions Recursive and forward declarations Funcon recursively-bind (I: ids, E: ⇒ values) : ⇒ environments ‣ bind I to a fresh link ‣ in the scope of that binding: - bind I to the value of E - set the link to refer to the value of E

  21. Examples of funcon descriptions Abstractions with static or dynamic binding Funcon abstraction (X: ⇒ T) : abstractions(T) 
 close (A: abstractions(T)) : ⇒ abstractions(T) ‣ dynamic bindings: bind (I, abstraction (X)) ‣ static bindings: bind (I, close ( abstraction (X))) Funcon closure (X: ⇒ T) : ⇒ abstractions(T) 
 ↝ close ( abstraction (X))

  22. Examples of funcon descriptions Abstractions with a call-by-value or -name argument Funcon force (A: abstractions(T)) : ⇒ T ‣ call-by-value: … bind (I, closure (… given …))… 
 … apply ( bound (I), E)… ‣ call-by-name: … bind (I, closure (… force ( given )…))… 
 … apply ( bound (I), closure (E)))…

  23. Examples of funcon descriptions Further programming concepts ‣ patterns ‣ variables ‣ input/output ‣ handling abrupt termination ‣ delimited continuations

  24. Tool support Prototype, implemented in Spoofax and Haskell ‣ editing and parsing ‣ checking translation and transition rules ‣ navigating and browsing ‣ generating parsers and interpreters ‣ running test programs

  25. Preliminary tool support for CBS [Van Binsbergen et al: Modularity 2016]

  26. Current and future work ‣ modular static semantics for funcons - modular type soundness proofs? ‣ improved tool support ‣ adding funcons for threads and concurrency ‣ completing a major case study: C#

  27. Funcons ‣ correspond to fundamental programming concepts ‣ language- independent ‣ have fixed behaviour ‣ new funcons can be added

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend