Programming in Linear Temporal Logic Correspondence Categorical - - PowerPoint PPT Presentation

programming in linear temporal logic
SMART_READER_LITE
LIVE PREVIEW

Programming in Linear Temporal Logic Correspondence Categorical - - PowerPoint PPT Presentation

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal CurryHoward Programming in Linear Temporal Logic Correspondence Categorical Semantics for Restricted LTL and FRP Wolfgang Jeltsch Hybrid Signals Functional Reactive


slide-1
SLIDE 1

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Programming in Linear Temporal Logic

Wolfgang Jeltsch

Brandenburgische Technische Universität Cottbus Cottbus, Germany

Seminar talk at the Institute of Cybernetics Tallinn, Estonia

February 10, 2011

slide-2
SLIDE 2

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

slide-3
SLIDE 3

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

slide-4
SLIDE 4

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Linear Temporal Logic

◮ trueness of a proposition depends on time ◮ times are natural numbers ◮ propositional logic extended with four new constructs:

ϕ ϕ will hold at the next time ϕ ϕ will always hold ϕ ϕ will eventually hold ϕ ⊲ ψ ϕ will hold for some time, and then ψ will hold

◮ for now only and :

◮ restricted LTL ◮ continuous time also possible

slide-5
SLIDE 5

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Embedding into predicate logic

◮ temporal formula ϕ can be translated into predicate

logic formula ϕ

◮ ϕ may contain a single free variable t that denotes

the time

◮ atomic propositions p correspond to predicates ˆ

p that take a time argument

◮ translation for propositional logic fragment:

p = ˆ

p(t)

ϕ ∧ ψ = ϕ ∧ ψ ⊤ = ⊤ ϕ ∨ ψ = ϕ ∨ ψ ⊥ = ⊥ ϕ → ψ = ϕ → ψ

◮ translation for and :

ϕ = ∀t′ ∈ [t, ∞) . ϕ[t′ /t] ϕ = ∃t′ ∈ [t, ∞) . ϕ[t′ /t]

slide-6
SLIDE 6

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Restricted LTL as a type system

◮ type inhabitation depends on time ◮ simple type system extended with two new type

constructors and

◮ temporal type α can be translated into dependent

type α

◮ α may contain a single-free variable t that denotes

the time

◮ translation for and :

α = Πt′ ∈ [t, ∞) . α[t′ /t] α = Σt′ ∈ [t, ∞) . α[t′ /t]

◮ concepts from Functional Reactive Programming (FRP):

behaviors events

◮ restricted LTL corresponds to a strongly typed form

  • f FRP

◮ t denotes start times of behaviors and events

slide-7
SLIDE 7

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

slide-8
SLIDE 8

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Basics

◮ categorical models should be CCCCs:

◮ LTL extends propositional logic ◮ FRP extends simply-typed λ-calculus

◮ components of a categorical model:

  • bjects propositions/types

morphisms time-independent proofs/functions: f : α → β ⇒ f : Πt . α → β

◮ and are (endo)functors:

f : α → β

f : α → β

f : α → β

f : α → β

◮ start time consistency is ensured:

: (Πt . α → β) → (Πt . α → β) : (Πt . α → β) → (Πt . α → β)

slide-9
SLIDE 9

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Operations on behaviors

◮ is a comonad:

head : α → α tails : α → α

◮ is a strong cartesian functor:

units : 1 → 1 zip : α × β → (α × β)

◮ is not an applicative functor:

◮ lifting of pure values would have to be possible:

const : α → α

◮ would break start time consistency:

const : Πt . α → Πt′ ∈ [t, ∞) . α[t′ /t]

◮ however, this is possible:

f : 1 → α

f ◦ units : 1 → α

slide-10
SLIDE 10

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Operations on events

◮ is a monad:

now : α → α join : α → α

◮ is not a strong monad:

◮ time shifting of values would have to be possible:

shift : α × β → (α × β)

◮ would break start time consistency:

