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 work with Nobuko Yoshida) 17th Dec ABCD Meeting - Imperial College London 2 /27
“The limits of my language mean the limits of my world.” –Ludwig Wittgenstein 3 /27
Who Am I? • I did my PhD at McGill University , advised by Brigitte Pientka. • I worked with Higher Order Abstract Syntax. • Also on the meta-theory of programming languages. 4 /27
Who Am I? • I did my PhD at McGill University , advised by Brigitte Pientka. • I worked with Higher Order Abstract Syntax. • Also on the meta-theory of programming languages. • I worked in the implementation of: 4 /27
Who Am I? • I did my PhD at McGill University , advised by Brigitte Pientka. • I worked with Higher Order Abstract Syntax. • Also on the meta-theory of programming languages. • I worked in the implementation of: • Beluga — My supervisor’s project on computational reasoning about LF definitions . 4 /27
Who Am I? • I did my PhD at McGill University , advised by Brigitte Pientka. • I worked with Higher Order Abstract Syntax. • Also on the meta-theory of programming languages. • I worked in the implementation of: • Beluga — My supervisor’s project on computational reasoning about LF definitions . • Babybel — Our project on supporting HOAS in functional programming languages (e.g.: OCaml). 4 /27
Who Am I? • I did my PhD at McGill University , advised by Brigitte Pientka. • I worked with Higher Order Abstract Syntax. • Also on the meta-theory of programming languages. • I worked in the implementation of: • Beluga — My supervisor’s project on computational reasoning about LF definitions . • Babybel — Our project on supporting HOAS in functional programming languages (e.g.: OCaml). • Orca — Our project on combining HOAS and Type Theory. 4 /27
Mechanising the Meta-Theory Session Types • Names are ubiquitous. • The binding structure is quite rich. • Channels are handled linearly. • Names exist besides binders. Names are a first class notion. 5 /27
The First Step • Do a case study: • Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited, by Yoshida and Vasconcelos. 6 /27
How Best To Represent Session Types Calculi? Constructive FOL + Induction Contextual types Logical framework LF 7 /27
How Best To Represent Session Types Calculi? Constructive FOL + Induction Nominal Equation Logic 7 /27
But, Really? Another Proof Assistant? 8 /27
But, Really? Another Proof Assistant? • What if we relax the requirement for α -conversion? 8 /27
But, Really? Another Proof Assistant? • What if we relax the requirement for α -conversion? • Work by Ernesto Copello, Maribel Fernandez, et al. • Defines a notion of α -compatible relations. • Defines a notion of α -structural induction. 8 /27
But, Really? Another Proof Assistant? • What if we relax the requirement for α -conversion? It can be readily • Work by Ernesto Copello, Maribel Fernandez, et al. implemented in Agda and Coq! • Defines a notion of α -compatible relations. • Defines a notion of α -structural induction. 8 /27
But, Really? Another Proof Assistant? • What if we relax the requirement for α -conversion? It can be readily • Work by Ernesto Copello, Maribel Fernandez, et al. Induction on implemented in Agda judgments is still an “it and Coq! should be possible” • Defines a notion of α -compatible relations. problem in this approach. • Defines a notion of α -structural induction. 8 /27
Time To Consider Existing Solutions • Well established work on Locally Nameless : • Use names for free variables. • Use indices for bound variables. • Mediate between them with open & close operations. 9 /27
STLC t bvar x fvar p abs x t app t t := | | | 10 /27
STLC t bvar x fvar p abs x t app t t := | | | 10 /27
STLC t bvar x fvar p abs x t app t t := | | | 10 /27
STLC t bvar x fvar p abs x t app t t := | | | 10 /27
STLC t bvar x fvar p abs x t app t t := | | | t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ 10 /27
STLC t bvar x fvar p abs x t app t t := | | | t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ ok E ( x : T ) ∈ E E ⊢ t 1 : T 1 → T 2 E ⊢ t 2 : T 1 typing-var typing-app E ⊢ fvar x : T E ⊢ app t 1 t 2 : T 2 E , x : T 1 ⊢ t x : T 2 ∀ x ̸∈ L , typing-abs E ⊢ abs t : T 1 → T 2 10 /27
STLC t bvar x fvar p abs x t app t t := | | | t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ ok E ( x : T ) ∈ E E ⊢ t 1 : T 1 → T 2 E ⊢ t 2 : T 1 typing-var typing-app E ⊢ fvar x : T E ⊢ app t 1 t 2 : T 2 E , x : T 1 ⊢ t x : T 2 ∀ x ̸∈ L , typing-abs E ⊢ abs t : T 1 → T 2 10 /27
STLC t bvar x fvar p abs x t app t t := | | | t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ ok E ( x : T ) ∈ E E ⊢ t 1 : T 1 → T 2 E ⊢ t 2 : T 1 typing-var typing-app E ⊢ fvar x : T E ⊢ app t 1 t 2 : T 2 E , x : T 1 ⊢ t x : T 2 ∀ x ̸∈ L , typing-abs E ⊢ abs t : T 1 → T 2 10 /27
STLC t bvar x fvar p abs x t app t t := | | | t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ ok E ( x : T ) ∈ E E ⊢ t 1 : T 1 → T 2 E ⊢ t 2 : T 1 typing-var typing-app E ⊢ fvar x : T E ⊢ app t 1 t 2 : T 2 E , x : T 1 ⊢ t x : T 2 ∀ x ̸∈ L , typing-abs E ⊢ abs t : T 1 → T 2 10 /27
STLC t bvar x fvar p abs x t app t t := | | | Open and close should admit several lemmas: • Opening locally closed terms does not change the t x \ x t { 0 → x } t { 0 ← x } t ≡ ≡ term • Opening and substitution commute • The interaction of opening and substitutions of variables ok E ( x : T ) ∈ E E ⊢ t 1 : T 1 → T 2 E ⊢ t 2 : T 1 typing-var typing-app E ⊢ fvar x : T E ⊢ app t 1 t 2 : T 2 E , x : T 1 ⊢ t x : T 2 ∀ x ̸∈ L , typing-abs E ⊢ abs t : T 1 → T 2 10 /27
The Send Receive System and its Cousins the Relaxed and the Revisited System. 11 /27
The Send Receive System and its Cousins the Relaxed and the Revisited System. Start developing the infrastructure and eventually move on to MPST 11 /27
A Tale of Three Systems • We set out to represent the three systems described in the paper: • The Honda, Vasconcelos, Kubo system from ESOP’98 • Its naïve but ultimately unsound extension • Its revised system inspired by Gay and Hole in Acta Informatica 12 /27
The Send Receive System 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 ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } 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 e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion 13 /27
The Send Receive System 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 ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } 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 e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion 13 /27
α -Conversion for Free • The original system depends crucially on names ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 14 /27
α -Conversion for Free • The original system depends crucially on names ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 14 /27
α -Conversion for Free • The original system depends crucially on names ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 This is a bound variable. 14 /27
α -Conversion for Free • The original system depends crucially on names ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 This is a bound variable. • If α -conversion is built in, this rule collapses to: ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′′ ) in P 2 ) → P 1 | P 2 [ k ′ /k ′′ ] 14 /27
α -Conversion for Free • The original system depends crucially on names ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 Locally Nameless makes it impossible to express the This is a bound variable. original system’s name handling! • If α -conversion is built in, this rule collapses to: ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′′ ) in P 2 ) → P 1 | P 2 [ k ′ /k ′′ ] 14 /27
Recommend
More recommend