Curry-Howard for GUIs:
classical linear linear temporal logic (work in progress!)
Steve Zdancewic Jennifer Paykin Neel Krishnaswami WG 2.8 2015
How do we think about GUIs? an array of buttons each button waits - - PowerPoint PPT Presentation
Curry-Howard for GUIs: classical linear linear temporal logic (work in progress!) Steve Zdancewic Jennifer Paykin Neel Krishnaswami WG 2.8 2015 How do we think about GUIs? an array of buttons each button waits for a click each
Steve Zdancewic Jennifer Paykin Neel Krishnaswami WG 2.8 2015
(e.g. starts a different app)
independent process
button.onClick : (ClickData -> IO ()) -> IO ()
button.onClick callback = handlers[click] := callback::(!handlers[click])
button.onClick : (ClickData -> IO ()) -> IO () : (ClickData -> IO ()) -> IO () : (¬ClickData) -> IO () : ¬¬ClickData : ♢ClickData
the outcome
the outcome
“good” computations
button.onClick : (ClickData -> IO ()) -> IO () button.onClick : (ClickData -> Safe) -> Safe
A widget contains:
… Some first-order data (color, height, text, etc.) … A collection of event handlers … So a heap can be formalized as:
Data heap h ::= · | h, h | l : d Queue q ∈ Loc → Mfin(Val) Store σ ∈ Data × Queue
… Key problem: event handlers are higher-order state
Ok =
⇢
(σ, t, σ0)
hσ · ϕ;ti +
⌦
π(σ0) · ϕ;()
↵
=
8 < :
σ
z }| {
(h, q)
Safe∗
n ((h, [q|l : ∅]), e, q(l))
9 = ;
Safe =
T
n Safen
Safe∗
0 (σ, e, ks)
= > Safe∗
n+1(σ, e, ε)
= > Safe∗
n+1(σ, e, k · ks)
= ∃σ0 2 Safen. Ok(σ, k e, σ0) ∧ Safe∗
n (σ0, e, ks)
… Safe = heaps maintaining safety on callbacks
⌦
↵
⇢⌦
↵
⇢
[[0]] = [[A B]] = [[A]] + [[B]] [[I]] = 1 [[A ⌦ B]] = [[A]] ∗ [[B]] [[>]] = ¬0 [[A & B]] = ¬(¬[[A]] + ¬[[B]]) [[?]] = ¬1 [[A ` B]] = ¬(¬[[A]] ∗ ¬[[B]]) [[ÉA]] =
É[[A]]
[[ÜA]] = ¬É¬[[A]]
Linearly ¡
Linearly ¡
Linearly ¡
See ¡e.g. ¡Benton’s ¡Linear—Nonlinear ¡Logic ¡
with the event handler
callbacks for each event
while (true) { let event = get_event(); for (f in handlers[event]) { f(event.data); } }
handlers[key] = [fun d -> …; fun d -> …;] handlers[click] = [fun d -> …; fun d -> …;] handlers[mouseMove] = [fun d -> …;]
A useable exactly once “now”
︎A useable once at any (future) time
♢A useable once at some (future) time
!A unrestricted uses at any time
button.onClick : (ClickData -> IO ()) -> IO () : (ClickData -> Safe) -> Safe : (ClickData -> Safe) -> Safe : ¬ClickData -> Safe : ¬¬ClickData : ♢ClickData
¬A = A ⟶ a