annotate src/Symmetric.agda @ 316:d712d2a1f8bb stack-8.10.7

fix for new agda stdlib
author kono
date Sat, 16 Sep 2023 14:59:33 +0900
parents 6d1619d9f880
children
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
37
32db08b3c1a3 emumelation done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 36
diff changeset
6 open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ )
41
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
7 open import Data.Fin.Properties hiding ( <-trans ; ≤-trans ) renaming ( <-cmp to <-fcmp )
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
46
88f9aff7eb71 eperm done?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
17 open import Data.List using (List; []; _∷_ ; length ; _++_ ; head ) 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
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
316
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
25 pid = permutation fid fid (λ x → refl) (λ x → refl) -- 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
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
316
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
29 pinv {p} P = permutation (_⟨$⟩ˡ_ P) (_⟨$⟩ʳ_ P ) (λ x → inverseˡ P ) ( λ x → inverseʳ P) -- record { left-inverse-of = λ x → inverseʳ P ; right-inverse-of = λ x → inverseˡ P }
0
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
70
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
46 peqˡ : {p : ℕ }{ x y : Permutation p p } → x =p= y → (q : Fin p) → x ⟨$⟩ˡ q ≡ y ⟨$⟩ˡ q
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
47 peqˡ {p} {x} {y} eq q = begin
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
48 x ⟨$⟩ˡ q
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
49 ≡⟨ sym ( inverseˡ y ) ⟩
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
50 y ⟨$⟩ˡ (y ⟨$⟩ʳ ( x ⟨$⟩ˡ q ))
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
51 ≡⟨ cong (λ k → y ⟨$⟩ˡ k ) (sym (peq eq _ )) ⟩
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
52 y ⟨$⟩ˡ (x ⟨$⟩ʳ ( x ⟨$⟩ˡ q ))
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
53 ≡⟨ cong (λ k → y ⟨$⟩ˡ k ) ( inverseʳ x ) ⟩
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
54 y ⟨$⟩ˡ q
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
55 ∎ where open ≡-Reasoning
32004c9a70b1 sym2 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
56
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
57 presp : { p : ℕ } {x y u v : Permutation p p } → x =p= y → u =p= v → (x ∘ₚ u) =p= (y ∘ₚ v)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
58 presp {p} {x} {y} {u} {v} x=y u=v = record { peq = λ q → lemma4 q } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
59 lemma4 : (q : Fin p) → ((x ∘ₚ u) ⟨$⟩ʳ q) ≡ ((y ∘ₚ v) ⟨$⟩ʳ q)
316
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
60 lemma4 q = begin
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
61 ((x ∘ₚ u) ⟨$⟩ʳ q) ≡⟨ peq u=v _ ⟩
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
62 ((x ∘ₚ v) ⟨$⟩ʳ q) ≡⟨ cong (λ k → Inverse.to v k ) (peq x=y _) ⟩
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
63 ((y ∘ₚ v) ⟨$⟩ʳ q) ∎
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
64 where
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
65 open ≡-Reasoning
d712d2a1f8bb fix for new agda stdlib
kono
parents: 255
diff changeset
66 -- lemma4 q = trans (cong (λ k → Inverse.to u Π.⟨$⟩ k) (peq x=y q) ) (peq u=v _ )
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
67 passoc : { p : ℕ } (x y z : Permutation p p) → ((x ∘ₚ y) ∘ₚ z) =p= (x ∘ₚ (y ∘ₚ z))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
68 passoc x y z = record { peq = λ q → refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
69 p-inv : { p : ℕ } {i j : Permutation p p} → i =p= j → (q : Fin p) → pinv i ⟨$⟩ʳ q ≡ pinv j ⟨$⟩ʳ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
70 p-inv {p} {i} {j} i=j q = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
71 i ⟨$⟩ˡ q ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (inverseʳ j) ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
72 i ⟨$⟩ˡ ( j ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (peq i=j _ )) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
73 i ⟨$⟩ˡ ( i ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ inverseˡ i ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
74 j ⟨$⟩ˡ q
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
75 ∎ where open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
76
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
77 Symmetric : ℕ → Group Level.zero Level.zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
78 Symmetric p = record {
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 Carrier = Permutation p p
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
80 ; _≈_ = _=p=_
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 ; _∙_ = _∘ₚ_
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 ; ε = pid
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 ; _⁻¹ = pinv
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
84 ; isGroup = record { isMonoid = record { isSemigroup = record { isMagma = record {
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
85 isEquivalence = record {refl = prefl ; trans = ptrans ; sym = psym }
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 ; ∙-cong = presp }
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 ; assoc = passoc }
3
6e77fefcbe41 Permutation Group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
88 ; 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
89 ; 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
90 ; ⁻¹-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
91 }
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 70
diff changeset
92 }
0
dc677bac3c54 Permutation group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93