annotate Putil.agda @ 105:e435dbe2e7a6

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 01 Sep 2020 17:45:33 +0900
parents 2d0738a38ac9
children 02f54eab9205
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 ∷ []
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
127 -- pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
128 -- pins {_} {zero} _ = pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
129 -- pins {suc _} {suc zero} _ = pswap pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
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: 93
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: 93
diff changeset
132 -- pins1 _ zero _ = pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
133 -- pins1 zero _ _ = pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
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
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
139 pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
140 pins {_} {zero} _ = pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
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
89
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
92
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
173 piso→ : (x : Fin (suc (suc n)) ) → p← ( p→ x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
174 piso→ zero with <-cmp (toℕ (fromℕ< (≤-trans (s≤s z≤n) (s≤s (s≤s m≤n) )))) (suc m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
175 ... | tri< a ¬b ¬c = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
176 piso→ (suc x) with <-cmp (toℕ (suc x)) (suc m)
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
177 ... | tri≈ ¬a refl ¬c = p13 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
178 p13 : fromℕ< (s≤s (s≤s m≤n)) ≡ suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
179 p13 = cong (λ k → suc k ) (fromℕ<-toℕ _ (s≤s m≤n) )
95
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
180 ... | tri> ¬a ¬b c = p16 (suc x) refl where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
181 p16 : (y : Fin (suc (suc n))) → y ≡ suc x → p← y ≡ suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
182 p16 zero eq = ⊥-elim ( nat-≡< (cong (λ k → suc (toℕ k) ) eq) (s≤s (s≤s (z≤n))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
183 p16 (suc y) eq with <-cmp (toℕ y) (suc m) -- suc (suc m) < toℕ (suc x)
96
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
184 ... | tri< a ¬b ¬c = ⊥-elim ( nat-≡< refl ( ≤-trans c (subst (λ k → k < suc m) p17 a )) ) where
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
185 -- x = suc m case, c : suc (suc m) ≤ suc (toℕ x), a : suc (toℕ y) ≤ suc m, suc y ≡ suc x
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
186 p17 : toℕ y ≡ toℕ x
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
187 p17 with <-cmp (toℕ y) (toℕ x) | cong toℕ eq
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
188 ... | tri< a ¬b ¬c | seq = ⊥-elim ( nat-≡< seq (s≤s a) )
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
189 ... | tri≈ ¬a b ¬c | seq = b
b43c4a7c57d9 pins done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
190 ... | tri> ¬a ¬b c | seq = ⊥-elim ( nat-≡< (sym seq) (s≤s c))
95
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
191 ... | tri≈ ¬a b ¬c = eq
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
192 ... | tri> ¬a ¬b c₁ = eq
92
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
193 ... | tri< a ¬b ¬c = p10 (fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) ))) refl where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
194 p10 : (y : Fin (suc (suc n)) ) → y ≡ fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) )) → p← y ≡ suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
195 p10 zero ()
93
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
196 p10 (suc y) eq = p15 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
197 p12 : toℕ y ≡ suc (toℕ x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
198 p12 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
199 toℕ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
200 ≡⟨ cong (λ k → Data.Nat.pred (toℕ k)) eq ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
201 toℕ (fromℕ< (≤-trans a (s≤s m≤n)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
202 ≡⟨ toℕ-fromℕ< {suc (toℕ x)} {suc n} (≤-trans a (s≤s m≤n)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
203 suc (toℕ x)
92
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
204
93
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
205 p15 : p← (suc y) ≡ suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
207 ... | tri< a₁ ¬b ¬c = p11 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
208 p11 : fromℕ< (≤-trans (fin<n {_} {y}) a≤sa ) ≡ suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
209 p11 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
210 fromℕ< (≤-trans (fin<n {_} {y}) a≤sa )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
211 ≡⟨ fromℕ<-irrelevant _ _ p12 _ (s≤s (fin<n {suc n})) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
212 suc (fromℕ< (fin<n {suc n} {x} ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
213 ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
214 suc x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
215
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
217 ... | tri> ¬a ¬b c = ⊥-elim ( nat-<> c (subst (λ k → k < suc m) (sym p12) a ))
92
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
218
89
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
219 piso← : (x : Fin (suc (suc n)) ) → p→ ( p← x ) ≡ x
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
220 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
221 ... | tri< a ¬b ¬c | t = ⊥-elim ( ¬b t )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
222 ... | tri≈ ¬a b ¬c | t = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
223 ... | tri> ¬a ¬b c | t = ⊥-elim ( ¬b t )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
224 piso← (suc x) with <-cmp (toℕ x) (suc m)
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
225 ... | tri> ¬a ¬b c with <-cmp (toℕ (suc x)) (suc m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
226 ... | tri< a ¬b₁ ¬c = ⊥-elim ( nat-<> a (<-trans c a<sa ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
227 ... | tri≈ ¬a₁ b ¬c = ⊥-elim ( nat-≡< (sym b) (<-trans c a<sa ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
228 ... | tri> ¬a₁ ¬b₁ c₁ = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
229 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
230 ... | tri< a ¬b ¬c₁ = ⊥-elim ( nat-≡< b (<-trans a<sa a) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
231 ... | tri≈ ¬a₁ refl ¬c₁ = ⊥-elim ( nat-≡< b a<sa )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
232 ... | tri> ¬a₁ ¬b c = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
233 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
234 ... | tri≈ ¬a b ¬c₁ = ⊥-elim ( ¬a (s≤s (mma x a)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
235 ... | tri> ¬a ¬b₁ c = ⊥-elim ( ¬a (s≤s (mma x a)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
236 ... | tri< a₁ ¬b₁ ¬c₁ = p0 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
237 p2 : suc (suc (toℕ x)) ≤ suc (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
238 p2 = s≤s (fin<n {suc n} {x})
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
239 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
240 p6 = s≤s (≤-trans a₁ (s≤s m≤n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
241 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
242 p0 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
243 fromℕ< (≤-trans (s≤s a₁) (s≤s (s≤s m≤n) ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
244 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
245 fromℕ< (s≤s (≤-trans a₁ (s≤s m≤n)))
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
246 ≡⟨ lemma10 (p3 x) {p6} {p2} ⟩
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
247 fromℕ< ( s≤s (fin<n {suc n} {x}) )
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
248 ≡⟨⟩
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
249 suc (fromℕ< (fin<n {suc n} {x} ))
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
250 ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
251 suc x
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
252
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
253
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
254 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: 93
diff changeset
255 -- t8 = {!!}
89
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
256
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
257 open import logic
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
258
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
259 open _∧_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
260
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
261 perm1 : {perm : Permutation 1 1 } {q : Fin 1} → (perm ⟨$⟩ʳ q ≡ # 0) ∧ ((perm ⟨$⟩ˡ q ≡ # 0))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
262 perm1 {p} {q} = ⟪ perm01 _ _ , perm00 _ _ ⟫ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
263 perm01 : (x y : Fin 1) → (p ⟨$⟩ʳ x) ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
264 perm01 x y with p ⟨$⟩ʳ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
265 perm01 zero zero | zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
266 perm00 : (x y : Fin 1) → (p ⟨$⟩ˡ x) ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
267 perm00 x y with p ⟨$⟩ˡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
268 perm00 zero zero | zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
269
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
270
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
271 p=0 : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) ≡ # 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
272 p=0 {zero} perm with ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
273 ... | zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
274 p=0 {suc n} perm with perm ⟨$⟩ʳ (# 0) | inspect (_⟨$⟩ʳ_ perm ) (# 0)| toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) | inspect toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
275 ... | zero | record { eq = e} | m<n | _ = p001 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
276 p001 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
277 p001 = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) e (inverseˡ perm)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
278 ... | suc t | record { eq = e } | m<n | record { eq = e1 } = p002 where -- m<n : suc (toℕ t) ≤ suc n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
279 p002 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
280 p002 = p005 zero (toℕ t) refl m<n refl where -- suc (toℕ t) ≤ suc n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
281 p003 : (s : Fin (suc (suc n))) → s ≡ (perm ⟨$⟩ʳ (# 0)) → perm ⟨$⟩ˡ s ≡ # 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
282 p003 s eq = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) (sym eq) (inverseˡ perm)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
284 p005 zero m eq (s≤s m≤n) meq = p004 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
285 p004 : perm ⟨$⟩ˡ (fromℕ< (s≤s (s≤s m≤n))) ≡ zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
286 p004 = p003 (fromℕ< (s≤s (s≤s m≤n))) (
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
287 begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
288 fromℕ< (s≤s (s≤s m≤n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
289 ≡⟨ 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)) ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
290 fromℕ< (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
291 ≡⟨ fromℕ<-toℕ {suc (suc n)} (suc t) (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
292 suc t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
293 ≡⟨ sym e ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
294 (perm ⟨$⟩ʳ (# 0))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
295 ∎ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
296
101
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
297 px=x : {n : ℕ } → (x : Fin (suc n)) → pins ( toℕ≤pred[n] x ) ⟨$⟩ʳ (# 0) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
298 px=x {n} zero = refl
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
299 px=x {suc n} (suc x) = p001 where
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
300 p002 : fromℕ< (s≤s (toℕ≤pred[n] x)) ≡ x
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
301 p002 = fromℕ<-toℕ x (s≤s (toℕ≤pred[n] x))
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
302 p001 : (pins (toℕ≤pred[n] (suc x)) ⟨$⟩ʳ (# 0)) ≡ suc x
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
303 p001 with <-cmp 0 ((toℕ x))
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
304 ... | tri< a ¬b ¬c = cong suc p002
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
305 ... | tri≈ ¬a b ¬c = cong suc p002
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
306
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
307 -- pp : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → Fin (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
308 -- pp perm → (( perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
309
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
310 plist2 : {n : ℕ} → Permutation (suc n) (suc n) → (i : ℕ ) → i < suc n → List ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
311 plist2 {n} perm zero _ = toℕ ( perm ⟨$⟩ʳ (fromℕ< {zero} (s≤s z≤n))) ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
312 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
313
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
314 plist0 : {n : ℕ} → Permutation n n → List ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
315 plist0 {0} perm = []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
316 plist0 {suc n} perm = plist2 perm n a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
317
85
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
318 open _=p=_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
319
86
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
320 --
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
321 -- plist cong
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
322 --
85
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
323 ←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
324 ←pleq {zero} x y eq = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
325 ←pleq {suc n} x y eq = ←pleq1 n a<sa where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
326 ←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
327 ←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
328 ←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
329
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
330 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
331 headeq refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
332
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
333 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
334 taileq refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
335
86
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
336 --
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
337 -- plist equalizer
c5329963c583 (x : Permutation 1 1 ) → x =p= pid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
338 --
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
339 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
340 pleq {0} x y refl = record { peq = λ q → pleq0 q } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
341 pleq0 : (q : Fin 0 ) → (x ⟨$⟩ʳ q) ≡ (y ⟨$⟩ʳ q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
342 pleq0 ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
343 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
344 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
345 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
346 ... | tri< () ¬b ¬c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
347 ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
348 ... | tri≈ ¬a b ¬c = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
349 x ⟨$⟩ʳ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
350 ≡⟨ cong ( λ k → x ⟨$⟩ʳ k ) (toℕ-injective b )⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
351 x ⟨$⟩ʳ zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
352 ≡⟨ toℕ-injective (headeq eq) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
353 y ⟨$⟩ʳ zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
354 ≡⟨ cong ( λ k → y ⟨$⟩ʳ k ) (sym (toℕ-injective b )) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
355 y ⟨$⟩ʳ q
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
356
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
357 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
358 ... | 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
359 ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i )
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
360 ... | tri≈ ¬a b ¬c = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
361 x ⟨$⟩ʳ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
362 ≡⟨ cong (λ k → x ⟨$⟩ʳ k) (pleq3 b) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
363 x ⟨$⟩ʳ (suc (fromℕ< i<sn))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
364 ≡⟨ toℕ-injective pleq2 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
365 y ⟨$⟩ʳ (suc (fromℕ< i<sn))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
366 ≡⟨ cong (λ k → y ⟨$⟩ʳ k) (sym (pleq3 b)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
367 y ⟨$⟩ʳ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
368 ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
369 pleq3 : toℕ q ≡ suc i → q ≡ suc (fromℕ< i<sn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
370 pleq3 tq=si = toℕ-injective ( begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
371 toℕ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
372 ≡⟨ b ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
373 suc i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
374 ≡⟨ sym (toℕ-fromℕ< (s≤s i<sn)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
375 toℕ (fromℕ< (s≤s i<sn))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
376 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
377 toℕ (suc (fromℕ< i<sn))
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
378 ∎ )
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
379 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
380 pleq2 = headeq eq
37
32db08b3c1a3 emumelation done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
381
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
382 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
383 pprep-cong {n} {x} {y} x=y = record { peq = pprep-cong1 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
384 pprep-cong1 : (q : Fin (suc n)) → (pprep x ⟨$⟩ʳ q) ≡ (pprep y ⟨$⟩ʳ q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
385 pprep-cong1 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
386 pprep-cong1 (suc q) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
387 pprep x ⟨$⟩ʳ suc q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
388 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
389 suc ( x ⟨$⟩ʳ q )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
390 ≡⟨ cong ( λ k → suc k ) ( peq x=y q ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
391 suc ( y ⟨$⟩ʳ q )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
392 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
393 pprep y ⟨$⟩ʳ suc q
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
394
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
395
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
396 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
397 pprep-dist {n} {x} {y} = record { peq = pprep-dist1 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
398 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
399 pprep-dist1 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
400 pprep-dist1 (suc q) = cong ( λ k → suc k ) refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
401
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
402 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
403 pswap-cong {n} {x} {y} x=y = record { peq = pswap-cong1 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
404 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
405 pswap-cong1 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
406 pswap-cong1 (suc zero) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
407 pswap-cong1 (suc (suc q)) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
408 pswap x ⟨$⟩ʳ suc (suc q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
409 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
410 suc (suc (x ⟨$⟩ʳ q))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
411 ≡⟨ cong ( λ k → suc (suc k) ) ( peq x=y q ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
412 suc (suc (y ⟨$⟩ʳ q))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
413 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
414 pswap y ⟨$⟩ʳ suc (suc q)
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
415
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
416
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
417 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
418 pswap-dist {n} {x} {y} = record { peq = pswap-dist1 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
419 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
420 pswap-dist1 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
421 pswap-dist1 (suc zero) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
422 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
423
49
8b3b95362ca9 remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
424 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
425 f0 : FL 0
8b3b95362ca9 remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
426 _::_ : { 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
427
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
428 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
429 shlem→ perm p0=0 x px=0 = begin
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
430 x ≡⟨ sym ( inverseʳ perm ) ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
431 perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ x) ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) px=0 ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
432 perm ⟨$⟩ʳ zero ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) (sym p0=0) ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
433 perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ zero) ≡⟨ inverseʳ perm ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
434 zero
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
435 ∎ where open ≡-Reasoning
54
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
436
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
437 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
438 shlem← perm p0=0 x px=0 = begin
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
439 x ≡⟨ sym (inverseˡ perm ) ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
440 perm ⟨$⟩ˡ ( perm ⟨$⟩ʳ x ) ≡⟨ cong (λ k → perm ⟨$⟩ˡ k ) px=0 ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
441 perm ⟨$⟩ˡ zero ≡⟨ p0=0 ⟩
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
442 zero
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
443 ∎ where open ≡-Reasoning
54
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
444
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
445 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
446 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
447 sh2 perm p0=0 {x} eq | ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
448
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
449 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
450 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
451 sh1 perm p0=0 {x} eq | ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
452
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
453
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
454 -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] → 0 ∷ 1 ∷ 2 ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
455 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
456 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
457
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
458 p→ : Fin n → Fin n
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
459 p→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
460 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
461 p→ x | suc t | _ = t
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
462
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
463 p← : Fin n → Fin n
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
464 p← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
465 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
466 p← x | suc t | _ = t
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
467
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
468 piso← : (x : Fin n ) → p→ ( p← x ) ≡ x
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
469 piso← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
470 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
471 piso← x | suc t | _ with perm ⟨$⟩ʳ (suc t) | inspect (_⟨$⟩ʳ_ perm ) (suc t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
472 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
473 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
474 t1
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
475 ≡⟨ plem0 plem1 ⟩
52
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
476 x
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
477 ∎ where
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
478 open ≡-Reasoning
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
479 plem0 : suc t1 ≡ suc x → t1 ≡ x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
480 plem0 refl = refl
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
481 plem1 : suc t1 ≡ suc x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
482 plem1 = begin
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
483 suc t1
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
484 ≡⟨ sym e1 ⟩
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
485 Inverse.to perm Π.⟨$⟩ suc t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
486 ≡⟨ cong (λ k → Inverse.to perm Π.⟨$⟩ k ) (sym e0) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
487 Inverse.to perm Π.⟨$⟩ ( Inverse.from perm Π.⟨$⟩ suc x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
488 ≡⟨ inverseʳ perm ⟩
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
489 suc x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
490
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
491
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
492 piso→ : (x : Fin n ) → p← ( p→ x ) ≡ x
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
493 piso→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
494 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
495 piso→ x | suc t | _ with perm ⟨$⟩ˡ (suc t) | inspect (_⟨$⟩ˡ_ perm ) (suc t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
496 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
497 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
498 t1
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
499 ≡⟨ plem2 plem3 ⟩
53
2283d6f8a2fb connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
500 x
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
501 ∎ where
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
502 open ≡-Reasoning
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
503 plem2 : suc t1 ≡ suc x → t1 ≡ x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
504 plem2 refl = refl
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
505 plem3 : suc t1 ≡ suc x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
506 plem3 = begin
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
507 suc t1
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
508 ≡⟨ sym e1 ⟩
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
509 Inverse.from perm Π.⟨$⟩ suc t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
510 ≡⟨ cong (λ k → Inverse.from perm Π.⟨$⟩ k ) (sym e0 ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
511 Inverse.from perm Π.⟨$⟩ ( Inverse.to perm Π.⟨$⟩ suc x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
512 ≡⟨ inverseˡ perm ⟩
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
513 suc x
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
514
57
518d364a58a3 shrink worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
515
88
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
516 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
517 shrink-iso {n} {perm} = record { peq = λ q → refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
518
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
519 shrink-cong : { n : ℕ } → {x y : Permutation (suc n) (suc n)}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
520 → x =p= y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
521 → (x=0 : x ⟨$⟩ˡ (# 0) ≡ # 0 ) → (y=0 : y ⟨$⟩ˡ (# 0) ≡ # 0 ) → shrink x x=0 =p= shrink y y=0
99
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
522 shrink-cong {n} {x} {y} x=y x=0 y=0 = record { peq = p002 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
523 p002 : (q : Fin n) → (shrink x x=0 ⟨$⟩ʳ q) ≡ (shrink y y=0 ⟨$⟩ʳ q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
524 p002 q with x ⟨$⟩ʳ (suc q) | inspect (_⟨$⟩ʳ_ x ) (suc q) | y ⟨$⟩ʳ (suc q) | inspect (_⟨$⟩ʳ_ y ) (suc q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
525 p002 q | zero | record { eq = ex } | zero | ey = ⊥-elim ( sh1 x x=0 ex )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
526 p002 q | zero | record { eq = ex } | suc py | ey = ⊥-elim ( sh1 x x=0 ex )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
527 p002 q | suc px | ex | zero | record { eq = ey } = ⊥-elim ( sh1 y y=0 ey )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
528 p002 q | suc px | record { eq = ex } | suc py | record { eq = ey } = p003 ( begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
529 suc px
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
530 ≡⟨ sym ex ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
531 x ⟨$⟩ʳ (suc q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
532 ≡⟨ peq x=y (suc q) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
533 y ⟨$⟩ʳ (suc q)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
534 ≡⟨ ey ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
535 suc py
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
536 ∎ ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
537 p003 : suc px ≡ suc py → px ≡ py
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
538 p003 refl = refl
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
539
57
518d364a58a3 shrink worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
540 FL→perm : {n : ℕ } → FL n → Permutation n n
518d364a58a3 shrink worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
541 FL→perm f0 = pid
518d364a58a3 shrink worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
542 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
543
60
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
544 t40 = (# 2) :: ( (# 1) :: (( # 0 ) :: f0 ))
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
545 t4 = FL→perm ((# 2) :: t40 )
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
546
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
547 -- 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
548 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
549 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
550 -- ∷ 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
551 -- ∷ 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
552 -- ∷ 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
553 -- ∷ 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
554 ∷ 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
555 ∷ 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
556 ∷ 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
557 ∷ 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
558 -- ∷ 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
559 -- ∷ 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
560 -- ∷ 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
561 -- ∷ 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
562 ∷ []
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
563
58
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
564
49
8b3b95362ca9 remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
565 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
566 perm→FL {zero} perm = f0
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
567 perm→FL {suc n} perm = (perm ⟨$⟩ʳ (# 0)) :: perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
568 -- perm→FL {suc n} perm = (perm ⟨$⟩ʳ (# 0)) :: perm→FL (remove (# 0) perm)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
569
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
570 pcong-pF : {n : ℕ } → {x y : Permutation n n} → x =p= y → perm→FL x ≡ perm→FL y
99
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
571 pcong-pF {zero} eq = refl
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
572 pcong-pF {suc n} {x} {y} eq = cong₂ (λ j k → j :: k ) ( peq eq (# 0)) (pcong-pF (shrink-cong (presp eq p001 ) (p=0 x) (p=0 y))) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
573 p002 : x ⟨$⟩ʳ (# 0) ≡ y ⟨$⟩ʳ (# 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
574 p002 = peq eq (# 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
575 p001 : flip (pins (toℕ≤pred[n] (x ⟨$⟩ʳ (# 0)))) =p= flip (pins (toℕ≤pred[n] (y ⟨$⟩ʳ (# 0))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
576 p001 = subst ( λ k → flip (pins (toℕ≤pred[n] (x ⟨$⟩ʳ (# 0)))) =p= flip (pins (toℕ≤pred[n] k ))) p002 prefl
60
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
577
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
578 -- 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
579 t5 = plist (t4) ∷ plist (flip t4)
74
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 67
diff changeset
580 ∷ ( toℕ (t4 ⟨$⟩ˡ fromℕ< a<sa) ∷ [] )
61
c16749815259 another shrink
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
581 ∷ ( toℕ (t4 ⟨$⟩ʳ (# 0)) ∷ [] )
60
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
582 -- ∷ plist ( t4 ∘ₚ flip (pins ( n≤ 1 ) ))
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
583 ∷ plist (remove (# 0) t4 )
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
584 ∷ plist ( FL→perm t40 )
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
585 ∷ []
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
586
48926e810f5f perm→FL done. pprep fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
587 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
588
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
589 ----
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
590 -- if n is fixed, perm→FL ( FL→perm fl ) ≡ fl is refl for each concrete fl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
591 -- so we may prove this easily by co-induction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
592 --
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
593 FL→iso : {n : ℕ } → (fl : FL n ) → perm→FL ( FL→perm fl ) ≡ fl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
594 FL→iso f0 = refl
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
595 FL→iso {suc n} (x :: fl) = cong₂ ( λ j k → j :: k ) f001 f002 where
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
596 perm = pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
597 f001 : perm ⟨$⟩ʳ (# 0) ≡ x
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
598 f001 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
599 (pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ (# 0)
101
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
600 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
601 pins ( toℕ≤pred[n] x ) ⟨$⟩ʳ (# 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
602 ≡⟨ px=x x ⟩
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
603 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
604
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
605 x=0 : (perm ∘ₚ flip (pins (toℕ≤pred[n] x))) ⟨$⟩ˡ (# 0) ≡ # 0
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
606 x=0 = subst ( λ k → (perm ∘ₚ flip (pins (toℕ≤pred[n] k))) ⟨$⟩ˡ (# 0) ≡ # 0 ) f001 (p=0 perm)
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
607 x=0' : (pprep (FL→perm fl) ∘ₚ pid) ⟨$⟩ˡ (# 0) ≡ # 0
100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
608 x=0' = refl
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
609 f003 : (q : Fin (suc n)) →
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
610 ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ʳ q) ≡
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
611 ((perm ∘ₚ flip (pins (toℕ≤pred[n] x))) ⟨$⟩ʳ q)
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
612 f003 q = cong (λ k → (perm ∘ₚ flip (pins (toℕ≤pred[n] k))) ⟨$⟩ʳ q ) f001
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
613 f002 : perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ) ≡ fl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
614 f002 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
615 perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) )
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
616 ≡⟨ pcong-pF (shrink-cong {n} {perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))} {perm ∘ₚ flip (pins (toℕ≤pred[n] x))} record {peq = f003 } (p=0 perm) x=0) ⟩
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
617 perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] x))) x=0 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
618 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
619 perm→FL (shrink ((pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )) ∘ₚ flip (pins (toℕ≤pred[n] x))) x=0 )
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
620 ≡⟨ pcong-pF (shrink-cong (passoc (pprep (FL→perm fl)) (pins ( toℕ≤pred[n] x )) (flip (pins (toℕ≤pred[n] x))) ) x=0 x=0) ⟩
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
621 perm→FL (shrink (pprep (FL→perm fl) ∘ₚ (pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))) x=0 )
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
622 ≡⟨ pcong-pF (shrink-cong {n} {pprep (FL→perm fl) ∘ₚ (pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))} {pprep (FL→perm fl) ∘ₚ pid}
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
623 ( presp {suc n} {pprep (FL→perm fl) } {_} {(pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))} {pid} prefl
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
624 record { peq = λ q → inverseˡ (pins ( toℕ≤pred[n] x )) } ) x=0 x=0') ⟩
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
625 perm→FL (shrink (pprep (FL→perm fl) ∘ₚ pid) x=0' )
103
7595ee384b3d FL→iso done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
626 ≡⟨ pcong-pF (shrink-cong {n} {pprep (FL→perm fl) ∘ₚ pid} {pprep (FL→perm fl)} record {peq = λ q → refl } x=0' x=0') ⟩ -- prefl won't work
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
627 perm→FL (shrink (pprep (FL→perm fl)) x=0' )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
628 ≡⟨ pcong-pF shrink-iso ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
629 perm→FL ( FL→perm fl )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
630 ≡⟨ FL→iso fl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
631 fl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
632
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
633
104
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
634 pcong-Fp : {n : ℕ } → {x y : FL n} → x ≡ y → FL→perm x =p= FL→perm y
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
635 pcong-Fp {n} {x} {x} refl = prefl
49
8b3b95362ca9 remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
636
104
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
637 FL←iso : {n : ℕ } → (perm : Permutation n n ) → FL→perm ( perm→FL perm ) =p= perm
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
638 FL←iso {0} perm = record { peq = λ () }
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
639 FL←iso {suc n} perm with perm→FL perm | inspect perm→FL perm
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
640 ... | x :: fl | record { eq = e } = ptrans (pcong-Fp e ) f004 where
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
641 f003 : perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm)) ≡ fl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
642 f003 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
643 f004 : FL→perm ( x :: fl ) =p= perm
104
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
644 f004 = record { peq = λ q → ( begin
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
645 (pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ q
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
646 ≡⟨ cong (λ k → (pprep (FL→perm k) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ q ) (sym f003 ) ⟩
104
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
647 (pprep (FL→perm (perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ))) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ q
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
648 ≡⟨ peq (presp (pprep-cong (FL←iso _ ) ) prefl ) q ⟩
104
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
649 (pprep (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm)) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ q
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
650 ≡⟨ {!!} ⟩
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
651 perm ⟨$⟩ʳ q
2d0738a38ac9 ... bad approach
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
652 ∎ ) }
49
8b3b95362ca9 remove (fromℕ≤ a<sa) perm is no good
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
653
66
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
654 lem2 : {i n : ℕ } → i ≤ n → i ≤ suc n
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
655 lem2 i≤n = ≤-trans i≤n ( a≤sa )
66
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
656
67
3825082ebdbd ∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 66
diff changeset
657 ∀-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
658 ∀-FL x = fls6 x where
3825082ebdbd ∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 66
diff changeset
659 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
660 fls4 zero n i≤n perm x = (zero :: perm ) ∷ x
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
661 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
662 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
663 fls5 n [] x = x
3825082ebdbd ∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 66
diff changeset
664 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
665 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
666 fls6 zero = (zero :: f0) ∷ []
3825082ebdbd ∀-FL : (n : ℕ ) → List (FL (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 66
diff changeset
667 fls6 (suc n) = fls5 (suc n) (fls6 n) []
65
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
668
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
669 tf1 = ∀-FL 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
670 tf2 = Data.List.map (λ k → ⟪ plist (FL→perm k ) , k ⟫ ) tf1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
671
48
ac2f21a2d467 cleanup
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
672 all-perm : (n : ℕ ) → List (Permutation (suc n) (suc n) )
ac2f21a2d467 cleanup
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
673 all-perm n = pls6 n where
38
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 37
diff changeset
674 lem1 : {i n : ℕ } → i ≤ n → i < suc n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 37
diff changeset
675 lem1 z≤n = s≤s z≤n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 37
diff changeset
676 lem1 (s≤s lt) = s≤s (lem1 lt)
40
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
677 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
678 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
679 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
680 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
681 pls5 n [] x = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
682 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
683 pls6 : ( n : ℕ ) → List (Permutation (suc n) (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
684 pls6 zero = pid ∷ []
48
ac2f21a2d467 cleanup
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
685 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
686
ac2f21a2d467 cleanup
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
687 pls : (n : ℕ ) → List (List ℕ )
75
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
688 pls n = Data.List.map plist (all-perm n)