annotate automaton-in-agda/src/non-regular.agda @ 296:2f113cac060b

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 31 Dec 2021 14:36:44 +0900
parents 99c2cbe6a862
children afc7db9b917d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module non-regular where
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Data.Nat
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
4 open import Data.Empty
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.List
278
e89957b99662 dup in finiteSet in long list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 277
diff changeset
6 open import Data.Maybe hiding ( map )
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Relation.Binary.PropositionalEquality hiding ( [_] )
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import logic
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import automaton
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
10 open import automaton-ex
278
e89957b99662 dup in finiteSet in long list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 277
diff changeset
11 open import finiteSetUtil
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open import finiteSet
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Relation.Nullary
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
14 open import regular-language
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
16 open FiniteSet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
18 inputnn : List In2 → Maybe (List In2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
19 inputnn [] = just []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
20 inputnn (i1 ∷ t) = just (i1 ∷ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
21 inputnn (i0 ∷ t) with inputnn t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
22 ... | nothing = nothing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
23 ... | just [] = nothing
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
24 ... | just (i0 ∷ t1) = nothing -- can't happen
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
25 ... | just (i1 ∷ t1) = just t1 -- remove i1 from later part
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
26
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
27 inputnn1 : List In2 → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
28 inputnn1 s with inputnn s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
29 ... | nothing = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
30 ... | just [] = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
31 ... | just _ = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
33 t1 = inputnn1 ( i0 ∷ i1 ∷ [] )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
34 t2 = inputnn1 ( i0 ∷ i0 ∷ i1 ∷ i1 ∷ [] )
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
35 t3 = inputnn1 ( i0 ∷ i0 ∷ i0 ∷ i1 ∷ i1 ∷ [] )
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
36
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
37 inputnn0 : ( n : ℕ ) → { Σ : Set } → ( x y : Σ ) → List Σ → List Σ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
38 inputnn0 zero {_} _ _ s = s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
39 inputnn0 (suc n) x y s = x ∷ ( inputnn0 n x y ( y ∷ s ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
40
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
41 t4 : inputnn1 ( inputnn0 5 i0 i1 [] ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
42 t4 = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
43
291
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
44 t5 : ( n : ℕ ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
45 t5 n = inputnn1 ( inputnn0 n i0 i1 [] ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
46
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
47 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
48 -- if there is an automaton with n states , which accespt inputnn1, it has a trasition function.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
49 -- The function is determinted by inputs,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
50 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
51
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
52 open RegularLanguage
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
53 open Automaton
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
54
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
55 open _∧_
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
57 data Trace { Q : Set } { Σ : Set } (fa : Automaton Q Σ ) : (is : List Σ) → Q → Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
58 tend : {q : Q} → aend fa q ≡ true → Trace fa [] q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
59 tnext : (q : Q) → {i : Σ} { is : List Σ}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
60 → Trace fa is (δ fa q i) → Trace fa (i ∷ is) q
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
61
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
62 tr-len : { Q : Set } { Σ : Set }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
63 → (fa : Automaton Q Σ )
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
64 → (is : List Σ) → (q : Q) → Trace fa is q → suc (length is) ≡ length (trace fa q is )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
65 tr-len {Q} {Σ} fa .[] q (tend x) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
66 tr-len {Q} {Σ} fa (i ∷ is) q (tnext .q t) = cong suc (tr-len {Q} {Σ} fa is (δ fa q i) t)
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
67
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
68 tr-accept→ : { Q : Set } { Σ : Set }
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
69 → (fa : Automaton Q Σ )
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
70 → (is : List Σ) → (q : Q) → Trace fa is q → accept fa q is ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
71 tr-accept→ {Q} {Σ} fa [] q (tend x) = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
72 tr-accept→ {Q} {Σ} fa (i ∷ is) q (tnext _ tr) = tr-accept→ {Q} {Σ} fa is (δ fa q i) tr
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
73
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
74 tr-accept← : { Q : Set } { Σ : Set }
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
75 → (fa : Automaton Q Σ )
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
76 → (is : List Σ) → (q : Q) → accept fa q is ≡ true → Trace fa is q
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
77 tr-accept← {Q} {Σ} fa [] q ac = tend ac
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
78 tr-accept← {Q} {Σ} fa (x ∷ []) q ac = tnext _ (tend ac )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
79 tr-accept← {Q} {Σ} fa (x ∷ x1 ∷ is) q ac = tnext _ (tr-accept← fa (x1 ∷ is) (δ fa q x) ac)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
81 tr→qs : { Q : Set } { Σ : Set }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
82 → (fa : Automaton Q Σ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
83 → (is : List Σ) → (q : Q) → Trace fa is q → List Q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
84 tr→qs fa [] q (tend x) = []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
85 tr→qs fa (i ∷ is) q (tnext q tr) = q ∷ tr→qs fa is (δ fa q i) tr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
86
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
87 tr→qs=is : { Q : Set } { Σ : Set }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
88 → (fa : Automaton Q Σ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
89 → (is : List Σ) → (q : Q) → (tr : Trace fa is q ) → length is ≡ length (tr→qs fa is q tr)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
90 tr→qs=is fa .[] q (tend x) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
91 tr→qs=is fa (i ∷ is) q (tnext .q tr) = cong suc (tr→qs=is fa is (δ fa q i) tr)
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
92
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
93 open Data.Maybe
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
95 -- head : {a : Set} → List a → Maybe a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
96 -- head [] = nothing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
97 -- head (h ∷ _ ) = just h
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
99 tr-append1 : { Q : Set } { Σ : Set }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
100 → (fa : Automaton Q Σ )
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
101 → (i : Σ) → ( q : Q)
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
102 → (is : List Σ)
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
103 → Trace fa is ( δ fa q i ) → Trace fa (i ∷ is) q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
104 tr-append1 fa i q is tr = tnext _ tr
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
105
279
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
106 open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ )
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
107
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
108 record TA { Q : Set } { Σ : Set } (fa : Automaton Q Σ ) (phase : ℕ) ( q qd : Q ) : Set where
279
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
109 field
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
110 x y z : List Σ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
111 trace-z : phase > 1 → Trace fa z qd
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
112 trace-yz : phase > 0 → Trace fa (y ++ z) qd
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
113 trace-xyz : phase ≡ 0 → Trace fa (x ++ y ++ z) q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
114 trace-xyyz : phase ≡ 0 → Trace fa (x ++ y ++ y ++ z) q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
115
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
116 open import nat
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
117
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
118 make-TA : { Q : Set } { Σ : Set } (fa : Automaton Q Σ ) (finq : FiniteSet Q) (q qd : Q) (is : List Σ)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
119 → (tr : Trace fa is q )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
120 → dup-in-list finq qd (tr→qs fa is q tr) ≡ true
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
121 → TA fa 0 q qd
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
122 make-TA {Q} {Σ} fa finq q qd is tr dup = tra-phase1 q is tr dup where
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
123 open TA
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
124 tra-phase2 : (q : Q) → (is : List Σ) → (tr : Trace fa is q ) → phase2 finq qd (tr→qs fa is q tr) ≡ true → TA fa 1 q qd
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
125 tra-phase2 q (i ∷ is) (tnext q tr) p with equal? finq qd q
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
126 ... | true = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
127 ... | false = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
128 tra-phase1 : (q : Q) → (is : List Σ) → (tr : Trace fa is q ) → phase1 finq qd (tr→qs fa is q tr) ≡ true → TA fa 0 q qd
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
129 tra-phase1 q (i ∷ is) (tnext q tr) p with equal? finq qd q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
130 ... | true = record { x = [] ; y = y TA0 ; z = z TA0 ; trace-z = λ () ; trace-yz = λ _ → trace-yz TA0 a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
131 ; trace-xyz = λ _ → subst (λ k → Trace fa (y TA0 ++ z TA0) k ) {!!} (trace-yz TA0 a<sa)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
132 ; trace-xyyz = λ _ → {!!}} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
133 TA0 : {!!}
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
134 TA0 = tra-phase2 (δ fa q i ) is tr p
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
135 ... | false = record { x = i ∷ x TA0 ; y = y TA0 ; z = z TA0 ; trace-z = λ () ; trace-yz = λ ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
136 ; trace-xyz = λ _ → tnext q (trace-xyz TA0 refl ) ; trace-xyyz = λ _ → tnext q (trace-xyyz TA0 refl )} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
137 TA0 : TA fa 0 (δ fa q i ) qd
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
138 TA0 = tra-phase1 (δ fa q i ) is tr p
277
42563cc6afdf non-regular
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 274
diff changeset
139
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
140 open RegularLanguage
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
141 open import Data.Nat.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
142 open import nat
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
143
274
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183
diff changeset
144 lemmaNN : (r : RegularLanguage In2 ) → ¬ ( (s : List In2) → isRegular inputnn1 s r )
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
145 lemmaNN r Rg = {!!} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
146 n : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
147 n = suc (finite (afin r))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
148 nn = inputnn0 n i0 i1 []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
149 nn01 : (i : ℕ) → inputnn1 ( inputnn0 i i0 i1 [] ) ≡ true
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
150 nn01 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
151 nn01 (suc i) with nn01 i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
152 ... | t = {!!}
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
153 nn03 : accept (automaton r) (astart r) nn ≡ true
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
154 nn03 = subst (λ k → k ≡ true ) (Rg nn ) (nn01 n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
155 count : In2 → List In2 → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
156 count _ [] = 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
157 count i0 (i0 ∷ s) = suc (count i0 s)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
158 count i1 (i1 ∷ s) = suc (count i1 s)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
159 count x (_ ∷ s) = count x s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
160 nn10 : (s : List In2) → accept (automaton r) (astart r) s ≡ true → count i0 s ≡ count i1 s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
161 nn10 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
162 nn11 : {x : In2} → (s t : List In2) → count x (s ++ t) ≡ count x s + count x t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
163 nn11 = {!!}
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
164 nntrace = trace (automaton r) (astart r) nn
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
165 nn04 : Trace (automaton r) nn (astart r)
280
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
166 nn04 = tr-accept← (automaton r) nn (astart r) nn03
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
167 nn07 : (n : ℕ) → length (inputnn0 n i0 i1 []) ≡ n + n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
168 nn07 n = subst (λ k → length (inputnn0 n i0 i1 []) ≡ k) (+-comm (n + n) _ ) (nn08 n [] )where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
169 nn08 : (n : ℕ) → (s : List In2) → length (inputnn0 n i0 i1 s) ≡ n + n + length s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
170 nn08 zero s = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
171 nn08 (suc n) s = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
172 length (inputnn0 (suc n) i0 i1 s) ≡⟨ refl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
173 suc (length (inputnn0 n i0 i1 (i1 ∷ s))) ≡⟨ cong suc (nn08 n (i1 ∷ s)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
174 suc (n + n + suc (length s)) ≡⟨ +-assoc (suc n) n _ ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
175 suc n + (n + suc (length s)) ≡⟨ cong (λ k → suc n + k) (sym (+-assoc n _ _)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
176 suc n + ((n + 1) + length s) ≡⟨ cong (λ k → suc n + (k + length s)) (+-comm n _) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
177 suc n + (suc n + length s) ≡⟨ sym (+-assoc (suc n) _ _) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
178 suc n + suc n + length s ∎ where open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
179 nn09 : (n m : ℕ) → n ≤ n + m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
180 nn09 zero m = z≤n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
181 nn09 (suc n) m = s≤s (nn09 n m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
182 nn05 : length nntrace > finite (afin r)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
183 nn05 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
184 suc (finite (afin r)) ≤⟨ nn09 _ _ ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
185 n + n ≡⟨ sym (nn07 n) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
186 length (inputnn0 n i0 i1 []) ≤⟨ refl-≤s ⟩
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
187 {!!} ≤⟨ {!!} ⟩
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
188 length nntrace ∎ where open ≤-Reasoning
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 295
diff changeset
189 nn02 : {!!} -- TA (automaton r) {!!} {!!} {!!}
295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 294
diff changeset
190 nn02 = {!!} where -- make-TA (automaton r) (afin r) (Dup-in-list.dup nn06) _ _ (Dup-in-list.is-dup nn06) ? where
294
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
191 nn06 : Dup-in-list ( afin r) nntrace
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
192 nn06 = dup-in-list>n (afin r) nntrace nn05
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
193 nn12 : (x y z : List In2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
194 → ¬ y ≡ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
195 → accept (automaton r) (astart r) (x ++ y ++ z) ≡ true → ¬ (accept (automaton r) (astart r) (x ++ y ++ y ++ z) ≡ true)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
196 nn12 x y z p q = {!!} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
197 mono-color : List In2 → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
198 mono-color [] = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
199 mono-color (i0 ∷ s) = mono-color0 s where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
200 mono-color0 : List In2 → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
201 mono-color0 [] = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
202 mono-color0 (i1 ∷ s) = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
203 mono-color0 (i0 ∷ s) = mono-color0 s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
204 mono-color (i1 ∷ s) = mono-color1 s where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
205 mono-color1 : List In2 → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
206 mono-color1 [] = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
207 mono-color1 (i0 ∷ s) = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
208 mono-color1 (i1 ∷ s) = mono-color1 s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
209 mono-color (i1 ∷ s) = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
210 i1-i0? : List In2 → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
211 i1-i0? [] = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
212 i1-i0? (i1 ∷ []) = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
213 i1-i0? (i0 ∷ []) = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
214 i1-i0? (i1 ∷ i0 ∷ s) = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
215 i1-i0? (_ ∷ s0 ∷ s1) = i1-i0? (s0 ∷ s1)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
216 nn13 : mono-color y ≡ true → count i0 (x ++ y ++ z) ≡ count i1 (x ++ y ++ z) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
217 ¬ ( count i0 (x ++ y ++ y ++ z) ≡ count i1 (x ++ y ++ y ++ z) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
218 nn13 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
219 nn16 : (s : List In2 ) → accept (automaton r) (astart r) s ≡ true → count i0 s ≡ count i1 s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
220 nn16 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
221 nn15 : (s : List In2 ) → i1-i0? s ≡ true → accept (automaton r) (astart r) s ≡ false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
222 nn15 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
223 nn14 : mono-color y ≡ false → i1-i0? (x ++ y ++ y ++ z) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
224 nn14 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
225 nn17 : accept (automaton r) (astart r) (x ++ y ++ z) ≡ true → ¬ (accept (automaton r) (astart r) (x ++ y ++ y ++ z) ≡ true)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
226 nn17 p q with mono-color y | inspect mono-color y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
227 ... | true | record { eq = eq } = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
228 ... | false | record { eq = eq } = {!!} -- q ( nn15 (x ++ y ++ z) (nn14 eq))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
229