effpi
play

Effpi concurrent programming with dependent behavioural types - PowerPoint PPT Presentation

Effpi concurrent programming with dependent behavioural types Alceste Scalas with Elias Benussi & Nobuko Yoshida VeTSS PhD school / FMATS workshop Microsoft Research Cambridge, 25 September 2018 Problem Introduction Calculus Types


  1. Effpi concurrent programming with dependent behavioural types Alceste Scalas with Elias Benussi & Nobuko Yoshida VeTSS PhD school / FMATS workshop Microsoft Research Cambridge, 25 September 2018

  2. Problem Introduction Calculus Types Properties Implementation Conclusion The problem Languages and toolkits for message-passing concurrent programming provide intuitive high-level abstractions ▸ e.g., actors, channels, processes (Akka, Erlang, Go, . . . ) . . . but do not allow to verify code against behavioural specs ▸ risks: protocol violations , deadlocks , starvation , . . . ▸ issues found at run-time , hence expensive to fix ▸ can vehicle attacks : e.g., data breaches, DoS 2 / 17

  3. Problem Introduction Calculus Types Properties Implementation Conclusion The problem and our solution Languages and toolkits for message-passing concurrent programming provide intuitive high-level abstractions ▸ e.g., actors, channels, processes (Akka, Erlang, Go, . . . ) . . . but do not allow to verify code against behavioural specs ▸ risks: protocol violations , deadlocks , starvation , . . . ▸ issues found at run-time , hence expensive to fix ▸ can vehicle attacks : e.g., data breaches, DoS Our solution: Effpi , a toolkit for strongly-typed concurrent programming in Dotty (a.k.a. Scala 3) ▸ using types as behavioural specifications ▸ and type-level model checking to verify code properties 2 / 17

  4. Problem Introduction Calculus Types Properties Implementation Conclusion Example: payment service with auditing A payment service should implement the following specification : 1. wait to receive a payment request 2. then, either : 2.1 reject the payment, or 2.2 report the payment to an audit service, and then accept it 3. continue from point 1 3 / 17

  5. Problem Introduction Calculus Types Properties Implementation Conclusion Example: payment service with auditing Demo! 4 / 17

  6. Problem Introduction Calculus Types Properties Implementation Conclusion What is the Dotty / Scala 3 compiler saying? found: Out[ActorRef[Result], Accepted] required: Out[ActorRef[Result](pay.replyTo), Rejected] ∣ Out[ActorRef[Audit[ ]](aud), Audit[Pay(pay)]] >>: Out[ActorRef[Result](pay.replyTo), Accepted] 5 / 17

  7. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" 6 / 17

  8. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( 6 / 17

  9. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( send ( pongc , self , λ . ( 6 / 17

  10. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( send ( pongc , self , λ . ( recv ( self , λ reply . ( 6 / 17

  11. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( send ( pongc , self , λ . ( recv ( self , λ reply . ( end ))))) 6 / 17

  12. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( let ponger = λ self . ( send ( pongc , self , λ . ( recv ( self , λ reqc . ( recv ( self , λ reply . ( send ( reqc , "Hello!" , λ . ( end ))))) end ))))) 6 / 17

  13. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( let ponger = λ self . ( send ( pongc , self , λ . ( recv ( self , λ reqc . ( recv ( self , λ reply . ( send ( reqc , "Hello!" , λ . ( end ))))) end ))))) let pingpong = λ c1 . λ c2 . ( pinger c1 c2 ∣∣ ponger c2 ) 6 / 17

  14. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( let ponger = λ self . ( send ( pongc , self , λ . ( recv ( self , λ reqc . ( recv ( self , λ reply . ( send ( reqc , "Hello!" , λ . ( end ))))) end ))))) let pingpong = λ c1 . λ c2 . ( pinger c1 c2 ∣∣ ponger c2 ) let main = let c1 = chan () ; let c2 = chan () ; pingpong c1 c2 6 / 17

  15. Problem Introduction Calculus Types Properties Implementation Conclusion A λ -calculus with communication & concurrency Example: a pinger process sends a communication channel to a ponger process, who uses the channel to reply "Hello!" let pinger = λ self . λ pongc . ( let ponger = λ self . ( send ( pongc , self , λ . ( recv ( self , λ reqc . ( recv ( self , λ reply . ( send ( reqc , "Hello!" , λ . ( end ))))) end ))))) let pingpong = λ c1 . λ c2 . ( pinger c1 c2 ∣∣ ponger c2 ) let main = let c1 = chan () ; let c2 = chan () ; pingpong c1 c2 Monadic encoding of the higher-order π -calculus ▸ λ -terms model abstract processes ▸ Continuations are expressed as λ -terms 6 / 17

  16. Problem Introduction Calculus Types Properties Implementation Conclusion How to type a process calculus For typing, we use a context Γ with channel types . E.g.: Γ = x ∶ str , y ∶ c o [ str ] Typing judgements are (partly) standard: Γ ⊢ "Hello " + + x ∶ str 7 / 17

  17. Problem Introduction Calculus Types Properties Implementation Conclusion How to type a process calculus For typing, we use a context Γ with channel types . E.g.: Γ = x ∶ str , y ∶ c o [ str ] Typing judgements are (partly) standard: Γ ⊢ "Hello " + + x ∶ str How do we type communication? E.g., if t = send ( y , x , λ . end ) Γ ⊢ t ∶ proc Classic approach: (“ t is a well-typed process in Γ ”) 7 / 17

  18. Problem Introduction Calculus Types Properties Implementation Conclusion How to type a process calculus For typing, we use a context Γ with channel types . E.g.: Γ = x ∶ str , y ∶ c o [ str ] Typing judgements are (partly) standard: Γ ⊢ "Hello " + + x ∶ str How do we type communication? E.g., if t = send ( y , x , λ . end ) Γ ⊢ t ∶ proc Classic approach: (“ t is a well-typed process in Γ ”) Γ ⊢ t ∶ T Our approach: ( “ t behaves as T in Γ ” ) 7 / 17

  19. Problem Introduction Calculus Types Properties Implementation Conclusion How to type a process calculus For typing, we use a context Γ with channel types . E.g.: Γ = x ∶ str , y ∶ c o [ str ] Typing judgements are (partly) standard: Γ ⊢ "Hello " + + x ∶ str How do we type communication? E.g., if t = send ( y , x , λ . end ) Γ ⊢ t ∶ proc Classic approach: (“ t is a well-typed process in Γ ”) Γ ⊢ t ∶ T Our approach: ( “ t behaves as T in Γ ” ) Γ ⊢ T ⩽ proc ( “ T is a refined process type ” ) 7 / 17

  20. Problem Introduction Calculus Types Properties Implementation Conclusion Behavioural types (inspired by π -calculus theory) Some examples: x ∶ str , y ∶ c o [ str ] ⊢ send ( y , x , λ . end ) ∶ T 8 / 17

  21. Problem Introduction Calculus Types Properties Implementation Conclusion Behavioural types (inspired by π -calculus theory) Some examples: x ∶ str , y ∶ c o [ str ] ⊢ send ( y , x , λ . end ) ∶ T = o [ c o [ str ] , str, nil ] 8 / 17

  22. Problem Introduction Calculus Types Properties Implementation Conclusion Behavioural types (inspired by π -calculus theory) Some examples: x ∶ str , y ∶ c o [ str ] ⊢ send ( y , x , λ . end ) ∶ T = o [ c o [ str ] , str, nil ] ∅ ⊢ λ x . λ y . send ( y , x , λ . end ) ∶ T ′ 8 / 17

  23. Problem Introduction Calculus Types Properties Implementation Conclusion Behavioural types (inspired by π -calculus theory) Some examples: x ∶ str , y ∶ c o [ str ] ⊢ send ( y , x , λ . end ) ∶ T = o [ c o [ str ] , str, nil ] ∅ ⊢ λ x . λ y . send ( y , x , λ . end ) ∶ T ′ = str → c o [ str ] → T 8 / 17

  24. Problem Introduction Calculus Types Properties Implementation Conclusion Behavioural types (inspired by π -calculus theory) Some examples: x ∶ str , y ∶ c o [ str ] ⊢ send ( y , x , λ . end ) ∶ T = o [ c o [ str ] , str, nil ] ∅ ⊢ λ x . λ y . send ( y , x , λ . end ) ∶ T ′ = str → c o [ str ] → T Can we use types to specify and verify process behaviours ? 8 / 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend