Larissa, an Aspect-Oriented Language for Reactive Systems PhD - - PowerPoint PPT Presentation

larissa an aspect oriented language for reactive systems
SMART_READER_LITE
LIVE PREVIEW

Larissa, an Aspect-Oriented Language for Reactive Systems PhD - - PowerPoint PPT Presentation

Larissa, an Aspect-Oriented Language for Reactive Systems PhD Defense David Stauch Verimag/Grenoble INP November 13th, 2007 Jury Roland Groz Shmuel Katz Mario Sdholt Pascal Fradet Florence Maraninchi Karine Altisen 2/36 Introduction


slide-1
SLIDE 1

Larissa, an Aspect-Oriented Language for Reactive Systems

PhD Defense David Stauch

Verimag/Grenoble INP

November 13th, 2007

Jury

Roland Groz Shmuel Katz Mario Südholt Pascal Fradet Florence Maraninchi Karine Altisen

slide-2
SLIDE 2

Introduction Larissa Formal Analysis Tools Conclusion

2/36

Outline

1

Introduction Aspect-Oriented Programming Reactive Systems and Synchronous Languages AOP for Reactive Systems

2

Larissa

3

Formal Analysis Tools

4

Conclusion and Further Work

slide-3
SLIDE 3

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Example: figure editor

slide-4
SLIDE 4

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Example: figure editor Program: modules implement concerns

slide-5
SLIDE 5

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display

slide-6
SLIDE 6

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display

slide-7
SLIDE 7

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display

slide-8
SLIDE 8

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display Solution: Add update() to methods Bad: scattered code

slide-9
SLIDE 9

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Aspect

display.update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display Solution: Add update() to methods Bad: scattered code Idea: put crosscutting code in aspect

slide-10
SLIDE 10

Introduction Larissa Formal Analysis Tools Conclusion

3/36

Aspect-Oriented Programming

Line Point

setX(int) setY(int) setP2(Point) setP1(Point)

Display

update()

Aspect

display.update()

Example: figure editor Program: modules implement concerns Crosscutting concerns: cannot be put in own module Example: update display Solution: Add update() to methods Bad: scattered code Idea: put crosscutting code in aspect Weave aspect in program

slide-11
SLIDE 11

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2)

slide-12
SLIDE 12

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ }

slide-13
SLIDE 13

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); }

slide-14
SLIDE 14

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); }

slide-15
SLIDE 15

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2) update() update()

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); after() : stateChanged() { display.update(); } }

slide-16
SLIDE 16

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2) update() update() setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); after() : stateChanged() { display.update(); } }

slide-17
SLIDE 17

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2) update() update() setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); after() : stateChanged() && !cflowbelow(stateChanged()){ display.update(); } }

slide-18
SLIDE 18

Introduction Larissa Formal Analysis Tools Conclusion

4/36

Example in Java and AspectJ

setY(int) setX(int) setP1(Point) setP2(Point)

Point Line

setP1(P) setX(2) update() update() setX(2)

AOP: Key Concepts

Join points: where aspects intervene Pointcut: select join points Advice: what aspect does aspect updateDisplay{ pointcut stateChanged() : || call(void Point.set*(..)) || call(void Line.set*(..)); after() : stateChanged() && !cflowbelow(stateChanged()){ display.update(); } }

Conclusion on AspectJ

Based on lexical elements Powerful constructs

slide-19
SLIDE 19

Introduction Larissa Formal Analysis Tools Conclusion

5/36

Reactive Systems and Synchronous Languages

Constant interaction with environment

slide-20
SLIDE 20

Introduction Larissa Formal Analysis Tools Conclusion

5/36

Reactive Systems and Synchronous Languages

Constant interaction with environment Receive inputs, emit outputs Often safety critical, need for formal semantics and verification

Reactive Systems Environment

  • utputs

inputs

slide-21
SLIDE 21

Introduction Larissa Formal Analysis Tools Conclusion

5/36

Reactive Systems and Synchronous Languages

Constant interaction with environment Receive inputs, emit outputs Often safety critical, need for formal semantics and verification Synchronous languages: simple semantics, discrete time

Reactive Systems Environment

  • utputs

inputs

slide-22
SLIDE 22

Introduction Larissa Formal Analysis Tools Conclusion

6/36

