### changeset 59:46b15f368905

Define bind and mu for Infinite Delta
author Yasutaka Higa Sat, 22 Nov 2014 16:03:40 +0900 1229ee398567 73bb981cb1c6 agda/delta.agda delta.hs 2 files changed, 126 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
```--- a/agda/delta.agda	Sat Nov 22 12:34:06 2014 +0900
+++ b/agda/delta.agda	Sat Nov 22 16:03:40 2014 +0900
@@ -33,14 +33,18 @@

-
--- TODO: mu
--- TODO: bind
-
-
eta : {l : Level} {A : Set l} -> A -> Delta A
eta x = mono x

+bind : {l ll : Level} {A : Set l} {B : Set ll} -> (Delta A) -> (A -> Delta B) -> Delta B
+bind (mono x)    f = f x
+bind (delta x d) f = deltaAppend (headDelta (f x)) (bind d (tailDelta ∙ f))
+
+-- can not apply id. because different Level
+mu : {l : Level} {A : Set l} -> Delta (Delta A) -> Delta A
+mu d = bind d id
+
+
returnS : {l : Level} {A : Set l} -> A -> Delta A
returnS x = mono x

@@ -81,7 +85,98 @@

-- monad-law-1 : join . fmap join = join . join
---monad-law-1 : {l : Level} {A : Set l} -> (d : Delta (Delta (Delta A))) -> ((mu ∙ (fmap mu)) d) ≡ ((mu ∙ mu) d)
+monad-law-1 : {l : Level} {A : Set l} -> (d : Delta (Delta (Delta A))) -> ((mu ∙ (fmap mu)) d) ≡ ((mu ∙ mu) d)
+monad-law-1 (delta (mono (mono x)) (mono (mono (mono xx)))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (mono (delta xx d)))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (mono (mono xxx))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (mono (delta xxx d))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (mono x₂)))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (delta x₂ (mono x₃))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (delta x₂ (delta x₃ d₂))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (mono x₂) (mono (mono x₃))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (delta x₂ (mono x₃)) (mono (mono x₄))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (delta x₂ (delta x₃ d₂)) (mono (mono x₄))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta d₂ (mono (delta x₂ d₃))))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta d₂ (delta d₃ d₄)))))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (delta x₁ d₁) d₂)))) = refl
+monad-law-1 (delta (mono (mono x)) (mono (delta (delta x₁ d) d₁))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (mono d₁)))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (mono x₃) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (delta x₃ (mono x₄)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (delta x₃ (delta x₄ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (delta (mono x₄) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (delta (delta x₄ (mono x₅)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (delta (delta x₄ (delta x₅ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (mono x₅) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (delta x₅ (mono x₆)) (mono d₃)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (delta x₅ (delta x₆ d₂)) (mono d₃)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (delta x₅ (mono x₆)) (delta d₃ d₄)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (delta x₅ (delta x₆ d₂)) (delta d₃ d₄)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ d₁))) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (mono x₅)))) (delta (mono x₆) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (mono x₅)))) (delta (delta x₆ (mono x₇)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (mono x₅)))) (delta (delta x₆ (delta x₇ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (mono x₆))))) (delta (mono x₇) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (mono x₆))))) (delta (delta x₇ (mono x₈)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (mono x₆))))) (delta (delta x₇ (delta x₈ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (mono x₇)))))) (delta (mono x₈) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (mono x₇)))))) (delta (delta x₈ (mono x₉)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (mono x₇)))))) (delta (delta x₈ (delta x₉ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (mono x₈))))))) (delta (mono x₉) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (mono x₈))))))) (delta (delta x₉ (mono x₁₀)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (mono x₈))))))) (delta (delta x₉ (delta x₁₀ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (mono x₉)))))))) (delta (mono x₁₀) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (mono x₉)))))))) (delta (delta x₁₀ (mono x₁₁)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (mono x₉)))))))) (delta (delta x₁₀ (delta x₁₁ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (mono x₁₀))))))))) (delta (mono x₁₁) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (mono x₁₀))))))))) (delta (delta x₁₁ (mono x₁₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (mono x₁₀))))))))) (delta (delta x₁₁ (delta x₁₂ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (mono x₁₁)))))))))) (delta (mono x₁₂) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (mono x₁₁)))))))))) (delta (delta x₁₂ (mono x₁₃)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (mono x₁₁)))))))))) (delta (delta x₁₂ (delta x₁₃ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (mono x₁₂))))))))))) (delta (mono x₁₃) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (mono x₁₂))))))))))) (delta (delta x₁₃ (mono x₁₄)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (mono x₁₂))))))))))) (delta (delta x₁₃ (delta x₁₄ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (mono x₁₃)))))))))))) (delta (mono x₁₄) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (mono x₁₃)))))))))))) (delta (delta x₁₄ (mono x₁₅)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (mono x₁₃)))))))))))) (delta (delta x₁₄ (delta x₁₅ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (mono x₁₄))))))))))))) (delta (mono x₁₅) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (mono x₁₄))))))))))))) (delta (delta x₁₅ (mono x₁₆)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (mono x₁₄))))))))))))) (delta (delta x₁₅ (delta x₁₆ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (delta x₁₄ d₁))))))))))))) (delta (mono x₁₅) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (delta x₁₄ d₁))))))))))))) (delta (delta x₁₅ (mono x₁₆)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (delta x₁₄ d₁))))))))))))) (delta (delta x₁₅ (delta x₁₆ d₂)) (mono d₃)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ (delta x₅ (delta x₆ (delta x₇ (delta x₈ (delta x₉ (delta x₁₀ (delta x₁₁ (delta x₁₂ (delta x₁₃ (delta x₁₄ d₁))))))))))))) (delta (delta x₁₅ (delta x₁₆ d₂)) (delta d₃ d₄)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ d)) (mono (mono (mono x₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ d)) (mono (mono (delta x₂ d₁))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (delta (mono x₄) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (delta (delta x₄ (mono x₅)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (delta (delta x₄ (delta x₅ d₂)) d₃))))) = refl
+
+-- 6 goals
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (mono (mono x₅)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (mono (delta x₅ d₂)))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (delta (mono x₅) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (delta (delta x₅ (mono x₆)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (delta (delta x₅ (delta x₆ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (mono x₅))) (mono d₂))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (mono x₅))) (delta (mono x₆) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (mono x₅))) (delta (delta x₆ (mono x₇)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (mono x₅))) (delta (delta x₆ (delta x₇ d₂)) d₃))))) = refl
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (delta x₅ d₁))) (mono d₂))))) = {!!}
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (delta x₅ d₁))) (delta d₂ d₃))))) = {!!}
+monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (delta x₂ d))) (mono (delta d₁ d₂)))) = {!!}
+monad-law-1 (delta (mono (mono x)) (delta (mono d) (delta d₁ d₂))) = {!!}
+monad-law-1 (delta (mono (mono x)) (delta (delta d d₁) d₂)) = {!!}
+--
+monad-law-1 (delta (mono (delta x x₁)) d) = {!!}
+monad-law-1 (delta (delta x x₁) d) = {!!}
+

{-
@@ -104,66 +199,31 @@
monad-law-h-1 : {l ll : Level} {A : Set l} {B : Set ll} ->
(a : A) -> (k : A -> (Delta B)) ->
(return a >>= k)  ≡ (k a)
-    return a >>= k
-  ≡⟨ refl ⟩
-    mu (fmap k (return a))
-  ≡⟨ refl ⟩
-    mu (return (k a))
-  ≡⟨ refl ⟩
-    (mu ∙ return) (k a)
-  ≡⟨ refl ⟩
-    (mu ∙ eta) (k a)
-  ≡⟨ (monad-law-2-2 (k a)) ⟩
-    id (k a)
-  ≡⟨ refl ⟩
-    k a
-  ∎
+
+

-- monad-law-h-2 : m >>= return  =  m
monad-law-h-2 : {l : Level}{A : Set l} -> (m : Delta A) -> (m >>= return)  ≡ m
-monad-law-h-2 (similar lx x ly y) = monad-law-2-1 (similar lx x ly y)
+
+
+

-- monad-law-h-3 : m >>= (\x -> k x >>= h)  =  (m >>= k) >>= h
monad-law-h-3 : {l ll lll : Level} {A : Set l} {B : Set ll} {C : Set lll} ->
(m : Delta A)  -> (k : A -> (Delta B)) -> (h : B -> (Delta C)) ->
(m >>= (\x -> k x >>= h)) ≡ ((m >>= k) >>= h)
-monad-law-h-3 (similar lx x ly y) k h = begin
-    ((similar lx x ly y) >>= (\x -> (k x) >>= h))
-  ≡⟨ refl ⟩
-    mu (fmap (\x -> k x >>= h) (similar lx x ly y))
-  ≡⟨ refl ⟩
-    (mu ∙ fmap (\x -> k x >>= h)) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ fmap (\x -> mu (fmap h (k x)))) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ fmap (mu ∙ (\x -> fmap h (k x)))) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ (fmap mu ∙ (fmap (\x -> fmap h (k x))))) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ (fmap mu)) ((fmap (\x -> fmap h (k x))) (similar lx x ly y))
-  ≡⟨ monad-law-1 (((fmap (\x -> fmap h (k x))) (similar lx x ly y))) ⟩
-    (mu ∙ mu) ((fmap (\x -> fmap h (k x))) (similar lx x ly y))
-  ≡⟨ refl ⟩
-    (mu ∙ (mu ∙ (fmap (\x -> fmap h (k x))))) (similar lx x ly y)
+monad-law-h-3 (mono x) k h    = refl
+monad-law-h-3 (delta x d) k h = begin
+  (delta x d) >>= (\x -> k x >>= h)
≡⟨ refl ⟩
-    (mu ∙ (mu ∙ (fmap ((fmap h) ∙ k)))) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ (mu ∙ ((fmap (fmap h)) ∙ (fmap k)))) (similar lx x ly y)
-  ≡⟨ refl ⟩
-    (mu ∙ (mu ∙ (fmap (fmap h)))) (fmap k (similar lx x ly y))
-  ≡⟨ refl ⟩
-    mu ((mu ∙ (fmap (fmap h))) (fmap k (similar lx x ly y)))
-  ≡⟨ cong (\fx -> mu fx) (monad-law-4 h (fmap k (similar lx x ly y))) ⟩
-    mu (fmap h (mu (similar lx (k x) ly (k y))))
+-- (delta x d) >>= f = deltaAppend (headDelta (f x)) (d >>= (tailDelta ∙ f))
+  deltaAppend (headDelta ((\x -> k x >>= h) x)) (d >>= (tailDelta ∙ (\x -> k x >>= h)))
≡⟨ refl ⟩
-    (mu ∙ fmap h) (mu (fmap k (similar lx x ly y)))
-  ≡⟨ refl ⟩
-    mu (fmap h (mu (fmap k (similar lx x ly y))))
-  ≡⟨ refl ⟩
-    (mu (fmap k (similar lx x ly y))) >>= h
-  ≡⟨ refl ⟩
-    ((similar lx x ly y) >>= k) >>= h
+  deltaAppend (headDelta (k x >>= h)) (d >>= (tailDelta ∙ (\x -> k x >>= h)))
+  ≡⟨ {!!} ⟩
+  ((delta x d) >>= k) >>= h
∎
-
-}
\ No newline at end of file```
```--- a/delta.hs	Sat Nov 22 12:34:06 2014 +0900
+++ b/delta.hs	Sat Nov 22 16:03:40 2014 +0900
@@ -32,10 +32,17 @@
(Delta f df) <*> d@(Mono x)  = Delta (f x) (df <*> d)
(Delta f df) <*> (Delta x d) = Delta (f x) (df <*> d)

+bind :: (Delta a) -> (a -> Delta b) -> (Delta b)
+bind (Mono x)    f = f x
+bind (Delta x d) f = (headDelta (f x)) `deltaAppend` (bind d (tailDelta . f))
+
+mu :: (Delta (Delta a)) -> (Delta a)
+mu d = bind d id
+