Semantic Subtyping for Session Types Luca Padovani Dipartimento di Informatica, Università di Torino BTW’11 Semantic Subtyping for Session Types (L. Padovani) BTW’11 1 / 20
Semantic subtyping in a nutshell • Frisch, Castagna, Benzaken, Semantic Subtyping , 2008 def t � s ⇐ ⇒ � t � ⊆ � s � + Intuition � t ∧ s � = � t � ∩ � s � � t ∨ s � = � t � ∪ � s � + Expressiveness � ¬ t � = V \ � t � + Precision t � � s v ∈ � t � \ � s � implies Semantic Subtyping for Session Types (L. Padovani) BTW’11 2 / 20
Subtyping for session types • Gay, Hole, Subtyping for session types in the pi calculus , 2005 end � U end ( i ∈ I ) ( i ∈ I ) T i � U S i T i � U S i � � � � ? a i . T i � U ? a i . S i ! a i . T i � U ! a i . S i i ∈ I i ∈ I ∪ J i ∈ I ∪ J i ∈ I T � U S means. . . • it is safe to use a channel of type T where a channel of type S is expected, or. . . • it is safe to use a process that behaves as S where a process that behaves as T is expected Semantic Subtyping for Session Types (L. Padovani) BTW’11 3 / 20
Subtyping for session types • Gay, Hole, Subtyping for session types in the pi calculus , 2005 end � U end ( i ∈ I ) ( i ∈ I ) T i � U S i T i � U S i � � � � p ? a i . T i � U p ? a i . S i p ! a i . T i � U p ! a i . S i i ∈ I i ∈ I ∪ J i ∈ I ∪ J i ∈ I T � U S means. . . • it is safe to use a channel of type T where a channel of type S is expected, or. . . • it is safe to use a process that behaves as S where a process that behaves as T is expected Semantic Subtyping for Session Types (L. Padovani) BTW’11 3 / 20
Example: multi-party session q ! a p ? a ⊕ ⊕ + + end end end q ! b r ! c p ? b p ? c • p : T = q ! a . T ⊕ q ! b . r ! a . end • q : S = p ? a . S + p ? b . end • r : p ? c . end Is this session “ OK ”? Semantic Subtyping for Session Types (L. Padovani) BTW’11 4 / 20
Example: multi-party session q ! a p ? a ⊕ ⊕ + + end end end q ! b r ! c p ? b p ? c • p : T = q ! a . T ⊕ q ! b . r ! a . end • q : S = p ? a . S + p ? b . end • r : p ? c . end Is this session “ OK ”? Yes, under a fairness assumption Semantic Subtyping for Session Types (L. Padovani) BTW’11 4 / 20
Example: multi-party session (and subtyping) q ! a p ? a ⊕ ⊕ + + end end end q ! b r ! c p ? b p ? c • p : T = q ! a . T ⊕ q ! b . r ! a . end • q : S = p ? a . S + p ? b . end • r : p ? c . end Semantic Subtyping for Session Types (L. Padovani) BTW’11 5 / 20
Example: multi-party session (and subtyping) p ? a + + end end p ? c p ? b q ! a ⊕ • p : T = q ! a . T • q : S = p ? a . S + p ? b . end • r : p ? c . end Is this session is “ OK ”? Semantic Subtyping for Session Types (L. Padovani) BTW’11 5 / 20
How to fix subtyping Definition ( OK session) • p 1 : T 1 | · · · | p n : T n OK if p 1 : T 1 | · · · | p n : T n � ⇒ p 1 : T ′ 1 | · · · | p n : T ′ n implies p 1 : T ′ 1 | · · · | p n : T ′ n � ⇒ p 1 : end | · · · | p n : end Definition (semantic subtyping) • � T � = { M | ( p : T | M ) is OK } • T � S � T � ⊆ � S � iff Semantic Subtyping for Session Types (L. Padovani) BTW’11 6 / 20
How to fix subtyping Definition ( OK session) • p 1 : T 1 | · · · | p n : T n OK if p 1 : T 1 | · · · | p n : T n � ⇒ p 1 : T ′ 1 | · · · | p n : T ′ n implies p 1 : T ′ 1 | · · · | p n : T ′ n � ⇒ p 1 : end | · · · | p n : end Definition (semantic subtyping) • � T � = { M | ( p : T | M ) is OK } • T � S � T � ⊆ � S � iff Semantic Subtyping for Session Types (L. Padovani) BTW’11 6 / 20
How to fix subtyping Definition ( OK session) • p 1 : T 1 | · · · | p n : T n OK if p 1 : T 1 | · · · | p n : T n � ⇒ p 1 : T ′ 1 | · · · | p n : T ′ n implies p 1 : T ′ 1 | · · · | p n : T ′ n � ⇒ p 1 : end | · · · | p n : end Definition (semantic subtyping) • � T � = { M | ( p : T | M ) is OK } • T � S � T � ⊆ � S � iff Semantic Subtyping for Session Types (L. Padovani) BTW’11 6 / 20
How to fix subtyping Definition ( OK session) • p 1 : T 1 | · · · | p n : T n OK if p 1 : T 1 | · · · | p n : T n � ⇒ p 1 : T ′ 1 | · · · | p n : T ′ n implies p 1 : T ′ 1 | · · · | p n : T ′ n � ⇒ p 1 : end | · · · | p n : end Definition (semantic subtyping) • � T � = { M | ( p : T | M ) is OK } • T � S � T � ⊆ � S � iff Semantic Subtyping for Session Types (L. Padovani) BTW’11 6 / 20
Dilemma � U � versus • � U is intuitive but unsound • � is sound but obscure Semantic Subtyping for Session Types (L. Padovani) BTW’11 7 / 20
(Fair) subtyping = (fair) testing preorder • P passes test T • P ⊑ Q iff P passes test T implies Q passes test T “Unfair” testing • De Nicola, Hennessy, Testing equivalences for processes , 1983 • . . . Fair testing • Cleaveland, Natarajan, Divergence and fair testing , 1995 • Rensink, Vogler, Fair testing , 2007 Semantic Subtyping for Session Types (L. Padovani) BTW’11 8 / 20
� U and � are incomparable = p ! a . T � � � U T T S T S = q ? b . S � � � U S S T S T Semantic Subtyping for Session Types (L. Padovani) BTW’11 9 / 20
� U and � are incomparable = p ! a . T � � � U T T S T S = q ? b . S � � � U S S T S T not viable fail ≶ T ≶ S ≶ · · · viable � ⊆ � U Semantic Subtyping for Session Types (L. Padovani) BTW’11 9 / 20
A normal form for session types T is in normal form if either • T = fail, or • end ∈ trees ( S ) for every S ∈ trees ( T ) Proposition For every T there exists S ≶ T in nf Theorem Let T , S �= fail be in nf. Then T � S implies T � U S Semantic Subtyping for Session Types (L. Padovani) BTW’11 10 / 20
Experiment 1 ⊕ ! a ! a ! a ⊕ ⊕ ! b ! b end end T = ! a . T ⊕ ! b . end S = ! a . ! a . S ⊕ ! b . end Is there a context R such that • R | T is OK • R | S � � ⇒ end | end ? Semantic Subtyping for Session Types (L. Padovani) BTW’11 11 / 20
Experiment 2 ? a ⊕ + ? a ! a , ! b ? a ⊕ + ⊕ + ! a ? b ! a , ! b ? b ? b end end Semantic Subtyping for Session Types (L. Padovani) BTW’11 12 / 20
Experiment 2 ? a ⊕ + ? a ! a , ! b ? a ⊕ + ⊕ + ! a ? b ! a , ! b ? b ? b end end ? a , ? b ! a ⊕ + ⊕ ? a + ! a ? b ⊕ end ! b Semantic Subtyping for Session Types (L. Padovani) BTW’11 12 / 20
Rule of thumb If • ! a . T does not occur in a loop or • ! a . T occurs in a loop ℓ of p , and • there exists an exit path in ℓ that starts from a ⊕ node, then • ! a . T can be safely pruned Rationale • no context can rely on the eventual observation of ! a from p because p can autonomously exit ℓ Semantic Subtyping for Session Types (L. Padovani) BTW’11 13 / 20
Behavioral difference Theorem Let T , S be in nf and T � U S. Then T − S viable iff R | T OK and R | S � � ⇒ end | end for some R end − end = fail � � � p ? a i . T i − p ? a i . S i = p ? a i .( T i − S i ) i ∈ I i ∈ I ∪ J i ∈ I � � � � p ! a i . T i − p ! a i . S i = p ! a i .( T i − S i ) ⊕ p ! a j . T j i ∈ I ∪ J i ∈ I i ∈ I j ∈ J Semantic Subtyping for Session Types (L. Padovani) BTW’11 14 / 20
Fair subtyping, at last fail � A T end � A end ( i ∈ I ) T i � A S i � � p ? a i . T i � A p ? a i . S i i ∈ I i ∈ I ∪ J ( i ∈ I ) T i � A S i nf ( T − S ) = fail � � T = p ! a i . T i � A p ! a i . S i = S i ∈ I ∪ J i ∈ I Theorem T � S iff nf ( T ) � A nf ( S ) Semantic Subtyping for Session Types (L. Padovani) BTW’11 15 / 20
Fair subtyping, at last fail � A T end � A end ( i ∈ I ) T i � A S i � � p ? a i . T i � A p ? a i . S i i ∈ I i ∈ I ∪ J ( i ∈ I ) T i � A S i nf ( T − S ) = fail � � T = p ! a i . T i � A p ! a i . S i = S i ∈ I ∪ J i ∈ I Theorem T � S iff nf ( T ) � A nf ( S ) Semantic Subtyping for Session Types (L. Padovani) BTW’11 15 / 20
Fair subtyping, at last fail � A T end � A end ( i ∈ I ) T i � A S i � � p ? a i . T i � A p ? a i . S i i ∈ I i ∈ I ∪ J ( i ∈ I ) T i � A S i nf ( T − S ) = fail � � T = p ! a i . T i � A p ! a i . S i = S i ∈ I ∪ J i ∈ I Theorem T � S iff nf ( T ) � A nf ( S ) Semantic Subtyping for Session Types (L. Padovani) BTW’11 15 / 20
Fair subtyping, at last fail � A T end � A end ( i ∈ I ) T i � A S i � � p ? a i . T i � A p ? a i . S i i ∈ I i ∈ I ∪ J ( i ∈ I ) T i � A S i nf ( T − S ) = fail � � T = p ! a i . T i � A p ! a i . S i = S i ∈ I ∪ J i ∈ I Theorem T � S iff nf ( T ) � A nf ( S ) Semantic Subtyping for Session Types (L. Padovani) BTW’11 15 / 20
Fair testing vs fair subtyping Fair testing • Cleaveland, Natarajan, Divergence and fair testing , 1995 • Rensink, Vogler, Fair testing , 2007 − denotational (= obscure) characterization − no complete deduction system − exponential Fair subtyping + operational (= hopefully less obscure) characterization (and maybe it can be further simplified) + complete deduction system + polynomial Semantic Subtyping for Session Types (L. Padovani) BTW’11 16 / 20
Recommend
More recommend