Towards Type Safety of Aspect-Oriented Languages by Florian - - PowerPoint PPT Presentation

towards type safety of aspect oriented languages
SMART_READER_LITE
LIVE PREVIEW

Towards Type Safety of Aspect-Oriented Languages by Florian - - PowerPoint PPT Presentation

Software Engineering Group TU Berlin Towards Type Safety of Aspect-Oriented Languages by Florian Kammller & Matthias Vsgen Outline Introduction Featherweight Java and formalization Formalization of aspects Formalization


slide-1
SLIDE 1

Towards Type Safety

  • f

Aspect-Oriented Languages

by Florian Kammüller & Matthias Vösgen TU Berlin Software Engineering Group

slide-2
SLIDE 2

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

2

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-3
SLIDE 3

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

3

Theorem provers

How do theorem provers work?

  • Automatic or human-aided term-rewriting

What are the applications?

  • Proofs over complex structures (like prog. languages)
  • Extraction of verified programs

Theorem provers and type-safety

Project Bali: Verification of the Java specification using the prover Isabelle.

slide-4
SLIDE 4

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

4

Popular theorem provers

Isabelle Coq PVS ACL 2 HOL 4 TWELF

(...)

  • Classical logic
  • Extensive libraries
  • User friendly
  • Constructive logic
  • Few libraries
slide-5
SLIDE 5

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

5

Why did we choose Coq?

Coq is a constructive theorem prover Constructive proofs can be interpreted as algorithms (Curry-Howard Isomorphism)

  • > Coq can extract code from proofs
  • > We can extract a typechecker out of a proof for type

safety

slide-6
SLIDE 6

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

6

Definitions of type soundness

Natural language definition:

“Well Typed terms never get stuck.”

Formal definition: Progress & Preservation

Progress: Well-typed terms can be evaluated

  • r they are values.

Preservation: The evaluation of a well-typed term leads to a another well-typed term.

slide-7
SLIDE 7

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

7

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-8
SLIDE 8

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

8

Featherweight Java

“Inside every large language is a small language struggling to get out.” Java reduced to:

  • Object creation
  • Method invocation
  • Field access
  • Casting
  • Variables
slide-9
SLIDE 9

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

9

Properties of Featherweight Java

  • Inheritance is part of the language
  • Strictly formalized type system
  • Very compact
  • Quasi-functional language
  • Nominal type system
  • λ-calculus can be implemented in it
slide-10
SLIDE 10

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

10

Featherweight Java example

class Pair extends Object { Object fst; Object snd; Pair(Object fst, Object snd) { super(); this.fst = fst; this.snd = snd; } Pair setfst(Object newfst) { return new Pair(newfst, this.snd); } }

slide-11
SLIDE 11

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

11

Coq-FJ-Formalization by Stephanie Weirich

  • Nearly complete formalization of FJ in Coq
  • Type soundness proofs were made
  • Clear top-down structure

Suitable foundation for extensions

slide-12
SLIDE 12

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

12

Type-soundness in FJ

Lemma type_soundness : forall CT: classTable e:expression e':expression, class_table_typing CT // All classes well typed

  • > multi_step CT e e' // Reduction from e to e' ex.
  • > ~(exists e'', reduction CT e' e'') // No reduction from e' ex.
  • > (value e' \/ failed_cast CT e'). // e' is a value or a failed cast

Coq-Code for progress and preservation

slide-13
SLIDE 13

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

13

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-14
SLIDE 14

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

14

Formalization of AO

Aspect Advice Pointcut Advice Expression

Weaving

Class Pointcut Selection

(...)

slide-15
SLIDE 15

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

15

Aspects

Aspect

Inductive aspectDef : Set := | Aspect : aspectName -> aspectName -> list fieldDef -> methodTable ->pointcutTable -> adviceTable -> aspectDef.

Name Superaspect-Name {Fields} {Pointcuts} {Advice} {Methods}

Coq-Code:

slide-16
SLIDE 16

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

16

Pointcuts

Execution Pointcut Name {Selections}

Coq-Code:

Inductive pointcutDef: Set := | Execution : pointcutName -> pointcutSelectionList

  • > pointcutDef.
slide-17
SLIDE 17

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

17

Pointcut Selections

Pointcut Selection Classname Methodname

Coq-Code:

Inductive pointcutSelection : Set := | methodSel: className -> methodName -> pointcutSelection.

slide-18
SLIDE 18

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

18

Advice

Inductive adviceDef: Set := | aroundAdvice: pointcutName -> adviceExp -> adviceDef.

Coq-Code:

Advice Pointcutname Advice expression

slide-19
SLIDE 19

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

19

Advice Expression

Inductive adviceExp : Set := | proceed: adviceExp | adVar : varName -> adviceExp | adFieldProj : adviceExp -> fieldName -> adviceExp | adMethodInvk : adviceExp -> methodName -> list adviceExp -> adviceExp | adNew : className -> list adviceExp -> adviceExp | adCast : className -> adviceExp -> adviceExp.

Coq-Code: They are method expressions including a proceed statement

slide-20
SLIDE 20

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

20

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-21
SLIDE 21

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

21

Weaving, top-level

{Aspects} {Classes}

Weaving An aspect-Table is weaved into a class-Table Coq-Code:

Definition wv_AT_CT (CT: classTable) (AT: aspectTable) : classTable := MapCollect _ _ (fun _ asp => wv_asp_CT CT asp) AT.

slide-22
SLIDE 22

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

22

Weaving, bottom level

Advice Expression Method Expression

Weaving An advice expression is weaved into a method expression Coq-Code:

Fixpoint merge_expr (mExpr: exp) (aExpr: adviceExp) {struct aExpr}: exp := match aExpr with proceed => mExpr | adVar v => Var v | adFieldProj aExpr2 fieldN => FieldProj (merge_expr mExpr aExpr2) fieldN (...) end.

slide-23
SLIDE 23

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

23

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-24
SLIDE 24

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

24

Type soundness (1)

Axiom type_soundness_woven: forall (AT:aspectTable) (CT:classTable), class_table_typing CT

  • > asp_table_typing AT
  • > class_table_typing (wv_AT_CT CT AT).

A well typed aspect table weaves a well typed class table

Parameter asp_table_typing: aspectTable -> Prop.

Is an aspect table well typed?

slide-25
SLIDE 25

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

25

Type soundness (2)

Lemma weave_type_soundness: forall (CT0 CT: classTable)(e e': exp)(AT: aspectTable), CT = wv_AT_CT CT0 AT

  • > class_table_typing CT0
  • > asp_table_typing AT
  • > multi_step CT e e'
  • > ~(exists e'', reduction CT e' e'')
  • > (value e' \/ failed_cast CT e').

Progress and Preservation with AO:

slide-26
SLIDE 26

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

26

Outline

  • Introduction
  • Featherweight Java and formalization
  • Formalization of aspects
  • Formalization of weaving
  • AO type soundness
  • Future Work
slide-27
SLIDE 27

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

27

Future work

There is a lot to do

  • Completion of the formalization
  • Proof type soundness, confinement etc.
  • Investigate the runtime weaving problem
slide-28
SLIDE 28

Towards Type Safety of Aspect-Oriented Languages

  • F. Kammüller &M. Vösgen

28

Thanks for listening!