Top Banner
ASP fun : a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik und Theoretische Informatik Synchrony and Asynchrony in Distributed Systems Braunschweig, tubs.CITY, Haus der Wissenschaft 1. Juli 2009
58

ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Jun 16, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun: a Deadlock-free Calculus forDistributed Active Objects

Florian Kammüller

Institut für Softwaretechnik und Theoretische Informatik

Synchrony and Asynchrony in Distributed SystemsBraunschweig, tubs.CITY, Haus der Wissenschaft

1. Juli 2009

Page 2: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Motivation and goals

• New language ASPfun• functional• active objects• distributed• plus typing

• Formal, mechanically supported language development• “Killer-Application” of theorem proving in Higher Order

Logic (HOL)• Java (with JVM) completely formalized in Isabelle/HOL

(Tobias Nipkow, TU München)• Complete re-engineering of a C-Compiler in Coq (Xavier

Leroy, INRIA Roquencourt)

=⇒ ASPfun in Isabelle/HOL

2

Page 3: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Overview

1 ASPfun

2 ASPfun in Isabelle/HOL

3 Example for ASPfun

4 Results, Discussion, Outlook

3

Page 4: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun– Asynchronous Sequential Processes –functional

• ProActive (Inria/ActiveEON): Java API for active objects

• New calculus ASPfun for ProActive

• Functional better properties: many applications can beseen as functions, for example web-services

• Asynchronous communication with futures• Futures : asynchronous method calls• Objects: ς-calculus of Abadi/Cardelli• Future access may cause deadlock: wait-by-necessity• Functional: reply with partially evaluated requests

⇒ ASPfun avoids deadlocks when accessing futures

4

Page 5: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun

ASPfun: at a glance

5

Page 6: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun

ASPfun: at a glance

5

Page 7: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun

ASPfun: at a glance

5

Page 8: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

From ς-calculus to ASPfun

Syntactic extension ofς-calculus by:

• Active: creation of a newactive object

• FutRef and ActRef:references for activitiesand futures (transparent)

• Semantics: local→ς and parallel evaluation

• Parallel semantics→‖: inductive relation on configurations

configuration = ActRef⇀(FutRef⇀term)× term

6

Page 9: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Parallel semantics→‖ informally

idea: evaluate terms (only) in future-lists

• LOCAL: reduction→ς of ς-calculus

• REQUEST: method call β.l creates new future fk infuture-list of activity β

• REPLY: return result, i.e. replace future fk by referencedresult term

REPLY

β[fk 7→ s ::R, t ′] ∈ α[fi 7→ E [fk ] ::Q, t ] :: C

α[fi 7→ E [fk ] ::Q, t ] :: C →‖ α[fi 7→ E [s] ::Q, t ] :: C

• UPDATE-AO: update activity, creates a copy on whichupdate (change) - original remains the same (immutable)

7

Page 10: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Overview

1 ASPfun

2 ASPfun in Isabelle/HOL

3 Example for ASPfun

4 Results, Discussion, Outlook

8

Page 11: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Language development in Isabelle/HOL

• Isabelle/HOL: interactivetheorem prover for HOL

• Enables formalization ofsyntax, semantics, and typesystems of languages

• Proofs of language properties

• Example property: typing is unique` x : T∧ ` x : T ′ ⇒ T = T ′

=⇒ interactive proof tool enables control (and code generation)

9

Page 12: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun is type safe and deadlock free

• Proof of properties in Isabelle/HOL, for example• Wellformedness: no dangling activity references or futures• Typing implies wellformedness

• Type safety: preservation and progress

Theorem (Preservation)

` C : 〈Γact, Γfut〉 ∧ C →‖ C′ =⇒ ∃ Γ′act, Γ′fut . ` C′ : 〈Γ′act, Γ

′fut〉

where Γact ⊆ Γ′act ∧ Γfut ⊆ Γ′fut

Theorem (Progress)

` C : 〈Γact, Γfut〉 ∧ α[fi 7→ a :: Q, t ] ∈ C

=⇒ isvalue(a) ∨ ∃ C′ . C →‖ C′

⇒ Always progress, hence no deadlock!

10

Page 13: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun is type safe and deadlock free

• Proof of properties in Isabelle/HOL, for example• Wellformedness: no dangling activity references or futures• Typing implies wellformedness

• Type safety: preservation and progress

Theorem (Preservation)

` C : 〈Γact, Γfut〉 ∧ C →‖ C′ =⇒ ∃ Γ′act, Γ′fut . ` C′ : 〈Γ′act, Γ

′fut〉

where Γact ⊆ Γ′act ∧ Γfut ⊆ Γ′fut

Theorem (Progress)

` C : 〈Γact, Γfut〉 ∧ α[fi 7→ a :: Q, t ] ∈ C

