annotate agda/delta/functor.agda @ 126:5902b2a24abf

Prove mu-is-nt for DeltaM with fmap-equiv
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Tue, 03 Feb 2015 11:45:33 +0900
parents 47f144540d51
children d205ff1e406f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 open import Level
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 open import Relation.Binary.PropositionalEquality
112
0a3b6cb91a05 Prove left-unity-law for DeltaM
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
3 open ≡-Reasoning
87
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
104
ebd0d6e2772c Trying redenition Delta with length constraints
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
5 open import basic
ebd0d6e2772c Trying redenition Delta with length constraints
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
6 open import delta
ebd0d6e2772c Trying redenition Delta with length constraints
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
7 open import laws
ebd0d6e2772c Trying redenition Delta with length constraints
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
8 open import nat
ebd0d6e2772c Trying redenition Delta with length constraints
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
9
87
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 module delta.functor where
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 -- Functor-laws
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 -- Functor-law-1 : T(id) = id'
105
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
15 functor-law-1 : {l : Level} {A : Set l} {n : Nat} -> (d : Delta A (S n)) -> (delta-fmap id) d ≡ id d
87
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 functor-law-1 (mono x) = refl
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 functor-law-1 (delta x d) = cong (delta x) (functor-law-1 d)
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 -- Functor-law-2 : T(f . g) = T(f) . T(g)
105
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
20 functor-law-2 : {l : Level} {n : Nat} {A B C : Set l} ->
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
21 (f : B -> C) -> (g : A -> B) -> (d : Delta A (S n)) ->
93
8d92ed54a94f Prove functor-laws for deltaM
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
22 (delta-fmap (f ∙ g)) d ≡ ((delta-fmap f) ∙ (delta-fmap g)) d
87
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 functor-law-2 f g (mono x) = refl
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 functor-law-2 f g (delta x d) = cong (delta (f (g x))) (functor-law-2 f g d)
6789c65a75bc Split functor-proofs into delta.functor
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
105
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
26
126
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
27 delta-fmap-equiv : {l : Level} {A B : Set l} {n : Nat} {f g : A -> B}
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
28 (eq : (x : A) -> f x ≡ g x) -> (d : Delta A (S n)) ->
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
29 delta-fmap f d ≡ delta-fmap g d
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
30 delta-fmap-equiv {l} {A} {B} {O} {f} {g} eq (mono x) = begin
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
31 mono (f x) ≡⟨ cong mono (eq x) ⟩
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
32 mono (g x)
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
33
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
34 delta-fmap-equiv {l} {A} {B} {S n} {f} {g} eq (delta x d) = begin
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
35 delta (f x) (delta-fmap f d) ≡⟨ cong (\de -> delta de (delta-fmap f d)) (eq x) ⟩
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
36 delta (g x) (delta-fmap f d) ≡⟨ cong (\de -> delta (g x) de) (delta-fmap-equiv eq d) ⟩
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
37 delta (g x) (delta-fmap g d)
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
38
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
39
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
40
105
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
41
e6499a50ccbd Retrying prove monad-laws for delta
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
42 delta-is-functor : {l : Level} {n : Nat} -> Functor {l} (\A -> Delta A (S n))
126
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
43 delta-is-functor = record { fmap = delta-fmap
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
44 ;preserve-id = functor-law-1
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
45 ; covariant = \f g -> functor-law-2 g f
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
46 ; fmap-equiv = delta-fmap-equiv
5902b2a24abf Prove mu-is-nt for DeltaM with fmap-equiv
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
47 }