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