=⇒ isvalue(a) ∨ ∃ C′ . C →‖ C′

⇒ Always progress, hence no deadlock!

10

Page 14: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun is type safe and deadlock free

• Proof of properties in Isabelle/HOL, for example• Wellformedness: no dangling activity references or futures• Typing implies wellformedness

• Type safety: preservation and progress

Theorem (Preservation)

` C : 〈Γact, Γfut〉 ∧ C →‖ C′ =⇒ ∃ Γ′act, Γ′fut . ` C′ : 〈Γ′act, Γ

′fut〉

where Γact ⊆ Γ′act ∧ Γfut ⊆ Γ′fut

Theorem (Progress)

` C : 〈Γact, Γfut〉 ∧ α[fi 7→ a :: Q, t ] ∈ C

=⇒ isvalue(a) ∨ ∃ C′ . C →‖ C′

⇒ Always progress, hence no deadlock!

10

Page 15: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun is type safe and deadlock free

• Proof of properties in Isabelle/HOL, for example• Wellformedness: no dangling activity references or futures• Typing implies wellformedness

• Type safety: preservation and progress

Theorem (Preservation)

` C : 〈Γact, Γfut〉 ∧ C →‖ C′ =⇒ ∃ Γ′act, Γ′fut . ` C′ : 〈Γ′act, Γ

′fut〉

where Γact ⊆ Γ′act ∧ Γfut ⊆ Γ′fut

Theorem (Progress)

` C : 〈Γact, Γfut〉 ∧ α[fi 7→ a :: Q, t ] ∈ C

=⇒ isvalue(a) ∨ ∃ C′ . C →‖ C′

⇒ Always progress, hence no deadlock!

10

Page 16: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Further results

• Cycles of futures: reduction introduces no cycles

• General results for Isabelle/HOL• FMaps: axiomatic type classes for finite maps• Theory of Objects ς• Contexts: “contextual semantics”, à la E(•)• Locally nameless for ς

11

Page 17: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Overview

1 ASPfun

2 ASPfun in Isabelle/HOL

3 Example for ASPfun

4 Results, Discussion, Outlook

12

Page 18: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Example: service broker

Client reserves a hotel using a broker

customer[f0 7→ broker.find(date,limit), ∅]‖ broker[∅, [find = ς(x , (date, limit)).hotel.room(date), . . .]]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ hotel.room(date), . . . ]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

→∗‖ (REPLY)

customer[f0 7→ bookingref, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

13

Page 19: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Example: service broker

Client reserves a hotel using a broker

customer[f0 7→ broker.find(date,limit), ∅]‖ broker[∅, [find = ς(x , (date, limit)).hotel.room(date), . . .]]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ hotel.room(date), . . . ]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

→∗‖ (REPLY)

customer[f0 7→ bookingref, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

13

Page 20: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Example: service broker

Client reserves a hotel using a broker

customer[f0 7→ broker.find(date,limit), ∅]‖ broker[∅, [find = ς(x , (date, limit)).hotel.room(date), . . .]]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ hotel.room(date), . . . ]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

→∗‖ (REPLY)

customer[f0 7→ bookingref, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

13

Page 21: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Example: service broker

Client reserves a hotel using a broker

customer[f0 7→ broker.find(date,limit), ∅]‖ broker[∅, [find = ς(x , (date, limit)).hotel.room(date), . . .]]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ hotel.room(date), . . . ]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

→∗‖ (REPLY)

