/27
Thinking About Mechanizing the Meta-Theory of Session Types
Francisco Ferreira (joint work with Nobuko Yoshida) 17th Dec ABCD Meeting - Imperial College London
1
Thinking About Mechanizing the Meta-Theory of Session Types - - PowerPoint PPT Presentation
Thinking About Mechanizing the Meta-Theory of Session Types Francisco Ferreira (joint work with Nobuko Yoshida) 17th Dec ABCD Meeting - Imperial College London 1 /27 Engineering the Meta-Theory of Session Types Francisco Ferreira (joint
/27
1
/27
2
/27
–Ludwig Wittgenstein
3
/27
4
/27
4
/27
definitions.
4
/27
definitions.
languages (e.g.: OCaml).
4
/27
definitions.
languages (e.g.: OCaml).
4
/27
5
/27
6
/27
7
/27
7
/27
8
/27
8
/27
8
/27
8
/27
8
/27
9
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
(x : T) ∈ E E ⊢ fvar x : T
typing-var
E ⊢ t1 : T1 → T2 E ⊢ t2 : T1 E ⊢ app t1 t2 : T2
typing-app
∀ x ̸∈ L, E, x : T1 ⊢ t x : T2 E ⊢ abs t : T1 → T2
typing-abs
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
(x : T) ∈ E E ⊢ fvar x : T
typing-var
E ⊢ t1 : T1 → T2 E ⊢ t2 : T1 E ⊢ app t1 t2 : T2
typing-app
∀ x ̸∈ L, E, x : T1 ⊢ t x : T2 E ⊢ abs t : T1 → T2
typing-abs
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
(x : T) ∈ E E ⊢ fvar x : T
typing-var
E ⊢ t1 : T1 → T2 E ⊢ t2 : T1 E ⊢ app t1 t2 : T2
typing-app
∀ x ̸∈ L, E, x : T1 ⊢ t x : T2 E ⊢ abs t : T1 → T2
typing-abs
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
(x : T) ∈ E E ⊢ fvar x : T
typing-var
E ⊢ t1 : T1 → T2 E ⊢ t2 : T1 E ⊢ app t1 t2 : T2
typing-app
∀ x ̸∈ L, E, x : T1 ⊢ t x : T2 E ⊢ abs t : T1 → T2
typing-abs
10
/27
t :=
bvar x
|
fvar p
|
abs x t
|
app t t t x ≡ {0 → x} t
\xt
≡ {0 ← x} t
(x : T) ∈ E E ⊢ fvar x : T
typing-var
E ⊢ t1 : T1 → T2 E ⊢ t2 : T1 E ⊢ app t1 t2 : T2
typing-app
∀ x ̸∈ L, E, x : T1 ⊢ t x : T2 E ⊢ abs t : T1 → T2
typing-abs
10
/27
11
/27
11
/27
12
/27
P ::= request a(k) in P session request | accept a(k) in P session acceptance | k![˜ e]; P data sending | k?(˜ x) in P data reception | k ✁ l; P label selection | k ✄ {l1 : P1[ ] · · · [ ]ln : Pn} label branching | throw k[k′]; P channel sending | catch k(k′) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition | inact inaction | (νu)P name/channel hiding | def D in P recursion | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .
D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion
13
/27
P ::= request a(k) in P session request | accept a(k) in P session acceptance | k![˜ e]; P data sending | k?(˜ x) in P data reception | k ✁ l; P label selection | k ✄ {l1 : P1[ ] · · · [ ]ln : Pn} label branching | throw k[k′]; P channel sending | catch k(k′) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition | inact inaction | (νu)P name/channel hiding | def D in P recursion | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .
D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion
13
/27
(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2
14
/27
(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2
14
/27
(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2
14
/27
(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2
(throw k[k′]; P1) | (catch k(k′′) in P2) → P1 | P2[k′/k′′]
14
/27
(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2
(throw k[k′]; P1) | (catch k(k′′) in P2) → P1 | P2[k′/k′′]
14
/27
15
/27
Θ; Γ ⊢ P ◃ ∆ Θ; Γ ⊢ Q ◃ ∆′ Θ; Γ ⊢ P | Q ◃ ∆ ◦ ∆′ (∆ ≍ ∆′) [Conc]
15
/27
Θ; Γ ⊢ P ◃ ∆ Θ; Γ ⊢ Q ◃ ∆′ Θ; Γ ⊢ P | Q ◃ ∆ ◦ ∆′ (∆ ≍ ∆′) [Conc]
15
/27
Θ; Γ ⊢ P ◃ ∆ Θ; Γ ⊢ Q ◃ ∆′ Θ; Γ ⊢ P | Q ◃ ∆ ◦ ∆′ (∆ ≍ ∆′) [Conc]
15
/27
Θ; Γ ⊢ P ◃ ∆ Θ; Γ ⊢ Q ◃ ∆′ Θ; Γ ⊢ P | Q ◃ ∆ ◦ ∆′ (∆ ≍ ∆′) [Conc]
Definition 2.4 (Type algebra) Typings ∆0 and ∆1 are compatible, written ∆0 ≍ ∆1, if ∆0(k) = ∆1(k) for all k ∈ dom(∆0) ∩ dom(∆1). When ∆0 ≍ ∆1, the com- position of ∆0 and ∆1, written ∆0 ◦ ∆1, is given as a typing such that (∆0 ◦ ∆1)(k) is (1) ⊥, if k ∈ dom(∆0) ∩ dom(∆1); (2) ∆i(k), if k ∈ dom(∆i) \ dom(∆i+1 mod 2) for i ∈ {0, 1}; and (3) undefined otherwise.
15
/27
16
/27
16
/27
16
/27
17
/27
17
/27
18
/27
19
/27
19
/27
20
/27
20
/27
20
/27
21
/27
21
/27
21
/27
21
/27
22
/27
Lemma 3.1 (Channel Replacement) If Θ; Γ ⊢ P◃∆·x: α, then Θ; Γ ⊢ P[κp/x]◃ ∆ · κp : α.
23
/27
Lemma 3.1 (Channel Replacement) If Θ; Γ ⊢ P◃∆·x: α, then Θ; Γ ⊢ P[κp/x]◃ ∆ · κp : α.
23
/27
Lemma 3.1 (Channel Replacement) If Θ; Γ ⊢ P◃∆·x: α, then Θ; Γ ⊢ P[κp/x]◃ ∆ · κp : α.
23
/27
Lemma 3.1 (Channel Replacement) If Θ; Γ ⊢ P◃∆·x: α, then Θ; Γ ⊢ P[κp/x]◃ ∆ · κp : α.
23
/27
Lemma 3.1 (Channel Replacement) If Θ; Γ ⊢ P◃∆·x: α, then Θ; Γ ⊢ P[κp/x]◃ ∆ · κp : α.
23
/27
Theorem 3.3 (Subject Reduction) If Θ; Γ ⊢ P ◃ ∆ with ∆ balanced and P →∗ Q, then Θ; Γ ⊢ Q ◃ ∆′ and ∆′ balanced.
24
/27
Theorem 3.3 (Subject Reduction) If Θ; Γ ⊢ P ◃ ∆ with ∆ balanced and P →∗ Q, then Θ; Γ ⊢ Q ◃ ∆′ and ∆′ balanced.
24
/27
25
/27
25
/27
25
/27
25
/27
25
/27
25
/27
25
/27
26
/27
27
/27
27