annotate agda/derive.agda @ 45:e9edc777dc03

fix derive
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 22 Dec 2018 15:48:05 +0900
parents aa15eff1aeb3
children 7a0634a7c25a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module derive where
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import nfa
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import regex1
44
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
5 open import Data.Nat hiding ( _<_ ; _>_ )
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
6 open import Data.Fin hiding ( _<_ )
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
7 open import Data.List hiding ( [_] )
36
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
9558d870e8ae add cfg and derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Bool using ( Bool ; true ; false ; _∧_ ; _∨_ )
44
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
10 open import Relation.Binary.PropositionalEquality hiding ( [_] )
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
11 open import Relation.Nullary using (¬_; Dec; yes; no)
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
12
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
13 open import finiteSet
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
14
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
15 finIn2 : FiniteSet In2
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
16 finIn2 = record {
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
17 Q←F = Q←F'
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
18 ; F←Q = F←Q'
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
19 ; finiso→ = finiso→'
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
20 ; finiso← = finiso←'
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
21 } where
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
22 Q←F' : Fin 2 → In2
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
23 Q←F' zero = i0
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
24 Q←F' (suc zero) = i1
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
25 Q←F' (suc (suc ()))
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
26 F←Q' : In2 → Fin 2
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
27 F←Q' i0 = zero
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
28 F←Q' i1 = suc (zero)
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
29 finiso→' : (q : In2) → Q←F' (F←Q' q) ≡ q
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
30 finiso→' i0 = refl
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
31 finiso→' i1 = refl
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
32 finiso←' : (f : Fin 2) → F←Q' (Q←F' f) ≡ f
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
33 finiso←' zero = refl
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
34 finiso←' (suc zero) = refl
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
35 finiso←' (suc (suc ()))
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
36
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
37
45
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
38 tr1 = < i0 > & < i1 >
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
39 tr2 = regular-language (< i0 > & < i1 >) finIn2 ( i0 ∷ i1 ∷ [] )
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
40 tr3 = regular-language (< i0 > & < i1 >) finIn2 ( i0 ∷ i0 ∷ [] )
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
41 tr4 = (< i0 > * ) & < i1 >
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
42 tr5 = ( ((< i0 > * ) & < i1 > ) || ( < i1 > & ( ( < i1 > * ) || ( < i0 > * )) ) ) *
44
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
43
45
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
44 sb : { Σ : Set } → Regex Σ → List ( Regex Σ )
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
45 sb (x *) = map (λ r → ( r & (x *) )) ( sb x ) ++ ( sb x )
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
46 sb (x & y) = map (λ r → ( r & y )) ( sb x ) ++ ( sb y )
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
47 sb (x || y) = sb x ++ sb y
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
48 sb < x > = < x > ∷ []
44
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
49
aa15eff1aeb3 seprate finite
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
50
45
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
51 nth : { S : Set } → (x : List S ) → Fin ( length x ) → S
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
52 nth [] ()
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
53 nth (s ∷ t) zero = s
e9edc777dc03 fix derive
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
54 nth (_ ∷ t) (suc f) = nth t f