Temporal-Logic Combinators Neil Sculthorpe Functional Programming - - PowerPoint PPT Presentation

temporal logic combinators
SMART_READER_LITE
LIVE PREVIEW

Temporal-Logic Combinators Neil Sculthorpe Functional Programming - - PowerPoint PPT Presentation

Introduction Operators Example Properties Summary Temporal-Logic Combinators Neil Sculthorpe Functional Programming Laboratory School of Computer Science University of Nottingham United Kingdom nas@cs.nott.ac.uk Functional Programming


slide-1
SLIDE 1

Introduction Operators Example Properties Summary

Temporal-Logic Combinators

Neil Sculthorpe

Functional Programming Laboratory School of Computer Science University of Nottingham United Kingdom nas@cs.nott.ac.uk

Functional Programming Laboratory Away Day Buxton, England 8th July 2011

Neil Sculthorpe Temporal-Logic Combinators

slide-2
SLIDE 2

Introduction Operators Example Properties Summary

What is Temporal Logic?

A modal logic where propositions are quantified over time. Also known as tense logic. Useful for reasoning about time-varying values.

Neil Sculthorpe Temporal-Logic Combinators

slide-3
SLIDE 3

Introduction Operators Example Properties Summary

What is Time?

A temporal logic has an underlying time domain. The nature of the time domain can vary. E.g.

Continuous or Discrete Linear, Cyclic or Branching Finite or Infinite

But we assume it is a pre-order.

Neil Sculthorpe Temporal-Logic Combinators

slide-4
SLIDE 4

Introduction Operators Example Properties Summary

Agda Encoding

Neil Sculthorpe Temporal-Logic Combinators

slide-5
SLIDE 5

Introduction Operators Example Properties Summary

Agda Encoding

Temporal Predicates

TPred = Time → Set

Neil Sculthorpe Temporal-Logic Combinators

slide-6
SLIDE 6

Introduction Operators Example Properties Summary

Agda Encoding

Temporal Predicates

TPred = Time → Set

The standard temporal-logic combinators can then be encoded directly in Agda.

Neil Sculthorpe Temporal-Logic Combinators

slide-7
SLIDE 7

Introduction Operators Example Properties Summary

Logical Operators

Lifted Operators

∧ : TPred → TPred → TPred (ϕ ∧ ψ) t = ϕ t × ψ t ∨ : TPred → TPred → TPred (ϕ ∨ ψ) t = ϕ t ⊎ ψ t ⇒ : TPred → TPred → TPred (ϕ ⇒ ψ) t = ϕ t → ψ t ⊥ : TPred ⊥ t = False ⊤ : TPred ⊤ t = True

Neil Sculthorpe Temporal-Logic Combinators

slide-8
SLIDE 8

Introduction Operators Example Properties Summary

Logical Operators

Defining Negation

¬ : TPred → TPred ¬ ϕ = ϕ ⇒ ⊥

Neil Sculthorpe Temporal-Logic Combinators

slide-9
SLIDE 9

Introduction Operators Example Properties Summary

Priorean Operators

First devised by Arthur Prior [Pri67].

Neil Sculthorpe Temporal-Logic Combinators

slide-10
SLIDE 10

Introduction Operators Example Properties Summary

Priorean Operators

First devised by Arthur Prior [Pri67]. Global ‘‘At all points in the future’’

G : TPred → TPred G ϕ t = (t′ : Time) → (t′ > t) → ϕ t′

Neil Sculthorpe Temporal-Logic Combinators

slide-11
SLIDE 11

Introduction Operators Example Properties Summary

Priorean Operators

First devised by Arthur Prior [Pri67]. Global ‘‘At all points in the future’’

G : TPred → TPred G ϕ t = (t′ : Time) → (t′ > t) → ϕ t′

History ‘‘At all points in the past’’

H : TPred → TPred H ϕ t = (t′ : Time) → (t′ < t) → ϕ t′

Neil Sculthorpe Temporal-Logic Combinators

slide-12
SLIDE 12

Introduction Operators Example Properties Summary

Priorean Operators

Future ‘‘At some point in the future’’

F : TPred → TPred F ϕ t = Σ [t′ : Time ] ((t′ > t) × ϕ t′)

Past ‘‘At some point in the past’’

P : TPred → TPred P ϕ t = Σ [t′ : Time ] ((t′ < t) × ϕ t′) syntax Σ A (λ a → B) = Σ [a : A] B

Neil Sculthorpe Temporal-Logic Combinators

slide-13
SLIDE 13

Introduction Operators Example Properties Summary

Reflexive Priorean Operators

Gr : TPred → TPred Gr ϕ = ϕ ∧ G ϕ Hr : TPred → TPred Hr ϕ = ϕ ∧ H ϕ Fr : TPred → TPred Fr ϕ = ϕ ∨ F ϕ Pr : TPred → TPred Pr ϕ = ϕ ∨ P ϕ