A Wristwatch – A Reactive System

Wristwatch with four buttons Two Models

Altimax: watch, altimeter, barometer Vector: Altimax + compass mode select minus plus

slide-23
SLIDE 23

Introduction Larissa Formal Analysis Tools Conclusion

6/36

A Wristwatch – A Reactive System

Wristwatch with four buttons Two Models

Altimax: watch, altimeter, barometer Vector: Altimax + compass

We model interface component

Interface

Display Memory

Inputs: buttons Outputs: signals to

  • ther components

mode select minus plus

slide-24
SLIDE 24

Introduction Larissa Formal Analysis Tools Conclusion

7/36

The Altimax Interface

Logbook Memory Barometer Altimeter Time Time Baro Alti Alti Baro Time mode/ mode/ mode/ mode/ mode/ mode mode mode select mode/ select mode mode select

slide-25
SLIDE 25

Introduction Larissa Formal Analysis Tools Conclusion

8/36

Argos, a Synchronous Language

Base element: Mealy automata Arrange modules in parallel Modules communicate with local signals

Time, Alti, Baro,... Memory Display

mode select mode mode select select mode mode/ mode/ mode/ mode/ mode/ Time mode/ Time Alti Baro Alti Baro mode

slide-26
SLIDE 26

Introduction Larissa Formal Analysis Tools Conclusion

9/36

Crosscutting Concern 1: Shortcut

Crosscutting concerns also in reactive systems?

slide-27
SLIDE 27

Introduction Larissa Formal Analysis Tools Conclusion

9/36

Crosscutting Concern 1: Shortcut

Crosscutting concerns also in reactive systems? Example from watch: minus button not used in main modes Use it to jump directly to Logbook mode

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select Memory Display

slide-28
SLIDE 28

Introduction Larissa Formal Analysis Tools Conclusion

9/36

Crosscutting Concern 1: Shortcut

Crosscutting concerns also in reactive systems? Example from watch: minus button not used in main modes Use it to jump directly to Logbook mode

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select Memory Display minus/Logbook minus/Logbook

slide-29
SLIDE 29

Introduction Larissa Formal Analysis Tools Conclusion

10/36

Crosscutting Concern 2: Compass Mode

Vector model has compass mode Add Compass mode to Altimax base program

Compass select mode mode/Compass

mode/... mode/... Time . . . Altimeter . . . Barometer . . .

Display Memory

mode/..

slide-30
SLIDE 30

Introduction Larissa Formal Analysis Tools Conclusion

10/36

Crosscutting Concern 2: Compass Mode

Compass mode/

Vector model has compass mode Add Compass mode to Altimax base program

Compass select mode mode/Compass

mode/... mode/... Time . . . Altimeter . . . Barometer . . .

Display Memory

slide-31
SLIDE 31

Introduction Larissa Formal Analysis Tools Conclusion

10/36

Crosscutting Concern 2: Compass Mode

Compass mode/ mode/Time

Vector model has compass mode Add Compass mode to Altimax base program

Compass select mode mode/Compass

mode/... mode/... Time . . . Altimeter . . . Barometer . . .

Display Memory

slide-32
SLIDE 32

Introduction Larissa Formal Analysis Tools Conclusion

11/36

Larissa: Aspects for Argos

Goal: aspect language for synchronous languages Argos adequate base language

simple synchronous language expressive, characterizing constructs

Must express cross-cutting concerns Same concepts as other aspect languages: join points, pointcuts, advice

slide-33
SLIDE 33

Introduction Larissa Formal Analysis Tools Conclusion

12/36

Outline

1

Introduction

2

Larissa Context and Requirements The Language Example

3

Formal Analysis Tools

4

Conclusion and Further Work

slide-34
SLIDE 34

Introduction Larissa Formal Analysis Tools Conclusion

13/36

Argos Operators

Base elements: boolean signals, complete and deterministic Mealy automata

a a/mod2 A

A

slide-35
SLIDE 35

Introduction Larissa Formal Analysis Tools Conclusion

13/36

Argos Operators

Base elements: boolean signals, complete and deterministic Mealy automata Main operators: parallel product, local signals

a a/mod2 A mod2 mod2/mod4 mod2 B

(AB) \ {mod2}

slide-36
SLIDE 36

Introduction Larissa Formal Analysis Tools Conclusion

