Mercurial > hg > Members > atton > delta_monad
annotate agda/similar.agda @ 28:6e6d646d7722
Split basic functions to file
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Oct 2014 14:55:40 +0900 |
parents | 742e62fc63e4 |
children | e0ba1bf564dd |
rev | line source |
---|---|
26
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 open import list |
28
6e6d646d7722
Split basic functions to file
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
27
diff
changeset
|
2 open import basic |
27
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
3 open import Relation.Binary.PropositionalEquality |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
4 open ≡-Reasoning |
26
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 module similar where |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 data Similar (A : Set) : Set where |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 similar : List String -> A -> List String -> A -> Similar A |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 fmap : {A B : Set} -> (A -> B) -> (Similar A) -> (Similar B) |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 fmap f (similar xs x ys y) = similar xs (f x) ys (f y) |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 mu : {A : Set} -> Similar (Similar A) -> Similar A |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 mu (similar lx (similar llx x _ _) ly (similar _ _ lly y)) = similar (lx ++ llx) x (ly ++ lly) y |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 |
27
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
17 return : {A : Set} -> A -> Similar A |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
18 return x = similar [] x [] x |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
19 |
26
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 returnS : {A : Set} -> A -> Similar A |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 returnS x = similar [[ (show x) ]] x [[ (show x) ]] x |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 returnSS : {A : Set} -> A -> A -> Similar A |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 returnSS x y = similar [[ (show x) ]] x [[ (show y) ]] y |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 |
5ba82f107a95
Define Similar in Agda
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
27
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
27 monad-law-1 : mu ∙ (fmap mu) ≡ mu ∙ mu |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
28 monad-law-1 = {!!} |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
29 |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
30 --monad-law-2 : mu ∙ fmap return ≡ mu ∙ return ≡id |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
31 monad-law-2-1 : mu ∙ fmap return ≡ mu ∙ return |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
32 monad-law-2-1 = {!!} |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
33 |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
34 monad-law-2-2 : mu ∙ return ≡ id |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
35 monad-law-2-2 = {!!} |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
36 |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
37 monad-law-3 : ∀{f} -> return ∙ f ≡ fmap f ∙ return |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
38 monad-law-3 = {!!} |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
39 |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
40 monad-law-4 : ∀{f} -> mu ∙ fmap (fmap f) ≡ fmap f ∙ mu |
742e62fc63e4
Define Monad-law 1-4
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
26
diff
changeset
|
41 monad-law-4 = {!!} |