annotate Putil.agda @ 91:482ef04890f8

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