A Generic Approach to Flow-Sensitive Polymorphic Effects

A Generic Approach to Flow-Sensitive Polymorphic Effects

Presentation for a paper at ECOOP 2017 in Barcelona.

A33216916f486b670031fabd1ddcf11a?s=128

Colin S Gordon

June 23, 2017
Tweet

Transcript

  1. A GENERIC APPROACH TO FLOW- SENSITIVE POLYMORPHIC EFFECTS COLIN S.

    GORDON ECOOP 2017 BARCELONA, SPAIN
  2. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK

  3. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK ▸

    Goal: Give an algebraic characterization of sequential effect systems, sufficient to model prior systems
  4. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK ▸

    Goal: Give an algebraic characterization of sequential effect systems, sufficient to model prior systems ▸ Guide design, implementation, communication
  5. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK ▸

    Goal: Give an algebraic characterization of sequential effect systems, sufficient to model prior systems ▸ Guide design, implementation, communication ▸ A new algebraic characterization of sequential effects
  6. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK ▸

    Goal: Give an algebraic characterization of sequential effect systems, sufficient to model prior systems ▸ Guide design, implementation, communication ▸ A new algebraic characterization of sequential effects ▸ Derivation of a free effect iteration for most sequential effect systems
  7. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS TODAY’S TALK ▸

    Goal: Give an algebraic characterization of sequential effect systems, sufficient to model prior systems ▸ Guide design, implementation, communication ▸ A new algebraic characterization of sequential effects ▸ Derivation of a free effect iteration for most sequential effect systems ▸ Mention of other results in the paper
  8. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

  9. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data:
  10. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data: ▸ ⊢ e : ⟹ ⊢ e : |
  11. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data: ▸ ⊢ e : ⟹ ⊢ e : | ▸ Locking, memory access, non-termination, Java’s checked exceptions…
  12. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data: ▸ ⊢ e : ⟹ ⊢ e : | ▸ Locking, memory access, non-termination, Java’s checked exceptions… ▸ For most effect systems, we have a concise formulation:
  13. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data: ▸ ⊢ e : ⟹ ⊢ e : | ▸ Locking, memory access, non-termination, Java’s checked exceptions… ▸ For most effect systems, we have a concise formulation: ▸ A join semilattice of effects (partial order w/ LUB)
  14. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS REVIEW: EFFECT SYSTEMS

    ▸ Extend type systems to describe internals of computations as well as shape of data: ▸ ⊢ e : ⟹ ⊢ e : | ▸ Locking, memory access, non-termination, Java’s checked exceptions… ▸ For most effect systems, we have a concise formulation: ▸ A join semilattice of effects (partial order w/ LUB) ▸ (More needed for effect masking)
  15. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT SYSTEMS, GENERICALLY

  16. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT SYSTEMS, GENERICALLY

    ⊢ e : | ⊢ e’ : ’ | ’
 ⊢ e; e’ : ’ | ⊔ ’ T-Seq
  17. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT SYSTEMS, GENERICALLY

    ⊢ e : | ⊢ e’ : ’ | ’
 ⊢ e; e’ : ’ | ⊔ ’ T-Seq + plugin for checked exceptions
  18. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT SYSTEMS, GENERICALLY

    ⊢ e : | {IOException} ⊢ e’ : ’ | {InvalidArgumentException}
 ⊢ e; e’ : ’ | {IOException, InvalidArgumentException} ⊢ e : | ⊢ e’ : ’ | ’
 ⊢ e; e’ : ’ | ⊔ ’ T-Seq + plugin for checked exceptions
  19. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS
  20. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom)
  21. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions
  22. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions)
  23. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions) ▸ Use of capabilities
  24. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions) ▸ Use of capabilities ▸ Access to UI elements
  25. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions) ▸ Use of capabilities ▸ Access to UI elements ▸ Blocking calls
  26. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions) ▸ Use of capabilities ▸ Access to UI elements ▸ Blocking calls ▸ …
  27. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS “MOST” EFFECT SYSTEMS:

    COMMUTATIVE EFFECT SYSTEMS ▸ Block-structured lock ownership (e.g., for data race freedom) ▸ Checked exceptions ▸ Memory access (regions) ▸ Use of capabilities ▸ Access to UI elements ▸ Blocking calls ▸ … ORDER DOESN’T MATTER!
  28. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING?
  29. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking
  30. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking ▸ Unstructured memory accesses (regions)
  31. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking ▸ Unstructured memory accesses (regions) ▸ Heap-shape-dependent locking
  32. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking ▸ Unstructured memory accesses (regions) ▸ Heap-shape-dependent locking ▸ …
  33. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking ▸ Unstructured memory accesses (regions) ▸ Heap-shape-dependent locking ▸ … ▸ We call such systems “sequential” (following Tate)
  34. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT ABOUT EFFECT

    SYSTEMS *WITH* ORDERING? ▸ Unstructured locking ▸ Unstructured memory accesses (regions) ▸ Heap-shape-dependent locking ▸ … ▸ We call such systems “sequential” (following Tate) ▸ These systems lack a common algebraic characterization
  35. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT DO WE

    NEED TO MODEL PRIOR SEQUENTIAL EFFECT SYSTEMS?
  36. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT DO WE

    NEED TO MODEL PRIOR SEQUENTIAL EFFECT SYSTEMS? ▸ Still need a join semilattice
  37. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT DO WE

    NEED TO MODEL PRIOR SEQUENTIAL EFFECT SYSTEMS? ▸ Still need a join semilattice ▸ Need (partial) sequencing of effects
  38. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT DO WE

    NEED TO MODEL PRIOR SEQUENTIAL EFFECT SYSTEMS? ▸ Still need a join semilattice ▸ Need (partial) sequencing of effects ▸ Need iteration of effects
  39. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS WHAT DO WE

    NEED TO MODEL PRIOR SEQUENTIAL EFFECT SYSTEMS? ▸ Still need a join semilattice ▸ Need (partial) sequencing of effects ▸ Need iteration of effects ▸ Need equational theory for simplifying complex effects with effect variables
  40. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES

  41. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references)
  42. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references) ▸ A set E with binary join ⊔, binary sequence Ὂ, top ⊤, seq- unit I
  43. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references) ▸ A set E with binary join ⊔, binary sequence Ὂ, top ⊤, seq- unit I ▸ Ὂ distributes over ⊔ on both sides:
 a Ὂ(b ⊔ c) = (aὊb) ⊔ (aὊc)
 (b ⊔ c)Ὂa = (bὊa) ⊔ (cὊa)
  44. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references) ▸ A set E with binary join ⊔, binary sequence Ὂ, top ⊤, seq- unit I ▸ Ὂ distributes over ⊔ on both sides:
 a Ὂ(b ⊔ c) = (aὊb) ⊔ (aὊc)
 (b ⊔ c)Ὂa = (bὊa) ⊔ (cὊa) ▸ ⊤ is nilpotent for Ὂ (aὊ⊤= ⊤= ⊤Ὂa)
  45. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references) ▸ A set E with binary join ⊔, binary sequence Ὂ, top ⊤, seq- unit I ▸ Ὂ distributes over ⊔ on both sides:
 a Ὂ(b ⊔ c) = (aὊb) ⊔ (aὊc)
 (b ⊔ c)Ὂa = (bὊa) ⊔ (cὊa) ▸ ⊤ is nilpotent for Ὂ (aὊ⊤= ⊤= ⊤Ὂa) MANY USEFUL PROPERTIES FOLLOW FROM THIS DEFINITION. E.G., A PARTIAL ORDER ⊑ MONOTONICITY OF Ὂ
  46. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT QUANTALES ▸

    A relaxation of quantales (see paper for references) ▸ A set E with binary join ⊔, binary sequence Ὂ, top ⊤, seq- unit I ▸ Ὂ distributes over ⊔ on both sides:
 a Ὂ(b ⊔ c) = (aὊb) ⊔ (aὊc)
 (b ⊔ c)Ὂa = (bὊa) ⊔ (cὊa) ▸ ⊤ is nilpotent for Ὂ (aὊ⊤= ⊤= ⊤Ὂa) MANY USEFUL PROPERTIES FOLLOW FROM THIS DEFINITION. E.G., A PARTIAL ORDER ⊑ MONOTONICITY OF Ὂ THIS IS ENOUGH TO MODEL PRIOR SYSTEMS!
  47. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN EFFECT

    SYSTEM FOR ATOMICITY
  48. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN EFFECT

    SYSTEM FOR ATOMICITY ▸ Flanagan and Qadeer wrote two atomicity effect systems — let’s model the simpler one (TLDI 2003)
  49. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN EFFECT

    SYSTEM FOR ATOMICITY ▸ Flanagan and Qadeer wrote two atomicity effect systems — let’s model the simpler one (TLDI 2003) ▸ Movers (Lipton ’75) are a way to reason about atomicity by considering how local actions commute with interference:
 
 

  50. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN EFFECT

    SYSTEM FOR ATOMICITY ▸ Flanagan and Qadeer wrote two atomicity effect systems — let’s model the simpler one (TLDI 2003) ▸ Movers (Lipton ’75) are a way to reason about atomicity by considering how local actions commute with interference:
 
 
 ▸ The mover types become effects (B, L, R, A, C), with requisite sequencing
  51. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE
  52. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE
  53. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE ▸ The set is the mover effects + ERR
  54. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE ▸ The set is the mover effects + ERR ▸ Join follows Flanagan and Qadeer (plus ERR) X
  55. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE ▸ The set is the mover effects + ERR ▸ Join follows Flanagan and Qadeer (plus ERR) ▸ Sequencing follows Flanagan and Qadeer (plus ERR) X X X X X X X X X X X X X X
  56. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EXAMPLE: AN ATOMICITY

    EFFECT QUANTALE ▸ The set is the mover effects + ERR ▸ Join follows Flanagan and Qadeer (plus ERR) ▸ Sequencing follows Flanagan and Qadeer (plus ERR) ▸ Flanagan and Qadeer already proved the EQ laws X X X X X X X X X X X X X X
  57. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES?
  58. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity
  59. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity ▸ Derived from prior systems’ type judgments (see paper)
  60. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity ▸ Derived from prior systems’ type judgments (see paper) ▸ Trickier examples: unstructured locking with recursive acquisition, product of effect quantales
  61. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity ▸ Derived from prior systems’ type judgments (see paper) ▸ Trickier examples: unstructured locking with recursive acquisition, product of effect quantales ▸ Clear relationship to more “foundational” work
  62. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity ▸ Derived from prior systems’ type judgments (see paper) ▸ Trickier examples: unstructured locking with recursive acquisition, product of effect quantales ▸ Clear relationship to more “foundational” work ▸ Short version: similar algebras, EQs are slightly more restrictive, EQs induce the other algebras
  63. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS HOW GENERAL ARE

    EFFECT QUANTALES? ▸ EQs cover more than just Flanagan and Qadeer’s atomicity ▸ Derived from prior systems’ type judgments (see paper) ▸ Trickier examples: unstructured locking with recursive acquisition, product of effect quantales ▸ Clear relationship to more “foundational” work ▸ Short version: similar algebras, EQs are slightly more restrictive, EQs induce the other algebras ▸ Free iteration construct for most EQs!
  64. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATING SEQUENTIAL EFFECTS:

    HARDER THAN IT LOOKS ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  65. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATING SEQUENTIAL EFFECTS:

    HARDER THAN IT LOOKS ▸ Prior abstract work on sequential effects defers iteration ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  66. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATING SEQUENTIAL EFFECTS:

    HARDER THAN IT LOOKS ▸ Prior abstract work on sequential effects defers iteration ▸ Mycroft et al. note that a naive fixed point operator makes every effect idempotent (∀X, XὊX=X), which is too strong ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  67. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATING SEQUENTIAL EFFECTS:

    HARDER THAN IT LOOKS ▸ Prior abstract work on sequential effects defers iteration ▸ Mycroft et al. note that a naive fixed point operator makes every effect idempotent (∀X, XὊX=X), which is too strong ▸ Many prior sequential effect systems with iteration are incompatible with that: e.g., Flanagan and Qadeer’s work:
 BὊB=B LὊL=L RὊR=R AὊA=C CὊC=C ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  68. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATING SEQUENTIAL EFFECTS:

    HARDER THAN IT LOOKS ▸ Prior abstract work on sequential effects defers iteration ▸ Mycroft et al. note that a naive fixed point operator makes every effect idempotent (∀X, XὊX=X), which is too strong ▸ Many prior sequential effect systems with iteration are incompatible with that: e.g., Flanagan and Qadeer’s work:
 BὊB=B LὊL=L RὊR=R AὊA=C CὊC=C EFFECT QUANTALES INDUCE AN ITERATION OPERATOR COMPATIBLE WITH PRIOR WORK! ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  69. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS A LITTLE BIT

    OF LATTICE THEORY: CLOSURE OPERATORS
  70. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS A LITTLE BIT

    OF LATTICE THEORY: CLOSURE OPERATORS ▸ A closure operator on a poset P is a function f:P→P that is ▸ Extensive: ∀e, e ⊑ f(e) ▸ Idempotent: ∀e, f(f(e)) ⊑ f(e) ▸ Monotone: ∀e,e’, e ⊑ e’ => f(e) ⊑ f(e’)
  71. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS A LITTLE BIT

    OF LATTICE THEORY: CLOSURE OPERATORS ▸ A closure operator on a poset P is a function f:P→P that is ▸ Extensive: ∀e, e ⊑ f(e) ▸ Idempotent: ∀e, f(f(e)) ⊑ f(e) ▸ Monotone: ∀e,e’, e ⊑ e’ => f(e) ⊑ f(e’) ▸ Codomain(f) is also the set of fixed points of f
  72. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS A LITTLE BIT

    OF LATTICE THEORY: CLOSURE OPERATORS ▸ A closure operator on a poset P is a function f:P→P that is ▸ Extensive: ∀e, e ⊑ f(e) ▸ Idempotent: ∀e, f(f(e)) ⊑ f(e) ▸ Monotone: ∀e,e’, e ⊑ e’ => f(e) ⊑ f(e’) ▸ Codomain(f) is also the set of fixed points of f ▸ A closure operator (if it exists) is uniquely defined by its range ▸ Simple check, constructive proof
  73. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS A LITTLE BIT

    OF LATTICE THEORY: CLOSURE OPERATORS ▸ A closure operator on a poset P is a function f:P→P that is ▸ Extensive: ∀e, e ⊑ f(e) ▸ Idempotent: ∀e, f(f(e)) ⊑ f(e) ▸ Monotone: ∀e,e’, e ⊑ e’ => f(e) ⊑ f(e’) ▸ Codomain(f) is also the set of fixed points of f ▸ A closure operator (if it exists) is uniquely defined by its range ▸ Simple check, constructive proof } 2/5 laws required for iteration!
  74. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS
  75. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS ▸ Picking the results of iteration is easier to think about, constrained by properties
  76. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS ▸ Picking the results of iteration is easier to think about, constrained by properties ▸ Other 3/5 iteration laws require the range elements are idempotent, closed under joins, and above I
  77. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS ▸ Picking the results of iteration is easier to think about, constrained by properties ▸ Other 3/5 iteration laws require the range elements are idempotent, closed under joins, and above I ▸ Taking X to the least idempotent element above X⊔I is a valid closure operator satisfying all 5 iteration laws
  78. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS ▸ Picking the results of iteration is easier to think about, constrained by properties ▸ Other 3/5 iteration laws require the range elements are idempotent, closed under joins, and above I ▸ Taking X to the least idempotent element above X⊔I is a valid closure operator satisfying all 5 iteration laws ▸ Under some mild conditions
  79. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ITERATION VIA CLOSURE

    OPERATORS ▸ Picking the results of iteration is easier to think about, constrained by properties ▸ Other 3/5 iteration laws require the range elements are idempotent, closed under joins, and above I ▸ Taking X to the least idempotent element above X⊔I is a valid closure operator satisfying all 5 iteration laws ▸ Under some mild conditions CLOSURE OPERATORS ALSO APPLY TO SEMANTIC APPROACHES
  80. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DOES ITERATION DO

    WHAT WE WANT? YES!
  81. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DOES ITERATION DO

    WHAT WE WANT? YES! ▸ For the EQ induced by a commutative system (i.e., reuse join as sequencing), iteration is the identity function, as expected
  82. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DOES ITERATION DO

    WHAT WE WANT? YES! ▸ For the EQ induced by a commutative system (i.e., reuse join as sequencing), iteration is the identity function, as expected ▸ For the atomicity EQ, the derived operator coincides with Flanagan and Qadeer’s hand-constructed version
  83. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DOES ITERATION DO

    WHAT WE WANT? YES! ▸ For the EQ induced by a commutative system (i.e., reuse join as sequencing), iteration is the identity function, as expected ▸ For the atomicity EQ, the derived operator coincides with Flanagan and Qadeer’s hand-constructed version ▸ For lock ownership: ▸ Iterating acquire/release is an error ▸ Iterating something that preserves lock ownership is the identity ▸ i.e., iteration is valid only for loop-invariant lock ownership
  84. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER
  85. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER ▸ An abstract core language with singleton effects and effect polymorphism, parameterized by effect quantale and primitives
  86. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER ▸ An abstract core language with singleton effects and effect polymorphism, parameterized by effect quantale and primitives ▸ Effect-preserving translation between Flanagan-Qadeer calculus and (instantiation of) our abstract core language
  87. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER ▸ An abstract core language with singleton effects and effect polymorphism, parameterized by effect quantale and primitives ▸ Effect-preserving translation between Flanagan-Qadeer calculus and (instantiation of) our abstract core language ▸ Precise (formal) relationship to prior semantic work
  88. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER ▸ An abstract core language with singleton effects and effect polymorphism, parameterized by effect quantale and primitives ▸ Effect-preserving translation between Flanagan-Qadeer calculus and (instantiation of) our abstract core language ▸ Precise (formal) relationship to prior semantic work ▸ Subtleties related to substitution with singleton effects
  89. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS ALSO IN THE

    PAPER ▸ An abstract core language with singleton effects and effect polymorphism, parameterized by effect quantale and primitives ▸ Effect-preserving translation between Flanagan-Qadeer calculus and (instantiation of) our abstract core language ▸ Precise (formal) relationship to prior semantic work ▸ Subtleties related to substitution with singleton effects THANKS! QUESTIONS?
  90. BACKUP SLIDES

  91. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS SEQUENTIAL EFFECT SYSTEMS

  92. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS SEQUENTIAL EFFECT SYSTEMS

    ⊢ e : | ⊢ e’ : ’ | ’
 ⊢ e; e’ : ’ | ▷’
  93. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS SEQUENTIAL EFFECT SYSTEMS

    ⊢ e : | ⊢ e’ : ’ | ’
 ⊢ e; e’ : ’ | ▷’ ⊢ e : bool | ⊢ e’ : | ’
 ⊢ while (e) e’ : | ▷(’Ὂ)*
  94. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS
  95. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS ▸ Some effect systems have “pre” and “post” states Δ, like lock sets, or heap shapes
  96. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS ;Δ ⊢ e : ⊣ Δ’ | ;Δ’ ⊢ e’ : ’ ⊣ Δ’’ | ’
 ;Δ ⊢ e; e’ : ’ ⊣ Δ’’ | ▷’ ▸ Some effect systems have “pre” and “post” states Δ, like lock sets, or heap shapes
  97. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS ;Δ ⊢ e : ⊣ Δ’ | ;Δ’ ⊢ e’ : ’ ⊣ Δ’’ | ’
 ;Δ ⊢ e; e’ : ’ ⊣ Δ’’ | ▷’ ;Δ ⊢ e : bool ⊣ Δ’ | ;Δ’ ⊢ e’ : ⊣ Δ | ’
 ;Δ ⊢ while (e) e’ : ⊣ Δ’ | ▷(’Ὂ)* ▸ Some effect systems have “pre” and “post” states Δ, like lock sets, or heap shapes
  98. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS ;Δ ⊢ e : ⊣ Δ’ | ;Δ’ ⊢ e’ : ’ ⊣ Δ’’ | ’
 ;Δ ⊢ e; e’ : ’ ⊣ Δ’’ | ▷’ ;Δ ⊢ e : bool ⊣ Δ’ | ;Δ’ ⊢ e’ : ⊣ Δ | ’
 ;Δ ⊢ while (e) e’ : ⊣ Δ’ | ▷(’Ὂ)* ▸ Some effect systems have “pre” and “post” states Δ, like lock sets, or heap shapes ▸ This obscures the fact that Δ and are managed the same way!
  99. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS — REWRITTEN
  100. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS — REWRITTEN ⊢ e : | (Δ⤳Δ’)⊗ ⊢ e’ : ’ | (Δ’⤳Δ’’)⊗’
 ⊢ e; e’ : ’ | ((Δ⤳Δ’)Ὂ(Δ’⤳Δ’’))⊗(▷’)
  101. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS — REWRITTEN ⊢ e : | (Δ⤳Δ’)⊗ ⊢ e’ : ’ | (Δ’⤳Δ’’)⊗’
 ⊢ e; e’ : ’ | ((Δ⤳Δ’)Ὂ(Δ’⤳Δ’’))⊗(▷’) ⊢ e : bool | (Δ⤳Δ’)⊗ ⊢ e’ : | (Δ’⤳Δ)⊗’
 ⊢ while (e) e’ : | ((Δ⤳Δ’)Ὂ((Δ’⤳Δ)Ὂ(Δ⤳Δ’))*)⊗(▷(’Ὂ)*)
  102. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS OTHER SEQUENTIAL EFFECT

    SYSTEMS — REWRITTEN ⊢ e : | (Δ⤳Δ’)⊗ ⊢ e’ : ’ | (Δ’⤳Δ’’)⊗’
 ⊢ e; e’ : ’ | ((Δ⤳Δ’)Ὂ(Δ’⤳Δ’’))⊗(▷’) ⊢ e : bool | (Δ⤳Δ’)⊗ ⊢ e’ : | (Δ’⤳Δ)⊗’
 ⊢ while (e) e’ : | ((Δ⤳Δ’)Ὂ((Δ’⤳Δ)Ὂ(Δ⤳Δ’))*)⊗(▷(’Ὂ)*) ‣ We can run two effect systems at once! ‣ Look at the (Δ⤳Δ’) effects — there is no natural bottom for their lattice!
  103. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED

    EFFECTS: X*
  104. ▸ P1: ∀e, e ⊑ e* A GENERIC APPROACH TO

    SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE
  105. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING
  106. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* ▸ P3: ∀e, (e*)* = e* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING IDEMPOTENT
  107. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* ▸ P3: ∀e, (e*)* = e* ▸ P4: ∀e,f, (e ⊔ f)* = e* ⊔ f* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING IDEMPOTENT DISTRIBUTIVE
  108. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* ▸ P3: ∀e, (e*)* = e* ▸ P4: ∀e,f, (e ⊔ f)* = e* ⊔ f* ▸ P5: ∀e, I ⊑ e* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING IDEMPOTENT DISTRIBUTIVE “SIMPLE”
  109. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* ▸ P3: ∀e, (e*)* = e* ▸ P4: ∀e,f, (e ⊔ f)* = e* ⊔ f* ▸ P5: ∀e, I ⊑ e* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING IDEMPOTENT DISTRIBUTIVE “SIMPLE” } Hand-IDed by 
 Flanagan & Qadeer
  110. ▸ P1: ∀e, e ⊑ e* ▸ P2: ∀e, eὊe*

    ⊑ e* and e*Ὂe ⊑ e* ▸ P3: ∀e, (e*)* = e* ▸ P4: ∀e,f, (e ⊔ f)* = e* ⊔ f* ▸ P5: ∀e, I ⊑ e* A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS DESIDERATA FOR ITERATED EFFECTS: X* EXTENSIVE FOLDING IDEMPOTENT DISTRIBUTIVE “SIMPLE” } Hand-IDed by 
 Flanagan & Qadeer <— Byproduct of I=⊥
 in Flanagan and Qadeer
  111. BRING ON THE MONADS!

  112. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS THE SEQUENTIAL SEMANTICS

    OF PRODUCER EFFECT SYSTEMS ▸ Ross Tate, POPL 2013 ▸ Derived effectoids: algebraic structure with sequencing, “subeffecting” ▸ Non-deterministic sequencing operation ▸ Coherence condition ~ “non-determinism respects subeffects” ▸ Every effect quantale induces an effectoid ▸ Effectoids lack an explicit join ▸ Many (most reasonable) effectoids induce an effect quantale
  113. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS PARAMETRIC EFFECT MONADS

    AND SEMANTICS OF EFFECT SYSTEMS ▸ Shin-ya Katsumata, POPL 2014 ▸ Index a monad by an algebra for sequencing: a partially- ordered monoid ▸ Now called “graded monads” ▸ “Most of the time” equivalent to effectoids ▸ Every effect quantale induces a graded monad ▸ Most partially-ordered monoids induce an effect quantale
  114. A GENERIC APPROACH TO SEQUENTIAL EFFECT SYSTEMS EFFECT SYSTEMS REVISITED

    — CONTROL-FLOW ALGEBRA AND SEMANTICS ▸ Mycroft, Orchard, & Petricek, Semantics, Logics, and Calculi, 2016 ▸ Extend graded monads to graded joinads: index by a joinoid rather than a po-monoid ▸ monoid + parallel composition + ordered-conditional ?(-,-,-) ▸ ?(I,-,-) induces a form of join ▸ Similar, but weaker equations to effect quantales (only right distributive laws for ?(-,-,-) ▸ Every total effect quantale induces a joinoid (w/ degenerate parallelism) ▸ Joinoids can model control effects (effect quantales can’t)