Neil Sculthorpe Temporal-Logic Combinators

slide-14
SLIDE 14

Introduction Operators Example Properties Summary

Since/Until Operators

There are also more expressive binary operators, such as Since and Until [Bur82]. Since

S : TPred → TPred → TPred ϕ S ψ ≈ ϕ has held since ψ held

Until

U : TPred → TPred → TPred ϕ U ψ ≈ ϕ will hold until ψ holds

Neil Sculthorpe Temporal-Logic Combinators

slide-15
SLIDE 15

Introduction Operators Example Properties Summary

Properties of Time

It is possible to state temporal formulae that hold if and only if the underlying time domain has a specific property [Ven01]. Time-Domain Properties

FirstPoint : TPred FirstPoint = Pr (H ⊥) EndPoint : TPred EndPoint = Fr (G ⊥)

Neil Sculthorpe Temporal-Logic Combinators

slide-16
SLIDE 16

Introduction Operators Example Properties Summary

Properties of Time

It is possible to state temporal formulae that hold if and only if the underlying time domain has a specific property [Ven01]. Time-Domain Properties

FirstPoint : TPred FirstPoint = Pr (H ⊥) EndPoint : TPred EndPoint = Fr (G ⊥) Density : Set Density = (ϕ : TPred) → Always (F ϕ ⇒ F (F ϕ)) where Always : TPred → Set Always ϕ = (t : Time) → ϕ t

Neil Sculthorpe Temporal-Logic Combinators

slide-17
SLIDE 17

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

FRP is based around time-varying values called signals: Signal A = Time → A

Neil Sculthorpe Temporal-Logic Combinators

slide-18
SLIDE 18

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

FRP is based around time-varying values called signals: Signal A = Time → A Typically, an FRP time domain:

is linear; has a start point; does not have an end point; may be either continuous or discrete.

Neil Sculthorpe Temporal-Logic Combinators

slide-19
SLIDE 19

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

Time-Varying Equality

. = : Signal A → Signal A → TPred (s1 . = s2) t = s1 t ≡ s2 t

Neil Sculthorpe Temporal-Logic Combinators

slide-20
SLIDE 20

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

Time-Varying Equality

. = : Signal A → Signal A → TPred (s1 . = s2) t = s1 t ≡ s2 t

Causality

Causal : (Signal A → Signal B) → Set Causal f = ∀ (s1 s2) → Always (Hr (s1 . = s2) ⇒ f s1 . = f s2)

Neil Sculthorpe Temporal-Logic Combinators

slide-21
SLIDE 21

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

Time-Varying Equality

. = : Signal A → Signal A → TPred (s1 . = s2) t = s1 t ≡ s2 t

Causality

Causal : (Signal A → Signal B) → Set Causal f = ∀ (s1 s2) → Always (Hr (s1 . = s2) ⇒ f s1 . = f s2) Causal f = ∀ (s1 s2 t t′) → t′ t → s1 t′ ≡ s2 t′ → f s1 t ≡ f s2 t

Neil Sculthorpe Temporal-Logic Combinators

slide-22
SLIDE 22

Introduction Operators Example Properties Summary

Functional Reactive Programming (FRP)

Time-Varying Equality

. = : Signal A → Signal A → TPred (s1 . = s2) t = s1 t ≡ s2 t

Causality

Causal : (Signal A → Signal B) → Set Causal f = ∀ (s1 s2) → Always (Hr (s1 . = s2) ⇒ f s1 . = f s2) Causal f = ∀ (s1 s2 t t′) → t′ t → s1 t′ ≡ s2 t′ → f s1 t ≡ f s2 t

Decoupledness

Decoupled : (Signal A → Signal B) → Set Decoupled f = ∀ (s1 s2) → Always (H (s1 . = s2) ⇒ f s1 . = f s2)

Neil Sculthorpe Temporal-Logic Combinators

slide-23
SLIDE 23

Introduction Operators Example Properties Summary

Summary

Temporal-logic combinators are a useful notation for expressing and reasoning about time-varying properties. They (often) allow definitions to be stated intuitively and concisely. See my thesis for more FRP-based examples [Scu11].

Neil Sculthorpe Temporal-Logic Combinators

slide-24
SLIDE 24

Introduction Operators Example Properties Summary

References

John P. Burgess. Axioms for tense logic. I. “Since” and “Until”. Notre Dame Journal of Formal Logic, 23(4):367–374, 1982. Arthur N. Prior. Past, Present and Future. Oxford University Press, 1967. Neil Sculthorpe. Towards Safe and Efficient Functional Reactive Programming. PhD thesis, School of Computer Science, University of Nottingham, 2011. Yde Venema. Temporal logic. In The Blackwell Guide to Philosophical Logic, chapter 10, pages 203–223. Blackwell, 2001.

Neil Sculthorpe Temporal-Logic Combinators