annotate automaton-in-agda/src/omega-automaton.agda @ 294:248711134141

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 29 Dec 2021 19:08:28 +0900
parents 3fa72793620b
children a3fb231feeb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module omega-automaton where
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
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
17 ω-run : { Q Σ : Set } → (Ω : Automaton Q Σ ) → (astart : Q ) → ℕ → ( ℕ → Σ ) → Q
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
18 ω-run Ω x zero s = x
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
19 ω-run Ω x (suc n) s = δ Ω (ω-run Ω x n s) ( s n )
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
21 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
22 -- accept as Buchi automaton
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
23 --
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
24 record Buchi { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 field
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 from : ℕ
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
27 stay : (x : Q) → (n : ℕ ) → n > from → aend Ω ( ω-run Ω x n S ) ≡ true
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 open Buchi
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
31 -- after sometimes, always p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
32 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
33 -- not p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
34 -- ------------>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
35 -- <> [] p * <> [] p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
36 -- <-----------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
37 -- p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
38
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
40 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
41 -- accept as Muller automaton
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
42 --
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
43 record Muller { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 field
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
45 next : (n : ℕ ) → ℕ
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
46 infinite : (x : Q) → (n : ℕ ) → aend Ω ( ω-run Ω x (n + (next n)) S ) ≡ true
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
48 -- always sometimes p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
49 --
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
50 -- not p
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 -- ------------>
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 -- [] <> p * [] <> p
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 -- <-----------
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 -- p
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 data States3 : Set where
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 ts* : States3
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 ts : States3
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 transition3 : States3 → Bool → States3
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 transition3 ts* true = ts*
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 transition3 ts* false = ts
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 transition3 ts true = ts*
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 transition3 ts false = ts
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 mark1 : States3 → Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 mark1 ts* = true
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 mark1 ts = false
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 ωa1 : Automaton States3 Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 ωa1 = record {
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 δ = transition3
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 ; aend = mark1
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 true-seq : ℕ → Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 true-seq _ = true
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 false-seq : ℕ → Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 false-seq _ = false
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 flip-seq : ℕ → Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 flip-seq zero = false
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
84 flip-seq (suc n) = not ( flip-seq n )
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
86 lemma0 : Muller ωa1 flip-seq
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
87 lemma0 = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
88 next = λ n → suc (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
89 ; infinite = lemma01
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
90 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
91 lemma01 : (x : States3) (n : ℕ) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
92 aend ωa1 (ω-run ωa1 x (n + suc (suc n)) flip-seq) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
93 lemma01 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
94
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
95 lemma1 : Buchi ωa1 true-seq
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 lemma1 = record {
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 from = zero
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
98 ; stay = {!!}
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 } where
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
100 lem1 : ( n : ℕ ) → n > zero → aend ωa1 (ω-run ωa1 {!!} n true-seq ) ≡ true
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 lem1 zero ()
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
102 lem1 (suc n) (s≤s z≤n) with ω-run ωa1 {!!} n true-seq
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
103 lem1 (suc n) (s≤s z≤n) | ts* = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
104 lem1 (suc n) (s≤s z≤n) | ts = {!!}
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 ωa2 : Automaton States3 Bool
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 ωa2 = record {
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 δ = transition3
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
109 ; aend = λ x → not ( mark1 x )
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 }
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
112 flip-dec : (n : ℕ ) → Dec ( flip-seq n ≡ true )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
113 flip-dec n with flip-seq n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
114 flip-dec n | false = no λ ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
115 flip-dec n | true = yes refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
116
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
117 flip-dec1 : (n : ℕ ) → flip-seq (suc n) ≡ ( not ( flip-seq n ) )
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
118 flip-dec1 n = let open ≡-Reasoning in
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
119 flip-seq (suc n )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
120 ≡⟨⟩
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
121 ( not ( flip-seq n ) )
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
122
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
123
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 24
diff changeset
124 flip-dec2 : (n : ℕ ) → not flip-seq (suc n) ≡ flip-seq n
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
125 flip-dec2 n = {!!}
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
126
23
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
127
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
128 record flipProperty : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
129 field
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
130 flipP : (n : ℕ) → ω-run ωa2 {!!} {!!} ≡ ω-run ωa2 {!!} {!!}
23
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
131
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
132 lemma2 : Muller ωa2 flip-seq
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 lemma2 = record {
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
134 next = next
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
135 ; infinite = {!!}
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 } where
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
137 next : ℕ → ℕ
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
138 next = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
139 infinite' : (n m : ℕ) → n ≥″ m → aend ωa2 {!!} ≡ true → aend ωa2 {!!} ≡ true
24
9406c2571fe7 naccept1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
140 infinite' = {!!}
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
141 infinite : (n : ℕ) → aend ωa2 {!!} ≡ true
24
9406c2571fe7 naccept1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
142 infinite = {!!}
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
144 lemma3 : Buchi ωa1 false-seq → ⊥
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 lemma3 = {!!}
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
147 lemma4 : Muller ωa1 flip-seq → ⊥
21
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 lemma4 = {!!}
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
ddf5f2f5fde8 add omega
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155