13/36

Argos Operators

Base elements: boolean signals, complete and deterministic Mealy automata Main operators: parallel product, local signals Semantics: compilation into flat automata

a a/mod2 A mod2 mod2/mod4 mod2 B a/mod4 a a a

(AB) \ {mod2}

slide-37
SLIDE 37

Introduction Larissa Formal Analysis Tools Conclusion

14/36

Encapsulation

Argos programs form expressions, e.g. ((AB) \ {a}) C A, B and C automata or Argos expressions

a B C

a/b a/b

A

slide-38
SLIDE 38

Introduction Larissa Formal Analysis Tools Conclusion

14/36

Encapsulation

Argos programs form expressions, e.g. ((AB) \ {a}) C A, B and C automata or Argos expressions Interface: inputs, outputs I O

a B C

a/b a/b

A

slide-39
SLIDE 39

Introduction Larissa Formal Analysis Tools Conclusion

14/36

Encapsulation

Argos programs form expressions, e.g. ((AB) \ {a}) C A, B and C automata or Argos expressions Interface: inputs, outputs Strong encapsulation: component structure invisible from outside I O

a/b a/b

a A B C

slide-40
SLIDE 40

Introduction Larissa Formal Analysis Tools Conclusion

14/36

Encapsulation

Argos programs form expressions, e.g. ((AB) \ {a}) C A, B and C automata or Argos expressions Interface: inputs, outputs Strong encapsulation: component structure invisible from outside Operators preserve i/o-trace equivalence (∼): if A′ ∼ A, then ((A′B) \ {a})C ∼ ((AB) \ {a})C I O

a B C

a/b a/b

A

slide-41
SLIDE 41

Introduction Larissa Formal Analysis Tools Conclusion

14/36

Encapsulation

Argos programs form expressions, e.g. ((AB) \ {a}) C A, B and C automata or Argos expressions Interface: inputs, outputs Strong encapsulation: component structure invisible from outside Operators preserve i/o-trace equivalence (∼): if A′ ∼ A, then ((A′B) \ {a})C ∼ ((AB) \ {a})C I O

a B C

a/b

A′

slide-42
SLIDE 42

Introduction Larissa Formal Analysis Tools Conclusion

15/36

Requirements: Aspects for Argos

Express cross-cutting concerns

crosscut structure of Argos expressions parallel composition can express some aspects for sequential languages

slide-43
SLIDE 43

Introduction Larissa Formal Analysis Tools Conclusion

15/36

Requirements: Aspects for Argos

Express cross-cutting concerns

crosscut structure of Argos expressions parallel composition can express some aspects for sequential languages

Integrate well into Argos

define as translation into automaton simple, formal semantics respect encapsulation, as other Argos operators

usually not respected by aspect languages

slide-44
SLIDE 44

Introduction Larissa Formal Analysis Tools Conclusion

16/36

Related Work

Aspects and Parallelism

Concurrent aspects [Douence et al, GPCE06]:

asynchronous base program, asynchronous execution

  • f advice
slide-45
SLIDE 45

Introduction Larissa Formal Analysis Tools Conclusion

16/36

Related Work

Aspects and Parallelism

Concurrent aspects [Douence et al, GPCE06]:

asynchronous base program, asynchronous execution

  • f advice

Formal Properties

Many formalisations of aspect languages Aspects preserving the encapsulation:

Composition Filters [Bergmans, Aksit]: intercept and modify messages between components Open Modules [Aldrich, ECOOP06]: add additional information to interface

slide-46
SLIDE 46

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton

slide-47
SLIDE 47

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Aspect

slide-48
SLIDE 48

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions

change target state and outputs

Aspect

slide-49
SLIDE 49

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions

change target state and outputs

Aspect

slide-50
SLIDE 50

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions

change target state and outputs

Challenge: respect encapsulation Aspect I O

slide-51
SLIDE 51

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions

change target state and outputs

Challenge: respect encapsulation Aspect I O

slide-52
SLIDE 52

Introduction Larissa Formal Analysis Tools Conclusion

17/36

Larissa

Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions

change target state and outputs

Challenge: respect encapsulation

aspect must only refer to interface

Aspect I O

slide-53
SLIDE 53

Introduction Larissa Formal Analysis Tools Conclusion

