Mercurial > hg > Members > kono > Proof > automaton
annotate agda/sbconst1.agda @ 84:29d81bcff049
found done
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 09 Nov 2019 07:47:32 +0900 |
parents | aa15eff1aeb3 |
children |
rev | line source |
---|---|
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 module sbconst1 where |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 open import Level renaming ( suc to succ ; zero to Zero ) |
44 | 4 open import Data.Nat hiding ( _≟_ ) |
5 open import Data.Fin | |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 open import Data.List |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 open import Data.Maybe |
44 | 8 open import Data.Bool using ( Bool ; true ; false ; _∧_ ) |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 open import Relation.Binary.PropositionalEquality hiding ( [_] ) |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 open import Relation.Nullary using (¬_; Dec; yes; no) |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 open import Data.Product |
44 | 12 open import finiteSet |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 open import automaton |
34 | 15 open import nfa-list |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 open Automaton |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 open NAutomaton |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 open FiniteSet |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 |
44 | 21 list2sbst : {Q : Set} { n : ℕ } → FiniteSet Q {n} → List Q → Q → Bool |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 list2sbst N [] _ = false |
44 | 23 list2sbst N ( h ∷ t ) q with F←Q N q ≟ F←Q N h |
13
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 ... | yes _ = true |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 ... | no _ = list2sbst N t q |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
02b4ecc9972c
start exp version of subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
44 | 28 δconv : { Q : Set } { Σ : Set } { n : ℕ } → FiniteSet Q {n} → ( nδ : Q → Σ → List Q ) → (Q → Bool) → Σ → (Q → Bool) |
29 δconv {Q} { Σ} { n} N nδ f i q = exists N ( λ r → f r ∧ list2sbst N (nδ r i) q ) | |
14 | 30 |
44 | 31 subset-construction : { Q : Set } { Σ : Set } { n : ℕ } → FiniteSet Q {n} → |
14 | 32 (NAutomaton Q Σ ) → (Automaton (Q → Bool) Σ ) |
33 subset-construction {Q} { Σ} {n} N NFA = record { | |
34 δ = λ q x → δconv N ( nδ NFA ) q x | |
35 ; astart = astart1 | |
36 ; aend = aend1 | |
37 } where | |
38 astart1 : Q → Bool | |
15 | 39 astart1 = list2sbst N [ nstart NFA ] |
14 | 40 aend1 : (Q → Bool) → Bool |
15 | 41 aend1 f = exists N f |
14 | 42 |