A type system for monotonicity Michael Arntzenius University of - - PowerPoint PPT Presentation

a type system for monotonicity
SMART_READER_LITE
LIVE PREVIEW

A type system for monotonicity Michael Arntzenius University of - - PowerPoint PPT Presentation

A type system for monotonicity Michael Arntzenius University of Birmingham ICFP 2018 Its just the simply-typed -calculus! A Poset A B = monotone maps A B , ordered pointwise op A A A b b


slide-1
SLIDE 1

A type system for monotonicity

Michael Arntzenius

University of Birmingham

ICFP 2018

slide-2
SLIDE 2

It’s just the simply-typed λ-calculus!

A ∈ Poset A → B = monotone maps A → B,

  • rdered pointwise
slide-3
SLIDE 3

a b c

A

a b c

  • p A

a b c

✷A

f : ✷A → B is monotone iff x = y = ⇒ f(x) f(y)

i.e. always!

slide-4
SLIDE 4

setMap : ✷(✷A → B) → Set A → Set B setMap f xs = let box g = f in do x ← xs let box y = x return (box (g (box y)))

slide-5
SLIDE 5

setMap : ✷(✷A → B) → Set A → Set B setMap f xs = do x ← xs return

(f x)

slide-6
SLIDE 6

A <: B

id :

A → B

slide-7
SLIDE 7

[T]A <: B

id : TA → B

T ∈ {id, op, ✷, ...}

slide-8
SLIDE 8

f : TA → B g : UB → C g ◦ f : (UT)A → C

slide-9
SLIDE 9

Monotonicity tames dragons!

  • 1. Eventual consistency in distributed systems

http://bloom-lang.net/calm/

  • 2. Determinism in parallel programs

LVars: Lattice-based Data Structures for Deterministic Parallelism, Lindsey Kuper & Ryan Newton

  • 3. Recursive queries in Datalog & Datafun

http://www.rntz.net/datafun

  • 4. Paradoxes of self-reference
slide-10
SLIDE 10

fin

slide-11
SLIDE 11

subtractEach : List (Z × op Z) → List Z subtractEach xs = [x − y | (x, y) ← xs]

slide-12
SLIDE 12

a b : id A ⇐ ⇒ a b : A a b : op A ⇐ ⇒ a b : A a b : ✷A ⇐ ⇒ a b ∧ a b : A a b : ♦A ⇐ = a b ∨ b a : A ♦

id

  • p

UT T

id

  • p

✷ ♦

U

id id

  • p

✷ ♦

  • p op

id

✷ ♦ ✷ ✷ ✷ ✷ ♦

♦ ♦ ♦

✷ ♦

slide-13
SLIDE 13

subsumption

Γ ⊢ M : A [T]A <: B TΓ ⊢ M : C