18/36

Pointcuts

Must select transitions I O

a b b

slide-54
SLIDE 54

Introduction Larissa Formal Analysis Tools Conclusion

18/36

Pointcuts

Must select transitions Solution: observer automaton

inputs: inputs and outputs

  • f observed program
  • ne output JP

I O

a b

Pointcut

a b b/JP

slide-55
SLIDE 55

Introduction Larissa Formal Analysis Tools Conclusion

18/36

Pointcuts

Must select transitions Solution: observer automaton

inputs: inputs and outputs

  • f observed program
  • ne output JP

Pointcut emits JP ⇒ transition in program selected I O

a b

Pointcut

a b b/JP

slide-56
SLIDE 56

Introduction Larissa Formal Analysis Tools Conclusion

18/36

Pointcuts

Must select transitions Solution: observer automaton

inputs: inputs and outputs

  • f observed program
  • ne output JP

Pointcut emits JP ⇒ transition in program selected I O

a b

Pointcut

a

JP

b b/JP

slide-57
SLIDE 57

Introduction Larissa Formal Analysis Tools Conclusion

18/36

Pointcuts

Must select transitions Solution: observer automaton

inputs: inputs and outputs

  • f observed program
  • ne output JP

Pointcut emits JP ⇒ transition in program selected Transitions identified statically by parallel product I O

a b

Pointcut

a

JP

b b/JP

slide-58
SLIDE 58

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Aspect I O

slide-59
SLIDE 59

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Solution: execute finite input trace

automaton deterministic, thus always identifies one state

b

O I

trace

Aspect

a a. b b

slide-60
SLIDE 60

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Solution: execute finite input trace

automaton deterministic, thus always identifies one state

b

O I

trace

Aspect

a a.

b b

slide-61
SLIDE 61

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Solution: execute finite input trace

automaton deterministic, thus always identifies one state

b

O I

trace

Aspect

a a. b b

slide-62
SLIDE 62

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Solution: execute finite input trace

automaton deterministic, thus always identifies one state

b

O I

trace

Aspect

a a. b b

slide-63
SLIDE 63

Introduction Larissa Formal Analysis Tools Conclusion

19/36

Advice

Difficulty: specify one new target state Solution: execute finite input trace

automaton deterministic, thus always identifies one state

Two kinds:

toInit advice: execute trace from initial state toCurrent advice: execute trace from source state of transition

b

O I

trace

Aspect

a a. b b

slide-64
SLIDE 64

Introduction Larissa Formal Analysis Tools Conclusion

20/36

Example: Logbook Shortcut Aspect LB

Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook

Logbook Memory Barometer Altimeter Time mode select select mode mode/ mode/ mode/ mode/ Time mode/ Time Baro Alti Baro mode Alti mode/ select mode mode

altimax

slide-65
SLIDE 65

Introduction Larissa Formal Analysis Tools Conclusion

20/36

Example: Logbook Shortcut Aspect LB

Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook

main sub minus/JP Time∨ Alti∨ Baro select

pointcut of LB

Logbook Memory Barometer Altimeter Time mode select select mode mode/ mode/ mode/ mode/ Time mode/ Time Baro Alti Baro mode Alti mode/ select mode mode .../JP .../JP .../JP .../JP .../JP .../JP minus∧mode/JP,Time

altimax

slide-66
SLIDE 66

Introduction Larissa Formal Analysis Tools Conclusion

20/36

Example: Logbook Shortcut Aspect LB

Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook

main sub minus/JP Time∨ Alti∨ Baro select

pointcut of LB

Logbook Memory Barometer Altimeter Time mode select select mode mode/ mode/ mode/ mode/ Time mode/ Time Baro Alti Baro mode .../JP .../JP .../JP .../JP .../JP .../JP minus∧mode/JP,Time

mode mode select mode

altimax

slide-67
SLIDE 67

Introduction Larissa Formal Analysis Tools Conclusion

20/36

Example: Logbook Shortcut Aspect LB

Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook

main sub minus/JP Time∨ Alti∨ Baro select

pointcut of LB

Logbook Memory Barometer Altimeter Time mode select select mode mode/ mode/ mode/ mode/ Time mode/ Time Baro Alti Baro mode

mode mode select mode

minus/Logbook minus/Logbook