customer[f0 7→ bookingref, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

13

Page 22: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Example: service broker

Client reserves a hotel using a broker

customer[f0 7→ broker.find(date,limit), ∅]‖ broker[∅, [find = ς(x , (date, limit)).hotel.room(date), . . .]]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ hotel.room(date), . . . ]‖ hotel[∅, [room = ς(x , date)bookingref, . . .]

→∗‖ (REQUEST, LOCAL)

customer[f0 7→ f1, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

→∗‖ (REPLY)

customer[f0 7→ bookingref, ∅]‖ broker[f1 7→ f2, . . . ]‖ hotel[f2 7→ bookingref, [room = ς(x , date)bookingref, . . .]

13

Page 23: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Observations

• Service broker has a private domain of hotel addresses.

• He searches, negotiates with hotel, and gives only thefuture f2 to client.

• Client receives bookingref using f2 without viewing detailsof the hotel nor others from broker’s domain.

14

Page 24: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Overview

1 ASPfun

2 ASPfun in Isabelle/HOL

3 Example for ASPfun

4 Results, Discussion, Outlook

15

Page 25: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Next goal: security, noninterference

• Noninterference: formal definition of security(confidentality)

• Security types for static security analysis, [3]• Type safety⇒ security

• Challenge: Literature [2] shows that for parallel programsnoninterference more difficult because a process canobserve termination of others.

⇒ ASPfun separate date spaces in active objects; strongernoninterference property expected

[2] G. Boudol, I. Castellani. Noninterference for Concurrent Programs.

ICALP’01. LNCS:2076, Springer, 2001.

[3] F. Kammüller. Formalizing Non-Interference for Bytecode-Languages in

Coq. Formal Aspects of Computing: 20(3):259–275. Springer, 2008.

16

Page 26: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Next goal: security, noninterference

• Noninterference: formal definition of security(confidentality)

• Security types for static security analysis, [3]• Type safety⇒ security

• Challenge: Literature [2] shows that for parallel programsnoninterference more difficult because a process canobserve termination of others.

⇒ ASPfun separate date spaces in active objects; strongernoninterference property expected

[2] G. Boudol, I. Castellani. Noninterference for Concurrent Programs.

ICALP’01. LNCS:2076, Springer, 2001.

[3] F. Kammüller. Formalizing Non-Interference for Bytecode-Languages in

Coq. Formal Aspects of Computing: 20(3):259–275. Springer, 2008.

16

Page 27: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Next goal: security, noninterference

• Noninterference: formal definition of security(confidentality)

• Security types for static security analysis, [3]• Type safety⇒ security

• Challenge: Literature [2] shows that for parallel programsnoninterference more difficult because a process canobserve termination of others.

⇒ ASPfun separate date spaces in active objects; strongernoninterference property expected

[2] G. Boudol, I. Castellani. Noninterference for Concurrent Programs.

ICALP’01. LNCS:2076, Springer, 2001.

[3] F. Kammüller. Formalizing Non-Interference for Bytecode-Languages in

Coq. Formal Aspects of Computing: 20(3):259–275. Springer, 2008.

16

Page 28: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Discussion and outlook

• ASPENDFG: Security analysis of distributed active objects• Development of a new language ASPfun

• Modelling language concepts• Proof of meta-theorems: well-formedness, no cycles• Type system and proof of type safety

⇒ deadlock freedom⇒ security

• Development in Isabelle/HOL• 100 % consistency (correctness)• Generation of prototypical tools (interpreter and type

checker)

• Outlook: components with futures in Isabelle/HOL

• Synergies with formalisation of aspect-orientedprogramming (ASCOTDFG)

17

Page 29: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Current papers (selection)

[1] L. Henrio, F. Kammüller. A Mechanized Model of the Theory of Objects.9th IFIP Int. Conference on Formal Methods for Open Object-BasedDistributed Systems, FMOODS’07. LNCS 4468, Springer 2007.

[2] L. Henrio and F. Kammüller. Functional Active Objects: Typing andFormalisation. Foundations of Coordination Languages and SystemArchitectures, FOCLASA’09. Satellite to ICALP’09. To appear inENTCS, 2009.

[3] F. Kammüller. Formalizing Non-Interference for A SmallBytecode-Language in Coq. Formal Aspects of Computing:20(3):259–275. Springer, 2008.

[4] F. Kammüller, H. Sudhof. Composing safely – A Type System forAspects. Software Composition, Satellite to ETAPS’08. LNCS4954:231–247, Springer 2008.

[5] F. Kammüller, H. Sudhof. Compositionality of Aspect Weaving.Autonomous Systems – Self-Organisation, Management, and Control.B. Mahr, Z. Sheng (Eds.), Springer, 2008.

[6] F. Kammüller, R. Kammüller. Enhancing Privacy Implementations ofDatabase Enquiries. The Fourth International Conference on InternetMonitoring and Protection. IEEE Computer Press, to appear 2009.

18

Page 30: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Further goals: components

primitivecomponent

primitive component

bindingComposite component

• Too much detail at object level• Formalising components

• Abstraction of data and algorithms• Model only structure of communication, i.e futures• Primitive und composite components• Specification of behaviour for primitive components• Composition of behaviour for composites

19

Page 31: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 32: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 33: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 34: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 35: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 36: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 37: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun : Premier Exemple

• Création d’une Activité paràllele, qui incrément 5 par 1

• Supposition : Nombres naturels en ς-calcul

• Configuration initial contient objet vide ∅ et le programcomme suivantα([f0 7→Active([m = ς(x)x .z + 1, z = 5]).m], ∅)

• Active crée activité β ...β([], [m = ς(x)x .z + 1, z = 5]) ... remplace à la locationappellante la reference β de l’Activitéα([f0 7→β.m], ∅)

• Request restant β.m crée Future, en résumé :α([f0 7→f1], ∅)‖ β([f1 7→[m = ς(x)x .z + 1, z = 5].m], ...)

• Evaluation suivant règle LOCAL donneα([f0 7→f1], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

• Par REPLY le résultat est rendu.α([f0 7→6], ∅)‖ β([f1 7→6, [m = ς(x)x .z + 1, z = 5])

20

Page 38: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun-Semantik

21

Page 39: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun-Typsystem Lokal

22

Page 40: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASPfun-Typsystem Global

23

Page 41: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Typsysteme und Typkorrektheit

• Typsystem gestattet statische Überprüfung gewissersemantischer Eigenschaften

• Typsicherheit informell: Ein wohlgetyptes Programm t

verhält sich vernünftig1. Auswertung von t respektiert die Typen

(Preservation/Subject Reduction)JE ` t : T; t →∗

ςt' K=⇒ E ` t' : T

2. Programm t bleibt nicht stecken (Progress)JE ` t : T; ¬ value (t) K=⇒ ∃ t', t →ςt'

• E ` t : T heisst term t hat Typ T in Typumgebung E

24

Page 42: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Bindungs-Techniken in Isabelle

• Wir benutzen DeBruijn-Indizes

• Sehr gewöhnungsbedürftig aber praktisch und einfach

• Nominal Techniques leider nicht einsatzbar• Locally Nameless:

• noch experimentell• Vorteile noch unklar• Vermutung: insbesondere bei Konfigurationen weniger

Problem mit “fresh”

25

Page 43: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Vom ς-Kalkül zu ASPfun

• Isabelle datatype für ς-Terme

• Erweiterung um Active-, ActRef- und FutRef-Terme fürActivation, Activity- und Futurereferenzen

datatype term = Var nat

| Obj label ⇀f term

| Call term label

| Upd term label term

| Active term

| ActRef ActivityRef

| FutRef FutureRef

26

Page 44: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Vom ς-Kalkül zu ASPfun

• Isabelle datatype für ς-Terme

• Erweiterung um Active-, ActRef- und FutRef-Terme fürActivation, Activity- und Futurereferenzen

datatype term = Var nat

| Obj label ⇀f term

| Call term label

| Upd term label term

| Active term

| ActRef ActivityRef

| FutRef FutureRef

26

Page 45: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

O: Theory of Objects, ς-calculus

• Terms in the ς-calculus

a, b ::= [lj = ς(xj)aj ]j∈1..n object definition

| a.lj (j ∈ 1..n) method call| a.lj := ς(x)b (j ∈ 1..n) update

• Semantics/Reduction for o ≡ [lj = ς(xj)aj ]j∈1..n (li distinct).

o object with method names limethods ς(xi)bi

o.lj(b)→ς bj{xj ← o} (j ∈ 1..n) selection / method call

o.lj := ς(x)b →ς [lj = ς(y)b, li = ς(xi)bi∈(1..n)−{j}i ]

(j ∈ 1..n) update/override

27

Page 46: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Die Theorie der Objekte: ς-Kalkül

• Semantik: Reduktionsrelation→ς

• Substitution des formalen Parameters mit a it”self”

a ≡ [lj = ς(xj)bj ]j∈1..n

a.lj →ς bj [a/xj ] j ∈ 1..n

28

Page 47: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Die Theorie der Objekte: ς-Kalkül

• Semantik: Reduktionsrelation→ς

• Substitution des formalen Parameters mit a it”self”

a ≡ [lj = ς(xj)bj ]j∈1..n

a.lj →ς bj [a/xj ] j ∈ 1..n

28

Page 48: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Beispiel ς-Kalkül

zero = [ iszero = true;

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x]

one = zero.succ

→ς (zero.iszero := false).pred := zero

→ς[iszero = false,

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x].pred := zero

→ς[iszero = false,

pred = zero,

succ = ς(x)(x.iszero := false).pred := x]

29

Page 49: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Beispiel ς-Kalkül

zero = [ iszero = true;

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x]

one = zero.succ

→ς (zero.iszero := false).pred := zero

→ς[iszero = false,

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x].pred := zero

→ς[iszero = false,

pred = zero,

succ = ς(x)(x.iszero := false).pred := x]

29

Page 50: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Beispiel ς-Kalkül

zero = [ iszero = true;

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x]

one = zero.succ

→ς (zero.iszero := false).pred := zero

→ς[iszero = false,

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x].pred := zero

→ς[iszero = false,

pred = zero,

succ = ς(x)(x.iszero := false).pred := x]

29

Page 51: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Beispiel ς-Kalkül

zero = [ iszero = true;

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x]

one = zero.succ

→ς (zero.iszero := false).pred := zero

→ς[iszero = false,

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x].pred := zero

→ς[iszero = false,

pred = zero,

succ = ς(x)(x.iszero := false).pred := x]

29

Page 52: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Beispiel ς-Kalkül

zero = [ iszero = true;

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x]

one = zero.succ

→ς (zero.iszero := false).pred := zero

→ς[iszero = false,

pred = ς(x)x,succ = ς(x)(x.iszero := false).pred := x].pred := zero

→ς[iszero = false,

pred = zero,

succ = ς(x)(x.iszero := false).pred := x]

29

Page 53: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

T: Typing rules for Sigma only

inductive typing

intros

Var: Jx < length E; (E!x) = T K=⇒ E ` Var x : T

Obj: Jlength b = len B;

∀ i < len B. E 〈0:B 〉` (b!i): (B!i)K=⇒ E ` (Obj b) : B

Call: JE ` a: A; l < len A K=⇒ E ` (Call a l): (A!l)

Upd: JE ` a: A; l < len A; E 〈0:A 〉` n: (A!l) K=⇒ E ` (Upd a l n) : A

30

Page 54: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

From ς-calculus to ASPfun

• ASPfun builds onς-Kalkül of Abadi andCardelli

• Activities α[R, t ] :• Lists of futures R

(request queue)• ς-Objekt t (immutable)

• Syntactic extension of ς-calculus by:• Active: creation of a new active object• FutRef and ActRef: references for activities and futures

(transparent)

• Semantics: local and parallel evaluation

31

Page 55: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Illustration: rule in semantic notation and inIsabelle/HOL

REPLY

β[fk 7→ s ::R, t ′] ∈ α[fi 7→ E [fk ] ::Q, t ] :: C

α[fi 7→ E [fk ] ::Q, t ] :: C →‖ α[fi 7→ E [s] ::Q, t ] :: C

reply:

J C α = Some (Ra, t); Ra(fi) = Some(E ↑(FutRef(fk)));C β = Some(Rb, t'); Rb(fk) = Some(s) K

=⇒ C →‖ C (α 7→(Ra (fi 7→(E↑s)), t)

32

Page 56: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Illustration: rule in semantic notation and inIsabelle/HOL

REPLY

β[fk 7→ s ::R, t ′] ∈ α[fi 7→ E [fk ] ::Q, t ] :: C

α[fi 7→ E [fk ] ::Q, t ] :: C →‖ α[fi 7→ E [s] ::Q, t ] :: C

reply:

J C α = Some (Ra, t); Ra(fi) = Some(E ↑(FutRef(fk)));C β = Some(Rb, t'); Rb(fk) = Some(s) K

=⇒ C →‖ C (α 7→(Ra (fi 7→(E↑s)), t)

32

Page 57: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

ASP: Topology of Activities

33

Page 58: ASPfun: a Deadlock-free Calculus for Distributed Active ...€¦ · ASPfun: a Deadlock-free Calculus for Distributed Active Objects Florian Kammüller Institut für Softwaretechnik

Characteristics of ASP

• Object-oriented language

• Asynchronous communication

• Parallel processes (active objects)• Futures

• Asynchronous method calls to active objects• Results of such calls are represented by futures until

corresponding response is returned

• Synchronization through wait-by-necessity: wait occurswhen a strict operation on a future is performed

34