Mercurial > hg > Members > kono > Proof > automaton
annotate automaton-in-agda/src/automaton.agda @ 395:cd81e0869fac
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 Aug 2023 14:55:14 +0900 |
parents | 91781b7c65a8 |
children | c298981108c1 |
rev | line source |
---|---|
0 | 1 module automaton where |
2 | |
2 | 3 open import Data.Nat |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
4 open import Data.List |
58 | 5 open import Relation.Binary.PropositionalEquality hiding ( [_] ) |
6 open import logic | |
0 | 7 |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
8 record Automaton ( Q : Set ) ( Σ : Set ) |
0 | 9 : Set where |
1 | 10 field |
11 δ : Q → Σ → Q | |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
12 aend : Q → Bool |
1 | 13 |
14 open Automaton | |
0 | 15 |
65 | 16 accept : { Q : Set } { Σ : Set } |
17 → Automaton Q Σ | |
318 | 18 → Q |
65 | 19 → List Σ → Bool |
318 | 20 accept M q [] = aend M q |
21 accept M q ( H ∷ T ) = accept M ( δ M q H ) T | |
65 | 22 |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
23 moves : { Q : Set } { Σ : Set } |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
24 → Automaton Q Σ |
0 | 25 → Q → List Σ → Q |
318 | 26 moves M q [] = q |
27 moves M q ( H ∷ T ) = moves M ( δ M q H) T | |
0 | 28 |
141 | 29 trace : { Q : Set } { Σ : Set } |
30 → Automaton Q Σ | |
31 → Q → List Σ → List Q | |
32 trace {Q} { Σ} M q [] = q ∷ [] | |
33 trace {Q} { Σ} M q ( H ∷ T ) = q ∷ trace M ( (δ M) q H ) T | |
0 | 34 |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
35 reachable : { Q : Set } { Σ : Set } |
1 | 36 → (M : Automaton Q Σ ) |
60 | 37 → (astart q : Q ) |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
38 → (L : List Σ ) → Set |
60 | 39 reachable M astart q L = moves M astart L ≡ q |
0 | 40 |