altimax⊳LB

slide-68
SLIDE 68

Introduction Larissa Formal Analysis Tools Conclusion

21/36

Advice Program

Advice insufficient for Compass Concern Replace transition by advice program Advice program has terminating state: represents return to base program

mainMode mode Compass select mode/ mode

advice program

mode/... mode/... Time . . . Altimeter . . . Barometer . . . mode/..

slide-69
SLIDE 69

Introduction Larissa Formal Analysis Tools Conclusion

21/36

Advice Program

Advice insufficient for Compass Concern Replace transition by advice program Advice program has terminating state: represents return to base program

mainMode mode Compass select mode/ mode

advice program

mode/... mode/... Time . . . Altimeter . . . Barometer . . . mode/... Compass . . . mode/..

altimax ⊳compass

slide-70
SLIDE 70

Introduction Larissa Formal Analysis Tools Conclusion

22/36

Recovery Advice and Compiler

Recovery advice

“Jumping backward” Identify set of recovery states Jump to last recovery state that was passed

slide-71
SLIDE 71

Introduction Larissa Formal Analysis Tools Conclusion

22/36

Recovery Advice and Compiler

Recovery advice

“Jumping backward” Identify set of recovery states Jump to last recovery state that was passed

Compiler for Argos and Larissa

All language variants implemented Experimentation with many examples Written in Java, AspectJ, BDD library Available at

http://www-verimag.imag.fr/∼stauch/ArgosCompiler/

slide-72
SLIDE 72

Introduction Larissa Formal Analysis Tools Conclusion

23/36

Outline

1

Introduction

2

Larissa

3

Formal Analysis Tools Aspect Interference Aspects and Contracts

4

Conclusion and Further Work

slide-73
SLIDE 73

Introduction Larissa Formal Analysis Tools Conclusion

24/36

Formal Analysis Tools

Larissa: small language, formally defined, with simple semantics Well adapted to study formal properties

  • f aspect languages

We studied two such properties:

interaction of several aspects combination of Larissa with contracts

slide-74
SLIDE 74

Introduction Larissa Formal Analysis Tools Conclusion

25/36

Aspect Interaction

Aspect Interaction

Do several aspects influence each other? When is P⊳A1⊳A2 ∼ P⊳A2⊳A1?

slide-75
SLIDE 75

Introduction Larissa Formal Analysis Tools Conclusion

25/36

Aspect Interaction

Aspect Interaction

Do several aspects influence each other? When is P⊳A1⊳A2 ∼ P⊳A2⊳A1?

Example: Second Shortcut Aspect M

Also use plus button as shortcut in the main modes Pressing plus goes to the Memory mode

select sub main Time∨ Alti∨ Baro plus/JPm Pointcut of M

slide-76
SLIDE 76

Introduction Larissa Formal Analysis Tools Conclusion

26/36

Weaving the Second Shortcut Aspect

Weave M into altimax⊳LB

select sub main Time∨ Alti∨ Baro plus/JPm Pointcut of M Logbook Time

... ...

Alti mode/ minus/... altimax⊳LB

slide-77
SLIDE 77

Introduction Larissa Formal Analysis Tools Conclusion

26/36

Weaving the Second Shortcut Aspect

Weave M into altimax⊳LB When pressing minus in main mode:

altimax⊳LB goes to submode pointcut stays in main mode select sub main Time∨ Alti∨ Baro plus/JPm Pointcut of M Logbook Time

... ...

Alti mode/ minus/... altimax⊳LB

slide-78
SLIDE 78

Introduction Larissa Formal Analysis Tools Conclusion

26/36

Weaving the Second Shortcut Aspect

Weave M into altimax⊳LB When pressing minus in main mode:

altimax⊳LB goes to submode pointcut stays in main mode select sub main Time∨ Alti∨ Baro plus/JPm Pointcut of M Logbook Time

... ...

Alti mode/ minus/... altimax⊳LB

slide-79
SLIDE 79

Introduction Larissa Formal Analysis Tools Conclusion

26/36

Weaving the Second Shortcut Aspect

Weave M into altimax⊳LB When pressing minus in main mode:

altimax⊳LB goes to submode pointcut stays in main mode

Error: Advice transitions added to Logbook mode

select sub main Time∨ Alti∨ Baro plus/JPm Pointcut of M Logbook Time

