This commit is contained in:
Leon Vatthauer 2023-12-06 09:16:10 +01:00
parent 64c4a4263d
commit 59f60810e7
Signed by: leonv
SSH key fingerprint: SHA256:G4+ddwoZmhLPRB1agvXzZMXIzkVJ36dUYZXf5NxT+u8

View file

@ -53,7 +53,7 @@ module Monad.Instance.K.Instance.Delay {c } where
data _≈_ : Delay C → Delay C → Set (c ⊔ ) where data _≈_ : Delay C → Delay C → Set (c ⊔ ) where
↓≈ : ∀ {x y a b} (ab : a b) (x↓a : x ↓ a) (y↓b : y ↓ b) → x ≈ y ↓≈ : ∀ {x y a b} (ab : a b) (x↓a : x ↓ a) (y↓b : y ↓ b) → x ≈ y
later≈ : ∀ {x y} → (∞ (♭ x ≈ ♭ y)) → later x ≈ later y later≈ : ∀ {x y} (x≈y : ∞ (♭ x ≈ ♭ y)) → later x ≈ later y
≈-refl : ∀ {x} → x ≈ x ≈-refl : ∀ {x} → x ≈ x
≈-refl {now x} = ↓≈ -refl (now↓ -refl) (now↓ -refl) ≈-refl {now x} = ↓≈ -refl (now↓ -refl) (now↓ -refl)
@ -85,7 +85,7 @@ module Monad.Instance.K.Instance.Delay {c } where
where where
open Setoid A using (Carrier) open Setoid A using (Carrier)
open Equality {A} open Equality {A}
open Equality using (↓≈; later≈; now↓; later↓; _↓_; ≈↓; ≈-refl; ≈-sym; ≈-trans) open Equality using (↓≈; later≈; now↓; later↓; _↓_; ≈↓; ∼↓; ≈-refl; ≈-sym; ≈-trans)
_[_≈_] : ∀ (A : Setoid c (c ⊔ )) → (x y : Delay (Setoid.Carrier A)) → Set (c ⊔ ) _[_≈_] : ∀ (A : Setoid c (c ⊔ )) → (x y : Delay (Setoid.Carrier A)) → Set (c ⊔ )
A [ x ≈ y ] = Equality._≈_ {A} x y A [ x ≈ y ] = Equality._≈_ {A} x y
@ -105,6 +105,9 @@ module Monad.Instance.K.Instance.Delay {c } where
now-cong : ∀ {A : Setoid c (c ⊔ )} {x y : Setoid.Carrier A} → A [ x y ] → A [ now x ≈ now y ] now-cong : ∀ {A : Setoid c (c ⊔ )} {x y : Setoid.Carrier A} → A [ x y ] → A [ now x ≈ now y ]
now-cong {A} {x} {y} xy = ↓≈ xy (now↓ (-refl A)) (now↓ (-refl A)) now-cong {A} {x} {y} xy = ↓≈ xy (now↓ (-refl A)) (now↓ (-refl A))
now-inj : ∀ {A : Setoid c (c ⊔ )} {x y : Setoid.Carrier A} → A [ now x ≈ now y ] → A [ x y ]
now-inj {A} {x} {y} (↓≈ ab (now↓ xa) (now↓ yb)) = -trans A xa (-trans A ab (-sym A yb))
delayFun : ∀ {A B : Setoid c (c ⊔ )} → A ⟶ B → delaySetoid A ⟶ delaySetoid B delayFun : ∀ {A B : Setoid c (c ⊔ )} → A ⟶ B → delaySetoid A ⟶ delaySetoid B
delayFun {A} {B} f = record { _⟨$⟩_ = app ; cong = cong' } delayFun {A} {B} f = record { _⟨$⟩_ = app ; cong = cong' }
where where
@ -159,24 +162,28 @@ module Monad.Instance.K.Instance.Delay {c } where
μ' {A} (now x) = x μ' {A} (now x) = x
μ' {A} (later x) = later (♯ μ' {A} (♭ x)) μ' {A} (later x) = later (♯ μ' {A} (♭ x))
μ↓ : ∀ {A B : Setoid c (c ⊔ )} (f : A ⟶ B) {x : Delay (Delay (Setoid.Carrier A))} {y : Delay (Setoid.Carrier A)} → _↓_ {delaySetoid A} x y → A [ (μ' {A} x) ≈ y ] μ↓ : ∀ {A : Setoid c (c ⊔ )} {x : Delay (Delay (Setoid.Carrier A))} {y : Delay (Setoid.Carrier A)} → _↓_ {delaySetoid A} x y → A [ (μ' {A} x) ≈ y ]
μ↓ {A} {B} f {now x} {y} (now↓ x≈y) = x≈y μ↓ {A} {now x} {y} (now↓ x≈y) = x≈y
μ↓ {A} {B} f {later x} {y} (later↓ x↓y) = ≈-trans (later≈ (♯ μ↓ f x↓y)) (≈-sym later-self) μ↓ {A} {later x} {y} (later↓ x↓y) = ≈-trans (later≈ (♯ μ↓ x↓y)) (≈-sym later-self)
-- TODO μ≈ -- TODO μ≈
-- TODO do delayFun and η in the same style as μ -- TODO do delayFun and η in the same style as μ
μ : ∀ (A : Setoid c (c ⊔ )) → delaySetoid (delaySetoid A) ⟶ delaySetoid A μ : ∀ (A : Setoid c (c ⊔ )) → delaySetoid (delaySetoid A) ⟶ delaySetoid A
μ A = record { _⟨$⟩_ = μ' {A} ; cong = {! !} } μ A = record { _⟨$⟩_ = μ' {A} ; cong = cong' }
where where
cong' : ∀ {x y : Delay (Delay (Setoid.Carrier A))} → (delaySetoid A) [ x ≈ y ] → A [ μ' x ≈ μ' y ] cong' : ∀ {x y : Delay (Delay (Setoid.Carrier A))} → (delaySetoid A) [ x ≈ y ] → A [ μ' {A} x ≈ μ' {A} y ]
cong' {now x} {now y} (↓≈ a≈b (now↓ x≈a) (now↓ y≈b)) = ≈-trans x≈a (≈-trans a≈b (≈-sym y≈b)) cong' {x} {now y} (↓≈ a≈b x↓a (now↓ y≈b)) = μ↓ (∼↓ (≈-trans a≈b (≈-sym y≈b)) x↓a)
cong' {now x} {later y} (↓≈ a≈b (now↓ x≈a) (later↓ y↓b)) = ↓≈ {A} {! a≈b !} {! !} (later↓ {! !}) cong' {now x} {later y} (↓≈ a≈b (now↓ x≈a) (later↓ y↓b)) = ≈-sym (μ↓ (∼↓ (≈-trans (≈-sym a≈b) (≈-sym x≈a)) (later↓ y↓b)))
cong' {later x} {now y} (↓≈ a≈b (later↓ x↓a) (now↓ (↓≈ ab x↓a₁ y↓b))) = ↓≈ {! !} (later↓ {! !}) x↓a₁ cong' {later x} {later y} (↓≈ a≈b (later↓ x↓a) (later↓ y↓b)) = later≈ (♯ cong' (↓≈ a≈b x↓a y↓b))
cong' {later x} {now .(later _)} (↓≈ a≈b (later↓ x↓a) (now↓ (later≈ x₁))) = ↓≈ {! !} {! !} {! !}
cong' {later x} {later y} (↓≈ ab (later↓ x↓a) (later↓ y↓b)) = later≈ (♯ cong' (↓≈ ab x↓a y↓b))
cong' {later x} {later y} (later≈ x≈y) = later≈ (♯ cong' (♭ x≈y)) cong' {later x} {later y} (later≈ x≈y) = later≈ (♯ cong' (♭ x≈y))
μ-natural : ∀ {A B : Setoid c (c ⊔ )} (f : A ⟶ B) → (μ B ∘ delayFun (delayFun f)) ≋ (delayFun f ∘ μ A)
μ-natural {A} {B} f {now x} {now y} nx≈ny = cong (delayFun f) (now-inj nx≈ny)
μ-natural {A} {B} f {now x} {later y} (↓≈ a≈b (now↓ x≈a) (later↓ y↓b)) = later-eq (later≈ (♯ cong (delayFun f) (≈-sym (μ↓ (∼↓ (≈-trans (≈-sym a≈b) (≈-sym x≈a)) y↓b)))))
μ-natural {A} {B} f {later x} {now y} (↓≈ ab x↓a y↓b) = {! !}
μ-natural {A} {B} f {later x} {later y} (↓≈ ab x↓a y↓b) = {! !}
μ-natural {A} {B} f {later x} {later y} (later≈ x≈y) = later≈ (♯ μ-natural f (♭ x≈y))
delayMonad : Monad (Setoids c (c ⊔ )) delayMonad : Monad (Setoids c (c ⊔ ))
delayMonad = record delayMonad = record
@ -188,7 +195,7 @@ module Monad.Instance.K.Instance.Delay {c } where
; F-resp-≈ = {! !} ; F-resp-≈ = {! !}
} }
; η = ntHelper (record { η = η ; commute = η-natural }) ; η = ntHelper (record { η = η ; commute = η-natural })
; μ = {! !} ; μ = ntHelper (record { η = μ ; commute = μ-natural })
; assoc = {! !} ; assoc = {! !}
; sym-assoc = {! !} ; sym-assoc = {! !}
; identityˡ = {! !} ; identityˡ = {! !}