annotate automaton-in-agda/src/temporal-logic.agda @ 327:4aa0ebd75673

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 21 Jan 2022 12:31:34 +0900
parents automaton-in-agda/src/omega-automaton.agda@a3fb231feeb9
children cd73fe566291
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
327
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
1 module temporal-logic where
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level renaming ( suc to succ ; zero to Zero )
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Nat
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.List
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Maybe
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
7 -- open import Data.Bool using ( Bool ; true ; false ; _∧_ ) renaming ( not to negate )
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Relation.Binary.PropositionalEquality hiding ( [_] )
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
9 open import Relation.Nullary -- using (not_; Dec; yes; no)
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.Empty
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
12 open import logic
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import automaton
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open Automaton
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
326
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
18 open import nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
19 open import Data.Nat.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
20
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
21 data LTTL ( V : Set ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
22 s : V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
23 ○ : LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
24 □ : LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
25 ⋄ : LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
26 _U_ : LTTL V → LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
27 t-not : LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
28 _t\/_ : LTTL V → LTTL V → LTTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
29 _t/\_ : LTTL V → LTTL V → LTTL V
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
326
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
31 {-# TERMINATING #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
32 M1 : { V : Set } → (ℕ → V → Bool) → ℕ → LTTL V → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
33 M1 σ i (s x) = σ i x ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
34 M1 σ i (○ x) = M1 σ (suc i) x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
35 M1 σ i (□ p) = (j : ℕ) → i ≤ j → M1 σ j p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
36 M1 σ i (⋄ p) = ¬ ( M1 σ i (t-not p) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
37 M1 σ i (p U q) = ¬ ( ( j : ℕ) → i ≤ j → ¬ (M1 σ j q ∧ (( k : ℕ) → i ≤ k → k < j → M1 σ j p )) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
38 M1 σ i (t-not p) = ¬ ( M1 σ i p )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
39 M1 σ i (p t\/ p₁) = M1 σ i p ∧ M1 σ i p₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
40 M1 σ i (p t/\ p₁) = M1 σ i p ∨ M1 σ i p₁
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
326
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
42 data LITL ( V : Set ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
43 iv : V → LITL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
44 i○ : LITL V → LITL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
45 _&_ : LITL V → LITL V → LITL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
46 i-not : LITL V → LITL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
47 _i\/_ : LITL V → LITL V → LITL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
48 _i/\_ : LITL V → LITL V → LITL V
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
326
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
50 open import Relation.Binary.Definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
51 open import Data.Unit using ( tt ; ⊤ )
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
326
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
53 {-# TERMINATING #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
54 MI : { V : Set } → (ℕ → V → Bool) → (i j : ℕ) → i ≤ j → LITL V → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
55 MI σ i j lt (iv x) = σ i x ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
56 MI σ i j lt (i○ x) with <-cmp i j
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
57 ... | tri< a ¬b ¬c = MI σ (suc i) j {!!} x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
58 ... | tri≈ ¬a b ¬c = ⊤
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
59 ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> lt c)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
60 MI σ i j lt (p & q) = ¬ ( ( k : ℕ) → (i<k : i ≤ k) → (k<j : k ≤ j) → ¬ ( MI σ i k i<k p ∧ MI σ k j k<j p))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
61 MI σ i j lt (i-not p) = ¬ ( MI σ i j lt p )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
62 MI σ i j lt (p i\/ p₁) = MI σ i j lt p ∧ MI σ i j lt p₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
63 MI σ i j lt (p i/\ p₁) = MI σ i j lt p ∨ MI σ i j lt p₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
64
327
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
65 data QBool ( V : Set ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
66 qb : Bool → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
67 qv : V → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
68 exists : V → QBool V → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
69 b-not : QBool V → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
70 _b\/_ : QBool V → QBool V → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
71 _b/\_ : QBool V → QBool V → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
72
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
73 {-# TERMINATING #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
74 SQ1 : { V : Set } → ((x y : V) → Dec ( x ≡ y)) → QBool V → V → Bool → QBool V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
75 SQ1 {V} dec (qb x) v t = qb x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
76 SQ1 {V} dec (qv x) v t with dec x v
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
77 ... | yes _ = qb t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
78 ... | no _ = qv x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
79 SQ1 {V} dec (exists x p) v t = SQ1 dec (SQ1 dec p x true) v t b\/ SQ1 dec (SQ1 dec p x false) v t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
80 SQ1 {V} dec (b-not p) v t = b-not (SQ1 dec p v t )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
81 SQ1 {V} dec (p b\/ p₁) v t = SQ1 dec p v t b\/ SQ1 dec p₁ v t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
82 SQ1 {V} dec (p b/\ p₁) v t = SQ1 dec p v t b/\ SQ1 dec p₁ v t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
83
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
84 {-# TERMINATING #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
85 MQ : { V : Set } → (V → Bool) → ((x y : V) → Dec ( x ≡ y)) → QBool V → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
86 MQ {V} val dec (qb x) = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
87 MQ {V} val dec (qv x) = val x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
88 MQ {V} val dec (exists x p) = MQ val dec ( SQ1 dec p x true b\/ SQ1 dec p x false )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
89 MQ {V} val dec (b-not p) = not ( MQ val dec p )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
90 MQ {V} val dec (p b\/ p₁) = MQ val dec p \/ MQ val dec p₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
91 MQ {V} val dec (p b/\ p₁) = MQ val dec p /\ MQ val dec p₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
92
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
93 data QPTL ( V : Set ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
94 qs : V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
95 q○ : QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
96 q□ : QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
97 q⋄ : QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
98 q-exists : V → QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
99 q-not : QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
100 _q\/_ : QPTL V → QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
101 _q/\_ : QPTL V → QPTL V → QPTL V
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
102