... ...

Alti mode/ minus/... plus/Memory altimax⊳LB⊳M

slide-80
SLIDE 80

Introduction Larissa Formal Analysis Tools Conclusion

27/36

Joint Weaving

Problem: aspect M written for altimax, not for altimax⊳LB Idea: weave aspects jointly into the program

slide-81
SLIDE 81

Introduction Larissa Formal Analysis Tools Conclusion

27/36

Joint Weaving

Problem: aspect M written for altimax, not for altimax⊳LB Idea: weave aspects jointly into the program Select join points for all aspects first, then apply advice

Joint Weaving: altimax⊳(LB,M)

1

apply pointcuts and determine join point transitions

2

sequentially apply advice

slide-82
SLIDE 82

Introduction Larissa Formal Analysis Tools Conclusion

28/36

Application to the Example: altimax⊳(LB,M)

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select

slide-83
SLIDE 83

Introduction Larissa Formal Analysis Tools Conclusion

28/36

Application to the Example: altimax⊳(LB,M)

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select .../JP .../JP .../JP .../JP .../JP .../JP minus∧mode/JP,Time .../JPm .../JPm .../JPm

slide-84
SLIDE 84

Introduction Larissa Formal Analysis Tools Conclusion

28/36

Application to the Example: altimax⊳(LB,M)

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select .../JP .../JP .../JP .../JP .../JP .../JP minus∧mode/JP,Time plus/Memory plus/Memory

slide-85
SLIDE 85

Introduction Larissa Formal Analysis Tools Conclusion

28/36

Application to the Example: altimax⊳(LB,M)

Logbook Memory Barometer Altimeter Time mode mode select mode/ Time mode mode mode/ Alti mode/ Time mode/ Baro mode/Alti mode select mode/ Baro select plus/Memory plus/Memory minus/Logbook minus/Logbook

slide-86
SLIDE 86

Introduction Larissa Formal Analysis Tools Conclusion

29/36

Proving Non-Interference

Is altimax⊳(LB,M)∼ altimax⊳(M,LB)?

slide-87
SLIDE 87

Introduction Larissa Formal Analysis Tools Conclusion

29/36

Proving Non-Interference

