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 Correspondence Categorical - - PowerPoint PPT Presentation
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
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
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
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
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]
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
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
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 . α → β)
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 → α
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
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:
= α × β < α × β > α × β
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
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 ⊲⊥ β
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.
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
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
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
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 = ⊥
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
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
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 : α × β → (α × β)
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
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
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
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