shift : Πt . α × β → Σt′ ∈ [t, ∞) . α[t′ /t] × β[t′ /t]

◮ however, is -strong:

age : α × β → (α × β)

◮ sampling can be derived:

sample : α × β → (α × β) sample = (head × id) ◦ age

slide-11
SLIDE 11

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

From S4 to restricted LTL

◮ until now, we have categorical models for CS4/IS4 ◮ no big surprise:

◮ classically, restricted LTL is a specialization of S4 ◮ intuitionistically, it is too

◮ classical S4 and restricted LTL differ in their restrictions

  • n the accessibility relation:

S4 reflexive order

  • restr. LTL total reflexive order

◮ add a further operation that ensures totality of time:

race : α × β → (α × β + α × β + α × β)

◮ possible outcomes of time comparison represented

by the different alternatives:

= α × β < α × β > α × β

slide-12
SLIDE 12

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

slide-13
SLIDE 13

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

⊲-LTL and its corresponding FRP dialect

◮ translation of ⊲-formulas into predicate logic formulas:

ϕ ⊲ ψ = ∃t′ ∈ (t, ∞) . (∀t′′ ∈ [t, t′) . ϕ[t′′ /t]) ∧ ψ[t′ /t]

◮ ⊲ as a type constructor of FRP:

α⊲β = Σt′ ∈ (t, ∞) . (Πt′′ ∈ [t, t′) . α[t′′ /t])× β[t′ /t]

◮ components of a value of type α ⊲ β:

◮ a finite behavior with values of type α ◮ a terminating event with a value of type β

◮ introduction of weak variant of ⊲ that does not

guarantee termination

◮ notation:

⊲⊥ strong variant (⊲ as defined above) ⊲⊤ weak variant

◮ and now derivable:

α = α ⊲⊤ 0 β = β + 1 ⊲⊥ β

slide-14
SLIDE 14

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Applications of ⊲-types

◮ ⊲-types are useful as such:

◮ temperatures from some sensor that may be detached

from the computer: R ⊲⊤ 1

◮ dialog window:

UI ⊲⊤ α etc.

◮ ⊲-types are useful in combination with (co)induction:

◮ audio signal that may switch between stereo

and mono: νσ . (R × R) ⊲⊤ R ⊲⊤ σ

◮ positions of a pen that might be taken off from

the drawing area: νσ . (R × R) ⊲⊤ 1 ⊲⊤ σ etc.

slide-15
SLIDE 15

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The ⊲-functor

◮ categorical model C is a CCCC ◮ derive a category U from C:

Obj U

= Obj C × Obj C × {⊥, ⊤}

hom((α1, β1, w1), (α2, β2, w2))

=       

hom(α1, α2) × hom( β1, β2) if w1 w2

  • therwise

◮ ⊲ is a functor from U to C ◮ notation:

α ⊲w β = ⊲(α, β, w)

◮ applying ⊲ to morphisms allows for several things:

◮ mapping of values of the behavior part ◮ mapping of value of the terminating event ◮ weakening

slide-16
SLIDE 16

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Comonadic and monadic structure

◮ _ ⊲w β is a comonad:

head : α ⊲w β → α tails : α ⊲w β → (α ⊲w β) ⊲w β

◮ β = 0 and w = ⊤ leads to comonadic structure of ◮ α ⊲w _ is an ideal monad:

  • ptjoin : α ⊲w ( β + α ⊲w β) → α ⊲w β

◮ monad can be derived:

now : β → ( β + α ⊲w β) join : ( β + α ⊲w β) + α ⊲w ( β + α ⊲w β) → β + α ⊲w β

◮ α = 1 and w = ⊥ leads to monadic structure of

slide-17
SLIDE 17

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Monoidal structure

◮ make U a symmetric monoidal category:

(α1, β1, w1) ⊗ (α2, β2, w2) = (α1 × α2, ρ, w1 ⊓ w2)

I = (1, 0, ⊤) where

ρ = β1 × β2 + β1 × α2 ⊲w2 β2 + α1 ⊲w1 β1 × β2

