Categorical Semantics for Functional Reactive Programming with - - PowerPoint PPT Presentation

categorical semantics for functional reactive programming
SMART_READER_LITE
LIVE PREVIEW

Categorical Semantics for Functional Reactive Programming with - - PowerPoint PPT Presentation

Categorical Semantics for Functional Reactive Programming with Temporal Recursion and Corecursion Wolfgang Jeltsch TT Kberneetika Instituut Tallinn, Estonia Teooriapevad Narva-Jesuus 1618 May 2014 Wolfgang Jeltsch (TT


slide-1
SLIDE 1

Categorical Semantics for Functional Reactive Programming with Temporal Recursion and Corecursion

Wolfgang Jeltsch

TTÜ Küberneetika Instituut Tallinn, Estonia

Teooriapäevad Narva-Jõesuus

16–18 May 2014

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 1 / 15

slide-2
SLIDE 2

Functional Reactive Programming (FRP)

programming paradigm for treating temporal aspects in a declarative fashion two key features:

time-dependent type membership temporal type constructors

Curry–Howard correspondence to temporal logic:

time-dependent trueness temporal operators

time:

linear not necessarily discrete

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 2 / 15

slide-3
SLIDE 3

Processes

process consists of a continuous part and optionally a terminal event: A ⊲′′ B: A B A different process types with different termination guarantees:

nontermination possible termination guaranteed termination guaranteed with upper bound on termination time

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 3 / 15

slide-4
SLIDE 4

Processes that deal with the present

processes that start immediately: A ⊲′ B: A B processes that may terminate immediately: A ⊲ B: B A B

⊲′ and ⊲ definable in terms of ⊲′′:

A ⊲′ B = A × A ⊲′′ B A ⊲ B = B + A ⊲′ B

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 4 / 15

slide-5
SLIDE 5

Abstract process categories (APCs)

cartesian closed category C with coproducts functors that model process type constructors:

⊲′′ : C × C → C

natural transformations that model FRP operations:

ideal monads ideal comonads further structure (not in this talk)

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 5 / 15

slide-6
SLIDE 6

Ideal monads

each A ⊲′ − is an ideal monad:

µ′

B : A ⊲′ (A ⊲ B) → A ⊲′ B

concatenation of a continuous part with a follow-up process: A ⊲′ (A ⊲ B): A B A ⊲′ B: A B

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 6 / 15

slide-7
SLIDE 7

Ideal comonads

each − ⊲′′ B is an ideal comonad:

δ′

A : A ⊲′′ B → (A ⊲′ B) ⊲′′ B

generation of a continuous part of shorter and shorter suffixes: A ⊲′′ B: A B

(A ⊲′ B) ⊲′′ B:

A ⊲′ B B

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 7 / 15

slide-8
SLIDE 8

Iteration of ideal multiplication and comultiplication

iterated concatenation via induction:

µC . A ⊲′ (B + C):

A B A ⊲′ B: A B iterated suffix generation via coinduction: A ⊲′′ B: A B

νC . (A × C) ⊲′′ B: νC . (A × C) ⊲′′ B

B

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 8 / 15

slide-9
SLIDE 9

Wanted: Stronger variants of these iterations

sequence of continuous parts may be infinite:

νC . A ⊲′ (B + C):

A A ⊲′ B: A nesting depth must be finite: A ⊲′′ B: A B

µC . (A × C) ⊲′′ B: µC . (A × C) ⊲′′ B

B

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 9 / 15

slide-10
SLIDE 10

Solution: Extending the ideal monad and comonad structure

each A ⊲′ − is a completely iterative monad: f : C → A ⊲′ (B + C) f∞ : C → A ⊲′ B each − ⊲′′ B is a recursive comonad: f : (A × C) ⊲′′ B → C f∗ : A ⊲′′ B → C

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 10 / 15

slide-11
SLIDE 11

Are these extensions reasonable?

check whether there are nontrivial instances of APCs that have the additional structure concrete process categories (CPCs) are instances of APCs do they have the required additional structure?

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 11 / 15

slide-12
SLIDE 12

Concrete process categories

make times explicit:

time scale can be any totally ordered set

express causality of operations:

the prefix of a result that ends at a time t can only depend

  • n the prefix of the argument that ends at t
  • perations expressed as families of prefix transformations, one for each t

process types with simple termination guarantee cannot be modeled:

termination is a liveness property

  • nly safety properties can be expressed, because only prefixes

are considered

the following process types can be modeled:

⊲∞ nontermination possible ⊲tb termination at or before tb guaranteed

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 12 / 15

slide-13
SLIDE 13

A constraint on time scales

infinitely many concatenations can be problematic:

νC . A ⊲′ (B + C):

A A ⊲′ B: A

?

analogous problem for suffix generation solution is to disallow “pathological” time scales:

every ascending sequence of times must be unbounded Achilles catches up with the Tortoise certain “interesting” time scales still allowed:

  • z + 1/n
  • z ∈ ∧ n ∈ \ {0}
  • Wolfgang Jeltsch (TTÜ Küberneetika Instituut)

FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 13 / 15

slide-14
SLIDE 14

Compatibility with different termination (non)guarantees

completely iterative monad:

⊲∞ infinitely many concatenations are no problem ⊲tb only finitely many concatenations can occur,

since all subprocesses terminate at or before tb recursive comonad:

⊲tb nesting depth is finite, since given process terminates ⊲∞ nesting depth is finite, since only finite prefixes of processes

are considered

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 14 / 15

slide-15
SLIDE 15

Categorical Semantics for Functional Reactive Programming with Temporal Recursion and Corecursion

Wolfgang Jeltsch

TTÜ Küberneetika Instituut Tallinn, Estonia

Teooriapäevad Narva-Jõesuus

16–18 May 2014

Wolfgang Jeltsch (TTÜ Küberneetika Instituut) FRP with Temporal Recursion and Corecursion Teooriapäevad Narva-Jõesuus 15 / 15