Event-B specification templates for defining dynamic...

17
Event-B specification templates Ulyana Tikhonova [email protected] for defining dynamic semantics of DSLs Mark van den Brand, Tim Willemse, Tom Verhoeff, Maarten Manders

Transcript of Event-B specification templates for defining dynamic...

Page 1: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Event-B specification

templates

Ulyana Tikhonova [email protected]

for defining dynamic semantics of DSLs

Mark van den Brand, Tim Willemse, Tom Verhoeff, Maarten Manders

Page 2: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Defining dynamic semantics of programming languages

2

Semantic mapping

Semantic domain • Variables/memory • Control flow • Branching

Language concepts (statements)

• Operational semantics (SOS) • Action semantics • Denotational semantics

Page 3: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Domain-Specific Languages (DSLs)

3

Page 4: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

4

Page 5: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Defining dynamic semantics of domain specific languages

5

Semantic mapping

Semantic domain • Variables/memory • Control flow • Branching

Language concepts (statements)

• Operational semantics (SOS) • Action semantics • Denotational semantics

Page 6: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Defining dynamic semantics of domain specific languages

6

Semantic mapping

Semantic domain • Variables/memory • Control flow • Branching

Language concepts (statements)

Semantic domain

Semantic mapping

• Architecture layers • Design patterns • Synchronization

protocols

• Operational semantics (SOS) • Action semantics • Denotational semantics

Page 7: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Defining dynamic semantics of domain specific languages

7

Semantic mapping

Semantic domain • Variables/memory • Control flow • Branching

Language concepts (statements)

Semantic domain

Semantic mapping

• Architecture layers • Design patterns • Synchronization

protocols

• Simulation • Formal analysis • Visualization

Specification templates

Page 8: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

8

Page 9: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

9

Page 10: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

10

VARIABLES curr_job, curr_la, la_input, ssa_output INVARIANTS

la_input ∈ ℕ ⇸ LogicalActions ssa_output ∈ ℕ ⇸ SSActions curr_job ∈ ℙ(SSAOccurences) curr_la ∈ LogicalActions

EVENTS Initialisation

curr_la :∈ LogicalActions curr_job ≔ ∅ la_input ≔ ∅ ssa_output ≔ ∅

request_la (la, n) where la ∈ LogicalActions curr_job = ∅ n ∈ ℕ la_input ≠ ∅ ⇒ ∀ i · i ∈ dom(la_input) ⇒ n > i then curr_job ≔ dom(LALabelDef(la)) curr_la ≔ la la_input ≔ la_input ∪ { n ↦ la }

request_ssa (ssaction, occurence) where occurence ∈ curr_job occurence ↦ ssaction ∈ LALabelDef (curr_la) then curr_job ≔ curr_job \ {occurence}

execute_ssa (ssaction, n)

where ssaction ∈ SSActions n ∈ ℕ ssa_output ≠ ∅ ⇒ ∀ i · i ∈ dom(ssa_output) ⇒ n > i then ssa_output ≔ ssa_output ∪ { n ↦ ssaction }

END

Page 11: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Generic programming: reuse of code

11

static void MakeAtLeast<T>(T[] list, T lowest) where T : IComparable<T> {

for (int i = 0; i < list.Length; i++) if (list[i].CompareTo(lowest) < 0) list[i] = lowest;

}

static void Main() {

int[] array = { 0, 1, 2, 3 }; MakeAtLeast<int>(array, 2); }

Page 12: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

12

MACHINE queue_machine SEES queue_context VARIABLES queue INVARIANTS inv1: queue ∈ ℕ ⇸ ElementType EVENTS

INITIALISATION ≙ act1: queue ≔ ∅ END

enqueue≙ ANY element, index WHERE grd1: element ∈ ElementType grd2: index ↦ element ∈ queue grd3: ∀i·i ∈ dom(queue) ⇒ index ≤ i THEN act1: queue ≔ queue ∖ {index ↦ element} END

dequeue≙ ANY element, index WHERE grd1: element ∈ ElementType grd2: index ∈ ℕ grd3: queue ≠ ∅ ⇒ (∀i·i ∈ dom(queue) ⇒ index > i) grd4: {index ↦ element} ∈ ℕ ⇸ ElementType grd5: index ∉ dom(queue) THEN act2: queue ≔ queue ∪ {index ↦ element} END END

MyType

MyType

MyType

MyType

Page 13: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Aspect Oriented Programming: cross cutting concerns

13

Queue enqueue dequeue

Listener subscribe notify

Partial Order init_partial_order is_max_element remove_element

method1 subscribe init_partial_order method2 notify enqueue is_max_element method3 dequeue remove_element

Page 14: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

14

Listener Queue Partial Order method1 subscribe init_partial_order method2 notify enqueue is_max_element method3 dequeue remove_element

Specializations of specification templates from the generic library

Page 15: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

demo 15

Page 16: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

16

Meta-model

DSL model

Event-B specification templates

Event-B specification

DSL/Ecore

Event-B/Rodin

Specification templates

Constelle definition

Constelle-to-Event-B

Page 17: Event-B specification templates for defining dynamic ...wiki.event-b.org/images/Event-B_Specification_Templates_for_Definin… · Event-B specification templates . Ulyana Tikhonova

Conclusions

17

• Constelle as a front-end – Reuse of Event-B code via generic programming – Clear design via composition/mapping of aspects – Intermediate layer for bridging different

technological platforms

• Event-B as a back-end – Generic instantiation – (Shared event) composition – Library of reusable specification templates