annotate applicative.agda @ 768:9bcdbfbaaa39

clean up
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 12 Dec 2017 10:25:59 +0900
parents monoidal.agda@c30ca91f3a76
children 43138aead09b
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
768
9bcdbfbaaa39 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 766
diff changeset
3 module applicative where
696
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
768
9bcdbfbaaa39 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 766
diff changeset
11 open import monoidal
9bcdbfbaaa39 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 766
diff changeset
12 open import Category.Sets
9bcdbfbaaa39 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 766
diff changeset
13 import Relation.Binary.PropositionalEquality
696
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open Functor
10ccac3bc285 Monoidal category and applicative functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
17
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
18 _・_ : {c₁ : Level} { a b c : Obj (Sets {c₁} ) } → (b → c) → (a → b) → a → c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
19 _・_ f g = λ x → f ( g x )
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
20
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
21 record IsApplicative {c₁ : Level} ( F : Functor (Sets {c₁}) (Sets {c₁}) )
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
22 ( pure : {a : Obj Sets} → Hom Sets a ( FObj F a ) )
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
23 ( _<*>_ : {a b : Obj Sets} → FObj F ( a → b ) → FObj F a → FObj F b )
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
24 : Set (suc (suc c₁)) where
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
25 field
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
26 identity : { a : Obj Sets } { u : FObj F a } → pure ( id1 Sets a ) <*> u ≡ u
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
27 composition : { a b c : Obj Sets } { u : FObj F ( b → c ) } { v : FObj F (a → b ) } { w : FObj F a }
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
28 → (( pure _・_ <*> u ) <*> v ) <*> w ≡ u <*> (v <*> w)
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
29 homomorphism : { a b : Obj Sets } { f : Hom Sets a b } { x : a } → pure f <*> pure x ≡ pure (f x)
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
30 interchange : { a b : Obj Sets } { u : FObj F ( a → b ) } { x : a } → u <*> pure x ≡ pure (λ f → f x) <*> u
730
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
31 -- from http://www.staff.city.ac.uk/~ross/papers/Applicative.pdf
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
32
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
33 record Applicative {c₁ : Level} ( F : Functor (Sets {c₁}) (Sets {c₁}) )
705
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
34 : Set (suc (suc c₁)) where
73a998711118 add Applicative and HaskellMonoidal Functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
35 field
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
36 pure : {a : Obj Sets} → Hom Sets a ( FObj F a )
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
37 <*> : {a b : Obj Sets} → FObj F ( a → b ) → FObj F a → FObj F b
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
38 isApplicative : IsApplicative F pure <*>
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
39
730
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
40 ------
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
41 --
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
42 -- Appllicative Functor is a Monoidal Functor
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
43 --
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
44
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
45 Applicative→Monoidal : {c : Level} ( F : Functor (Sets {c}) (Sets {c}) ) → (mf : Applicative F )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
46 → IsApplicative F ( Applicative.pure mf ) ( Applicative.<*> mf )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
47 → MonoidalFunctor {_} {c} {_} {Sets} {Sets} MonoidalSets MonoidalSets
727
ea84cc6c1797 monoidal functor and applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
48 Applicative→Monoidal {l} F mf ismf = record {
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
49 MF = F
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
50 ; ψ = λ x → unit
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
51 ; isMonodailFunctor = record {
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
52 φab = record { TMap = λ x → φ ; isNTrans = record { commute = comm0 } }
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
53 ; associativity = λ {a b c} → comm1 {a} {b} {c}
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
54 ; unitarity-idr = λ {a b} → comm2 {a} {b}
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
55 ; unitarity-idl = λ {a b} → comm3 {a} {b}
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
56 }
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
57 } where
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
58 open Monoidal
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
59 open IsMonoidal hiding ( _■_ ; _□_ )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
60 M = MonoidalSets
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
61 isM = Monoidal.isMonoidal MonoidalSets
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
62 unit = Applicative.pure mf OneObj
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
63 _⊗_ : (x y : Obj Sets ) → Obj Sets
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
64 _⊗_ x y = (IsMonoidal._□_ (Monoidal.isMonoidal M) ) x y
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
65 _□_ : {a b c d : Obj Sets } ( f : Hom Sets a c ) ( g : Hom Sets b d ) → Hom Sets ( a ⊗ b ) ( c ⊗ d )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
66 _□_ f g = FMap (m-bi M) ( f , g )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
67 φ : {x : Obj (Sets × Sets) } → Hom Sets (FObj (Functor● Sets Sets MonoidalSets F) x) (FObj (Functor⊗ Sets Sets MonoidalSets F) x)
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
68 φ x = Applicative.<*> mf (FMap F (λ j k → (j , k)) (proj₁ x )) (proj₂ x)
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
69 _<*>_ : {a b : Obj Sets} → FObj F ( a → b ) → FObj F a → FObj F b
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
70 _<*>_ = Applicative.<*> mf
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
71 left : {a b : Obj Sets} → {x y : FObj F ( a → b )} → {h : FObj F a } → ( x ≡ y ) → x <*> h ≡ y <*> h
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
72 left {_} {_} {_} {_} {h} eq = ≡-cong ( λ k → k <*> h ) eq
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
73 right : {a b : Obj Sets} → {h : FObj F ( a → b )} → {x y : FObj F a } → ( x ≡ y ) → h <*> x ≡ h <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
74 right {_} {_} {h} {_} {_} eq = ≡-cong ( λ k → h <*> k ) eq
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
75 id : { a : Obj Sets } → a → a
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
76 id x = x
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
77 pure : {a : Obj Sets } → Hom Sets a ( FObj F a )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
78 pure a = Applicative.pure mf a
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
79 -- special case
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
80 F→pureid : {a b : Obj Sets } → (x : FObj F a ) → FMap F id x ≡ pure id <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
81 F→pureid {a} {b} x = sym ( begin
722
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
82 pure id <*> x
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
83 ≡⟨ IsApplicative.identity ismf ⟩
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
84 x
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
85 ≡⟨ ≡-cong ( λ k → k x ) (sym ( IsFunctor.identity (isFunctor F ) )) ⟩ FMap F id x
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
86 ∎ )
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
87 where
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
88 open Relation.Binary.PropositionalEquality
69f01b82dfc9 uniquness of functor fmap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
89 open Relation.Binary.PropositionalEquality.≡-Reasoning
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
90 F→pure : {a b : Obj Sets } → { f : a → b } → {x : FObj F a } → FMap F f x ≡ pure f <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
91 F→pure {a} {b} {f} {x} = sym ( begin
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
92 pure f <*> x
731
117e5b392673 Generalize Free Theorem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 730
diff changeset
93 ≡⟨ ≡-cong ( λ k → k x ) (UniquenessOfFunctor Sets Sets F ( λ f x → pure f <*> x ) ( extensionality Sets ( λ x → IsApplicative.identity ismf ))) ⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
94 FMap F f x
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
95 ∎ )
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
96 where
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
97 open Relation.Binary.PropositionalEquality
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
98 open Relation.Binary.PropositionalEquality.≡-Reasoning
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
99 p*p : { a b : Obj Sets } { f : Hom Sets a b } { x : a } → pure f <*> pure x ≡ pure (f x)
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
100 p*p = IsApplicative.homomorphism ismf
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
101 comp = IsApplicative.composition ismf
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
102 inter = IsApplicative.interchange ismf
729
6bc9d68898ef clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 727
diff changeset
103 pureAssoc : {a b c : Obj Sets } ( f : b → c ) ( g : a → b ) ( h : FObj F a ) → pure f <*> ( pure g <*> h ) ≡ pure ( f ・ g ) <*> h
6bc9d68898ef clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 727
diff changeset
104 pureAssoc f g h = trans ( trans (sym comp) (left (left p*p) )) ( left p*p )
6bc9d68898ef clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 727
diff changeset
105 where
6bc9d68898ef clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 727
diff changeset
106 open Relation.Binary.PropositionalEquality
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
107 comm00 : {a b : Obj (Sets × Sets)} { f : Hom (Sets × Sets) a b} (x : ( FObj F (proj₁ a) * FObj F (proj₂ a)) ) →
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
108 (Sets [ FMap (Functor⊗ Sets Sets MonoidalSets F) f o φ ]) x ≡ (Sets [ φ o FMap (Functor● Sets Sets MonoidalSets F) f ]) x
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
109 comm00 {a} {b} {(f , g)} (x , y) = begin
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
110 ( FMap (Functor⊗ Sets Sets MonoidalSets F) (f , g) ) ( φ (x , y) )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
111 ≡⟨⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
112 FMap F (λ xy → f (proj₁ xy) , g (proj₂ xy)) ((FMap F (λ j k → j , k) x) <*> y)
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
113 ≡⟨⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
114 FMap F (map f g) ((FMap F (λ j k → j , k) x) <*> y)
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
115 ≡⟨ F→pure ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
116 (pure (map f g) <*> (FMap F (λ j k → j , k) x <*> y))
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
117 ≡⟨ right ( left F→pure ) ⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
118 (pure (map f g)) <*> ((pure (λ j k → j , k) <*> x) <*> y)
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
119 ≡⟨ sym ( IsApplicative.composition ismf ) ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
120 (( pure _・_ <*> (pure (map f g))) <*> (pure (λ j k → j , k) <*> x)) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
121 ≡⟨ left ( sym ( IsApplicative.composition ismf )) ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
122 ((( pure _・_ <*> (( pure _・_ <*> (pure (map f g))))) <*> pure (λ j k → j , k)) <*> x) <*> y
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
123 ≡⟨ trans ( trans (left ( left (left (right p*p )))) ( left ( left ( left p*p)))) (left (left p*p)) ⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
124 (pure (( _・_ (( _・_ ((map f g))))) (λ j k → j , k)) <*> x) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
125 ≡⟨⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
126 (pure (λ j k → f j , g k) <*> x) <*> y
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
127 ≡⟨⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
128 ( pure ((_・_ (( _・_ ( ( λ h → h g ))) ( _・_ ))) ((λ j k → f j , k))) <*> x ) <*> y
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
129 ≡⟨ sym ( trans (left (left (left p*p))) (left ( left p*p)) ) ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
130 ((((pure _・_ <*> pure ((λ h → h g) ・ _・_)) <*> pure (λ j k → f j , k)) <*> x) <*> y)
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
131 ≡⟨ sym (trans ( left ( left ( left (right (left p*p) )))) (left ( left (left (right p*p ))))) ⟩
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
132 (((pure _・_ <*> (( pure _・_ <*> ( pure ( λ h → h g ))) <*> ( pure _・_ ))) <*> (pure (λ j k → f j , k))) <*> x ) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
133 ≡⟨ left ( ( IsApplicative.composition ismf )) ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
134 ((( pure _・_ <*> ( pure ( λ h → h g ))) <*> ( pure _・_ )) <*> (pure (λ j k → f j , k) <*> x )) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
135 ≡⟨ left (IsApplicative.composition ismf ) ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
136 ( pure ( λ h → h g ) <*> ( pure _・_ <*> (pure (λ j k → f j , k) <*> x )) ) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
137 ≡⟨ left (sym (IsApplicative.interchange ismf )) ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
138 (( pure _・_ <*> (pure (λ j k → f j , k) <*> x )) <*> pure g) <*> y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
139 ≡⟨ IsApplicative.composition ismf ⟩
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
140 (pure (λ j k → f j , k) <*> x) <*> (pure g <*> y)
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
141 ≡⟨ sym ( trans (left F→pure ) ( right F→pure ) ) ⟩
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
142 (FMap F (λ j k → f j , k) x) <*> (FMap F g y)
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
143 ≡⟨ ≡-cong ( λ k → k x <*> (FMap F g y)) ( IsFunctor.distr (isFunctor F )) ⟩
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
144 (FMap F (λ j k → j , k) (FMap F f x)) <*> (FMap F g y)
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
145 ≡⟨⟩
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
146 φ ( ( FMap (Functor● Sets Sets MonoidalSets F) (f , g) ) ( x , y ) )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
147
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
148 where
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
149 open Relation.Binary.PropositionalEquality
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
150 open Relation.Binary.PropositionalEquality.≡-Reasoning
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
151 comm0 : {a b : Obj (Sets × Sets)} { f : Hom (Sets × Sets) a b} → Sets [ Sets [ FMap (Functor⊗ Sets Sets MonoidalSets F) f o φ ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
152 ≈ Sets [ φ o FMap (Functor● Sets Sets MonoidalSets F) f ] ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
153 comm0 {a} {b} {f} = extensionality Sets ( λ (x : ( FObj F (proj₁ a) * FObj F (proj₂ a)) ) → comm00 x )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
154 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 ≡
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
155 (Sets [ FMap F (Iso.≅→ (mα-iso isM)) o Sets [ φ o φ □ id1 Sets (FObj F c) ] ]) x
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
156 comm10 {x} {y} {f} ((a , b) , c ) = begin
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
157 φ (( id □ φ ) ( ( Iso.≅→ (mα-iso isM) ) ((a , b) , c)))
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
158 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
159 (FMap F (λ j k → j , k) a) <*> ( (FMap F (λ j k → j , k) b) <*> c)
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
160 ≡⟨ trans (left F→pure) (right (left F→pure) ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
161 (pure (λ j k → j , k) <*> a) <*> ( (pure (λ j k → j , k) <*> b) <*> c)
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
162 ≡⟨ sym comp ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
163 ( ( pure _・_ <*> (pure (λ j k → j , k) <*> a)) <*> (pure (λ j k → j , k) <*> b)) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
164 ≡⟨ sym ( left comp ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
165 (( ( pure _・_ <*> ( pure _・_ <*> (pure (λ j k → j , k) <*> a))) <*> (pure (λ j k → j , k))) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
166 ≡⟨ sym ( left ( left ( left (right comp )))) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
167 (( ( pure _・_ <*> (( (pure _・_ <*> pure _・_ ) <*> (pure (λ j k → j , k))) <*> a)) <*> (pure (λ j k → j , k))) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
168 ≡⟨ trans (left ( left (left ( right (left ( left p*p )))))) (left ( left ( left (right (left p*p))))) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
169 (( ( pure _・_ <*> ((pure ((_・_ ( _・_ )) ((λ j k → j , k)))) <*> a)) <*> (pure (λ j k → j , k))) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
170 ≡⟨ sym (left ( left ( left comp ) )) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
171 (((( ( pure _・_ <*> (pure _・_ )) <*> (pure ((_・_ ( _・_ )) ((λ j k → j , k))))) <*> a) <*> (pure (λ j k → j , k))) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
172 ≡⟨ trans (left ( left ( left (left (left p*p))))) (left ( left ( left (left p*p )))) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
173 ((((pure ( ( _・_ (_・_ )) (((_・_ ( _・_ )) ((λ j k → j , k)))))) <*> a) <*> (pure (λ j k → j , k))) <*> b) <*> c
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
174 ≡⟨⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
175 ((((pure (λ f g x y → f , g x y)) <*> a) <*> (pure (λ j k → j , k))) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
176 ≡⟨ left ( left inter ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
177 (((pure (λ f → f (λ j k → j , k))) <*> ((pure (λ f g x y → f , g x y)) <*> a) ) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
178 ≡⟨ sym ( left ( left comp )) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
179 (((( pure _・_ <*> (pure (λ f → f (λ j k → j , k)))) <*> (pure (λ f g x y → f , g x y))) <*> a ) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
180 ≡⟨ trans (left ( left (left (left p*p) ))) (left (left (left p*p ) )) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
181 ((pure (( _・_ (λ f → f (λ j k → j , k))) (λ f g x y → f , g x y)) <*> a ) <*> b) <*> c
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
182 ≡⟨⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
183 (((pure (λ f g h → f , g , h)) <*> a) <*> b) <*> c
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
184 ≡⟨⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
185 ((pure ((_・_ ((_・_ ((_・_ ( (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc)))))))
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
186 (( _・_ ( _・_ ((λ j k → j , k)))) (λ j k → j , k))) <*> a) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
187 ≡⟨ sym (trans ( left ( left ( left (left (right (right p*p))) ) )) (trans (left (left( left (left (right p*p)))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
188 (trans (left (left (left (left p*p)))) (trans ( left (left (left (right (left (right p*p ))))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
189 (trans (left (left (left (right (left p*p))))) (trans (left (left (left (right p*p)))) (left (left (left p*p)))) ) ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
190 ) ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
191 ((((pure _・_ <*> ((pure _・_ <*> ((pure _・_ <*> ( pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc))))))) <*>
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
192 (( pure _・_ <*> ( pure _・_ <*> (pure (λ j k → j , k)))) <*> pure (λ j k → j , k))) <*> a) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
193 ≡⟨ left (left comp ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
194 (((pure _・_ <*> ((pure _・_ <*> ( pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc))))) <*>
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
195 ((( pure _・_ <*> ( pure _・_ <*> (pure (λ j k → j , k)))) <*> pure (λ j k → j , k)) <*> a)) <*> b) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
196 ≡⟨ left comp ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
197 ((pure _・_ <*> ( pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc))) <*>
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
198 (((( pure _・_ <*> ( pure _・_ <*> (pure (λ j k → j , k)))) <*> pure (λ j k → j , k)) <*> a) <*> b)) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
199 ≡⟨ left ( right (left comp )) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
200 ((pure _・_ <*> ( pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc))) <*>
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
201 ((( pure _・_ <*> (pure (λ j k → j , k))) <*> (pure (λ j k → j , k) <*> a)) <*> b)) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
202 ≡⟨ left ( right comp ) ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
203 ((pure _・_ <*> ( pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc))) <*>
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
204 (pure (λ j k → j , k) <*> ( (pure (λ j k → j , k) <*> a) <*> b))) <*> c
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
205 ≡⟨ comp ⟩
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
206 pure (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc) <*> ( (pure (λ j k → j , k) <*> ( (pure (λ j k → j , k) <*> a) <*> b)) <*> c)
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
207 ≡⟨ sym ( trans ( trans F→pure (right (left F→pure ))) ( right ( left (right (left F→pure ))))) ⟩
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
208 FMap F (λ abc → proj₁ (proj₁ abc) , proj₂ (proj₁ abc) , proj₂ abc) ( (FMap F (λ j k → j , k) ( (FMap F (λ j k → j , k) a) <*> b)) <*> c)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
209 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
210 ( FMap F (Iso.≅→ (mα-iso isM))) (φ (( φ □ id1 Sets (FObj F f) ) ((a , b) , c)))
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
211
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
212 where
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
213 open Relation.Binary.PropositionalEquality
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
214 open Relation.Binary.PropositionalEquality.≡-Reasoning
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
215 comm1 : {a b c : Obj Sets} → Sets [ Sets [ φ
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
216 o Sets [ (id1 Sets (FObj F a) □ φ ) o Iso.≅→ (mα-iso isM) ] ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
217 ≈ Sets [ FMap F (Iso.≅→ (mα-iso isM)) o Sets [ φ o (φ □ id1 Sets (FObj F c)) ] ] ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
218 comm1 {a} {b} {c} = extensionality Sets ( λ x → comm10 x )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
219 comm20 : {a b : Obj Sets} ( x : FObj F a * One ) → ( Sets [
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
220 FMap F (Iso.≅→ (mρ-iso isM)) o Sets [ φ o
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
221 FMap (m-bi MonoidalSets) (id1 Sets (FObj F a) , (λ _ → unit )) ] ] ) x ≡ Iso.≅→ (mρ-iso isM) x
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
222 comm20 {a} {b} (x , OneObj ) = begin
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
223 (FMap F (Iso.≅→ (mρ-iso isM))) ( φ (( FMap (m-bi MonoidalSets) (id1 Sets (FObj F a) , (λ _ → unit))) (x , OneObj) ))
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
224 ≡⟨⟩
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
225 FMap F proj₁ ((FMap F (λ j k → j , k) x) <*> (pure OneObj))
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
226 ≡⟨ ≡-cong ( λ k → FMap F proj₁ k) ( IsApplicative.interchange ismf ) ⟩
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
227 FMap F proj₁ ((pure (λ f → f OneObj)) <*> (FMap F (λ j k → j , k) x))
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
228 ≡⟨ ( trans F→pure (right ( right F→pure )) ) ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
229 pure proj₁ <*> ((pure (λ f → f OneObj)) <*> (pure (λ j k → j , k) <*> x))
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
230 ≡⟨ sym ( right comp ) ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
231 pure proj₁ <*> (((pure _・_ <*> (pure (λ f → f OneObj))) <*> pure (λ j k → j , k)) <*> x)
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
232 ≡⟨ sym comp ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
233 ( ( pure _・_ <*> (pure proj₁ ) ) <*> ((pure _・_ <*> (pure (λ f → f OneObj))) <*> pure (λ j k → j , k))) <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
234 ≡⟨ trans ( trans ( trans ( left ( left p*p)) ( left ( right (left p*p) ))) (left (right p*p) ) ) (left p*p) ⟩
727
ea84cc6c1797 monoidal functor and applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
235 pure ( ( _・_ (proj₁ {l} {l})) ((_・_ ((λ f → f OneObj))) (λ j k → j , k))) <*> x
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
236 ≡⟨⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
237 pure id <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
238 ≡⟨ IsApplicative.identity ismf ⟩
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
239 x
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
240 ≡⟨⟩
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
241 Iso.≅→ (mρ-iso isM) (x , OneObj)
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
242
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
243 where
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
244 open Relation.Binary.PropositionalEquality
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
245 open Relation.Binary.PropositionalEquality.≡-Reasoning
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
246 comm2 : {a b : Obj Sets} → Sets [ Sets [
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
247 FMap F (Iso.≅→ (mρ-iso isM)) o Sets [ φ o
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
248 FMap (m-bi MonoidalSets) (id1 Sets (FObj F a) , (λ _ → unit )) ] ] ≈ Iso.≅→ (mρ-iso isM) ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
249 comm2 {a} {b} = extensionality Sets ( λ x → comm20 {a} {b} x )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
250 comm30 : {a b : Obj Sets} ( x : One * FObj F b ) → ( Sets [
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
251 FMap F (Iso.≅→ (mλ-iso isM)) o Sets [ φ o
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
252 FMap (m-bi MonoidalSets) ((λ _ → unit ) , id1 Sets (FObj F b) ) ] ] ) x ≡ Iso.≅→ (mλ-iso isM) x
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
253 comm30 {a} {b} ( OneObj , x) = begin
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
254 (FMap F (Iso.≅→ (mλ-iso isM))) ( φ ( unit , x ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
255 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
256 FMap F proj₂ ((FMap F (λ j k → j , k) (pure OneObj)) <*> x)
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
257 ≡⟨ ( trans F→pure (right ( left F→pure )) ) ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
258 pure proj₂ <*> ((pure (λ j k → j , k) <*> (pure OneObj)) <*> x)
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
259 ≡⟨ sym comp ⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
260 ((pure _・_ <*> (pure proj₂)) <*> (pure (λ j k → j , k) <*> (pure OneObj))) <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
261 ≡⟨ trans (trans (left (left p*p )) (left ( right p*p)) ) (left p*p) ⟩
727
ea84cc6c1797 monoidal functor and applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
262 pure ((_・_ (proj₂ {l}) )((λ (j : One {l}) (k : b ) → j , k) OneObj)) <*> x
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
263 ≡⟨⟩
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
264 pure id <*> x
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
265 ≡⟨ IsApplicative.identity ismf ⟩
720
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
266 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
267 ≡⟨⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
268 Iso.≅→ (mλ-iso isM) ( OneObj , x )
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
269
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
270 where
725
bd371f36df9a fill proofs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
271 open Relation.Binary.PropositionalEquality
719
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
272 open Relation.Binary.PropositionalEquality.≡-Reasoning
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
273 comm3 : {a b : Obj Sets} → Sets [ Sets [ FMap F (Iso.≅→ (mλ-iso isM)) o
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
274 Sets [ φ o FMap (m-bi MonoidalSets) ((λ _ → unit ) , id1 Sets (FObj F b)) ] ] ≈ Iso.≅→ (mλ-iso isM) ]
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
275 comm3 {a} {b} = extensionality Sets ( λ x → comm30 {a} {b} x )
a017ed40dd77 Applicative law → Monoidal law begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
276
730
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
277 ----
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
278 --
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
279 -- Monoidal laws imples Applicative laws
e4ef69bae044 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
280 --
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
281
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
282 HaskellMonoidal→Applicative : {c₁ : Level} ( F : Functor (Sets {c₁}) (Sets {c₁}) )
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
283 ( Mono : HaskellMonoidalFunctor F )
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
284 → Applicative F
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
285 HaskellMonoidal→Applicative {c₁} F Mono = record {
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
286 pure = pure ;
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
287 <*> = _<*>_ ;
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
288 isApplicative = record {
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
289 identity = identity
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
290 ; composition = composition
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
291 ; homomorphism = homomorphism
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
292 ; interchange = interchange
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
293 }
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
294 }
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
295 where
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
296 unit : FObj F One
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
297 unit = HaskellMonoidalFunctor.unit Mono
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
298 φ : {a b : Obj Sets} → Hom Sets ((FObj F a) * (FObj F b )) ( FObj F ( a * b ) )
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
299 φ = HaskellMonoidalFunctor.φ Mono
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
300 mono : IsHaskellMonoidalFunctor F unit φ
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
301 mono = HaskellMonoidalFunctor.isHaskellMonoidalFunctor Mono
714
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 713
diff changeset
302 id : { a : Obj Sets } → a → a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 713
diff changeset
303 id x = x
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
304 isM : IsMonoidal (Sets {c₁}) One SetsTensorProduct
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
305 isM = Monoidal.isMonoidal MonoidalSets
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
306 pure : {a : Obj Sets} → Hom Sets a ( FObj F a )
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
307 pure {a} x = FMap F ( λ y → x ) (unit )
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
308 _<*>_ : {a b : Obj Sets} → FObj F ( a → b ) → FObj F a → FObj F b
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
309 _<*>_ {a} {b} x y = FMap F ( λ r → ( proj₁ r ) ( proj₂ r ) ) (φ ( x , y ))
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
310 -- right does not work right it makes yellows. why?
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
311 -- right : {n : Level} { a b : Set n} → { x y : a } { h : a → b } → ( x ≡ y ) → h x ≡ h y
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
312 -- right {_} {_} {_} {_} {_} {h} eq = ≡-cong ( λ k → h k ) eq
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
313 left : {n : Level} { a b : Set n} → { x y : a → b } { h : a } → ( x ≡ y ) → x h ≡ y h
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
314 left {_} {_} {_} {_} {_} {h} eq = ≡-cong ( λ k → k h ) eq
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
315 open Relation.Binary.PropositionalEquality
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
316 FφF→F : { a b c d e : Obj Sets } { g : Hom Sets a c } { h : Hom Sets b d }
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
317 { f : Hom Sets (c * d) e }
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
318 { x : FObj F a } { y : FObj F b }
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
319 → FMap F f ( φ ( FMap F g x , FMap F h y ) ) ≡ FMap F ( f o map g h ) ( φ ( x , y ) )
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
320 FφF→F {a} {b} {c} {d} {e} {g} {h} {f} {x} {y} = sym ( begin
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
321 FMap F ( f o map g h ) ( φ ( x , y ) )
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
322 ≡⟨ ≡-cong ( λ k → k ( φ ( x , y ))) ( IsFunctor.distr (isFunctor F) ) ⟩
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
323 FMap F f (( FMap F ( map g h ) ) ( φ ( x , y )))
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
324 ≡⟨ ≡-cong ( λ k → FMap F f k ) ( IsHaskellMonoidalFunctor.natφ mono ) ⟩
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
325 FMap F f ( φ ( FMap F g x , FMap F h y ) )
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
326 ∎ )
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
327 where
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
328 open Relation.Binary.PropositionalEquality.≡-Reasoning
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
329 u→F : {a : Obj Sets } {u : FObj F a} → u ≡ FMap F id u
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
330 u→F {a} {u} = sym ( ≡-cong ( λ k → k u ) ( IsFunctor.identity ( isFunctor F ) ) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
331 φunitr : {a : Obj Sets } {u : FObj F a} → φ ( unit , u) ≡ FMap F (Iso.≅← (IsMonoidal.mλ-iso isM)) u
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
332 φunitr {a} {u} = sym ( begin
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
333 FMap F (Iso.≅← (IsMonoidal.mλ-iso isM)) u
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
334 ≡⟨ ≡-cong ( λ k → FMap F (Iso.≅← (IsMonoidal.mλ-iso isM)) k ) (sym (IsHaskellMonoidalFunctor.idlφ mono)) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
335 FMap F (Iso.≅← (IsMonoidal.mλ-iso isM)) ( FMap F (Iso.≅→ (IsMonoidal.mλ-iso isM)) ( φ ( unit , u) ) )
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
336 ≡⟨ left ( sym ( IsFunctor.distr ( isFunctor F ) )) ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
337 (FMap F ( (Iso.≅← (IsMonoidal.mλ-iso isM)) o (Iso.≅→ (IsMonoidal.mλ-iso isM)))) ( φ ( unit , u) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
338 ≡⟨ ≡-cong ( λ k → FMap F k ( φ ( unit , u) )) (Iso.iso→ ( (IsMonoidal.mλ-iso isM) )) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
339 FMap F id ( φ ( unit , u) )
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
340 ≡⟨ left ( IsFunctor.identity ( isFunctor F ) ) ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
341 id ( φ ( unit , u) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
342 ≡⟨⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
343 φ ( unit , u)
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
344 ∎ )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
345 where
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
346 open Relation.Binary.PropositionalEquality.≡-Reasoning
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
347 φunitl : {a : Obj Sets } {u : FObj F a} → φ ( u , unit ) ≡ FMap F (Iso.≅← (IsMonoidal.mρ-iso isM)) u
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
348 φunitl {a} {u} = sym ( begin
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
349 FMap F (Iso.≅← (IsMonoidal.mρ-iso isM)) u
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
350 ≡⟨ ≡-cong ( λ k → FMap F (Iso.≅← (IsMonoidal.mρ-iso isM)) k ) (sym (IsHaskellMonoidalFunctor.idrφ mono)) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
351 FMap F (Iso.≅← (IsMonoidal.mρ-iso isM)) ( FMap F (Iso.≅→ (IsMonoidal.mρ-iso isM)) ( φ ( u , unit ) ) )
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
352 ≡⟨ left ( sym ( IsFunctor.distr ( isFunctor F ) )) ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
353 (FMap F ( (Iso.≅← (IsMonoidal.mρ-iso isM)) o (Iso.≅→ (IsMonoidal.mρ-iso isM)))) ( φ ( u , unit ) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
354 ≡⟨ ≡-cong ( λ k → FMap F k ( φ ( u , unit ) )) (Iso.iso→ ( (IsMonoidal.mρ-iso isM) )) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
355 FMap F id ( φ ( u , unit ) )
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
356 ≡⟨ left ( IsFunctor.identity ( isFunctor F ) ) ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
357 id ( φ ( u , unit ) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
358 ≡⟨⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
359 φ ( u , unit )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
360 ∎ )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
361 where
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
362 open Relation.Binary.PropositionalEquality.≡-Reasoning
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
363 open IsMonoidal
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
364 identity : { a : Obj Sets } { u : FObj F a } → pure ( id1 Sets a ) <*> u ≡ u
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
365 identity {a} {u} = begin
714
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 713
diff changeset
366 pure id <*> u
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
367 ≡⟨⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
368 ( FMap F ( λ r → ( proj₁ r ) ( proj₂ r )) ) ( φ ( FMap F ( λ y → id ) unit , u ) )
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
369 ≡⟨ ≡-cong ( λ k → ( FMap F ( λ r → ( proj₁ r ) ( proj₂ r )) ) ( φ ( FMap F ( λ y → id ) unit , k ))) u→F ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
370 ( FMap F ( λ r → ( proj₁ r ) ( proj₂ r )) ) ( φ ( FMap F ( λ y → id ) unit , FMap F id u ) )
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
371 ≡⟨ FφF→F ⟩
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
372 FMap F (λ x → proj₂ x ) (φ (unit , u ) )
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
373 ≡⟨⟩
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
374 FMap F (Iso.≅→ (mλ-iso isM)) (φ (unit , u ))
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
375 ≡⟨ IsHaskellMonoidalFunctor.idlφ mono ⟩
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
376 u
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
377
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
378 where
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
379 open Relation.Binary.PropositionalEquality.≡-Reasoning
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
380 composition : { a b c : Obj Sets } { u : FObj F ( b → c ) } { v : FObj F (a → b ) } { w : FObj F a }
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
381 → (( pure _・_ <*> u ) <*> v ) <*> w ≡ u <*> (v <*> w)
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
382 composition {a} {b} {c} {u} {v} {w} = begin
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
383 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
384 (FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f g x → f (g x)) unit , u)) , v)) , w))
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
385 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f g x → f (g x)) unit , k)) , v)) , w)) ) u→F ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
386 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
387 (FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f g x → f (g x)) unit , FMap F id u )) , v)) , w))
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
388 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ ( k , v)) , w)) ) FφF→F ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
389 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
390 (FMap F ( λ x → (λ r → proj₁ r (proj₂ r)) ((map (λ y f g x → f (g x)) id ) x)) (φ ( unit , u)) , v)) , w))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
391 ≡⟨ ≡-cong ( λ k → ( FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
392 (FMap F ( λ x → (λ r → proj₁ r (proj₂ r)) ((map (λ y f g x → f (g x)) id ) x)) k , v)) , w)) ) ) φunitr ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
393 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
394 ( (FMap F ( λ x → (λ r → proj₁ r (proj₂ r)) ((map (λ y f g x → f (g x)) id ) x)) (FMap F (Iso.≅← (mλ-iso isM)) u) ) , v)) , w))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
395 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
396 (k u , v)) , w)) ) (sym ( IsFunctor.distr (isFunctor F ))) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
397 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
398 ( FMap F (λ x → ((λ y f g x₁ → f (g x₁)) unit x) ) u , v)) , w))
714
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 713
diff changeset
399 ≡⟨⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
400 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
401 ( FMap F (λ x g h → x (g h) ) u , v)) , w))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
402 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ ( FMap F (λ x g h → x (g h) ) u , k)) , w)) ) u→F ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
403 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ x g h → x (g h)) u , FMap F id v)) , w))
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
404 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (k , w)) ) FφF→F ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
405 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F ((λ r → proj₁ r (proj₂ r)) o map (λ x g h → x (g h)) id) (φ (u , v)) , w))
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
406 ≡⟨⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
407 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ x h → proj₁ x (proj₂ x h)) (φ (u , v)) , w))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
408 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ x h → proj₁ x (proj₂ x h)) (φ (u , v)) , k)) ) u→F ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
409 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ x h → proj₁ x (proj₂ x h)) (φ (u , v)) , FMap F id w))
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
410 ≡⟨ FφF→F ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
411 FMap F ((λ r → proj₁ r (proj₂ r)) o map (λ x h → proj₁ x (proj₂ x h)) id) (φ (φ (u , v) , w))
714
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 713
diff changeset
412 ≡⟨⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
413 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (φ (φ (u , v) , w))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
414 ≡⟨ ≡-cong ( λ k → FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (k (φ (φ (u , v) , w)) )) (sym (IsFunctor.identity (isFunctor F ))) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
415 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F id (φ (φ (u , v) , w)) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
416 ≡⟨ ≡-cong ( λ k → FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F k (φ (φ (u , v) , w)) ) ) (sym (Iso.iso→ (mα-iso isM))) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
417 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F ( (Iso.≅← (mα-iso isM)) o (Iso.≅→ (mα-iso isM))) (φ (φ (u , v) , w)) )
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
418 ≡⟨ ≡-cong ( λ k → FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (k (φ (φ (u , v) , w)))) ( IsFunctor.distr (isFunctor F )) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
419 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F (Iso.≅← (mα-iso isM)) ( FMap F (Iso.≅→ (mα-iso isM)) (φ (φ (u , v) , w)) ))
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
420 ≡⟨ ≡-cong ( λ k → FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F (Iso.≅← (mα-iso isM)) k) ) (sym ( IsHaskellMonoidalFunctor.assocφ mono ) ) ⟩
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
421 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F (Iso.≅← (mα-iso isM)) (φ (u , φ (v , w))))
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
422 ≡⟨⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
423 FMap F (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) (FMap F (λ r → (proj₁ r , proj₁ (proj₂ r)) , proj₂ (proj₂ r)) (φ (u , φ (v , w))))
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
424 ≡⟨ left (sym ( IsFunctor.distr (isFunctor F ))) ⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
425 FMap F (λ y → (λ x → proj₁ (proj₁ x) (proj₂ (proj₁ x) (proj₂ x))) ((λ r → (proj₁ r , proj₁ (proj₂ r)) , proj₂ (proj₂ r)) y )) (φ (u , φ (v , w)))
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
426 ≡⟨⟩
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
427 FMap F (λ y → proj₁ y (proj₁ (proj₂ y) (proj₂ (proj₂ y)))) (φ (u , φ (v , w)))
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
428 ≡⟨⟩
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
429 FMap F ( λ x → (proj₁ x) ((λ r → proj₁ r (proj₂ r)) ( proj₂ x))) ( φ ( u , (φ (v , w))))
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
430 ≡⟨ sym FφF→F ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
431 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F id u , FMap F (λ r → proj₁ r (proj₂ r)) (φ (v , w))))
716
35457f9568f3 composition done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 715
diff changeset
432 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (k , FMap F (λ r → proj₁ r (proj₂ r)) (φ (v , w)))) ) (sym u→F ) ⟩
715
1be42267eeee add some tools
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 714
diff changeset
433 FMap F (λ r → proj₁ r (proj₂ r)) (φ (u , FMap F (λ r → proj₁ r (proj₂ r)) (φ (v , w))))
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
434
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
435 where
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
436 open Relation.Binary.PropositionalEquality.≡-Reasoning
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
437 homomorphism : { a b : Obj Sets } { f : Hom Sets a b } { x : a } → pure f <*> pure x ≡ pure (f x)
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
438 homomorphism {a} {b} {f} {x} = begin
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
439 pure f <*> pure x
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
440 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
441 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y → f) unit , FMap F (λ y → x) unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
442 ≡⟨ FφF→F ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
443 FMap F ((λ r → proj₁ r (proj₂ r)) o map (λ y → f) (λ y → x)) (φ (unit , unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
444 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
445 FMap F (λ y → f x) (φ (unit , unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
446 ≡⟨ ≡-cong ( λ k → FMap F (λ y → f x) k ) φunitl ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
447 FMap F (λ y → f x) (FMap F (Iso.≅← (mρ-iso isM)) unit)
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
448 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
449 FMap F (λ y → f x) (FMap F (λ y → (y , OneObj)) unit)
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
450 ≡⟨ left ( sym ( IsFunctor.distr (isFunctor F ))) ⟩
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
451 FMap F (λ y → f x) unit
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
452 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
453 pure (f x)
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
454
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
455 where
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
456 open Relation.Binary.PropositionalEquality.≡-Reasoning
713
5e101ee6dab9 identity done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
457 interchange : { a b : Obj Sets } { u : FObj F ( a → b ) } { x : a } → u <*> pure x ≡ pure (λ f → f x) <*> u
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
458 interchange {a} {b} {u} {x} = begin
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
459 u <*> pure x
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
460 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
461 FMap F (λ r → proj₁ r (proj₂ r)) (φ (u , FMap F (λ y → x) unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
462 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (k , FMap F (λ y → x) unit)) ) u→F ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
463 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F id u , FMap F (λ y → x) unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
464 ≡⟨ FφF→F ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
465 FMap F ((λ r → proj₁ r (proj₂ r)) o map id (λ y → x)) (φ (u , unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
466 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
467 FMap F (λ r → proj₁ r x) (φ (u , unit))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
468 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r x) k ) φunitl ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
469 FMap F (λ r → proj₁ r x) (( FMap F (Iso.≅← (mρ-iso isM))) u )
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
470 ≡⟨ left ( sym ( IsFunctor.distr (isFunctor F )) ) ⟩
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
471 FMap F (( λ r → proj₁ r x) o ((Iso.≅← (mρ-iso isM) ))) u
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
472 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
473 FMap F (( λ r → proj₂ r x) o ((Iso.≅← (mλ-iso isM) ))) u
721
a8b595fb4905 use FMap F f x ≡ pure f <*> x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
474 ≡⟨ left ( IsFunctor.distr (isFunctor F )) ⟩
717
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
475 FMap F (λ r → proj₂ r x) (FMap F (Iso.≅← (IsMonoidal.mλ-iso isM)) u)
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
476 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₂ r x) k ) (sym φunitr ) ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
477 FMap F (λ r → proj₂ r x) (φ (unit , u))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
478 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
479 FMap F ((λ r → proj₁ r (proj₂ r)) o map (λ y f → f x) id) (φ (unit , u))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
480 ≡⟨ sym FφF→F ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
481 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f → f x) unit , FMap F id u))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
482 ≡⟨ ≡-cong ( λ k → FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f → f x) unit , k)) ) (sym u→F) ⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
483 FMap F (λ r → proj₁ r (proj₂ r)) (φ (FMap F (λ y f → f x) unit , u))
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
484 ≡⟨⟩
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
485 pure (λ f → f x) <*> u
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
486
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
487 where
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
488 open Relation.Binary.PropositionalEquality.≡-Reasoning
a41b2b9b0407 Haskell Monoidal Funtor to Applicative done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 716
diff changeset
489
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
490 ----
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
491 --
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
492 -- Applicative laws imples Monoidal laws
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
493 --
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
494
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
495 Applicative→HaskellMonoidal : {c₁ : Level} ( F : Functor (Sets {c₁}) (Sets {c₁}) )
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
496 ( App : Applicative F )
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
497 → HaskellMonoidalFunctor F
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
498 Applicative→HaskellMonoidal {l} F App = record {
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
499 unit = unit ;
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
500 φ = φ ;
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
501 isHaskellMonoidalFunctor = record {
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
502 natφ = natφ
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
503 ; assocφ = assocφ
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
504 ; idrφ = idrφ
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
505 ; idlφ = idlφ
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
506 }
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
507 } where
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
508 pure = Applicative.pure App
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
509 <*> = Applicative.<*> App
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
510 app = Applicative.isApplicative App
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
511 unit : FObj F One
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
512 unit = pure OneObj
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
513 φ : {a b : Obj Sets} → Hom Sets ((FObj F a) * (FObj F b )) ( FObj F ( a * b ) )
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
514 φ = λ x → <*> (FMap F (λ j k → (j , k)) ( proj₁ x)) ( proj₂ x)
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
515 isM : IsMonoidal (Sets {l}) One SetsTensorProduct
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
516 isM = Monoidal.isMonoidal MonoidalSets
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
517 MF : MonoidalFunctor {_} {l} {_} {Sets} {Sets} MonoidalSets MonoidalSets
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
518 MF = Applicative→Monoidal F App app
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
519 isMF = MonoidalFunctor.isMonodailFunctor MF
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
520 natφ : { a b c d : Obj Sets } { x : FObj F a} { y : FObj F b} { f : a → c } { g : b → d }
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
521 → FMap F (map f g) (φ (x , y)) ≡ φ (FMap F f x , FMap F g y)
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
522 natφ {a} {b} {c} {d} {x} {y} {f} {g} = begin
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
523 FMap F (map f g) (φ (x , y))
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
524 ≡⟨⟩
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
525 FMap F (λ xy → f (proj₁ xy) , g (proj₂ xy)) (<*> (FMap F (λ j k → j , k) x) y)
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
526 ≡⟨ ≡-cong ( λ h → h (x , y)) ( IsNTrans.commute ( NTrans.isNTrans ( IsMonoidalFunctor.φab isMF ))) ⟩
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
527 <*> (FMap F (λ j k → j , k) (FMap F f x)) (FMap F g y)
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
528 ≡⟨⟩
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
529 φ (FMap F f x , FMap F g y)
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
530
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
531 where
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
532 open Relation.Binary.PropositionalEquality.≡-Reasoning
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
533 assocφ : { x y z : Obj Sets } { a : FObj F x } { b : FObj F y }{ c : FObj F z }
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
534 → φ (a , φ (b , c)) ≡ FMap F (Iso.≅→ (IsMonoidal.mα-iso isM)) (φ (φ (a , b) , c))
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
535 assocφ {x} {y} {z} {a} {b} {c} = ≡-cong ( λ h → h ((a , b) , c ) ) ( IsMonoidalFunctor.associativity isMF )
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
536 idrφ : {a : Obj Sets } { x : FObj F a } → FMap F (Iso.≅→ (IsMonoidal.mρ-iso isM)) (φ (x , unit)) ≡ x
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
537 idrφ {a} {x} = ≡-cong ( λ h → h (x , OneObj ) ) ( IsMonoidalFunctor.unitarity-idr isMF {a} {One} )
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
538 idlφ : {a : Obj Sets } { x : FObj F a } → FMap F (Iso.≅→ (IsMonoidal.mλ-iso isM)) (φ (unit , x)) ≡ x
766
c30ca91f3a76 Applicative all done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 765
diff changeset
539 idlφ {a} {x} = ≡-cong ( λ h → h (OneObj , x ) ) ( IsMonoidalFunctor.unitarity-idl isMF {One} {a} )
765
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
540
171f5386e87e Applicative→HaskellMonoidal begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 732
diff changeset
541