Erlang/OTP Meets Dependent Types

334a587ef1901e2d48dfd15f90522496?s=47 Sam Elliott
September 04, 2015

Erlang/OTP Meets Dependent Types

Talk given at Erlang Workshop 2015, September 2015.

Extended Abstract (for ICFP Student Research Competition): http://lenary.co.uk/publications/erlang_deptypes_src/

My Dissertation: http://lenary.co.uk/publications/dissertation/

334a587ef1901e2d48dfd15f90522496?s=128

Sam Elliott

September 04, 2015
Tweet

Transcript

  1. Erlang/OTP Meets Dependent Types Archibald Samuel Elliott Edwin Brady University

    of St Andrews Erlang Workshop, 4 September 2015
  2. Introduction Compiler Concurrency OTP Conclusion Archibald Samuel Elliott, Edwin Brady

    Erlang/OTP Meets Dependent Types
  3. Introduction Compiler Concurrency OTP Conclusion Dependent Types • Types are

    Values • Values are Types • Programs and Proofs Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  4. Introduction Compiler Concurrency OTP Conclusion Compiler Archibald Samuel Elliott, Edwin

    Brady Erlang/OTP Meets Dependent Types
  5. Introduction Compiler Concurrency OTP Conclusion Actors data Actor : Type

    → Type → Type action : Actor interface term recieve : Actor i i spawn : (Actor i a) → IO (ActorID i) data ActorID : Type → Type pid : ActorID i send : ActorID i → i → IO () Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  6. Introduction Compiler Concurrency OTP Conclusion -type lock_req () :: lock

    | unlock. -type lock_lock_resp () :: grant | wait. -type lock_resp () :: lock_lock_resp () | ok. -type lock_st () :: locked | unlocked. -spec handle_call(lock_req (), term(), lock_st ()) → {ok , lock_resp (), lock_st ()} | error (). handle_call(lock , _, locked) → {ok , wait , locked}; handle_call(lock , _, unlocked) → {ok , grant , locked}; handle_call(unlock , _, locked) → {ok , ok , unlocked}; handle_call(unlock , _, unlocked) → {ok , ok , unlocked}. Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  7. Introduction Compiler Concurrency OTP Conclusion Request Response data ReqResI :

    (r : Type) → (r → Type) → Type data ReqResId : ReqResI r f → Type req : {i : ReqResI r f} → ReqResId i → (m : r) → IO (f m) spawn : {i : ReqResI r f} → ((m : r) → f m) → IO (ReqResId i) Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  8. Introduction Compiler Concurrency OTP Conclusion data LockReq = Lock |

    Unlock data LockLockResp = Grant | Wait total LockResp : LockReq → Type LockResp Lock = LockLockResp LockResp Unlock = Unit LockI : ReqResI LockReq LockResp total lock_srv : (r : LockReq) → LockResp r lock_srv Lock = Wait lock_srv Unlock = () spawn lock_srv : IO (ReqResId LockI) lock_pid : ReqResId LockI req lock_pid Lock : LockLockResp req lock_pid Unlock : Unit Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  9. Introduction Compiler Concurrency OTP Conclusion Behaviours • gen server •

    gen fsm • gen event Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  10. Introduction Compiler Concurrency OTP Conclusion Conclusion • We can produce

    verified concurrent programs in Idris • We can compile these programs to work with Erlang • We can run verified programs in Erlang Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  11. Introduction Compiler Concurrency OTP Conclusion Any Questions? Archibald Samuel Elliott,

    Edwin Brady Erlang/OTP Meets Dependent Types