A type language for message passing component …...Choreographies for reactive programming. CoRR,...

17
A type language for message passing component-based systems Zorica Savanovi´ c 1 , Hugo Vieira 2 and Letterio Galletta 1 ICE 2020, June 19, 2020 1 IMT School for Advanced Studies, Lucca, Italy 2 University of Beira Interior, Portugal

Transcript of A type language for message passing component …...Choreographies for reactive programming. CoRR,...

Page 1: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

A type language for message passingcomponent-based systems

Zorica Savanovic1, Hugo Vieira2 and Letterio Galletta1

ICE 2020, June 19, 2020

1IMT School for Advanced Studies, Lucca, Italy2University of Beira Interior, Portugal

Page 2: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Introduction

I Code reusability is a key principle in Component-BasedDevelopment (CBD).1

I Solutions for code reuse in distributed software systems are lacking.

I A component should be able to carry out a certain sequence ofinput/output actions in order to fulfil its role in the protocol.

Too strict.I Components respond to an external stimulus.

Too wild.I Carbone, Montesi and Vieira 2 proposed a language (Governed

components language): merging reactive components withchoreographic specifications of communication protocols 3.

I Our contribution is at the level of the type language that allows tocapture component’s behaviour so as to check its compatibility witha protocol.

I Once the component’s type is identified, there is no further need tocheck the implementation.

1M. D. Mcllroy. Mass produced software components. In Software Engineering: Report of a conferencesponsored by the NATO Science Committee, pages 138–155. Garmisch, 1969.

2M. Carbone, F. Montesi, and H. T. Vieira. Choreographies for reactive programming. CoRR, abs/1801.08107,2018.

3F. Montesi. Choreographic Programming. PhD thesis, IT University of Copenhagen, 2013.

Zorica Savanovic 1/12

Page 3: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Image Recognition System

Zorica Savanovic 2/12

Page 4: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Base Components

Base component KPortal

PortalI fu(xp) = image, fr (x ′p) = class and

f ( ) = version

I Received images/classes are pro-cessed in a FIFO discipline

I f ( ) can always perform an output re-gardless of inputs

Zorica Savanovic 3/12

Page 5: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

“One-shot” protocol G

Zorica Savanovic 4/12

Page 6: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Recursive protocol G

Zorica Savanovic 5/12

Page 7: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

The Type language syntax

I Two type extraction procedures:

I For base components

I For composite components

I Interfacing componentI Local protocol (projection of a global protocol)

Zorica Savanovic 6/12

Page 8: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

The type of KIRS , G “one-shot”

TIRS =< x(image); y(class) : 1 : [x : Ω], y ′(version) :∞ : [∅] >

Zorica Savanovic 7/12

Page 9: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Type of KIRS , G recursive protocol

< x(image); y(class) :∞ : [x :0], y ′(version) :∞ : [∅] >

I Input two values on port x

I < x(image); y(class) :∞ : [x :2], y ′(version) :∞ : [∅] >I Output from port y one value

I < x(image); y(class) :∞ : [x :1], y ′(version) :∞ : [∅] >I CAN DO: y ′!.x?.y !.x?.y !.x?

I CANNOT DO: x?.y !.y !.x?.x?.y ′! (dependency)

Zorica Savanovic 8/12

Page 10: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Type of KIRS , G recursive protocol

< x(image); y(class) :∞ : [x :0], y ′(version) :∞ : [∅] >

I Input two values on port x

I < x(image); y(class) :∞ : [x :2], y ′(version) :∞ : [∅] >

I Output from port y one value

I < x(image); y(class) :∞ : [x :1], y ′(version) :∞ : [∅] >I CAN DO: y ′!.x?.y !.x?.y !.x?

I CANNOT DO: x?.y !.y !.x?.x?.y ′! (dependency)

Zorica Savanovic 8/12

Page 11: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Type of KIRS , G recursive protocol

