Work on delay example

This commit is contained in:
Leon Vatthauer 2023-12-04 15:53:57 +01:00
parent d299a7d09a
commit 08dfc41178
Signed by: leonv
SSH key fingerprint: SHA256:G4+ddwoZmhLPRB1agvXzZMXIzkVJ36dUYZXf5NxT+u8
2 changed files with 63 additions and 3 deletions

View file

@ -101,8 +101,53 @@ module Monad.Instance.K.Instance.Delay' {c } where
≈-trans a b (later c) a≈b b≈c = later-trans a≈b b≈c
delay-setoid : Setoid c → Setoid c
delay-setoid A = record { Carrier = Delay Carrier ; _≈_ = _≈_ {A} ; isEquivalence = record { refl = λ {x} → ≈-refl x ; sym = λ {x y} → ≈-sym x y ; trans = λ {x y z} → ≈-trans x y z } }
delay-setoid A = record { Carrier = Delay Carrier ; _≈_ = _≈_ ; isEquivalence = record { refl = λ {x} → ≈-refl x ; sym = λ {x y} → ≈-sym x y ; trans = λ {x y z} → ≈-trans x y z } }
where
open Setoid A using (Carrier)
open Equality
open Equality {A}
module Equality' {A : Setoid c } where
open Setoid A renaming (Carrier to C; _≈_ to __)
open IsEquivalence (Setoid.isEquivalence A) renaming (refl to -refl; sym to -sym; trans to -trans)
data _↓_ : Delay C → C → Set where
now↓ : ∀ {x y} (eq : x y) → now x ↓ y
later↓ : ∀ {x y} (eq : ♭ x ↓ y) → later x ↓ y
unique↓ : ∀ {c : Delay C} {x y : C} → c ↓ x → c ↓ y → x y
unique↓ (now↓ eq₁) (now↓ eq₂) = -trans (-sym eq₁) eq₂
unique↓ (later↓ p) (later↓ q) = unique↓ p q
data _≈_ : Delay C → Delay C → Set (c ⊔ ) where
↓≈ : ∀ {x y a b} (ab : a b) (x↓z : x ↓ a) (y↓z : y ↓ b) → x ≈ y
later≈ : ∀ {x y} → (∞ (♭ x ≈ ♭ y)) → later x ≈ later y
refl' : ∀ {x} → x ≈ x
refl' {now x} = ↓≈ -refl (now↓ -refl) (now↓ -refl)
refl' {later x} = later≈ (♯ refl')
sym' : ∀ {x y} → x ≈ y → y ≈ x
sym' (↓≈ ab x↓a y↓b) = ↓≈ (-sym ab) y↓b x↓a
sym' (later≈ x≈y) = later≈ (♯ sym' (♭ x≈y))
-- TODO needed for trans'
≈↓ : ∀ {x y : Delay C} {z : C} → x ≈ y → x ↓ z → y ↓ z
≈↓ x≈y x↓z = {! !}
-- ≈↓ (↓≈ a(now↓ refl) q) (now↓ refl) = q
-- ≈↓ (↓≈ (later↓ p) r) (later↓ q) with unique↓ p q
-- ≈↓ (↓≈ (later↓ p) r) (later↓ q) | refl = r
-- ≈↓ (later≈ p) (later↓ q) = later↓ (≈↓ (♭ p) q)
trans' : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z
trans' (↓≈ ab x↓a y↓b) (↓≈ cd y↓c z↓d) with unique↓ y↓b y↓c
... | bc = ↓≈ (-trans (-trans ab bc) cd) x↓a z↓d
trans' (↓≈ ab x↓a (later↓ y↓b)) (later≈ x) = ↓≈ ab x↓a {! !}
trans' (later≈ x) (↓≈ ab x↓a y↓b) = {! !}
trans' (later≈ x) (later≈ y) = {! !}
delay-setoid' : Setoid c → Setoid c (c ⊔ )
delay-setoid' A = record { Carrier = Delay Carrier ; _≈_ = _≈_ ; isEquivalence = record { refl = λ {x} → {! !} ; sym = λ {x y} → {! !} ; trans = λ {x y z} → {! !} } }
where
open Setoid A using (Carrier)
open Equality' {A}
```

View file

@ -49,6 +49,21 @@ module Monad.Instance.K.Instance.Delay {c } where
never : ∀ {A : Set c} → Delay A
node (never {A}) = inj₂ never
module Equality {A : Setoid c } where
open Setoid A using () renaming (Carrier to C; _≈_ to __)
data _↓_ : Delay C → C → Set (c ⊔ ) where
now↓ : ∀ {x y} (p : x y) → now x ↓ y
later↓ : ∀ {x y} (p : _↓_ x y) → later x ↓ y
data _≈_ : Delay C → Delay C → Set (c ⊔ ) where
↓≈ : ∀ {x y z} → x ↓ z → y ↓ z → x ≈ y
later-≈ : ∀ {x y} → x ≈ y → later x ≈ later y
refl : ∀ {x} → x ≈ x
refl {x} with node x
... | inj₁ z = ↓≈ {! !} {! !}
... | inj₂ z = {! !}
-- first try
delay-eq-strong : ∀ (A : Setoid c ) → Delay (Setoid.Carrier A) → Delay (Setoid.Carrier A) → Set
delay-eq-strong A x y with node x | node y
@ -136,7 +151,7 @@ module Monad.Instance.K.Instance.Delay {c } where
... | inj₂ x | inj₁ y | inj₂ z | eq₁ | eq₂ = trans' eq₁ eq₂
... | inj₁ x | inj₁ y | inj₂ z | eq₁ | eq₂ = trans' (now-cong eq₁) eq₂ -- trans' (now-cong eq₁) eq₂
... | inj₂ x | inj₂ y | inj₁ z | eq₁ | eq₂ = trans' eq₁ eq₂
... | inj₁ x | inj₂ y | inj₁ z | eq₁ | eq₂ = {! trans' eq₁ eq₂ !} -- now-inj {A} {x} {z} (trans' eq₁ eq₂)
... | inj₁ x | inj₂ y | inj₁ z | eq₁ | eq₂ = {! !} -- now-inj {A} {x} {z} (trans' eq₁ eq₂)
... | inj₂ x | inj₁ y | inj₁ z | eq₁ | eq₂ = trans' eq₁ (now-cong eq₂)
... | inj₁ x | inj₁ y | inj₁ z | eq₁ | eq₂ = IsEquivalence.trans (Setoid.isEquivalence A) eq₁ eq₂
```