◮ ⊲ is a strong symmetric monoidal functor from U to C:

merge : α1 ⊲w1 β1 × α2 ⊲w2 β2 → α1 × α2 ⊲w1⊓w2 ρ never : 1 ⊲⊤ 0

slide-18
SLIDE 18

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Specializations

◮ ⊲ is a strong symmetric monoidal functor from U to C:

merge : α1 ⊲w1 β1 × α2 ⊲w2 β2 → α1 × α2 ⊲w1⊓w2 ρ never : 1 ⊲⊤ 0 where

ρ = β1 × β2 + β1 × α2 ⊲w2 β2 + α1 ⊲w1 β1 × β2

◮ strong cartesian functor structure of :

β1 = β2 = 0

w1 = w2 = ⊤

◮ from merge to age:

β1 = 0

w1 = ⊤

α2 = 1

w2 = ⊥

◮ from merge to race:

α1 = α2 = 1

w1 = w2 = ⊥

slide-19
SLIDE 19

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The inverse of merge

◮ the type of the terminating event:

ρ = β1 × β2 + β1 × α2 ⊲w2 β2 + α1 ⊲w1 β1 × β2

◮ drop information from the terminating event:

restricti : ρ → βi + αi ⊲wi βi restricti = [ι1 ◦ πi, ιi ◦ πi, ι1−i ◦ πi]

◮ recover the original ⊲-values:

recoveri : α1 × α2 ⊲w1⊓w2 ρ → αi ⊲wi βi recoveri = optjoin ◦ (πi ⊲ restricti)

◮ combine the recovered values:

merge−1 : α1 × α2 ⊲w1⊓w2 ρ → α1 ⊲ β1 × α2 ⊲ β2 merge−1 = recover1, recover2

slide-20
SLIDE 20

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

slide-21
SLIDE 21

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

in LTL and FRP

◮ use N as the set of times ◮ translation of -formulas into predicate logic formulas:

ϕ = ϕ[t + 1/t]

◮ as a type constructor of FRP:

α = α[t + 1/t]

◮ value of type α is a value of type α occurring

at the next time

◮ semantically, is just a strong cartesian functor:

f : α → β

f : α → β

unit : 1 → 1 pair : α × β → (α × β)

slide-22
SLIDE 22

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Deriving the other constructs

◮ , , and ⊲ derivable via induction and coinduction:

α = νσ . α × σ β = µσ . β + σ α ⊲⊥ β = µσ . α × ( β + σ) α ⊲⊤ β = νσ . α × ( β + σ)

◮ interesting exercise:

◮ derive all operations of ⊲-FRP from the -operations ◮ proof that the derived operations fulfill the necessary

laws

slide-23
SLIDE 23

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Advanced dataflow programming

◮ -FRP is a kind of dataflow language:

◮ streams over α:

α

◮ partial streams over α:

(1 + α) × νσ . 1 ⊲⊤ (α × σ)

◮ more powerful than traditional dataflow languages:

◮ productive partial streams over α:

(1 + α) × νσ . 1 ⊲⊥ (α × σ)

◮ streams with values of different type

slide-24
SLIDE 24

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Shifting

◮ fby operator appends a stream to an initial value:

fby : α × α → α

◮ needs to shift values to the future ◮ cannot be done implicitely, since it would break

start time consistency

◮ can be made possible by introducing tensorial strength:

shift : α × β → (α × β)

◮ simpler operator is sufficient:

later : α → α

◮ is now an applicative functor

slide-25
SLIDE 25

Programming in Linear Temporal Logic Wolfgang Jeltsch The Temporal Curry–Howard Correspondence Categorical Semantics for Restricted LTL and FRP Hybrid Signals Functional Reactive Dataflow Programming

Programming in Linear Temporal Logic

Wolfgang Jeltsch

Brandenburgische Technische Universität Cottbus Cottbus, Germany

Seminar talk at the Institute of Cybernetics Tallinn, Estonia

February 10, 2011