< x(image); y(class) :∞ : [x :0], y ′(version) :∞ : [∅] >

I Input two values on port x

I < x(image); y(class) :∞ : [x :2], y ′(version) :∞ : [∅] >I Output from port y one value

I < x(image); y(class) :∞ : [x :1], y ′(version) :∞ : [∅] >I CAN DO: y ′!.x?.y !.x?.y !.x?

I CANNOT DO: x?.y !.y !.x?.x?.y ′! (dependency)

Zorica Savanovic 8/12

Page 12: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Type of KIRS , G recursive protocol

< x(image); y(class) :∞ : [x :0], y ′(version) :∞ : [∅] >

I Input two values on port x

I < x(image); y(class) :∞ : [x :2], y ′(version) :∞ : [∅] >I Output from port y one value

I < x(image); y(class) :∞ : [x :1], y ′(version) :∞ : [∅] >

I CAN DO: y ′!.x?.y !.x?.y !.x?

I CANNOT DO: x?.y !.y !.x?.x?.y ′! (dependency)

Zorica Savanovic 8/12

Page 13: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Type of KIRS , G recursive protocol

< x(image); y(class) :∞ : [x :0], y ′(version) :∞ : [∅] >

I Input two values on port x

I < x(image); y(class) :∞ : [x :2], y ′(version) :∞ : [∅] >I Output from port y one value

I < x(image); y(class) :∞ : [x :1], y ′(version) :∞ : [∅] >I CAN DO: y ′!.x?.y !.x?.y !.x?

I CANNOT DO: x?.y !.y !.x?.x?.y ′! (dependency)

Zorica Savanovic 8/12

Page 14: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Main Results

Theorem (Subject Reduction)

If K ⇓ T and Kλ(v)−−→ K ′ and v has type b then T

λ(b)−−→ T ′ and K ′ ⇓ T ′.

Theorem (Progress)

If K ⇓ T and Tλ(b)−−→ T ′ and λ(b) 6= τ then b is the type of a value v

and Kλ(v)==⇒ K ′ and K ′ ⇓ T ′.

Kλ(v)==⇒ K ′ denotes a sequence of transitions

Kτ−→ · · ·K ′′ λ(v)−−→ K ′′′ τ−→ · · ·K ′.

Zorica Savanovic 9/12

Page 15: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Difference with respect to related approaches

I The approach proposed by Carbone, Montesi and Vieira 4: weconsider a different approach, avoiding the implementation checkeach time a component is to be used.

I Open Multiparty Sessions 5: our components are potentially morereusable considering the I/O flexibility provided the reactive flavour;

I CHOReVOLUTION project6: our type-based approach that aims atabstracting from the implementation and providing more generalsupport for component substitution and reuse.

I FACTum7: do not provide any means to automatically extract typesfrom given components.

4M. Carbone, F. Montesi, and H. T. Vieira. Choreographies for reactive programming. CoRR, abs/1801.08107,2018.

5F. Barbanera and M. Dezani-Ciancaglini. Open multiparty sessions.6CHOReVOLUTION project. http://www.chorevolution.eu.7Marmsoler Diego, and Habtom Kashay Gidey. ”Interactive verification of architectural design patterns in

FACTum.” Formal Aspects of Computing 31.5 (2019): 541-610.

Zorica Savanovic 10/12

Page 16: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Concluding Remarks

I We introduce a type language for the choice-free subset of the GClanguage

I Type language (syntax)

I We do static typing: inspecting the source code so as to avoidruntime errors.

I Subject reduction and Progress

I Typing descriptions such as ours are crucial to promote componentreusability

I Support for protocols with branching;

I Subtyping;

I Conveying the theoretical model to concrete applications.

Zorica Savanovic 11/12

Page 17: A type language for message passing component …...Choreographies for reactive programming. CoRR, abs/1801.08107, 2018. 3F. Montesi. Choreographic Programming. PhD thesis, IT University

Zorica Savanovic 12/12