annotate monoidal.agda @ 712:9092874a0633

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 23 Nov 2017 12:37:22 +0900
parents bb5b028489dc
children 5e101ee6dab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 open import Level
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 open import Category
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 module monoidal where
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Product renaming (_×_ to _*_)
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Category.Constructions.Product
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import HomReasoning
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import cat-utility
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Relation.Binary.Core
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Relation.Binary
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open Functor
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
14 record Iso {c₁ c₂ ℓ : Level} (C : Category c₁ c₂ ℓ)
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
15 (x y : Obj C )
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
16 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 field
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
18 ≅→ : Hom C x y
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
19 ≅← : Hom C y x
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
20 iso→ : C [ C [ ≅← o ≅→ ] ≈ id1 C x ]
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
21 iso← : C [ C [ ≅→ o ≅← ] ≈ id1 C y ]
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
23 record IsStrictMonoidal {c₁ c₂ ℓ : Level} (C : Category c₁ c₂ ℓ) (I : Obj C) ( BI : Functor ( C × C ) C )
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
25 infixr 9 _□_
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
26 _□_ : ( x y : Obj C ) → Obj C
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
27 _□_ x y = FObj BI ( x , y )
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 field
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
29 mα : {a b c : Obj C} → ( a □ b) □ c ≡ a □ ( b □ c )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
30 mλ : (a : Obj C) → I □ a ≡ a
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
31 mρ : (a : Obj C) → a □ I ≡ a
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
32
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
33 record StrictMonoidal {c₁ c₂ ℓ : Level} (C : Category c₁ c₂ ℓ)
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
34 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
35 field
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
36 m-i : Obj C
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
37 m-bi : Functor ( C × C ) C
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
38 isMonoidal : IsStrictMonoidal C m-i m-bi
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
39
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
41 -- non strict version includes 5 naturalities
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
42 record IsMonoidal {c₁ c₂ ℓ : Level} (C : Category c₁ c₂ ℓ) (I : Obj C) ( BI : Functor ( C × C ) C )
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
43 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
44 open Iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
45 infixr 9 _□_ _■_
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
46 _□_ : ( x y : Obj C ) → Obj C
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
47 _□_ x y = FObj BI ( x , y )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
48 _■_ : {a b c d : Obj C } ( f : Hom C a c ) ( g : Hom C b d ) → Hom C ( a □ b ) ( c □ d )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
49 _■_ f g = FMap BI ( f , g )
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
50 field
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
51 mα-iso : {a b c : Obj C} → Iso C ( ( a □ b) □ c) ( a □ ( b □ c ) )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
52 mλ-iso : {a : Obj C} → Iso C ( I □ a) a
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
53 mρ-iso : {a : Obj C} → Iso C ( a □ I) a
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
54 mα→nat1 : {a a' b c : Obj C} → ( f : Hom C a a' ) →
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
55 C [ C [ ( f ■ id1 C ( b □ c )) o ≅→ (mα-iso {a} {b} {c}) ] ≈
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
56 C [ ≅→ (mα-iso ) o ( (f ■ id1 C b ) ■ id1 C c ) ] ]
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
57 mα→nat2 : {a b b' c : Obj C} → ( f : Hom C b b' ) →
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
58 C [ C [ ( id1 C a ■ ( f ■ id1 C c ) ) o ≅→ (mα-iso {a} {b} {c} ) ] ≈
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
59 C [ ≅→ (mα-iso ) o ( (id1 C a ■ f ) ■ id1 C c ) ] ]
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
60 mα→nat3 : {a b c c' : Obj C} → ( f : Hom C c c' ) →
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
61 C [ C [ ( id1 C a ■ ( id1 C b ■ f ) ) o ≅→ (mα-iso {a} {b} {c} ) ] ≈
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
62 C [ ≅→ (mα-iso ) o ( id1 C ( a □ b ) ■ f ) ] ]
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
63 mλ→nat : {a a' : Obj C} → ( f : Hom C a a' ) →
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
64 C [ C [ f o ≅→ (mλ-iso {a} ) ] ≈
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
65 C [ ≅→ (mλ-iso ) o ( id1 C I ■ f ) ] ]
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
66 mρ→nat : {a a' : Obj C} → ( f : Hom C a a' ) →
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
67 C [ C [ f o ≅→ (mρ-iso {a} ) ] ≈
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
68 C [ ≅→ (mρ-iso ) o ( f ■ id1 C I ) ] ]
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
69 -- we should write naturalities for ≅← (maybe derived from above )
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
70 αABC□1D : {a b c d e : Obj C } → Hom C (((a □ b) □ c ) □ d) ((a □ (b □ c)) □ d)
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
71 αABC□1D {a} {b} {c} {d} {e} = ( ≅→ mα-iso ■ id1 C d )
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
72 αAB□CD : {a b c d e : Obj C } → Hom C ((a □ (b □ c)) □ d) (a □ ((b □ c ) □ d))
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
73 αAB□CD {a} {b} {c} {d} {e} = ≅→ mα-iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
74 1A□BCD : {a b c d e : Obj C } → Hom C (a □ ((b □ c ) □ d)) (a □ (b □ ( c □ d) ))
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
75 1A□BCD {a} {b} {c} {d} {e} = ( id1 C a ■ ≅→ mα-iso )
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
76 αABC□D : {a b c d e : Obj C } → Hom C (a □ (b □ ( c □ d) )) ((a □ b ) □ (c □ d))
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
77 αABC□D {a} {b} {c} {d} {e} = ≅← mα-iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
78 αA□BCD : {a b c d e : Obj C } → Hom C (((a □ b) □ c ) □ d) ((a □ b ) □ (c □ d))
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
79 αA□BCD {a} {b} {c} {d} {e} = ≅→ mα-iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
80 αAIB : {a b : Obj C } → Hom C (( a □ I ) □ b ) (a □ ( I □ b ))
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
81 αAIB {a} {b} = ≅→ mα-iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
82 1A□λB : {a b : Obj C } → Hom C (a □ ( I □ b )) ( a □ b )
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
83 1A□λB {a} {b} = id1 C a ■ ≅→ mλ-iso
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
84 ρA□IB : {a b : Obj C } → Hom C (( a □ I ) □ b ) ( a □ b )
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
85 ρA□IB {a} {b} = ≅→ mρ-iso ■ id1 C b
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
86
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
87 field
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
88 comm-penta : {a b c d e : Obj C}
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
89 → C [ C [ αABC□D {a} {b} {c} {d} {e} o C [ 1A□BCD {a} {b} {c} {d} {e} o C [ αAB□CD {a} {b} {c} {d} {e} o αABC□1D {a} {b} {c} {d} {e} ] ] ]
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
90 ≈ αA□BCD {a} {b} {c} {d} {e} ]
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
91 comm-unit : {a b : Obj C}
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
92 → C [ C [ 1A□λB {a} {b} o αAIB ] ≈ ρA□IB {a} {b} ]
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 record Monoidal {c₁ c₂ ℓ : Level} (C : Category c₁ c₂ ℓ)
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 field
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 m-i : Obj C
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 m-bi : Functor ( C × C ) C
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 isMonoidal : IsMonoidal C m-i m-bi
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
101 ---------
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
102 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
103 -- Lax Monoidal Functor
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
104 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
105 -- N → M
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
106 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
107 ---------
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
108
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
109 ---------
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
110 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
111 -- Two implementations of Functor ( C × C ) → D from F : Functor C → D (given)
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
112 -- dervied from F and two Monoidal Categories
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
113 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
114 -- F x ● F y
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
115 -- F ( x ⊗ y )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
116 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
117 -- and a given natural transformation for them
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
118 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
119 -- φ : F x ● F y → F ( x ⊗ y )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
120 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
121 -- TMap φ : ( x y : Obj C ) → Hom D ( F x ● F y ) ( F ( x ⊗ y ))
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
122 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
123 -- a given unit arrow
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
124 --
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
125 -- ψ : IN → IM
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
126
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
127 Functor● : {c₁ c₂ ℓ : Level} (C D : Category c₁ c₂ ℓ) ( N : Monoidal D )
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
128 ( MF : Functor C D ) → Functor ( C × C ) D
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
129 Functor● C D N MF = record {
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
130 FObj = λ x → (FObj MF (proj₁ x) ) ● (FObj MF (proj₂ x) )
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
131 ; FMap = λ {x : Obj ( C × C ) } {y} f → ( FMap MF (proj₁ f ) ■ FMap MF (proj₂ f) )
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
132 ; isFunctor = record {
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
133 ≈-cong = ≈-cong
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
134 ; identity = identity
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
135 ; distr = distr
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
136 }
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
137 } where
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
138 _●_ : (x y : Obj D ) → Obj D
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
139 _●_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal N) ) x y
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
140 _■_ : {a b c d : Obj D } ( f : Hom D a c ) ( g : Hom D b d ) → Hom D ( a ● b ) ( c ● d )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
141 _■_ f g = FMap (Monoidal.m-bi N) ( f , g )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
142 F : { a b : Obj C } → ( f : Hom C a b ) → Hom D (FObj MF a) (FObj MF b )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
143 F f = FMap MF f
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
144 ≈-cong : {a b : Obj (C × C)} {f g : Hom (C × C) a b} → (C × C) [ f ≈ g ] →
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
145 D [ (F (proj₁ f) ■ F (proj₂ f)) ≈ (F (proj₁ g) ■ F (proj₂ g)) ]
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
146 ≈-cong {a} {b} {f} {g} f≈g = let open ≈-Reasoning D in begin
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
147 F (proj₁ f) ■ F (proj₂ f)
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
148 ≈⟨ fcong (Monoidal.m-bi N) ( fcong MF ( proj₁ f≈g ) , fcong MF ( proj₂ f≈g )) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
149 F (proj₁ g) ■ F (proj₂ g)
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
150
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
151 identity : {a : Obj (C × C)} → D [ (F (proj₁ (id1 (C × C) a)) ■ F (proj₂ (id1 (C × C) a)))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
152 ≈ id1 D (FObj MF (proj₁ a) ● FObj MF (proj₂ a)) ]
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
153 identity {a} = let open ≈-Reasoning D in begin
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
154 F (proj₁ (id1 (C × C) a)) ■ F (proj₂ (id1 (C × C) a))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
155 ≈⟨ fcong (Monoidal.m-bi N) ( IsFunctor.identity (isFunctor MF ) , IsFunctor.identity (isFunctor MF )) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
156 id1 D (FObj MF (proj₁ a)) ■ id1 D (FObj MF (proj₂ a))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
157 ≈⟨ IsFunctor.identity (isFunctor (Monoidal.m-bi N)) ⟩
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
158 id1 D (FObj MF (proj₁ a) ● FObj MF (proj₂ a))
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
159
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
160 distr : {a b c : Obj (C × C)} {f : Hom (C × C) a b} {g : Hom (C × C) b c} →
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
161 D [ (F (proj₁ ((C × C) [ g o f ])) ■ F (proj₂ ((C × C) [ g o f ])))
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
162 ≈ D [ (F (proj₁ g) ■ F (proj₂ g)) o (F (proj₁ f) ■ F (proj₂ f)) ] ]
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
163 distr {a} {b} {c} {f} {g} = let open ≈-Reasoning D in begin
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
164 (F (proj₁ ((C × C) [ g o f ])) ■ F (proj₂ ((C × C) [ g o f ])))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
165 ≈⟨ fcong (Monoidal.m-bi N) ( IsFunctor.distr ( isFunctor MF) , IsFunctor.distr ( isFunctor MF )) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
166 ( F (proj₁ g) o F (proj₁ f) ) ■ ( F (proj₂ g) o F (proj₂ f) )
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
167 ≈⟨ IsFunctor.distr ( isFunctor (Monoidal.m-bi N)) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
168 (F (proj₁ g) ■ F (proj₂ g)) o (F (proj₁ f) ■ F (proj₂ f))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
169
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
171 Functor⊗ : {c₁ c₂ ℓ : Level} (C D : Category c₁ c₂ ℓ) ( M : Monoidal C )
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
172 ( MF : Functor C D ) → Functor ( C × C ) D
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
173 Functor⊗ C D M MF = record {
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
174 FObj = λ x → FObj MF ( proj₁ x ⊗ proj₂ x )
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
175 ; FMap = λ {a} {b} f → F ( proj₁ f □ proj₂ f )
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
176 ; isFunctor = record {
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
177 ≈-cong = ≈-cong
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
178 ; identity = identity
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
179 ; distr = distr
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
180 }
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
181 } where
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
182 _⊗_ : (x y : Obj C ) → Obj C
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
183 _⊗_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal M) ) x y
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
184 _□_ : {a b c d : Obj C } ( f : Hom C a c ) ( g : Hom C b d ) → Hom C ( a ⊗ b ) ( c ⊗ d )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
185 _□_ f g = FMap (Monoidal.m-bi M) ( f , g )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
186 F : { a b : Obj C } → ( f : Hom C a b ) → Hom D (FObj MF a) (FObj MF b )
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
187 F f = FMap MF f
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
188 ≈-cong : {a b : Obj (C × C)} {f g : Hom (C × C) a b} → (C × C) [ f ≈ g ] →
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
189 D [ F ( (proj₁ f □ proj₂ f)) ≈ F ( (proj₁ g □ proj₂ g)) ]
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
190 ≈-cong {a} {b} {f} {g} f≈g = IsFunctor.≈-cong (isFunctor MF ) ( IsFunctor.≈-cong (isFunctor (Monoidal.m-bi M) ) f≈g )
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
191 identity : {a : Obj (C × C)} → D [ F ( (proj₁ (id1 (C × C) a) □ proj₂ (id1 (C × C) a)))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
192 ≈ id1 D (FObj MF (proj₁ a ⊗ proj₂ a)) ]
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
193 identity {a} = let open ≈-Reasoning D in begin
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
194 F ( (proj₁ (id1 (C × C) a) □ proj₂ (id1 (C × C) a)))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
195 ≈⟨⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
196 F (FMap (Monoidal.m-bi M) (id1 (C × C) a ) )
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
197 ≈⟨ fcong MF ( IsFunctor.identity (isFunctor (Monoidal.m-bi M) )) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
198 F (id1 C (proj₁ a ⊗ proj₂ a))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
199 ≈⟨ IsFunctor.identity (isFunctor MF) ⟩
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
200 id1 D (FObj MF (proj₁ a ⊗ proj₂ a))
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
201
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
202 distr : {a b c : Obj (C × C)} {f : Hom (C × C) a b} {g : Hom (C × C) b c} → D [
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
203 F ( (proj₁ ((C × C) [ g o f ]) □ proj₂ ((C × C) [ g o f ])))
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
204 ≈ D [ F ( (proj₁ g □ proj₂ g)) o F ( (proj₁ f □ proj₂ f)) ] ]
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
205 distr {a} {b} {c} {f} {g} = let open ≈-Reasoning D in begin
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
206 F ( (proj₁ ((C × C) [ g o f ]) □ proj₂ ((C × C) [ g o f ])))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
207 ≈⟨⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
208 F (FMap (Monoidal.m-bi M) ( (C × C) [ g o f ] ))
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
209 ≈⟨ fcong MF ( IsFunctor.distr (isFunctor (Monoidal.m-bi M))) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
210 F (C [ FMap (Monoidal.m-bi M) g o FMap (Monoidal.m-bi M) f ])
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
211 ≈⟨ IsFunctor.distr ( isFunctor MF ) ⟩
704
b48c2d1c0796 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
212 F ( proj₁ g □ proj₂ g) o F ( proj₁ f □ proj₂ f)
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
213
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
214
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 record IsMonoidalFunctor {c₁ c₂ ℓ : Level} {C D : Category c₁ c₂ ℓ} ( M : Monoidal C ) ( N : Monoidal D )
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
217 ( MF : Functor C D )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
218 ( ψ : Hom D (Monoidal.m-i N) (FObj MF (Monoidal.m-i M) ) )
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
220 _⊗_ : (x y : Obj C ) → Obj C
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
221 _⊗_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal M) ) x y
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
222 _□_ : {a b c d : Obj C } ( f : Hom C a c ) ( g : Hom C b d ) → Hom C ( a ⊗ b ) ( c ⊗ d )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
223 _□_ f g = FMap (Monoidal.m-bi M) ( f , g )
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
224 _●_ : (x y : Obj D ) → Obj D
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
225 _●_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal N) ) x y
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
226 _■_ : {a b c d : Obj D } ( f : Hom D a c ) ( g : Hom D b d ) → Hom D ( a ● b ) ( c ● d )
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
227 _■_ f g = FMap (Monoidal.m-bi N) ( f , g )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
228 F● : Functor ( C × C ) D
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
229 F● = Functor● C D N MF
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
230 F⊗ : Functor ( C × C ) D
703
df3f1aae984f Monidal functor done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 702
diff changeset
231 F⊗ = Functor⊗ C D M MF
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
232 field
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
233 φab : NTrans ( C × C ) D F● F⊗
698
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
234 open Iso
d648ebb8ac29 Monoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
235 open Monoidal
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
236 open IsMonoidal hiding ( _■_ ; _□_ )
699
10ab28030c20 add definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 698
diff changeset
237 αC : {a b c : Obj C} → Hom C (( a ⊗ b ) ⊗ c ) ( a ⊗ ( b ⊗ c ) )
10ab28030c20 add definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 698
diff changeset
238 αC {a} {b} {c} = ≅→ (mα-iso (isMonoidal M) {a} {b} {c})
10ab28030c20 add definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 698
diff changeset
239 αD : {a b c : Obj D} → Hom D (( a ● b ) ● c ) ( a ● ( b ● c ) )
10ab28030c20 add definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 698
diff changeset
240 αD {a} {b} {c} = ≅→ (mα-iso (isMonoidal N) {a} {b} {c})
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
241 F : Obj C → Obj D
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
242 F x = FObj MF x
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
243 φ : ( x y : Obj C ) → Hom D ( FObj F● (x , y) ) ( FObj F⊗ ( x , y ))
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
244 φ x y = NTrans.TMap φab ( x , y )
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
245 1●φBC : {a b c : Obj C} → Hom D ( F a ● ( F b ● F c ) ) ( F a ● ( F ( b ⊗ c ) ))
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
246 1●φBC {a} {b} {c} = id1 D (F a) ■ φ b c
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
247 φAB⊗C : {a b c : Obj C} → Hom D ( F a ● ( F ( b ⊗ c ) )) (F ( a ⊗ ( b ⊗ c )))
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
248 φAB⊗C {a} {b} {c} = φ a (b ⊗ c )
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
249 φAB●1 : {a b c : Obj C} → Hom D ( ( F a ● F b ) ● F c ) ( F ( a ⊗ b ) ● F c )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
250 φAB●1 {a} {b} {c} = φ a b ■ id1 D (F c)
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
251 φA⊗BC : {a b c : Obj C} → Hom D ( F ( a ⊗ b ) ● F c ) (F ( (a ⊗ b ) ⊗ c ))
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
252 φA⊗BC {a} {b} {c} = φ ( a ⊗ b ) c
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
253 FαC : {a b c : Obj C} → Hom D (F ( (a ⊗ b ) ⊗ c )) (F ( a ⊗ ( b ⊗ c )))
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
254 FαC {a} {b} {c} = FMap MF ( ≅→ (mα-iso (isMonoidal M) {a} {b} {c}) )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
255 1●ψ : { a b : Obj C } → Hom D (F a ● Monoidal.m-i N ) ( F a ● F ( Monoidal.m-i M ) )
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
256 1●ψ{a} {b} = id1 D (F a) ■ ψ
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
257 φAIC : { a b : Obj C } → Hom D ( F a ● F ( Monoidal.m-i M ) ) (F ( a ⊗ Monoidal.m-i M ))
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
258 φAIC {a} {b} = φ a ( Monoidal.m-i M )
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
259 FρC : { a b : Obj C } → Hom D (F ( a ⊗ Monoidal.m-i M ))( F a )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
260 FρC {a} {b} = FMap MF ( ≅→ (mρ-iso (isMonoidal M) {a} ) )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
261 ρD : { a b : Obj C } → Hom D (F a ● Monoidal.m-i N ) ( F a )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
262 ρD {a} {b} = ≅→ (mρ-iso (isMonoidal N) {F a} )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
263 ψ●1 : { a b : Obj C } → Hom D (Monoidal.m-i N ● F b ) ( F ( Monoidal.m-i M ) ● F b )
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
264 ψ●1 {a} {b} = ψ ■ id1 D (F b)
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
265 φICB : { a b : Obj C } → Hom D ( F ( Monoidal.m-i M ) ● F b ) ( F ( ( Monoidal.m-i M ) ⊗ b ) )
702
d16327b48b83 Monoidal Functor ( two functor remains )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 701
diff changeset
266 φICB {a} {b} = φ ( Monoidal.m-i M ) b
701
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
267 FλD : { a b : Obj C } → Hom D ( F ( ( Monoidal.m-i M ) ⊗ b ) ) (F b )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
268 FλD {a} {b} = FMap MF ( ≅→ (mλ-iso (isMonoidal M) {b} ) )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
269 λD : { a b : Obj C } → Hom D (Monoidal.m-i N ● F b ) (F b )
7a729bb62ce3 Monoidal Functor on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
270 λD {a} {b} = ≅→ (mλ-iso (isMonoidal N) {F b} )
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 field
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
272 associativity : {a b c : Obj C } → D [ D [ φAB⊗C {a} {b} {c} o D [ 1●φBC o αD ] ] ≈ D [ FαC o D [ φA⊗BC o φAB●1 ] ] ]
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
273 unitarity-idr : {a b : Obj C } → D [ D [ FρC {a} {b} o D [ φAIC {a} {b} o 1●ψ{a} {b} ] ] ≈ ρD {a} {b} ]
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
274 unitarity-idl : {a b : Obj C } → D [ D [ FλD {a} {b} o D [ φICB {a} {b} o ψ●1 {a} {b} ] ] ≈ λD {a} {b} ]
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 record MonoidalFunctor {c₁ c₂ ℓ : Level} {C D : Category c₁ c₂ ℓ} ( M : Monoidal C ) ( N : Monoidal D )
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
278 field
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
279 MF : Functor C D
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
280 ψ : Hom D (Monoidal.m-i N) (FObj MF (Monoidal.m-i M) )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
281 isMonodailFunctor : IsMonoidalFunctor M N MF ψ
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
282
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
283 record MonoidalFunctorWithoutCommutativities {c₁ c₂ ℓ : Level} {C D : Category c₁ c₂ ℓ} ( M : Monoidal C ) ( N : Monoidal D )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
284 : Set ( suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁)) where
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 _⊗_ : (x y : Obj C ) → Obj C
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
286 _⊗_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal M) ) x y
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 _●_ : (x y : Obj D ) → Obj D
700
cfd2d402c486 monodial cateogry and functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 699
diff changeset
288 _●_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal N) ) x y
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 field
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
290 MF : Functor C D
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
291 unit : Hom D (Monoidal.m-i N) (FObj MF (Monoidal.m-i M) )
708
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
292 φ : {a b : Obj C} → Hom D ((FObj MF a) ● (FObj MF b )) ( FObj MF ( a ⊗ b ) )
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
293
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
294 open import Category.Sets
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
295
706
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
296 import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
297 -- Extensionality a b = {A : Set a} {B : A → Set b} {f g : (x : A) → B x} → (∀ x → f x ≡ g x) → f ≡ g → ( λ x → f x ≡ λ x → g x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
298 postulate extensionality : { c₁ c₂ ℓ : Level} ( A : Category c₁ c₂ ℓ ) → Relation.Binary.PropositionalEquality.Extensionality c₂ c₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
299
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
300 data One {c : Level} : Set c where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
301 OneObj : One -- () in Haskell ( or any one object set )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
302
708
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
303 SetsTensorProduct : {c : Level} → Functor ( Sets {c} × Sets {c} ) (Sets {c})
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
304 SetsTensorProduct = record {
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
305 FObj = λ x → proj₁ x * proj₂ x
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
306 ; FMap = λ {x : Obj ( Sets × Sets ) } {y} f → map (proj₁ f) (proj₂ f)
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
307 ; isFunctor = record {
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
308 ≈-cong = ≈-cong
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
309 ; identity = refl
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
310 ; distr = refl
706
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
311 }
708
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
312 } where
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
313 ≈-cong : {a b : Obj (Sets × Sets)} {f g : Hom (Sets × Sets) a b} →
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
314 (Sets × Sets) [ f ≈ g ] → Sets [ map (proj₁ f) (proj₂ f) ≈ map (proj₁ g) (proj₂ g) ]
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
315 ≈-cong (refl , refl) = refl
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
316
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
317
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
318
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
319 MonoidalSets : {c : Level} → Monoidal (Sets {c})
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
320 MonoidalSets = record {
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
321 m-i = One ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
322 m-bi = SetsTensorProduct ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
323 isMonoidal = record {
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
324 mα-iso = record { ≅→ = mα→ ; ≅← = mα← ; iso→ = refl ; iso← = refl } ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
325 mλ-iso = record { ≅→ = mλ→ ; ≅← = mλ← ; iso→ = extensionality Sets ( λ x → mλiso x ) ; iso← = refl } ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
326 mρ-iso = record { ≅→ = mρ→ ; ≅← = mρ← ; iso→ = extensionality Sets ( λ x → mρiso x ) ; iso← = refl } ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
327 mα→nat1 = λ f → refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
328 mα→nat2 = λ f → refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
329 mα→nat3 = λ f → refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
330 mλ→nat = λ f → refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
331 mρ→nat = λ f → refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
332 comm-penta = refl ;
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
333 comm-unit = refl
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
334 }
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
335 } where
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
336 _⊗_ : ( a b : Obj Sets ) → Obj Sets
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
337 _⊗_ a b = FObj SetsTensorProduct (a , b )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
338 mα→ : {a b c : Obj Sets} → Hom Sets ( ( a ⊗ b ) ⊗ c ) ( a ⊗ ( b ⊗ c ) )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
339 mα→ ((a , b) , c ) = (a , ( b , c ) )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
340 mα← : {a b c : Obj Sets} → Hom Sets ( a ⊗ ( b ⊗ c ) ) ( ( a ⊗ b ) ⊗ c )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
341 mα← (a , ( b , c ) ) = ((a , b) , c )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
342 mλ→ : {a : Obj Sets} → Hom Sets ( One ⊗ a ) a
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
343 mλ→ (_ , a) = a
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
344 mλ← : {a : Obj Sets} → Hom Sets a ( One ⊗ a )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
345 mλ← a = ( OneObj , a )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
346 mλiso : {a : Obj Sets} (x : One ⊗ a) → (Sets [ mλ← o mλ→ ]) x ≡ id1 Sets (One ⊗ a) x
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
347 mλiso (OneObj , _ ) = refl
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
348 mρ→ : {a : Obj Sets} → Hom Sets ( a ⊗ One ) a
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
349 mρ→ (a , _) = a
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
350 mρ← : {a : Obj Sets} → Hom Sets a ( a ⊗ One )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
351 mρ← a = ( a , OneObj )
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
352 mρiso : {a : Obj Sets} (x : a ⊗ One ) → (Sets [ mρ← o mρ→ ]) x ≡ id1 Sets (a ⊗ One) x
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
353 mρiso (_ , OneObj ) = refl
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
354
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
355 ≡-cong = Relation.Binary.PropositionalEquality.cong
706
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
356
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
357 record HaskellMonoidalFunctor {c₁ : Level} ( f : Functor (Sets {c₁}) (Sets {c₁}) )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
358 : Set (suc (suc c₁)) where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
359 field
706
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
360 unit : FObj f One
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
361 φ : {a b : Obj Sets} → Hom Sets ((FObj f a) * (FObj f b )) ( FObj f ( a * b ) )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
362 ** : {a b : Obj Sets} → FObj f a → FObj f b → FObj f ( a * b )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
363 ** x y = φ ( x , y )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
364
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
365 lemma0 : {c : Level} ( F : Functor (Sets {c}) (Sets {c}) ) → HaskellMonoidalFunctor F → MonoidalFunctor {_} {c} {_} {Sets} {Sets} MonoidalSets MonoidalSets
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
366 lemma0 F mf = record {
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
367 MF = F
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
368 ; ψ = λ _ → HaskellMonoidalFunctor.unit mf
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
369 ; isMonodailFunctor = record {
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
370 φab = record { TMap = λ x → φ ; isNTrans = record { commute = comm0 } }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
371 ; associativity = λ {a b c} → comm1 {a} {b} {c}
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
372 ; unitarity-idr = λ {a b} → comm2 {a} {b}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
373 ; unitarity-idl = λ {a b} → comm3 {a} {b}
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
374 }
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
375 } where
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
376 open Monoidal
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
377 open IsMonoidal hiding ( _■_ ; _□_ )
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
378 M = MonoidalSets
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
379 isM = Monoidal.isMonoidal MonoidalSets
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
380 unit = HaskellMonoidalFunctor.unit mf
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
381 _⊗_ : (x y : Obj Sets ) → Obj Sets
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
382 _⊗_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal M) ) x y
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
383 _□_ : {a b c d : Obj Sets } ( f : Hom Sets a c ) ( g : Hom Sets b d ) → Hom Sets ( a ⊗ b ) ( c ⊗ d )
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
384 _□_ f g = FMap (m-bi M) ( f , g )
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
385 φ : {x : Obj (Sets × Sets) } → Hom Sets (FObj (Functor● Sets Sets MonoidalSets F) x) (FObj (Functor⊗ Sets Sets MonoidalSets F) x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
386 φ z = HaskellMonoidalFunctor.φ mf z
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
387 comm00 : {a b : Obj (Sets × Sets)} { f : Hom (Sets × Sets) a b} (x : ( FObj F (proj₁ a) * FObj F (proj₂ a)) ) →
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
388 (Sets [ FMap (Functor⊗ Sets Sets MonoidalSets F) f o φ ]) x ≡ (Sets [ φ o FMap (Functor● Sets Sets MonoidalSets F) f ]) x
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
389 comm00 {a} {b} {(f , g)} (x , y) = begin
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
390 (FMap (Functor⊗ Sets Sets MonoidalSets F) (f , g) ) (φ (x , y))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
391 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
392 (FMap F ( f □ g ) ) (φ (x , y))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
393 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
394 FMap F ( map f g ) (φ (x , y))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
395 ≡⟨ {!!} ⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
396 φ ( FMap F f x , FMap F g y )
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
397 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
398 φ ( ( FMap F f □ FMap F g ) (x , y) )
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
399 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
400 φ ((FMap (Functor● Sets Sets MonoidalSets F) (f , g) ) (x , y) )
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
401
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
402 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
403 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
404 open ≡-Reasoning
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
405 comm0 : {a b : Obj (Sets × Sets)} { f : Hom (Sets × Sets) a b} → Sets [ Sets [ FMap (Functor⊗ Sets Sets MonoidalSets F) f o φ ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
406 ≈ Sets [ φ o FMap (Functor● Sets Sets MonoidalSets F) f ] ]
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
407 comm0 {a} {b} {f} = extensionality Sets ( λ (x : ( FObj F (proj₁ a) * FObj F (proj₂ a)) ) → comm00 x )
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
408 comm10 : {a b c : Obj Sets} → (x : ((FObj F a ⊗ FObj F b) ⊗ FObj F c) ) → (Sets [ φ o Sets [ id1 Sets (FObj F a) □ φ o Iso.≅→ (mα-iso isM) ] ]) x ≡
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
409 (Sets [ FMap F (Iso.≅→ (mα-iso isM)) o Sets [ φ o φ □ id1 Sets (FObj F c) ] ]) x
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
410 comm10 {x} {y} {f} ((a , b) , c ) = begin
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
411 φ (( id1 Sets (FObj F x) □ φ ) ( ( Iso.≅→ (mα-iso isM) ) ((a , b) , c)))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
412 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
413 φ ( a , φ (b , c))
712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
414 ≡⟨ {!!} ⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
415 ( FMap F (Iso.≅→ (mα-iso isM))) (φ (( φ (a , b)) , c ))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
416 ≡⟨⟩
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
417 ( FMap F (Iso.≅→ (mα-iso isM))) (φ (( φ □ id1 Sets (FObj F f) ) ((a , b) , c)))
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
418
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
419 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
420 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
421 open ≡-Reasoning
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
422 comm1 : {a b c : Obj Sets} → Sets [ Sets [ φ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
423 o Sets [ (id1 Sets (FObj F a) □ φ ) o Iso.≅→ (mα-iso isM) ] ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
424 ≈ Sets [ FMap F (Iso.≅→ (mα-iso isM)) o Sets [ φ o (φ □ id1 Sets (FObj F c)) ] ] ]
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
425 comm1 {a} {b} {c} = extensionality Sets ( λ x → comm10 x )
712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
426 comm20 : {a b : Obj Sets} ( x : FObj F a * One ) → ( Sets [
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
427 FMap F (Iso.≅→ (mρ-iso isM)) o Sets [ φ o
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
428 FMap (m-bi MonoidalSets) (id1 Sets (FObj F a) , (λ _ → unit )) ] ] ) x ≡ Iso.≅→ (mρ-iso isM) x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
429 comm20 {a} {b} (x , OneObj ) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
430 (FMap F (Iso.≅→ (mρ-iso isM))) ( φ ( x , unit ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
431 ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
432 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
433 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
434 Iso.≅→ (mρ-iso isM) ( x , OneObj )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
435
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
436 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
437 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
438 open ≡-Reasoning
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
439 comm2 : {a b : Obj Sets} → Sets [ Sets [
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
440 FMap F (Iso.≅→ (mρ-iso isM)) o Sets [ φ o
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
441 FMap (m-bi MonoidalSets) (id1 Sets (FObj F a) , (λ _ → unit )) ] ] ≈ Iso.≅→ (mρ-iso isM) ]
712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
442 comm2 {a} {b} = extensionality Sets ( λ x → comm20 {a} {b} x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
443 comm30 : {a b : Obj Sets} ( x : One * FObj F b ) → ( Sets [
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
444 FMap F (Iso.≅→ (mλ-iso isM)) o Sets [ φ o
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
445 FMap (m-bi MonoidalSets) ((λ _ → unit ) , id1 Sets (FObj F b) ) ] ] ) x ≡ Iso.≅→ (mλ-iso isM) x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
446 comm30 {a} {b} ( OneObj , x) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
447 (FMap F (Iso.≅→ (mλ-iso isM))) ( φ ( unit , x ) )
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
448 ≡⟨ {!!} ⟩
712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
449 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
450 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
451 Iso.≅→ (mλ-iso isM) ( OneObj , x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
452
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
453 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
454 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
455 open ≡-Reasoning
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
456 comm3 : {a b : Obj Sets} → Sets [ Sets [ FMap F (Iso.≅→ (mλ-iso isM)) o
711
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 710
diff changeset
457 Sets [ φ o FMap (m-bi MonoidalSets) ((λ _ → unit ) , id1 Sets (FObj F b)) ] ] ≈ Iso.≅→ (mλ-iso isM) ]
712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 711
diff changeset
458 comm3 {a} {b} = extensionality Sets ( λ x → comm30 {a} {b} x )
709
2807335e3fa0 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
459
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
460
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
461 record Applicative {c₁ : Level} ( f : Functor (Sets {c₁}) (Sets {c₁}) )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
462 : Set (suc (suc c₁)) where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
463 field
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
464 pure : {a : Obj Sets} → Hom Sets a ( FObj f a )
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
465 <*> : {a b : Obj Sets} → FObj f ( a → b ) → FObj f a → FObj f b
707
808b03184fd3 Applicative ⇔ Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 706
diff changeset
466 -- should have Applicative law
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
467
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
468 lemma1 : {c₁ : Level} ( f : Functor (Sets {c₁}) (Sets {c₁}) ) → Applicative f → HaskellMonoidalFunctor f
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
469 lemma1 f app = record { unit = unit ; φ = φ }
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
470 where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
471 open Applicative
706
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
472 unit : FObj f One
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 705
diff changeset
473 unit = pure app OneObj
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
474 φ : {a b : Obj Sets} → Hom Sets ((FObj f a) * (FObj f b )) ( FObj f ( a * b ) )
707
808b03184fd3 Applicative ⇔ Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 706
diff changeset
475 φ {a} {b} ( x , y ) = <*> app (FMap f (λ j k → (j , k)) x) y
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
476
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
477 lemma2 : {c₁ : Level} ( f : Functor (Sets {c₁}) (Sets {c₁}) ) → HaskellMonoidalFunctor f → Applicative f
707
808b03184fd3 Applicative ⇔ Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 706
diff changeset
478 lemma2 f mono = record { pure = pure ; <*> = <*> }
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
479 where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
480 open HaskellMonoidalFunctor
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
481 pure : {a : Obj Sets} → Hom Sets a ( FObj f a )
707
808b03184fd3 Applicative ⇔ Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 706
diff changeset
482 pure {a} x = FMap f ( λ y → x ) (unit mono)
708
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
483 <*> : {a b : Obj Sets} → FObj f ( a → b ) → FObj f a → FObj f b -- ** mono x y
975aa343a963 Sets is Monoidal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 707
diff changeset
484 <*> {a} {b} x y = FMap f ( λ a→b*b → ( proj₁ a→b*b ) ( proj₂ a→b*b ) ) (φ mono ( x , y ))