annotate Symmetric.agda @ 33:a986f22cde84

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 19 Aug 2020 18:23:20 +0900
parents 5b299203acf0
children c9dbbe12a03b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
1 module Symmetric where
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level hiding ( suc ; zero )
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Algebra
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Algebra.Structures
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
6 open import Data.Fin hiding ( _<_ )
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
7 open import Data.Fin.Properties hiding ( <-cmp ; <-trans )
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
8 open import Data.Product
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
17 open import Data.List using (List; []; _∷_ ; length)
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
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 fid : {p : ℕ } → Fin p → Fin p
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 fid x = x
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 -- Data.Fin.Permutation.id
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 pid : {p : ℕ } → Permutation p p
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 pid = permutation fid fid record { left-inverse-of = λ x → refl ; right-inverse-of = λ x → refl }
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 -- Data.Fin.Permutation.flip
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 pinv : {p : ℕ } → Permutation p p → Permutation p p
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 pinv {p} P = permutation (_⟨$⟩ˡ_ P) (_⟨$⟩ʳ_ P ) record { left-inverse-of = λ x → inverseʳ P ; right-inverse-of = λ x → inverseˡ P }
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
31 record _=p=_ {p : ℕ } ( x y : Permutation p p ) : Set where
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
32 field
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
33 peq : ( q : Fin p ) → x ⟨$⟩ʳ q ≡ y ⟨$⟩ʳ q
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
35 open _=p=_
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
37 prefl : {p : ℕ } { x : Permutation p p } → x =p= x
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
38 peq (prefl {p} {x}) q = refl
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
39
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
40 psym : {p : ℕ } { x y : Permutation p p } → x =p= y → y =p= x
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
41 peq (psym {p} {x} {y} eq ) q = sym (peq eq q)
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
42
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
43 ptrans : {p : ℕ } { x y z : Permutation p p } → x =p= y → y =p= z → x =p= z
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
44 peq (ptrans {p} {x} {y} x=y y=z ) q = trans (peq x=y q) (peq y=z q)
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
46 Symmetric : ℕ → Group Level.zero Level.zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
47 Symmetric p = record {
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 Carrier = Permutation p p
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
49 ; _≈_ = _=p=_
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 ; _∙_ = _∘ₚ_
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 ; ε = pid
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 ; _⁻¹ = pinv
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
53 ; isGroup = record { isMonoid = record { isSemigroup = record { isMagma = record {
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
54 isEquivalence = record {refl = prefl ; trans = ptrans ; sym = psym }
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 ; ∙-cong = presp }
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 ; assoc = passoc }
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
57 ; identity = ( (λ q → record { peq = λ q → refl } ) , (λ q → record { peq = λ q → refl } )) }
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
58 ; inverse = ( (λ x → record { peq = λ q → inverseʳ x} ) , (λ x → record { peq = λ q → inverseˡ x} ))
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
59 ; ⁻¹-cong = λ i=j → record { peq = λ q → p-inv i=j q }
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 } where
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
62 presp : {x y u v : Permutation p p } → x =p= y → u =p= v → (x ∘ₚ u) =p= (y ∘ₚ v)
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
63 presp {x} {y} {u} {v} x=y u=v = record { peq = λ q → lemma4 q } where
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
64 lemma4 : (q : Fin p) → ((x ∘ₚ u) ⟨$⟩ʳ q) ≡ ((y ∘ₚ v) ⟨$⟩ʳ q)
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
65 lemma4 q = trans (cong (λ k → Inverse.to u Π.⟨$⟩ k) (peq x=y q) ) (peq u=v _ )
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
66 passoc : (x y z : Permutation p p) → ((x ∘ₚ y) ∘ₚ z) =p= (x ∘ₚ (y ∘ₚ z))
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
67 passoc x y z = record { peq = λ q → refl }
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
68 p-inv : {i j : Permutation p p} → i =p= j → (q : Fin p) → pinv i ⟨$⟩ʳ q ≡ pinv j ⟨$⟩ʳ q
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
69 p-inv {i} {j} i=j q = begin
4
121213cfc85a add Solvable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
70 i ⟨$⟩ˡ q ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (inverseʳ j) ) ⟩
121213cfc85a add Solvable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
71 i ⟨$⟩ˡ ( j ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (peq i=j _ )) ⟩
121213cfc85a add Solvable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
72 i ⟨$⟩ˡ ( i ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ inverseˡ i ⟩
121213cfc85a add Solvable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
73 j ⟨$⟩ˡ q
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
74 ∎ where open ≡-Reasoning
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
33
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
76 perm0 : {n : ℕ } → Permutation n n
16
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
77 perm0 = permutation fid fid record { left-inverse-of = λ x → refl ; right-inverse-of = λ x → refl }
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
16
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
79 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
80 open import Data.Empty
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
81 open import Relation.Binary.Core
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
82 open import fin
16
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
83
33
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
84 fperm0 : {n : ℕ } → Permutation n n → Permutation (suc n) (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
85 fperm0 {n} perm = permutation p→ p← record { left-inverse-of = piso← ; right-inverse-of = {!!} } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
86 p→ : Fin (suc n) → Fin (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
87 p→ x with <-cmp (toℕ x) n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
88 p→ x | tri< a ¬b ¬c = fin+1 ( perm ⟨$⟩ˡ ( fromℕ≤ a ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
89 p→ x | tri≈ ¬a b ¬c = fromℕ≤ a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
90 p→ x | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c fin<n )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
92 p← : Fin (suc n) → Fin (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
93 p← x with <-cmp (toℕ x) n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
94 p← x | tri< a ¬b ¬c = fin+1 ( perm ⟨$⟩ʳ ( fromℕ≤ a ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
95 p← x | tri≈ ¬a b ¬c = fromℕ≤ a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
96 p← x | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c fin<n )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
98 piso← : (x : Fin (suc n)) → p← ( p→ x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
99 piso← x with <-cmp (toℕ x) n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
100 piso← x | tri< a ¬b ¬c = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
101 p← ( fin+1 (perm ⟨$⟩ˡ (fromℕ≤ a)) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
102 ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
103 fin+1 ( perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ ( fromℕ≤ a )) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
104 ≡⟨ cong (λ k → fin+1 k ) ( inverseʳ perm ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
105 fin+1 (fromℕ≤ a)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
106 ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
107 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
108 ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
109 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
110 piso← x | tri≈ ¬a b ¬c = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
111 p← ( fromℕ≤ a<sa )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
112 ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
113 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
114 ∎ where open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
115 piso← x | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c fin<n )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
116
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
117 fswap : {n m : ℕ } → suc m < n → Permutation n n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
118 fswap {n} {m} n<m = permutation p→ p→ record { left-inverse-of = piso← ; right-inverse-of = piso←} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
119 p→ : Fin n → Fin (n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
120 p→ x with <-cmp (toℕ x) m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
121 p→ x | tri< a ¬b ¬c = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
122 p→ x | tri≈ ¬a b ¬c = fromℕ≤ {suc m} {n} n<m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
123 p→ x | tri> ¬a ¬b c with <-cmp (toℕ x) (suc m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
124 p→ x | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
125 p→ x | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = fromℕ≤ {m} {n} (<-trans a<sa n<m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
126 p→ x | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
127
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
128 piso← : (x : Fin (n)) → p→ ( p→ x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
129 piso← x with <-cmp (toℕ x) m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
130 piso← x | tri< a ¬b ¬c = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
131 piso← x | tri≈ ¬a b ¬c = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
132 piso← x | tri> ¬a ¬b c with <-cmp (toℕ x) (suc m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
133 piso← x | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
134 piso← x | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
135 piso← x | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
136
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
137
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
138 fperm : {n m : ℕ} → m < n → Permutation n n → Permutation (suc n) (suc n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
139 fperm {zero} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
140 fperm {suc n} {m} (s≤s m<n) perm = permutation p→ p← record { left-inverse-of = piso← ; right-inverse-of = piso→ } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
141 p→ : Fin (suc (suc n)) → Fin (suc (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
142 p→ x with <-cmp (toℕ x) m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
143 p→ x | tri< a ¬b ¬c = fin+1 (perm ⟨$⟩ʳ (fromℕ≤ x<sn)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
144 x<sn : toℕ x < suc n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
145 x<sn = <-trans a (s≤s m<n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
146 p→ x | tri≈ ¬a b ¬c = fromℕ≤ a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
147 p→ x | tri> ¬a ¬b c = fin+1 (perm ⟨$⟩ʳ (fromℕ≤ (pred<n {_} {x} 0<s )))
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
148
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
149 p← : Fin (suc (suc n)) → Fin (suc (suc n))
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
150 p← x = lemma (suc n) refl x where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
151 lemma : (i : ℕ ) → i ≡ suc n → (x : Fin (suc (suc n))) → Fin (suc (suc n))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
152 lemma i refl x with <-cmp (toℕ x) i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
153 lemma i refl x | tri< a ¬b ¬c = fin+1 (perm ⟨$⟩ˡ (fromℕ≤ x<sn)) where
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
154 x<sn : toℕ x < suc n
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
155 x<sn = a
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
156 lemma i refl x | tri≈ ¬a b ¬c = fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa )
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
157 lemma i refl x | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c fin<n )
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
158 lem8 : {x : Fin (suc (suc n)) } → toℕ ( fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa )) ≡ m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
159 lem8 {x} = toℕ-fromℕ≤ (<-trans (s≤s m<n ) a<sa )
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
160 piso← : (x : Fin (suc (suc n))) → p← ( p→ x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
161 piso← x with <-cmp (toℕ x) m
31
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
162 piso← x | tri< a ¬b ¬c = begin
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
163 p← ( fin+1 (perm ⟨$⟩ʳ (fromℕ≤ x<sn)) )
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
164 ≡⟨ {!!} ⟩
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
165 fin+1 (perm ⟨$⟩ˡ (perm ⟨$⟩ʳ fromℕ≤ (<-trans a (s≤s m<n))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
166 ≡⟨ cong (λ k → fin+1 k ) (inverseˡ perm) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
167 fin+1 (fromℕ≤ x<sn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
168 ≡⟨ {!!} ⟩
31
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
169 x
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
170 ∎ where
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
171 open ≡-Reasoning
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
172 k = inverseˡ perm
31
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
173 x<sn : toℕ x < suc n
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
174 x<sn = <-trans a (s≤s m<n)
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
175 piso← x | tri> ¬a ¬b c = begin
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
176 p← ( fin+1 (perm ⟨$⟩ʳ (fromℕ≤ (pred<n {_} {x} 0<s ))))
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
177 ≡⟨ {!!} ⟩
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
178 x
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
179 ∎ where
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
180 open ≡-Reasoning
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
181 piso← x | tri≈ ¬a refl ¬c = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
182 p← ( fromℕ≤ a<sa )
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
183 ≡⟨ lem4 refl ⟩
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
184 fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa )
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
185 ≡⟨ {!!} ⟩
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
186 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
187 ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
188 open ≡-Reasoning
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
189 lem4 : {x : Fin (suc (suc n)) } → x ≡ fromℕ≤ {suc n} a<sa → p← x ≡ fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa )
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
190 lem4 {x} refl with <-cmp (toℕ x) (suc n)
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
191 lem4 refl | tri< a ¬b ¬c = ⊥-elim ( ¬b {!!} )
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
192 lem4 refl | tri≈ ¬a b ¬c = refl
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
193 lem4 refl | tri> ¬a ¬b c = ⊥-elim ( ¬b {!!} )
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
194 piso→ : (x : Fin (suc (suc n))) → p→ ( p← x ) ≡ x
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
195 piso→ x = lemma2 (suc n) refl x where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
196 lemma2 : (i : ℕ ) → i ≡ suc n → (x : Fin (suc (suc n))) → p→ ( p← x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
197 lemma2 i refl x with <-cmp (toℕ x) i
31
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
198 lemma2 i refl x | tri< a ¬b ¬c = begin
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
199 p→ ( fin+1 (perm ⟨$⟩ˡ (fromℕ≤ x<sn)))
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
200 ≡⟨ {!!} ⟩
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
201 x
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
202 ∎ where
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
203 open ≡-Reasoning
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
204 x<sn : toℕ x < suc n
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
205 x<sn = a
039e8511da2a fperm connected
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 30
diff changeset
206 lemma2 i refl x | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c fin<n )
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
207 lemma2 i refl x | tri≈ ¬a b ¬c = begin
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
208 p→ (fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
209 ≡⟨ lem5 (fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa )) {!!} ⟩
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
210 fromℕ≤ a<sa
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
211 ≡⟨ {!!} ⟩
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
212 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
213 ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
214 open ≡-Reasoning
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
215 lem7 : {x : Fin (suc (suc n)) } → x ≡ fromℕ≤ (s≤s (s≤s m<n)) → toℕ x ≡ m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
216 lem7 refl = trans (toℕ-fromℕ≤ _) {!!}
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
217 lem6 : {x : Fin (suc (suc n)) } → x ≡ fromℕ≤ (s≤s (s≤s m<n)) → toℕ x ≡ (suc m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
218 lem6 refl = toℕ-fromℕ≤ _
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
219 -- lem5 : {x : Fin (suc (suc n)) } → x ≡ fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa ) → p→ x ≡ fromℕ≤ a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
220 lem5 : (x : Fin (suc (suc n)) ) → x ≡ fromℕ≤ {m} {suc (suc n)} (<-trans (s≤s m<n ) a<sa ) → p→ x ≡ fromℕ≤ a<sa
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
221 lem5 x eq with <-cmp (toℕ x) m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
222 lem5 x eq | tri< a ¬b ¬c = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
223 lem5 x eq | tri≈ ¬a refl ¬c = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
224 lem5 x eq | tri> ¬a ¬b c = {!!}
16
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
225