Mercurial > hg > Members > kono > Proof > galois
annotate Putil.agda @ 97:f4ff8e352aa7
p=0
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 31 Aug 2020 07:18:54 +0900 |
parents | b43c4a7c57d9 |
children | 3a37a8f8cb39 |
rev | line source |
---|---|
90 | 1 {-# OPTIONS --allow-unsolved-metas #-} |
48 | 2 module Putil where |
0 | 3 |
4 open import Level hiding ( suc ; zero ) | |
5 open import Algebra | |
6 open import Algebra.Structures | |
37 | 7 open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ) |
90 | 8 open import Data.Fin.Properties hiding ( <-trans ; ≤-trans ; ≤-irrelevant ) renaming ( <-cmp to <-fcmp ) |
0 | 9 open import Data.Fin.Permutation |
10 open import Function hiding (id ; flip) | |
11 open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_) | |
12 open import Function.LeftInverse using ( _LeftInverseOf_ ) | |
13 open import Function.Equality using (Π) | |
17 | 14 open import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n ) |
15 open import Data.Nat.Properties -- using (<-trans) | |
16 | 16 open import Relation.Binary.PropositionalEquality |
80 | 17 open import Data.List using (List; []; _∷_ ; length ; _++_ ; head ; tail ) renaming (reverse to rev ) |
16 | 18 open import nat |
0 | 19 |
48 | 20 open import Symmetric |
0 | 21 |
22 | |
16 | 23 open import Relation.Nullary |
24 open import Data.Empty | |
17 | 25 open import Relation.Binary.Core |
80 | 26 open import Relation.Binary.Definitions |
17 | 27 open import fin |
16 | 28 |
38 | 29 -- An inductive construction of permutation |
34 | 30 |
59 | 31 -- Todo |
32 -- | |
33 -- describe property of pins ( move 0 to any position) | |
34 -- describe property of shrink ( remove one column ) | |
35 -- prove FL→iso | |
36 -- prove FL←iso | |
37 | |
48 | 38 -- we already have refl and trans in the Symmetric Group |
41 | 39 |
34 | 40 pprep : {n : ℕ } → Permutation n n → Permutation (suc n) (suc n) |
41 pprep {n} perm = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where | |
33 | 42 p→ : Fin (suc n) → Fin (suc n) |
34 | 43 p→ zero = zero |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
44 p→ (suc x) = suc ( perm ⟨$⟩ʳ x) |
33 | 45 |
34 | 46 p← : Fin (suc n) → Fin (suc n) |
47 p← zero = zero | |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
48 p← (suc x) = suc ( perm ⟨$⟩ˡ x) |
34 | 49 |
50 piso← : (x : Fin (suc n)) → p→ ( p← x ) ≡ x | |
51 piso← zero = refl | |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
52 piso← (suc x) = cong (λ k → suc k ) (inverseʳ perm) |
33 | 53 |
34 | 54 piso→ : (x : Fin (suc n)) → p← ( p→ x ) ≡ x |
55 piso→ zero = refl | |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
56 piso→ (suc x) = cong (λ k → suc k ) (inverseˡ perm) |
33 | 57 |
34 | 58 pswap : {n : ℕ } → Permutation n n → Permutation (suc (suc n)) (suc (suc n )) |
59 pswap {n} perm = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where | |
60 p→ : Fin (suc (suc n)) → Fin (suc (suc n)) | |
61 p→ zero = suc zero | |
62 p→ (suc zero) = zero | |
62 | 63 p→ (suc (suc x)) = suc ( suc ( perm ⟨$⟩ʳ x) ) |
18 | 64 |
34 | 65 p← : Fin (suc (suc n)) → Fin (suc (suc n)) |
66 p← zero = suc zero | |
67 p← (suc zero) = zero | |
62 | 68 p← (suc (suc x)) = suc ( suc ( perm ⟨$⟩ˡ x) ) |
34 | 69 |
70 piso← : (x : Fin (suc (suc n)) ) → p→ ( p← x ) ≡ x | |
71 piso← zero = refl | |
72 piso← (suc zero) = refl | |
62 | 73 piso← (suc (suc x)) = cong (λ k → suc (suc k) ) (inverseʳ perm) |
16 | 74 |
34 | 75 piso→ : (x : Fin (suc (suc n)) ) → p← ( p→ x ) ≡ x |
76 piso→ zero = refl | |
77 piso→ (suc zero) = refl | |
62 | 78 piso→ (suc (suc x)) = cong (λ k → suc (suc k) ) (inverseˡ perm) |
34 | 79 |
80 -- enumeration | |
81 | |
44 | 82 psawpn : {n : ℕ} → 1 < n → Permutation n n |
83 psawpn {suc zero} (s≤s ()) | |
84 psawpn {suc n} (s≤s (s≤s x)) = pswap pid | |
34 | 85 |
35 | 86 pfill : { n m : ℕ } → m ≤ n → Permutation m m → Permutation n n |
87 pfill {n} {m} m≤n perm = pfill1 (n - m) (n-m<n n m ) (subst (λ k → Permutation k k ) (n-n-m=m m≤n ) perm) where | |
88 pfill1 : (i : ℕ ) → i ≤ n → Permutation (n - i) (n - i) → Permutation n n | |
89 pfill1 0 _ perm = perm | |
90 pfill1 (suc i) i<n perm = pfill1 i (≤to< i<n) (subst (λ k → Permutation k k ) (si-sn=i-n i<n ) ( pprep perm ) ) | |
34 | 91 |
48 | 92 -- |
93 -- psawpim (inseert swap at position m ) | |
94 -- | |
45 | 95 psawpim : {n m : ℕ} → suc (suc m) ≤ n → Permutation n n |
96 psawpim {n} {m} m≤n = pfill m≤n ( psawpn (s≤s (s≤s z≤n)) ) | |
97 | |
98 n≤ : (i : ℕ ) → {j : ℕ } → i ≤ i + j | |
99 n≤ (zero) {j} = z≤n | |
100 n≤ (suc i) {j} = s≤s ( n≤ i ) | |
101 | |
102 lem0 : {n : ℕ } → n ≤ n | |
103 lem0 {zero} = z≤n | |
104 lem0 {suc n} = s≤s lem0 | |
105 | |
106 lem00 : {n m : ℕ } → n ≡ m → n ≤ m | |
107 lem00 refl = lem0 | |
44 | 108 |
80 | 109 plist1 : {n : ℕ} → Permutation (suc n) (suc n) → (i : ℕ ) → i < suc n → List ℕ |
110 plist1 {n} perm zero _ = toℕ ( perm ⟨$⟩ˡ (fromℕ< {zero} (s≤s z≤n))) ∷ [] | |
111 plist1 {n} perm (suc i) (s≤s lt) = toℕ ( perm ⟨$⟩ˡ (fromℕ< (s≤s lt))) ∷ plist1 perm i (<-trans lt a<sa) | |
112 | |
37 | 113 plist : {n : ℕ} → Permutation n n → List ℕ |
114 plist {0} perm = [] | |
80 | 115 plist {suc n} perm = rev (plist1 perm n a<sa) |
116 | |
89 | 117 -- pconcat : {n m : ℕ } → Permutation m m → Permutation n n → Permutation (m + n) (m + n) |
118 -- pconcat {n} {m} p q = pfill {n + m} {m} ? p ∘ₚ ? | |
119 | |
120 -- inductivley enmumerate permutations | |
121 -- from n-1 length create n length inserting new element at position m | |
122 | |
123 -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] | |
124 -- 1 ∷ 0 ∷ 2 ∷ 3 ∷ [] plist ( pins {3} (n≤ 1) ) 1 ∷ 0 ∷ 2 ∷ 3 ∷ [] | |
125 -- 1 ∷ 2 ∷ 0 ∷ 3 ∷ [] plist ( pins {3} (n≤ 2) ) 2 ∷ 0 ∷ 1 ∷ 3 ∷ [] | |
126 -- 1 ∷ 2 ∷ 3 ∷ 0 ∷ [] plist ( pins {3} (n≤ 3) ) 3 ∷ 0 ∷ 1 ∷ 2 ∷ [] | |
94 | 127 -- pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n) |
128 -- pins {_} {zero} _ = pid | |
129 -- pins {suc _} {suc zero} _ = pswap pid | |
130 -- pins {suc (suc n)} {suc m} (s≤s m<n) = pins1 (suc m) (suc (suc n)) lem0 where | |
131 -- pins1 : (i j : ℕ ) → j ≤ suc (suc n) → Permutation (suc (suc (suc n ))) (suc (suc (suc n))) | |
132 -- pins1 _ zero _ = pid | |
133 -- pins1 zero _ _ = pid | |
134 -- pins1 (suc i) (suc j) (s≤s si≤n) = psawpim {suc (suc (suc n))} {j} (s≤s (s≤s si≤n)) ∘ₚ pins1 i j (≤-trans si≤n a≤sa ) | |
89 | 135 |
90 | 136 open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) |
91 | 137 open ≡-Reasoning |
90 | 138 |
94 | 139 pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n) |
140 pins {_} {zero} _ = pid | |
141 pins {suc n} {suc m} (s≤s m≤n) = permutation p← p→ record { left-inverse-of = piso← ; right-inverse-of = piso→ } where | |
89 | 142 |
143 next : Fin (suc (suc n)) → Fin (suc (suc n)) | |
144 next zero = suc zero | |
91 | 145 next (suc x) = fromℕ< (≤-trans (fin<n {_} {x} ) a≤sa ) |
89 | 146 |
147 p→ : Fin (suc (suc n)) → Fin (suc (suc n)) | |
148 p→ x with <-cmp (toℕ x) (suc m) | |
90 | 149 ... | tri< a ¬b ¬c = fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) )) |
89 | 150 ... | tri≈ ¬a b ¬c = zero |
151 ... | tri> ¬a ¬b c = x | |
152 | |
153 p← : Fin (suc (suc n)) → Fin (suc (suc n)) | |
154 p← zero = fromℕ< (s≤s (s≤s m≤n)) | |
155 p← (suc x) with <-cmp (toℕ x) (suc m) | |
91 | 156 ... | tri< a ¬b ¬c = fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) |
89 | 157 ... | tri≈ ¬a b ¬c = suc x |
158 ... | tri> ¬a ¬b c = suc x | |
90 | 159 |
160 mm : toℕ (fromℕ< {suc m} {suc (suc n)} (s≤s (s≤s m≤n))) ≡ suc m | |
161 mm = toℕ-fromℕ< (s≤s (s≤s m≤n)) | |
162 | |
91 | 163 mma : (x : Fin (suc n) ) → suc (toℕ x) ≤ suc m → toℕ ( fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) ) ≤ m |
164 mma x (s≤s x<sm) = subst (λ k → k ≤ m) (sym (toℕ-fromℕ< (≤-trans fin<n a≤sa ) )) x<sm | |
89 | 165 |
91 | 166 p3 : (x : Fin (suc n) ) → toℕ (fromℕ< (≤-trans (fin<n {_} {suc x} ) (s≤s a≤sa))) ≡ suc (toℕ x) |
167 p3 x = begin | |
168 toℕ (fromℕ< (≤-trans (fin<n {_} {suc x} ) (s≤s a≤sa))) | |
169 ≡⟨ toℕ-fromℕ< ( s≤s ( ≤-trans fin<n a≤sa ) ) ⟩ | |
170 suc (toℕ x) | |
171 ∎ | |
92 | 172 |
173 piso→ : (x : Fin (suc (suc n)) ) → p← ( p→ x ) ≡ x | |
174 piso→ zero with <-cmp (toℕ (fromℕ< (≤-trans (s≤s z≤n) (s≤s (s≤s m≤n) )))) (suc m) | |
175 ... | tri< a ¬b ¬c = refl | |
176 piso→ (suc x) with <-cmp (toℕ (suc x)) (suc m) | |
94 | 177 ... | tri≈ ¬a refl ¬c = p13 where |
178 p13 : fromℕ< (s≤s (s≤s m≤n)) ≡ suc x | |
179 p13 = cong (λ k → suc k ) (fromℕ<-toℕ _ (s≤s m≤n) ) | |
95 | 180 ... | tri> ¬a ¬b c = p16 (suc x) refl where |
181 p16 : (y : Fin (suc (suc n))) → y ≡ suc x → p← y ≡ suc x | |
182 p16 zero eq = ⊥-elim ( nat-≡< (cong (λ k → suc (toℕ k) ) eq) (s≤s (s≤s (z≤n)))) | |
183 p16 (suc y) eq with <-cmp (toℕ y) (suc m) -- suc (suc m) < toℕ (suc x) | |
96 | 184 ... | tri< a ¬b ¬c = ⊥-elim ( nat-≡< refl ( ≤-trans c (subst (λ k → k < suc m) p17 a )) ) where |
185 -- x = suc m case, c : suc (suc m) ≤ suc (toℕ x), a : suc (toℕ y) ≤ suc m, suc y ≡ suc x | |
186 p17 : toℕ y ≡ toℕ x | |
187 p17 with <-cmp (toℕ y) (toℕ x) | cong toℕ eq | |
188 ... | tri< a ¬b ¬c | seq = ⊥-elim ( nat-≡< seq (s≤s a) ) | |
189 ... | tri≈ ¬a b ¬c | seq = b | |
190 ... | tri> ¬a ¬b c | seq = ⊥-elim ( nat-≡< (sym seq) (s≤s c)) | |
95 | 191 ... | tri≈ ¬a b ¬c = eq |
192 ... | tri> ¬a ¬b c₁ = eq | |
92 | 193 ... | tri< a ¬b ¬c = p10 (fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) ))) refl where |
194 p10 : (y : Fin (suc (suc n)) ) → y ≡ fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) )) → p← y ≡ suc x | |
195 p10 zero () | |
93 | 196 p10 (suc y) eq = p15 where |
197 p12 : toℕ y ≡ suc (toℕ x) | |
198 p12 = begin | |
199 toℕ y | |
200 ≡⟨ cong (λ k → Data.Nat.pred (toℕ k)) eq ⟩ | |
201 toℕ (fromℕ< (≤-trans a (s≤s m≤n))) | |
202 ≡⟨ toℕ-fromℕ< {suc (toℕ x)} {suc n} (≤-trans a (s≤s m≤n)) ⟩ | |
203 suc (toℕ x) | |
92 | 204 ∎ |
93 | 205 p15 : p← (suc y) ≡ suc x |
206 p15 with <-cmp (toℕ y) (suc m) -- eq : suc y ≡ suc (suc (fromℕ< (≤-pred (≤-trans a (s≤s m≤n))))) , a : suc x < suc m | |
207 ... | tri< a₁ ¬b ¬c = p11 where | |
208 p11 : fromℕ< (≤-trans (fin<n {_} {y}) a≤sa ) ≡ suc x | |
209 p11 = begin | |
210 fromℕ< (≤-trans (fin<n {_} {y}) a≤sa ) | |
211 ≡⟨ fromℕ<-irrelevant _ _ p12 _ (s≤s (fin<n {suc n})) ⟩ | |
212 suc (fromℕ< (fin<n {suc n} {x} )) | |
213 ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩ | |
214 suc x | |
215 ∎ | |
216 ... | tri≈ ¬a b ¬c = ⊥-elim ( nat-≡< b (subst (λ k → k < suc m) (sym p12) a )) -- suc x < suc m -> y = suc x → toℕ y < suc m | |
217 ... | tri> ¬a ¬b c = ⊥-elim ( nat-<> c (subst (λ k → k < suc m) (sym p12) a )) | |
92 | 218 |
89 | 219 piso← : (x : Fin (suc (suc n)) ) → p→ ( p← x ) ≡ x |
90 | 220 piso← zero with <-cmp (toℕ (fromℕ< (s≤s (s≤s m≤n)))) (suc m) | mm |
221 ... | tri< a ¬b ¬c | t = ⊥-elim ( ¬b t ) | |
222 ... | tri≈ ¬a b ¬c | t = refl | |
223 ... | tri> ¬a ¬b c | t = ⊥-elim ( ¬b t ) | |
224 piso← (suc x) with <-cmp (toℕ x) (suc m) | |
91 | 225 ... | tri> ¬a ¬b c with <-cmp (toℕ (suc x)) (suc m) |
226 ... | tri< a ¬b₁ ¬c = ⊥-elim ( nat-<> a (<-trans c a<sa ) ) | |
227 ... | tri≈ ¬a₁ b ¬c = ⊥-elim ( nat-≡< (sym b) (<-trans c a<sa )) | |
228 ... | tri> ¬a₁ ¬b₁ c₁ = refl | |
229 piso← (suc x) | tri≈ ¬a b ¬c with <-cmp (toℕ (suc x)) (suc m) | |
230 ... | tri< a ¬b ¬c₁ = ⊥-elim ( nat-≡< b (<-trans a<sa a) ) | |
231 ... | tri≈ ¬a₁ refl ¬c₁ = ⊥-elim ( nat-≡< b a<sa ) | |
232 ... | tri> ¬a₁ ¬b c = refl | |
233 piso← (suc x) | tri< a ¬b ¬c with <-cmp (toℕ ( fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) )) (suc m) | |
90 | 234 ... | tri≈ ¬a b ¬c₁ = ⊥-elim ( ¬a (s≤s (mma x a))) |
235 ... | tri> ¬a ¬b₁ c = ⊥-elim ( ¬a (s≤s (mma x a))) | |
236 ... | tri< a₁ ¬b₁ ¬c₁ = p0 where | |
237 p2 : suc (suc (toℕ x)) ≤ suc (suc n) | |
238 p2 = s≤s (fin<n {suc n} {x}) | |
91 | 239 p6 : suc (toℕ (fromℕ< (≤-trans (fin<n {_} {suc x}) (s≤s a≤sa)))) ≤ suc (suc n) |
90 | 240 p6 = s≤s (≤-trans a₁ (s≤s m≤n)) |
241 p0 : fromℕ< (≤-trans (s≤s a₁) (s≤s (s≤s m≤n) )) ≡ suc x | |
242 p0 = begin | |
243 fromℕ< (≤-trans (s≤s a₁) (s≤s (s≤s m≤n) )) | |
244 ≡⟨⟩ | |
245 fromℕ< (s≤s (≤-trans a₁ (s≤s m≤n))) | |
91 | 246 ≡⟨ lemma10 (p3 x) {p6} {p2} ⟩ |
90 | 247 fromℕ< ( s≤s (fin<n {suc n} {x}) ) |
91 | 248 ≡⟨⟩ |
90 | 249 suc (fromℕ< (fin<n {suc n} {x} )) |
91 | 250 ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩ |
90 | 251 suc x |
91 | 252 ∎ |
90 | 253 |
94 | 254 t7 = plist (pins {3} (n≤ 3)) ∷ plist (flip ( pins {3} (n≤ 3) )) ∷ plist ( pins {3} (n≤ 3) ∘ₚ flip ( pins {3} (n≤ 3))) ∷ [] |
255 -- t8 = {!!} | |
89 | 256 |
97 | 257 open import logic |
258 | |
259 open _∧_ | |
260 | |
261 perm1 : {perm : Permutation 1 1 } {q : Fin 1} → (perm ⟨$⟩ʳ q ≡ # 0) ∧ ((perm ⟨$⟩ˡ q ≡ # 0)) | |
262 perm1 {p} {q} = ⟪ perm01 _ _ , perm00 _ _ ⟫ where | |
263 perm01 : (x y : Fin 1) → (p ⟨$⟩ʳ x) ≡ y | |
264 perm01 x y with p ⟨$⟩ʳ x | |
265 perm01 zero zero | zero = refl | |
266 perm00 : (x y : Fin 1) → (p ⟨$⟩ˡ x) ≡ y | |
267 perm00 x y with p ⟨$⟩ˡ x | |
268 perm00 zero zero | zero = refl | |
269 | |
270 | |
271 p=0 : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) ≡ # 0 | |
272 p=0 {zero} perm with ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) | |
273 ... | zero = refl | |
274 p=0 {suc n} perm with perm ⟨$⟩ʳ (# 0) | inspect (_⟨$⟩ʳ_ perm ) (# 0)| toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) | inspect toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) | |
275 ... | zero | record { eq = e} | m<n | _ = p001 where | |
276 p001 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero | |
277 p001 = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) e (inverseˡ perm) | |
278 ... | suc t | record { eq = e } | m<n | record { eq = e1 } = p002 where -- m<n : suc (toℕ t) ≤ suc n | |
279 p002 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero | |
280 p002 = p005 zero (toℕ t) refl m<n refl where -- suc (toℕ t) ≤ suc n | |
281 p003 : (s : Fin (suc (suc n))) → s ≡ (perm ⟨$⟩ʳ (# 0)) → perm ⟨$⟩ˡ s ≡ # 0 | |
282 p003 s eq = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) (sym eq) (inverseˡ perm) | |
283 p005 : (x : Fin (suc (suc n))) → (m : ℕ ) → x ≡ zero → (m≤n : suc m ≤ suc n ) → m ≡ toℕ t → perm ⟨$⟩ˡ ( pins m≤n ⟨$⟩ʳ zero) ≡ zero | |
284 p005 zero m eq (s≤s m≤n) meq = p004 where | |
285 p006 : toℕ (suc t) < suc (suc n) | |
286 p006 = subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) | |
287 p004 : perm ⟨$⟩ˡ (fromℕ< (s≤s (s≤s m≤n))) ≡ zero | |
288 p004 = p003 (fromℕ< (s≤s (s≤s m≤n))) ( | |
289 begin | |
290 fromℕ< (s≤s (s≤s m≤n)) | |
291 ≡⟨ fromℕ<-irrelevant _ _ (cong suc meq) (s≤s (s≤s m≤n)) (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) ⟩ | |
292 fromℕ< (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) | |
293 ≡⟨ fromℕ<-toℕ {suc (suc n)} (suc t) (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) ⟩ | |
294 suc t | |
295 ≡⟨ sym e ⟩ | |
296 (perm ⟨$⟩ʳ (# 0)) | |
297 ∎ ) | |
298 | |
299 | |
300 -- pp : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → Fin (suc n) | |
301 -- pp perm → (( perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) | |
302 | |
89 | 303 |
80 | 304 plist2 : {n : ℕ} → Permutation (suc n) (suc n) → (i : ℕ ) → i < suc n → List ℕ |
305 plist2 {n} perm zero _ = toℕ ( perm ⟨$⟩ʳ (fromℕ< {zero} (s≤s z≤n))) ∷ [] | |
306 plist2 {n} perm (suc i) (s≤s lt) = toℕ ( perm ⟨$⟩ʳ (fromℕ< (s≤s lt))) ∷ plist2 perm i (<-trans lt a<sa) | |
307 | |
308 plist0 : {n : ℕ} → Permutation n n → List ℕ | |
309 plist0 {0} perm = [] | |
310 plist0 {suc n} perm = plist2 perm n a<sa | |
311 | |
85 | 312 open _=p=_ |
313 | |
86
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
314 -- |
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
315 -- plist cong |
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
316 -- |
85 | 317 ←pleq : {n : ℕ} → (x y : Permutation n n ) → x =p= y → plist0 x ≡ plist0 y |
318 ←pleq {zero} x y eq = refl | |
319 ←pleq {suc n} x y eq = ←pleq1 n a<sa where | |
320 ←pleq1 : (i : ℕ ) → (i<sn : i < suc n ) → plist2 x i i<sn ≡ plist2 y i i<sn | |
321 ←pleq1 zero _ = cong ( λ k → toℕ k ∷ [] ) ( peq eq (fromℕ< {zero} (s≤s z≤n))) | |
322 ←pleq1 (suc i) (s≤s lt) = cong₂ ( λ j k → toℕ j ∷ k ) ( peq eq (fromℕ< (s≤s lt))) ( ←pleq1 i (<-trans lt a<sa) ) | |
80 | 323 |
324 headeq : {A : Set } → {x y : A } → {xt yt : List A } → (x ∷ xt) ≡ (y ∷ yt) → x ≡ y | |
325 headeq refl = refl | |
326 | |
327 taileq : {A : Set } → {x y : A } → {xt yt : List A } → (x ∷ xt) ≡ (y ∷ yt) → xt ≡ yt | |
328 taileq refl = refl | |
329 | |
86
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
330 -- |
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
331 -- plist equalizer |
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
332 -- |
80 | 333 pleq : {n : ℕ} → (x y : Permutation n n ) → plist0 x ≡ plist0 y → x =p= y |
334 pleq {0} x y refl = record { peq = λ q → pleq0 q } where | |
335 pleq0 : (q : Fin 0 ) → (x ⟨$⟩ʳ q) ≡ (y ⟨$⟩ʳ q) | |
336 pleq0 () | |
337 pleq {suc n} x y eq = record { peq = λ q → pleq1 n a<sa eq q fin<n } where | |
338 pleq1 : (i : ℕ ) → (i<sn : i < suc n ) → plist2 x i i<sn ≡ plist2 y i i<sn → (q : Fin (suc n)) → toℕ q < suc i → x ⟨$⟩ʳ q ≡ y ⟨$⟩ʳ q | |
81 | 339 pleq1 zero i<sn eq q q<i with <-cmp (toℕ q) zero |
340 ... | tri< () ¬b ¬c | |
341 ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i ) | |
342 ... | tri≈ ¬a b ¬c = begin | |
343 x ⟨$⟩ʳ q | |
344 ≡⟨ cong ( λ k → x ⟨$⟩ʳ k ) (toℕ-injective b )⟩ | |
345 x ⟨$⟩ʳ zero | |
346 ≡⟨ toℕ-injective (headeq eq) ⟩ | |
347 y ⟨$⟩ʳ zero | |
348 ≡⟨ cong ( λ k → y ⟨$⟩ʳ k ) (sym (toℕ-injective b )) ⟩ | |
349 y ⟨$⟩ʳ q | |
91 | 350 ∎ |
80 | 351 pleq1 (suc i) (s≤s i<sn) eq q q<i with <-cmp (toℕ q) (suc i) |
352 ... | tri< a ¬b ¬c = pleq1 i (<-trans i<sn a<sa ) (taileq eq) q a | |
81 | 353 ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i ) |
80 | 354 ... | tri≈ ¬a b ¬c = begin |
355 x ⟨$⟩ʳ q | |
356 ≡⟨ cong (λ k → x ⟨$⟩ʳ k) (pleq3 b) ⟩ | |
357 x ⟨$⟩ʳ (suc (fromℕ< i<sn)) | |
358 ≡⟨ toℕ-injective pleq2 ⟩ | |
359 y ⟨$⟩ʳ (suc (fromℕ< i<sn)) | |
360 ≡⟨ cong (λ k → y ⟨$⟩ʳ k) (sym (pleq3 b)) ⟩ | |
361 y ⟨$⟩ʳ q | |
362 ∎ where | |
363 pleq3 : toℕ q ≡ suc i → q ≡ suc (fromℕ< i<sn) | |
364 pleq3 tq=si = toℕ-injective ( begin | |
365 toℕ q | |
366 ≡⟨ b ⟩ | |
367 suc i | |
368 ≡⟨ sym (toℕ-fromℕ< (s≤s i<sn)) ⟩ | |
369 toℕ (fromℕ< (s≤s i<sn)) | |
370 ≡⟨⟩ | |
371 toℕ (suc (fromℕ< i<sn)) | |
91 | 372 ∎ ) |
80 | 373 pleq2 : toℕ ( x ⟨$⟩ʳ (suc (fromℕ< i<sn)) ) ≡ toℕ ( y ⟨$⟩ʳ (suc (fromℕ< i<sn)) ) |
374 pleq2 = headeq eq | |
37 | 375 |
87 | 376 pprep-cong : {n : ℕ} → {x y : Permutation n n } → x =p= y → pprep x =p= pprep y |
377 pprep-cong {n} {x} {y} x=y = record { peq = pprep-cong1 } where | |
378 pprep-cong1 : (q : Fin (suc n)) → (pprep x ⟨$⟩ʳ q) ≡ (pprep y ⟨$⟩ʳ q) | |
379 pprep-cong1 zero = refl | |
380 pprep-cong1 (suc q) = begin | |
381 pprep x ⟨$⟩ʳ suc q | |
382 ≡⟨⟩ | |
383 suc ( x ⟨$⟩ʳ q ) | |
384 ≡⟨ cong ( λ k → suc k ) ( peq x=y q ) ⟩ | |
385 suc ( y ⟨$⟩ʳ q ) | |
386 ≡⟨⟩ | |
387 pprep y ⟨$⟩ʳ suc q | |
91 | 388 ∎ |
87 | 389 |
390 pprep-dist : {n : ℕ} → {x y : Permutation n n } → pprep (x ∘ₚ y) =p= (pprep x ∘ₚ pprep y) | |
391 pprep-dist {n} {x} {y} = record { peq = pprep-dist1 } where | |
392 pprep-dist1 : (q : Fin (suc n)) → (pprep (x ∘ₚ y) ⟨$⟩ʳ q) ≡ ((pprep x ∘ₚ pprep y) ⟨$⟩ʳ q) | |
393 pprep-dist1 zero = refl | |
394 pprep-dist1 (suc q) = cong ( λ k → suc k ) refl | |
395 | |
396 pswap-cong : {n : ℕ} → {x y : Permutation n n } → x =p= y → pswap x =p= pswap y | |
397 pswap-cong {n} {x} {y} x=y = record { peq = pswap-cong1 } where | |
398 pswap-cong1 : (q : Fin (suc (suc n))) → (pswap x ⟨$⟩ʳ q) ≡ (pswap y ⟨$⟩ʳ q) | |
399 pswap-cong1 zero = refl | |
400 pswap-cong1 (suc zero) = refl | |
401 pswap-cong1 (suc (suc q)) = begin | |
402 pswap x ⟨$⟩ʳ suc (suc q) | |
403 ≡⟨⟩ | |
404 suc (suc (x ⟨$⟩ʳ q)) | |
405 ≡⟨ cong ( λ k → suc (suc k) ) ( peq x=y q ) ⟩ | |
406 suc (suc (y ⟨$⟩ʳ q)) | |
407 ≡⟨⟩ | |
408 pswap y ⟨$⟩ʳ suc (suc q) | |
91 | 409 ∎ |
87 | 410 |
411 pswap-dist : {n : ℕ} → {x y : Permutation n n } → pprep (pprep (x ∘ₚ y)) =p= (pswap x ∘ₚ pswap y) | |
412 pswap-dist {n} {x} {y} = record { peq = pswap-dist1 } where | |
413 pswap-dist1 : (q : Fin (suc (suc n))) → ((pprep (pprep (x ∘ₚ y))) ⟨$⟩ʳ q) ≡ ((pswap x ∘ₚ pswap y) ⟨$⟩ʳ q) | |
414 pswap-dist1 zero = refl | |
415 pswap-dist1 (suc zero) = refl | |
416 pswap-dist1 (suc (suc q)) = cong ( λ k → suc (suc k) ) refl | |
86
c5329963c583
(x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
85
diff
changeset
|
417 |
49
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
418 data FL : (n : ℕ )→ Set where |
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
419 f0 : FL 0 |
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
420 _::_ : { n : ℕ } → Fin (suc n ) → FL n → FL (suc n) |
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
421 |
88 | 422 shlem→ : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → (x : Fin (suc n) ) → perm ⟨$⟩ˡ x ≡ zero → x ≡ zero |
423 shlem→ perm p0=0 x px=0 = begin | |
61 | 424 x ≡⟨ sym ( inverseʳ perm ) ⟩ |
425 perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ x) ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) px=0 ⟩ | |
426 perm ⟨$⟩ʳ zero ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) (sym p0=0) ⟩ | |
427 perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ zero) ≡⟨ inverseʳ perm ⟩ | |
428 zero | |
429 ∎ where open ≡-Reasoning | |
54 | 430 |
88 | 431 shlem← : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → (x : Fin (suc n)) → perm ⟨$⟩ʳ x ≡ zero → x ≡ zero |
432 shlem← perm p0=0 x px=0 = begin | |
61 | 433 x ≡⟨ sym (inverseˡ perm ) ⟩ |
434 perm ⟨$⟩ˡ ( perm ⟨$⟩ʳ x ) ≡⟨ cong (λ k → perm ⟨$⟩ˡ k ) px=0 ⟩ | |
435 perm ⟨$⟩ˡ zero ≡⟨ p0=0 ⟩ | |
436 zero | |
437 ∎ where open ≡-Reasoning | |
54 | 438 |
88 | 439 sh2 : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → {x : Fin n} → ¬ perm ⟨$⟩ˡ (suc x) ≡ zero |
440 sh2 perm p0=0 {x} eq with shlem→ perm p0=0 (suc x) eq | |
441 sh2 perm p0=0 {x} eq | () | |
442 | |
443 sh1 : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → {x : Fin n} → ¬ perm ⟨$⟩ʳ (suc x) ≡ zero | |
444 sh1 perm p0=0 {x} eq with shlem← perm p0=0 (suc x) eq | |
445 sh1 perm p0=0 {x} eq | () | |
446 | |
447 | |
448 -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] → 0 ∷ 1 ∷ 2 ∷ [] | |
449 shrink : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → perm ⟨$⟩ˡ (# 0) ≡ # 0 → Permutation n n | |
450 shrink {n} perm p0=0 = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where | |
57 | 451 |
61 | 452 p→ : Fin n → Fin n |
88 | 453 p→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x) |
454 p→ x | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 {x} e ) | |
61 | 455 p→ x | suc t | _ = t |
50 | 456 |
457 p← : Fin n → Fin n | |
88 | 458 p← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x) |
459 p← x | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 {x} e ) | |
61 | 460 p← x | suc t | _ = t |
50 | 461 |
462 piso← : (x : Fin n ) → p→ ( p← x ) ≡ x | |
88 | 463 piso← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x) |
464 piso← x | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 {x} e ) | |
465 piso← x | suc t | _ with perm ⟨$⟩ʳ (suc t) | inspect (_⟨$⟩ʳ_ perm ) (suc t) | |
466 piso← x | suc t | _ | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 e ) | |
61 | 467 piso← x | suc t | record { eq = e0 } | suc t1 | record { eq = e1 } = begin |
468 t1 | |
469 ≡⟨ plem0 plem1 ⟩ | |
52 | 470 x |
61 | 471 ∎ where |
472 open ≡-Reasoning | |
473 plem0 : suc t1 ≡ suc x → t1 ≡ x | |
474 plem0 refl = refl | |
475 plem1 : suc t1 ≡ suc x | |
476 plem1 = begin | |
477 suc t1 | |
478 ≡⟨ sym e1 ⟩ | |
88 | 479 Inverse.to perm Π.⟨$⟩ suc t |
480 ≡⟨ cong (λ k → Inverse.to perm Π.⟨$⟩ k ) (sym e0) ⟩ | |
481 Inverse.to perm Π.⟨$⟩ ( Inverse.from perm Π.⟨$⟩ suc x ) | |
482 ≡⟨ inverseʳ perm ⟩ | |
61 | 483 suc x |
484 ∎ | |
50 | 485 |
486 piso→ : (x : Fin n ) → p← ( p→ x ) ≡ x | |
88 | 487 piso→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x) |
488 piso→ x | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 {x} e ) | |
489 piso→ x | suc t | _ with perm ⟨$⟩ˡ (suc t) | inspect (_⟨$⟩ˡ_ perm ) (suc t) | |
490 piso→ x | suc t | _ | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 e ) | |
61 | 491 piso→ x | suc t | record { eq = e0 } | suc t1 | record { eq = e1 } = begin |
492 t1 | |
493 ≡⟨ plem2 plem3 ⟩ | |
53 | 494 x |
61 | 495 ∎ where |
496 open ≡-Reasoning | |
497 plem2 : suc t1 ≡ suc x → t1 ≡ x | |
498 plem2 refl = refl | |
499 plem3 : suc t1 ≡ suc x | |
500 plem3 = begin | |
501 suc t1 | |
502 ≡⟨ sym e1 ⟩ | |
88 | 503 Inverse.from perm Π.⟨$⟩ suc t |
504 ≡⟨ cong (λ k → Inverse.from perm Π.⟨$⟩ k ) (sym e0 ) ⟩ | |
505 Inverse.from perm Π.⟨$⟩ ( Inverse.to perm Π.⟨$⟩ suc x ) | |
506 ≡⟨ inverseˡ perm ⟩ | |
61 | 507 suc x |
508 ∎ | |
57 | 509 |
88 | 510 shrink-iso : { n : ℕ } → {perm : Permutation n n} → shrink (pprep perm) refl =p= perm |
511 shrink-iso {n} {perm} = record { peq = λ q → refl } | |
512 | |
57 | 513 FL→perm : {n : ℕ } → FL n → Permutation n n |
514 FL→perm f0 = pid | |
515 FL→perm (x :: fl) = pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x ) | |
516 | |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
517 t40 = (# 2) :: ( (# 1) :: (( # 0 ) :: f0 )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
518 t4 = FL→perm ((# 2) :: t40 ) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
519 |
61 | 520 -- t1 = plist (shrink (pid {3} ∘ₚ (pins (n≤ 1))) refl) |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
521 t2 = plist ((pid {5} ) ∘ₚ transpose (# 2) (# 4)) ∷ plist (pid {5} ∘ₚ reverse ) ∷ [] |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
522 t3 = plist (FL→perm t40) -- ∷ plist (pprep (FL→perm t40)) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
523 -- ∷ plist ( pprep (FL→perm t40) ∘ₚ pins ( n≤ 0 {3} )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
524 -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 1 {2} )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
525 -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 2 {1} )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
526 -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 3 {0} )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
527 ∷ plist ( FL→perm ((# 0) :: t40)) -- (0 ∷ 1 ∷ 2 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
528 ∷ plist ( FL→perm ((# 1) :: t40)) -- (0 ∷ 2 ∷ 1 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
529 ∷ plist ( FL→perm ((# 2) :: t40)) -- (1 ∷ 0 ∷ 2 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
530 ∷ plist ( FL→perm ((# 3) :: t40)) -- (2 ∷ 0 ∷ 1 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
531 -- ∷ plist ( FL→perm ((# 3) :: ((# 2) :: ( (# 0) :: (( # 0 ) :: f0 )) ))) -- (1 ∷ 2 ∷ 0 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
532 -- ∷ plist ( FL→perm ((# 3) :: ((# 2) :: ( (# 1) :: (( # 0 ) :: f0 )) ))) -- (2 ∷ 1 ∷ 0 ∷ []) ∷ |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
533 -- ∷ plist ( (flip (FL→perm ((# 3) :: ((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) ))))) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
534 -- ∷ plist ( (flip (FL→perm ((# 3) :: ((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) ))) ∘ₚ (FL→perm ((# 3) :: (((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) )))) )) |
57 | 535 ∷ [] |
50 | 536 |
58 | 537 |
49
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
538 perm→FL : {n : ℕ } → Permutation n n → FL n |
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
539 perm→FL {zero} perm = f0 |
89 | 540 perm→FL {suc n} perm = (perm ⟨$⟩ʳ (# 0)) :: perm→FL (remove (# 0) perm) |
541 -- perm→FL {suc n} perm = (perm ⟨$⟩ʳ (# 0)) :: perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ) | |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
542 |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
543 -- t5 = plist t4 ∷ plist ( t4 ∘ₚ flip (pins ( n≤ 3 ) )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
544 t5 = plist (t4) ∷ plist (flip t4) |
74 | 545 ∷ ( toℕ (t4 ⟨$⟩ˡ fromℕ< a<sa) ∷ [] ) |
61 | 546 ∷ ( toℕ (t4 ⟨$⟩ʳ (# 0)) ∷ [] ) |
60
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
547 -- ∷ plist ( t4 ∘ₚ flip (pins ( n≤ 1 ) )) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
548 ∷ plist (remove (# 0) t4 ) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
549 ∷ plist ( FL→perm t40 ) |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
550 ∷ [] |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
551 |
48926e810f5f
perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
552 t6 = perm→FL t4 |
49
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
553 |
97 | 554 -- postulate |
555 -- FL→iso : {n : ℕ } → (fl : FL n ) → perm→FL ( FL→perm fl ) ≡ fl | |
63 | 556 -- FL→iso f0 = refl |
557 -- FL→iso (x :: fl) = {!!} -- with FL→iso fl | |
61 | 558 -- ... | t = {!!} |
49
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
559 |
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
560 open _=p=_ |
97 | 561 -- FL←iso : {n : ℕ } → (perm : Permutation n n ) → FL→perm ( perm→FL perm ) =p= perm |
63 | 562 -- FL←iso {0} perm = record { peq = λ () } |
563 -- FL←iso {suc n} perm = {!!} | |
49
8b3b95362ca9
remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
564 |
66 | 565 lem2 : {i n : ℕ } → i ≤ n → i ≤ suc n |
91 | 566 lem2 i≤n = ≤-trans i≤n ( a≤sa ) |
66 | 567 |
67
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
568 ∀-FL : (n : ℕ ) → List (FL (suc n)) |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
569 ∀-FL x = fls6 x where |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
570 fls4 : ( i n : ℕ ) → (i<n : i ≤ n ) → FL n → List (FL (suc n)) → List (FL (suc n)) |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
571 fls4 zero n i≤n perm x = (zero :: perm ) ∷ x |
91 | 572 fls4 (suc i) n i≤n perm x = fls4 i n (≤-trans a≤sa i≤n ) perm ((fromℕ< (s≤s i≤n) :: perm ) ∷ x) |
67
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
573 fls5 : ( n : ℕ ) → List (FL n) → List (FL (suc n)) → List (FL (suc n)) |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
574 fls5 n [] x = x |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
575 fls5 n (h ∷ x) y = fls5 n x (fls4 n n lem0 h y) |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
576 fls6 : ( n : ℕ ) → List (FL (suc n)) |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
577 fls6 zero = (zero :: f0) ∷ [] |
3825082ebdbd
∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
578 fls6 (suc n) = fls5 (suc n) (fls6 n) [] |
65 | 579 |
97 | 580 tf1 = ∀-FL 4 |
581 tf2 = Data.List.map (λ k → ⟪ plist (FL→perm k ) , k ⟫ ) tf1 | |
582 | |
48 | 583 all-perm : (n : ℕ ) → List (Permutation (suc n) (suc n) ) |
584 all-perm n = pls6 n where | |
38 | 585 lem1 : {i n : ℕ } → i ≤ n → i < suc n |
586 lem1 z≤n = s≤s z≤n | |
587 lem1 (s≤s lt) = s≤s (lem1 lt) | |
40 | 588 pls4 : ( i n : ℕ ) → (i<n : i ≤ n ) → Permutation n n → List (Permutation (suc n) (suc n)) → List (Permutation (suc n) (suc n)) |
48 | 589 pls4 zero n i≤n perm x = (pprep perm ∘ₚ pins i≤n ) ∷ x |
91 | 590 pls4 (suc i) n i≤n perm x = pls4 i n (≤-trans a≤sa i≤n ) perm (pprep perm ∘ₚ pins {n} {suc i} i≤n ∷ x) |
40 | 591 pls5 : ( n : ℕ ) → List (Permutation n n) → List (Permutation (suc n) (suc n)) → List (Permutation (suc n) (suc n)) |
592 pls5 n [] x = x | |
593 pls5 n (h ∷ x) y = pls5 n x (pls4 n n lem0 h y) | |
594 pls6 : ( n : ℕ ) → List (Permutation (suc n) (suc n)) | |
595 pls6 zero = pid ∷ [] | |
48 | 596 pls6 (suc n) = pls5 (suc n) (rev (pls6 n) ) [] -- rev to put id first |
597 | |
598 pls : (n : ℕ ) → List (List ℕ ) | |
75 | 599 pls n = Data.List.map plist (all-perm n) |