annotate a11/lecture.ind @ 413:ad086c3161d7 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 18 Jun 2024 14:05:44 +0900
parents b85402051cdb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 -title: ωオートマトン
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 オートマトンは入力を受け付けるかどうかを問題にするので計算は有限時間に終わる。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 しかし、サーバなどの計算は終了することは想定されてない。入力が無限にある場合を考えたい。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 例えば、信号機は停まらずにずーっと動くことが期待されていて、正しい信号機の動作とそうでない動作がある。そして信号機はオートマトン的に動作している。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 --ωオートマトンと様相論理
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 これらは時間の様相を表す論理に関係している。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13     [] p ずーっとpが成立する
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14     <> p いつかpが成立する
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 これを組み合わせると
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18     <> [] p いつからか、ずーっとpが成立するようになる
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19     [] <> p ずーっと、いつかpが起きる
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 [] はbox、<>はdiamonと呼ばれたりする。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 [] p = ¬ ( <> ¬ p )
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 <> p = ¬ ( [] ¬ p )
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 である。[] <> p をωオートマトンとして考えることができる。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 ¬ p
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 ------------>
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 [] <> p * [] <> p
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 <-----------
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 p
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 p と ¬ p で二つの状態 ( [] <> p * と [] <> p)を行き来する。
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 data States3 : Set where
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 ts* : States3
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 ts : States3
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 transition3 : States3 → Bool → States3
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 transition3 ts* true = ts*
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 transition3 ts* false = ts
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 transition3 ts true = ts*
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 transition3 ts false = ts
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 mark1 : States3 → Bool
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 mark1 ts* = true
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 mark1 ts = false
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 ωa1 : Automaton States3 Bool
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 ωa1 = record {
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 δ = transition3
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 ; astart = ts*
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 ; aend = mark1
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 }
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
58 ここで、[] <> p * ( 上では ts* ) を無限回通れば、 [] <> p が成立していることになる。(Buchi automaton )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
59
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
60 これの否定は、<> [] ( ¬ p ) ということになる。これは、ある時点からずーっと ¬ p が続く。(Muller automaton )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
61
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
62 --ωオートマトンの定義
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
63
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
64 オートマトンの定義は同じものを用いる。ただし、入力は無限にある。
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
66 record Automaton ( Q : Set ) ( Σ : Set )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
67 : Set where
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
68 field
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
69 δ : Q → Σ → Q
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
70 astart : Q
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
71 aend : Q → Bool
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
72
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
73 automaton の定義にはもともと入力の実装が何かは記述されていない。
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
74
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
75 Agda では無限の長さのリストを扱うことはできない。その代わり、自然数 n から入力Σを生成する関数( ℕ → Σ )を用いる。
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
76 これを用いて、
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
79 ω-run : { Q Σ : Set } → (Ω : Automaton Q Σ ) → ℕ → ( ℕ → Σ ) → Q
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
80 ω-run Ω zero s = astart Ω
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
81 ω-run Ω (suc n) s = δ Ω (ω-run Ω n s) ( s n )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
82
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
83 と言う形でオートマトンが無限に実行される。
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
84
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
85 この無限長の入力をどう受け付けるかを定義する必要がある。これには二通りの方法がある。
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
86
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
87 record Muller { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
88 field
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
89 from : ℕ
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
90 stay : (x : Q) → (n : ℕ ) → n > from → aend Ω ( ω-run Ω x S n ) ≡ true
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
91
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
92 record Buchi { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
93 field
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
94 next : (n : ℕ ) → ℕ
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
95 infinite : (x : Q) → (n : ℕ ) → aend Ω ( ω-run Ω x S (n + (suc (next n)))) ≡ true
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
98 Muller ではある時刻から先では、aend で定義される状態の集合にずーっと留まる。Buchi ではaendで定義されるある状態の集合を無限回通る。
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
100 --Muller automaton と Buchi automaton の関係
127
0e8a0e50ed26 add some files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
412
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
102 B→M : { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) → Q
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
103 → Muller Ω S → ¬ ( Buchi record { δ = δ Ω ; aend = λ q → not (aend Ω q)} S )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
104
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
105 M→B : { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) → Q
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
106 → Buchi Ω S → ¬ ( Muller record { δ = δ Ω ; aend = λ q → not (aend Ω q)} S )
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
107
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
108 これが証明できる
b85402051cdb add mul
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 127
diff changeset
109