{-# OPTIONS --type-in-type
#-}
open import NeilPrelude
open import Logic
module TemporalLogic
(Time : Set)
(_<'_ : Rel Time)
(irreflex : Irreflexive _<'_)
(transit : Transitive _<'_)
where
import StrictPreOrder
open StrictPreOrder _<'_ irreflex transit public
infixr 0 _⇒_
infixr 5 _∨_
infixr 6 _∧_
TPred = Time → Set
TimePred = TPred
_∨_ : TPred → TPred → TPred
(φ ∨ ψ) t = φ t ⊎ ψ t
_∧_ : TPred → TPred → TPred
(φ ∧ ψ) t = φ t × ψ t
_⇒_ : TPred → TPred → TPred
(φ ⇒ ψ) t = φ t → ψ t
⊥ : TPred
⊥ t = False
⊤ : TPred
⊤ t = True
¬_ : TPred → TPred
¬ φ = φ ⇒ ⊥
G : TPred → TPred
G φ t = (t' : Time) → t' > t → φ t'
H : TPred → TPred
H φ t = (t' : Time) → t' < t → φ t'
F : TPred → TPred
F φ t = Σ Time (λ t' → t' > t × φ t')
P : TPred → TPred
P φ t = Σ Time (λ t' → t' < t × φ t')
Between : Time → Time → TPred → Set
Between t₀ t₁ φ = (t : Time) → t > t₀ → t < t₁ → φ t
Between* : Time → Time → TPred → Set
Between* t₀ t₁ φ = (t : Time) → t ≥ t₀ → t ≤ t₁ → φ t
After : Time → TPred → TPred
After t₀ φ t₁ = Between t₀ t₁ φ
After* : Time → TPred → TPred
After* t₀ φ t₁ = Between* t₀ t₁ φ
Before : Time → TPred → TPred
Before t₁ φ t₀ = Between t₀ t₁ φ
Before* : Time → TPred → TPred
Before* t₁ φ t₀ = Between* t₀ t₁ φ
_U_ : TPred → TPred → TPred
(φ U ψ) t = F (ψ ∧ After t φ) t
private _S_ : TPred → TPred → TPred
(φ S ψ) t = P (ψ ∧ Before t φ) t
_Since_ = _S_
_S*_ : TPred → TPred → TPred
(φ S* ψ) t = P (ψ ∧ Before* t φ) t
Gʳ : TPred → TPred
Gʳ φ = φ ∧ G φ
Hʳ : TPred → TPred
Hʳ φ = φ ∧ H φ
Fʳ : TPred → TPred
Fʳ φ = φ ∨ F φ
Pʳ : TPred → TPred
Pʳ φ = φ ∨ P φ
_Uʳ_ : TPred → TPred → TPred
φ Uʳ ψ = ψ ∨ (φ ∧ (φ U ψ))
_Sʳ_ : TPred → TPred → TPred
φ Sʳ ψ = ψ ∨ (φ ∧ (φ S ψ))
_W_ : TPred → TPred → TPred
(φ W ψ) t = G (After t (¬ ψ) ⇒ After t φ) t
_Wʳ_ : TPred → TPred → TPred
φ Wʳ ψ = ψ ∨ (φ ∧ (φ W ψ))
private _B_ : TPred → TPred → TPred
φ B ψ = (φ S ψ) ∨ H φ
_Back-To_ = _B_
_Bʳ_ : TPred → TPred → TPred
φ Bʳ ψ = ψ ∨ (φ ∧ (φ B ψ))
Always : TPred → Set
Always = Π Time
FirstPoint : Set
FirstPoint = Always (Pʳ (H ⊥))
EndPoint : Set
EndPoint = Always (Fʳ (G ⊥))
Density : Set
Density = ∀ {φ} → Always (F φ ⇒ F (F φ))
NonBranching : Set
NonBranching = ∀ {φ} → Always ( (P (F φ) ⇒ (P φ ∨ φ ∨ F φ))
∧ (F (P φ) ⇒ (F φ ∨ φ ∨ P φ)))
lem-G : {φ ψ : TPred} → Always (G (φ ⇒ ψ) ⇒ G φ ⇒ G ψ)
lem-G t = S-comb₂
lemGn : {φ ψ : TPred} → Always (G (φ ⇒ ψ) ⇒ ¬ G ψ ⇒ ¬ G φ)
lemGn t φ⇒ψ = argument (lem-G t φ⇒ψ)
lem-GF : {φ ψ : TPred} → Always (G (φ ⇒ ψ) ⇒ F φ ⇒ F ψ)
lem-GF t φ⇒ψ (t' , lt , φ') = t' , lt , φ⇒ψ t' lt φ'
lem-NF⇒GN : {φ : TPred} → Always (¬ F φ ⇒ G (¬ φ))
lem-NF⇒GN t = curry2
lem-NG⇒FN : {φ : TPred} → EM → Always (¬ G φ ⇒ F (¬ φ))
lem-NG⇒FN em t = must-exist-not2 em
lem-NP⇒HN : {φ : TPred} → Always (¬ P φ ⇒ H (¬ φ))
lem-NP⇒HN t = curry2
lem-F⇒NGN : {φ : TPred} → Always (F φ ⇒ ¬ G (¬ φ))
lem-F⇒NGN t = flip uncurry2
lem-G⇒NFN : {φ : TPred} → Always (G φ ⇒ ¬ F (¬ φ))
lem-G⇒NFN t Gφ (t' , gt , nφt) = nφt (Gφ t' gt)
lem-NFN⇒G : {φ : TPred} → EM → Always (¬ F (¬ φ) ⇒ G φ)
lem-NFN⇒G em t = result2' (contradiction em) ∘ curry2
lem-NGN⇒F : {φ : TPred} → EM → Always (¬ G (¬ φ) ⇒ F φ)
lem-NGN⇒F em t = contradiction em ∘ argument curry2
lem-Gr : {φ : TPred} → EM → Always (¬ Gʳ φ ⇒ ¬ φ ∨ ¬ G φ)
lem-Gr {φ} em t nGrφ with em {φ t}
... | inr nφt = inl nφt
... | inl φt = left (flip (curry nGrφ)) em
lem-NGr⇒FrN : {φ : TPred} → EM → Always (¬ Gʳ φ ⇒ Fʳ (¬ φ))
lem-NGr⇒FrN em t nGrφ = right (lem-NG⇒FN em t) (lem-Gr em t nGrφ)
lem-Wʳ : {φ ψ : TPred} → EM → Always (Gʳ (φ ⇒ ψ) ⇒ (ψ Wʳ ¬ φ))
lem-Wʳ {φ} em t (φt⇒ψt , Gφ⇒ψ) with em {φ t}
... | inr nφt = inl nφt
... | inl φt with φt⇒ψt φt
... | ψt = inr (ψt , λ t' gt f u gt1 gt2 → Gφ⇒ψ u gt1 (contradiction em (f u gt1 gt2)))
lem-Wʳn' : {φ ψ : TPred} → EM → Always (Gʳ (¬ φ ⇒ ¬ ψ) ⇒ (¬ ψ Wʳ ¬ ¬ φ))
lem-Wʳn' = lem-Wʳ
lem-Wʳn : {φ ψ : TPred} → EM → Always (Gʳ (¬ φ ⇒ ¬ ψ) ⇒ (¬ ψ Wʳ φ))
lem-Wʳn {φ} {ψ} em t = result (map-⊎ (contradiction em) (second (result2' (argument (result3' NotNot))))) (lem-Wʳn' {φ} {ψ} em t)