Is altimax⊳(LB,M)∼ altimax⊳(M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions

slide-88
SLIDE 88

Introduction Larissa Formal Analysis Tools Conclusion

29/36

Proving Non-Interference

Is altimax⊳(LB,M)∼ altimax⊳(M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions

Theorem for Jointly-Woven Aspects

Noninterference of two aspects, for any base program:

if no transition selected by both aspects in product of pointcuts

slide-89
SLIDE 89

Introduction Larissa Formal Analysis Tools Conclusion

29/36

Proving Non-Interference

Is altimax⊳(LB,M)∼ altimax⊳(M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions

Theorem for Jointly-Woven Aspects

Noninterference of two aspects, for any base program:

if no transition selected by both aspects in product of pointcuts

Noninterference of two aspects, for given base program P:

if no transition selected by both aspects in product of pointcuts and P

slide-90
SLIDE 90

Introduction Larissa Formal Analysis Tools Conclusion

30/36

Design-by-Contract

Originally introduced by Bertrand Meyer for object-oriented programming Contract: assumption A ⇒ guarantee G

slide-91
SLIDE 91

Introduction Larissa Formal Analysis Tools Conclusion

30/36

Design-by-Contract

Originally introduced by Bertrand Meyer for object-oriented programming Contract: assumption A ⇒ guarantee G Example (in Java): class C{ /∗ @ assume i < 10 ∗/ /∗ @ guarantee \result < 10 ∗/ int m(int i ) { . . . } }

slide-92
SLIDE 92

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 9 m(9) result<10 i<10

slide-93
SLIDE 93

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } 9 m(9) result<10 i<10

slide-94
SLIDE 94

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } 9 m(9) result<10 i<10

slide-95
SLIDE 95

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated 9 m(10) m(9) result<10 i<10

slide-96
SLIDE 96

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated, G violated 9 m(10) 10 m(9) result<10 i<10

slide-97
SLIDE 97

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: /∗ @ assume i < 10 ∗/ /∗ @ guarantee \result < 10 ∗/ 9 m(10) 10 m(9) result<10 i<10

slide-98
SLIDE 98

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: /∗ @ assume i < 9 ∗/ /∗ @ guarantee \result < 10 ∗/ 9 m(9) 10 m(8) result<10 i<10 i<9

slide-99
SLIDE 99

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: /∗ @ assume i < 9 ∗/ /∗ @ guarantee \result < 11 ∗/ 9 m(9) 10 m(8) result<10 result<11 i<10 i<9

slide-100
SLIDE 100

Introduction Larissa Formal Analysis Tools Conclusion

31/36

Aspects Modify Contracts

Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: /∗ @ assume i < 9 ∗/ /∗ @ guarantee \result < 11 ∗/ Idea: derive new contracts automatically 9 m(9) 10 m(8) result<10 result<11 i<10 i<9

slide-101
SLIDE 101

Introduction Larissa Formal Analysis Tools Conclusion

32/36

Contracts for Reactive Systems

Assumption constrains inputs Guarantee constrains outputs Example with input a and output b:

Assumption: a always occurs in pairs Guarantee: a is immediately followed by b

slide-102
SLIDE 102

Introduction Larissa Formal Analysis Tools Conclusion

32/36

Contracts for Reactive Systems

Assumption constrains inputs Guarantee constrains outputs Example with input a and output b:

Assumption: a always occurs in pairs Guarantee: a is immediately followed by b

Observers can express such properties Inputs are accepted until output err is emitted

E a a Assumption true/err a/err E b Guarantee a b/err true/err

slide-103
SLIDE 103

Introduction Larissa Formal Analysis Tools Conclusion

33/36

Generating New Contracts

Goal: apply asp to (A, G), and obtain (A′, G′), such that P | = (A, G) ⇒ P⊳asp | = (A′, G′) Idea: Simulate the effect of the aspect on the program as far as possible on A and G Done for Argos and Larissa aspects Advantages of the approach:

determine effect of the aspect on program before it is written allows modular verification

slide-104
SLIDE 104

Introduction Larissa Formal Analysis Tools Conclusion

34/36

Outline

1

Introduction

2

Larissa

3

Formal Analysis Tools

4

Conclusion and Further Work Contributions Further Work

slide-105
SLIDE 105

Introduction Larissa Formal Analysis Tools Conclusion

35/36

Contributions

Contributions:

Identification of cross-cutting concerns in reactive systems Larissa, an aspect language for Argos

formal definition and properties, preservation of equivalence developed many examples and case studies

Formal analysis tools for Larissa

Non-Interference Combination with Design-by-Contract

Compiler for Larissa

implements all language variants handles large programs

slide-106
SLIDE 106

Introduction Larissa Formal Analysis Tools Conclusion

36/36

Further Work

Extension with variables

possible to respect encapsulation

Extension to other synchronous languages Non-functional concerns in reactive contexts

Modeling of systems-on-a-chip Modeling of sensor networks b a/i:=1 int i := 0 a.i>0

slide-107
SLIDE 107

Appendix

37/36

Outline

5

Appendix More on Further Work More on Contract Weaving More on Interference More on Recovery Advice

slide-108
SLIDE 108

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

b a/i:=1 int i := 0 a.i>0

slide-109
SLIDE 109

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

b a/i:=1 int i := 0 a.i>0 a.i≤1

slide-110
SLIDE 110

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

aspect must not change them directly pointcut, advice program cannot use them, but can have their own trace execution must set them b a/i:=1 int i := 0 a.i>0 a.i≤1

slide-111
SLIDE 111

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

aspect must not change them directly pointcut, advice program cannot use them, but can have their own trace execution must set them b a/i:=1 int i := 1 a.i>0 Trace a.a a.i≤1

slide-112
SLIDE 112

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

aspect must not change them directly pointcut, advice program cannot use them, but can have their own trace execution must set them b a/i:=1 int i := 1 a.i>0 Trace a.a a.i≤1

slide-113
SLIDE 113

Appendix

38/36

Extension with Variables

Difficulty: respect encapsulation Internal integer variables: part of implementation

aspect must not change them directly pointcut, advice program cannot use them, but can have their own trace execution must set them

Integer In/Outputs:

Aspect can modify outputs only if program cannot read them i.e., o:=o+1 impossible b a/i:=1 int i := 1 a.i>0 Trace a.a a.i≤1

slide-114
SLIDE 114

Appendix

39/36

Aspect Languages for Other Synchronous Languages

Synchronous languages have different styles:

Argos, Esterel: Imperative base + parallel composition Lustre: purely parallel

Adapt Larissa to other languages?

Pointcut: powerful, semantic, built-in everywhere Advice: similar for Esterel (but trace automata specific) Lustre: something different needed

slide-115
SLIDE 115

Appendix

40/36

Non-Functional Properties in Reactive Contexts

Modeling and simulation of reactive systems Start by abstract functional model, add non-functional properties Non-functional properties often cross-cutting Identified two areas

Systems-on-a-chip: add timing information Investigated in Quentin Meuniers Master’s Thesis Wireless sensor networks: energy consumption

slide-116
SLIDE 116

Appendix

41/36

Contract Weaving — Technical Overview

Problem: aspects cannot be applied directly to observer automata

slide-117
SLIDE 117

Appendix

41/36

Contract Weaving — Technical Overview

Problem: aspects cannot be applied directly to observer automata Solution:

Transform observers into generator automata nd Apply aspect to generators Transform woven generators back to observers obs Different for assumption and guarantee:

A′ = obsA(ndA(A)⊳asp) G′ = obsG(ndG(G)⊳asp)

Then, P | = (A, G) ⇒ P⊳asp | = (A′, G′)

slide-118
SLIDE 118

Appendix

42/36

Example – Guarantee Weaving

Example aspect: advice

  • utput b, trace a

a.b/JP Pointcut

E b Guarantee a b/err true/err

slide-119
SLIDE 119

Appendix

42/36

Example – Guarantee Weaving

Example aspect: advice

  • utput b, trace a

a.b/JP Pointcut

E b Guarantee a b/err true/err true/b ndG(Guarantee) a, a/b a/b, a

slide-120
SLIDE 120

Appendix

42/36

Example – Guarantee Weaving

Example aspect: advice

  • utput b, trace a

a.b/JP Pointcut

E b Guarantee a b/err true/err true/b ndG(Guarantee) a, a/b a/b, a a/b a/b a, ndG(Guarantee)⊳asp a/b a/b, a

slide-121
SLIDE 121

Appendix

42/36

Example – Guarantee Weaving

Example aspect: advice

  • utput b, trace a

a.b/JP Pointcut

E b Guarantee a b/err true/err true/b ndG(Guarantee) a, a/b a/b, a a/b a/b a, ndG(Guarantee)⊳asp a/b a/b, a a a a.b E b/err a.b

  • bsG(ndG(Guarantee)⊳asp)

true/err

slide-122
SLIDE 122

Appendix

43/36

Interference: Shortcut Aspects

Use first method: calculate product of two pointcuts

minus∧ plus/JPl select sub main Time∨ Alti∨ Baro minus∧plus/JPm minus∧plus/JPl,JPm

slide-123
SLIDE 123

Appendix

43/36

Interference: Shortcut Aspects

Use first method: calculate product of two pointcuts

minus∧ plus/JPl select sub main Time∨ Alti∨ Baro minus∧plus/JPm minus∧plus/JPl,JPm

Aspects interfere when both buttons are pressed at the same time in a main mode Product tells us exactly where aspects may interfere

slide-124
SLIDE 124

Appendix

44/36

Recovery Advice

toInit advice: jumping to a fixed location toCurrent advice: jumping forward Missing: jumping backwards Specification with trace impossible: automaton not deterministic Different solution:

specify recovery states in base program target state of advice transition: the last recovery state passed

slide-125
SLIDE 125

Appendix

45/36

Example

Example: R1, R2 recovery states (selected by an observer) Return to recovery state that was passed last R1 R2

a a a a a/JP

slide-126
SLIDE 126

Appendix

45/36

Example

Example: R1, R2 recovery states (selected by an observer) Return to recovery state that was passed last R1 R2

a a a a a.R2 a.R1

slide-127
SLIDE 127

Appendix

45/36

Example

Example: R1, R2 recovery states (selected by an observer) Return to recovery state that was passed last R1 R2

a a a a a.R2 a.R1

Signals R1 and R2 decide which transition is taken Must be emitted by an Memory Automaton, run in parallel, which remembers which recovery state was passed last