Mercurial > hg > Members > kono > Proof > automaton
annotate automaton-in-agda/src/finiteSet.agda @ 330:407684f806e4
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Nov 2022 17:43:10 +0900 |
parents | 91781b7c65a8 |
children | c298981108c1 |
rev | line source |
---|---|
111 | 1 {-# OPTIONS --allow-unsolved-metas #-} |
44 | 2 module finiteSet where |
3 | |
69 | 4 open import Data.Nat hiding ( _≟_ ) |
83 | 5 open import Data.Fin renaming ( _<_ to _<<_ ) hiding (_≤_) |
318 | 6 -- open import Data.Fin.Properties hiding ( ≤-refl ) |
76 | 7 open import Data.Empty |
69 | 8 open import Relation.Nullary |
141 | 9 open import Relation.Binary.Definitions |
46 | 10 open import Relation.Binary.PropositionalEquality |
69 | 11 open import logic |
78 | 12 open import nat |
141 | 13 open import Data.Nat.Properties hiding ( _≟_ ) |
44 | 14 |
79 | 15 open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) |
16 | |
141 | 17 record FiniteSet ( Q : Set ) : Set where |
85 | 18 field |
141 | 19 finite : ℕ |
20 Q←F : Fin finite → Q | |
21 F←Q : Q → Fin finite | |
44 | 22 finiso→ : (q : Q) → Q←F ( F←Q q ) ≡ q |
141 | 23 finiso← : (f : Fin finite ) → F←Q ( Q←F f ) ≡ f |
24 exists1 : (m : ℕ ) → m Data.Nat.≤ finite → (Q → Bool) → Bool | |
76 | 25 exists1 zero _ _ = false |
264 | 26 exists1 ( suc m ) m<n p = p (Q←F (fromℕ< {m} {finite} m<n)) \/ exists1 m (<to≤ m<n) p |
44 | 27 exists : ( Q → Bool ) → Bool |
141 | 28 exists p = exists1 finite ≤-refl p |
104
fba1cd54581d
use exists in cond, nfa example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
29 |
114 | 30 open import Data.List |
141 | 31 list1 : (m : ℕ ) → m Data.Nat.≤ finite → (Q → Bool) → List Q |
104
fba1cd54581d
use exists in cond, nfa example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
32 list1 zero _ _ = [] |
141 | 33 list1 ( suc m ) m<n p with bool-≡-? (p (Q←F (fromℕ< {m} {finite} m<n))) true |
264 | 34 ... | yes _ = Q←F (fromℕ< {m} {finite} m<n) ∷ list1 m (<to≤ m<n) p |
35 ... | no _ = list1 m (<to≤ m<n) p | |
114 | 36 to-list : ( Q → Bool ) → List Q |
141 | 37 to-list p = list1 finite ≤-refl p |
104
fba1cd54581d
use exists in cond, nfa example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
38 |
69 | 39 equal? : Q → Q → Bool |
40 equal? q0 q1 with F←Q q0 ≟ F←Q q1 | |
41 ... | yes p = true | |
42 ... | no ¬p = false |