Mercurial > hg > Members > atton > delta_monad
changeset 26:5ba82f107a95
Define Similar in Agda
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Oct 2014 14:43:33 +0900 |
parents | a5aadebc084d |
children | 742e62fc63e4 |
files | agda/list.agda agda/similar.agda |
diffstat | 2 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/agda/list.agda Tue Oct 07 10:38:57 2014 +0900 +++ b/agda/list.agda Tue Oct 07 14:43:33 2014 +0900 @@ -14,6 +14,9 @@ [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) +[[_]] : {A : Set} -> A -> List A +[[ x ]] = x :: [] + empty-append : {A : Set} -> (xs : List A) -> xs ++ [] ≡ [] ++ xs empty-append [] = refl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agda/similar.agda Tue Oct 07 14:43:33 2014 +0900 @@ -0,0 +1,25 @@ +open import list + +module similar where + +postulate String : Set +postulate show : {A : Set} -> A -> String + +data Similar (A : Set) : Set where + similar : List String -> A -> List String -> A -> Similar A + + +fmap : {A B : Set} -> (A -> B) -> (Similar A) -> (Similar B) +fmap f (similar xs x ys y) = similar xs (f x) ys (f y) + + +mu : {A : Set} -> Similar (Similar A) -> Similar A +mu (similar lx (similar llx x _ _) ly (similar _ _ lly y)) = similar (lx ++ llx) x (ly ++ lly) y + +returnS : {A : Set} -> A -> Similar A +returnS x = similar [[ (show x) ]] x [[ (show x) ]] x + +returnSS : {A : Set} -> A -> A -> Similar A +returnSS x y = similar [[ (show x) ]] x [[ (show y) ]] y + +