comparison agda/delta.agda @ 59:46b15f368905

Define bind and mu for Infinite Delta
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sat, 22 Nov 2014 16:03:40 +0900
parents dfcd72dc697e
children 73bb981cb1c6
comparison
equal deleted inserted replaced
58:1229ee398567 59:46b15f368905
31 fmap f (delta x d) = delta (f x) (fmap f d) 31 fmap f (delta x d) = delta (f x) (fmap f d)
32 32
33 33
34 34
35 -- Monad (Category) 35 -- Monad (Category)
36
37 -- TODO: mu
38 -- TODO: bind
39
40
41 eta : {l : Level} {A : Set l} -> A -> Delta A 36 eta : {l : Level} {A : Set l} -> A -> Delta A
42 eta x = mono x 37 eta x = mono x
38
39 bind : {l ll : Level} {A : Set l} {B : Set ll} -> (Delta A) -> (A -> Delta B) -> Delta B
40 bind (mono x) f = f x
41 bind (delta x d) f = deltaAppend (headDelta (f x)) (bind d (tailDelta ∙ f))
42
43 -- can not apply id. because different Level
44 mu : {l : Level} {A : Set l} -> Delta (Delta A) -> Delta A
45 mu d = bind d id
46
43 47
44 returnS : {l : Level} {A : Set l} -> A -> Delta A 48 returnS : {l : Level} {A : Set l} -> A -> Delta A
45 returnS x = mono x 49 returnS x = mono x
46 50
47 returnSS : {l : Level} {A : Set l} -> A -> A -> Delta A 51 returnSS : {l : Level} {A : Set l} -> A -> A -> Delta A
79 83
80 84
81 -- Monad-laws (Category) 85 -- Monad-laws (Category)
82 86
83 -- monad-law-1 : join . fmap join = join . join 87 -- monad-law-1 : join . fmap join = join . join
84 --monad-law-1 : {l : Level} {A : Set l} -> (d : Delta (Delta (Delta A))) -> ((mu ∙ (fmap mu)) d) ≡ ((mu ∙ mu) d) 88 monad-law-1 : {l : Level} {A : Set l} -> (d : Delta (Delta (Delta A))) -> ((mu ∙ (fmap mu)) d) ≡ ((mu ∙ mu) d)
89 monad-law-1 (mono d) = refl
90 monad-law-1 (delta (mono (mono x)) (mono (mono (mono xx)))) = refl
91 monad-law-1 (delta (mono (mono x)) (mono (mono (delta xx d)))) = refl
92 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (mono (mono xxx))))) = refl
93 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (mono (delta xxx d))))) = refl
94 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (mono x₂)))))) = refl
95 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (delta x₂ (mono x₃))))))) = refl
96 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (mono (delta x₂ (delta x₃ d₂))))))) = refl
97 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (mono x₂) (mono (mono x₃))))))) = refl
98 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (delta x₂ (mono x₃)) (mono (mono x₄))))))) = refl
99 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta (delta x₂ (delta x₃ d₂)) (mono (mono x₄))))))) = refl
100 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta d₂ (mono (delta x₂ d₃))))))) = refl
101 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (mono x₁) (delta d₂ (delta d₃ d₄)))))) = refl
102 monad-law-1 (delta (mono (mono x)) (mono (delta (mono xx) (delta (delta x₁ d₁) d₂)))) = refl
103 monad-law-1 (delta (mono (mono x)) (mono (delta (delta x₁ d) d₁))) = refl
104 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (mono d₁)))) = refl
105 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (mono d₂))))) = refl
106 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (mono x₃) d₃))))) = refl
107 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (delta x₃ (mono x₄)) d₃))))) = refl
108 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (mono x₂) (delta (delta x₃ (delta x₄ d₂)) d₃))))) = refl
109 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (mono d₂))))) = refl
110 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (delta (mono x₄) d₃))))) = refl
111 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (mono x₃)) (delta (delta x₄ (mono x₅)) d₃))))) = refl
112 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
113 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (mono d₂))))) = refl
114 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (mono x₄))) (delta (mono x₅) d₃))))) = refl
115 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
116 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
117 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
118 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
119 monad-law-1 (delta (mono (mono x)) (delta (mono (mono x₁)) (mono (delta (delta x₂ (delta x₃ (delta x₄ d₁))) (mono d₂))))) = refl
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ d)) (mono (mono (mono x₂))))) = refl
155 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ d)) (mono (mono (delta x₂ d₁))))) = refl
156 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (mono d₂))))) = refl
157 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (delta (mono x₄) d₃))))) = refl
158 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (mono x₃) (delta (delta x₄ (mono x₅)) d₃))))) = refl
159 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
160
161 -- 6 goals
162 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (mono (mono x₅)))))) = refl
163 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (mono (delta x₅ d₂)))))) = refl
164 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (mono x₄)) (delta (mono x₅) d₃))))) = refl
165 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
166 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
167 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (mono x₅))) (mono d₂))))) = refl
168 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
169 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
170 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
171 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (mono x₂))) (mono (delta (delta x₃ (delta x₄ (delta x₅ d₁))) (mono d₂))))) = {!!}
172 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₃))))) = {!!}
173 monad-law-1 (delta (mono (mono x)) (delta (mono (delta x₁ (delta x₂ d))) (mono (delta d₁ d₂)))) = {!!}
174 monad-law-1 (delta (mono (mono x)) (delta (mono d) (delta d₁ d₂))) = {!!}
175 monad-law-1 (delta (mono (mono x)) (delta (delta d d₁) d₂)) = {!!}
176 --
177 monad-law-1 (delta (mono (delta x x₁)) d) = {!!}
178 monad-law-1 (delta (delta x x₁) d) = {!!}
179
85 180
86 181
87 {- 182 {-
88 -- monad-law-2-2 : join . return = id 183 -- monad-law-2-2 : join . return = id
89 monad-law-2-2 : {l : Level} {A : Set l } -> (s : Delta A) -> (mu ∙ eta) s ≡ id s 184 monad-law-2-2 : {l : Level} {A : Set l } -> (s : Delta A) -> (mu ∙ eta) s ≡ id s
102 -- Monad-laws (Haskell) 197 -- Monad-laws (Haskell)
103 -- monad-law-h-1 : return a >>= k = k a 198 -- monad-law-h-1 : return a >>= k = k a
104 monad-law-h-1 : {l ll : Level} {A : Set l} {B : Set ll} -> 199 monad-law-h-1 : {l ll : Level} {A : Set l} {B : Set ll} ->
105 (a : A) -> (k : A -> (Delta B)) -> 200 (a : A) -> (k : A -> (Delta B)) ->
106 (return a >>= k) ≡ (k a) 201 (return a >>= k) ≡ (k a)
107 monad-law-h-1 a k = begin 202 monad-law-h-1 a k = refl
108 return a >>= k 203
109 ≡⟨ refl ⟩ 204
110 mu (fmap k (return a))
111 ≡⟨ refl ⟩
112 mu (return (k a))
113 ≡⟨ refl ⟩
114 (mu ∙ return) (k a)
115 ≡⟨ refl ⟩
116 (mu ∙ eta) (k a)
117 ≡⟨ (monad-law-2-2 (k a)) ⟩
118 id (k a)
119 ≡⟨ refl ⟩
120 k a
121
122 205
123 -- monad-law-h-2 : m >>= return = m 206 -- monad-law-h-2 : m >>= return = m
124 monad-law-h-2 : {l : Level}{A : Set l} -> (m : Delta A) -> (m >>= return) ≡ m 207 monad-law-h-2 : {l : Level}{A : Set l} -> (m : Delta A) -> (m >>= return) ≡ m
125 monad-law-h-2 (similar lx x ly y) = monad-law-2-1 (similar lx x ly y) 208 monad-law-h-2 (mono x) = refl
209 monad-law-h-2 (delta x d) = cong (delta x) (monad-law-h-2 d)
210
211
212
126 213
127 -- monad-law-h-3 : m >>= (\x -> k x >>= h) = (m >>= k) >>= h 214 -- monad-law-h-3 : m >>= (\x -> k x >>= h) = (m >>= k) >>= h
128 monad-law-h-3 : {l ll lll : Level} {A : Set l} {B : Set ll} {C : Set lll} -> 215 monad-law-h-3 : {l ll lll : Level} {A : Set l} {B : Set ll} {C : Set lll} ->
129 (m : Delta A) -> (k : A -> (Delta B)) -> (h : B -> (Delta C)) -> 216 (m : Delta A) -> (k : A -> (Delta B)) -> (h : B -> (Delta C)) ->
130 (m >>= (\x -> k x >>= h)) ≡ ((m >>= k) >>= h) 217 (m >>= (\x -> k x >>= h)) ≡ ((m >>= k) >>= h)
131 monad-law-h-3 (similar lx x ly y) k h = begin 218 monad-law-h-3 (mono x) k h = refl
132 ((similar lx x ly y) >>= (\x -> (k x) >>= h)) 219 monad-law-h-3 (delta x d) k h = begin
220 (delta x d) >>= (\x -> k x >>= h)
133 ≡⟨ refl ⟩ 221 ≡⟨ refl ⟩
134 mu (fmap (\x -> k x >>= h) (similar lx x ly y)) 222 -- (delta x d) >>= f = deltaAppend (headDelta (f x)) (d >>= (tailDelta ∙ f))
223 deltaAppend (headDelta ((\x -> k x >>= h) x)) (d >>= (tailDelta ∙ (\x -> k x >>= h)))
135 ≡⟨ refl ⟩ 224 ≡⟨ refl ⟩
136 (mu ∙ fmap (\x -> k x >>= h)) (similar lx x ly y) 225 deltaAppend (headDelta (k x >>= h)) (d >>= (tailDelta ∙ (\x -> k x >>= h)))
137 ≡⟨ refl ⟩ 226 ≡⟨ {!!} ⟩
138 (mu ∙ fmap (\x -> mu (fmap h (k x)))) (similar lx x ly y) 227 ((delta x d) >>= k) >>= h
139 ≡⟨ refl ⟩
140 (mu ∙ fmap (mu ∙ (\x -> fmap h (k x)))) (similar lx x ly y)
141 ≡⟨ refl ⟩
142 (mu ∙ (fmap mu ∙ (fmap (\x -> fmap h (k x))))) (similar lx x ly y)
143 ≡⟨ refl ⟩
144 (mu ∙ (fmap mu)) ((fmap (\x -> fmap h (k x))) (similar lx x ly y))
145 ≡⟨ monad-law-1 (((fmap (\x -> fmap h (k x))) (similar lx x ly y))) ⟩
146 (mu ∙ mu) ((fmap (\x -> fmap h (k x))) (similar lx x ly y))
147 ≡⟨ refl ⟩
148 (mu ∙ (mu ∙ (fmap (\x -> fmap h (k x))))) (similar lx x ly y)
149 ≡⟨ refl ⟩
150 (mu ∙ (mu ∙ (fmap ((fmap h) ∙ k)))) (similar lx x ly y)
151 ≡⟨ refl ⟩
152 (mu ∙ (mu ∙ ((fmap (fmap h)) ∙ (fmap k)))) (similar lx x ly y)
153 ≡⟨ refl ⟩
154 (mu ∙ (mu ∙ (fmap (fmap h)))) (fmap k (similar lx x ly y))
155 ≡⟨ refl ⟩
156 mu ((mu ∙ (fmap (fmap h))) (fmap k (similar lx x ly y)))
157 ≡⟨ cong (\fx -> mu fx) (monad-law-4 h (fmap k (similar lx x ly y))) ⟩
158 mu (fmap h (mu (similar lx (k x) ly (k y))))
159 ≡⟨ refl ⟩
160 (mu ∙ fmap h) (mu (fmap k (similar lx x ly y)))
161 ≡⟨ refl ⟩
162 mu (fmap h (mu (fmap k (similar lx x ly y))))
163 ≡⟨ refl ⟩
164 (mu (fmap k (similar lx x ly y))) >>= h
165 ≡⟨ refl ⟩
166 ((similar lx x ly y) >>= k) >>= h
167 228
168
169 -} 229 -}