{-# OPTIONS --safe --cubical-compatible --guardedness --exact-split --double-check #-}
module ALMA.Base.Equivalence.LayeredEqGenDepth where
open import Agda.Primitive using (_⊔_)
open import Agda.Builtin.Sigma using (Σ; _,_)
open import Data.Unit.Polymorphic.Base using (⊤; tt)
open import Data.Product.Base using (proj₁; proj₂)
open import Data.Nat.Base using (ℕ; zero; suc; _≤_; z≤n; s≤s)
open import ALMA.Base.IndexedMType using (fst; snd)
open import ALMA.Base.Equivalence.Core using (LayeredEqGen)
module LayeredEqGen-Depth
{a b c} {X : Set a}
{Obs : X → Set b}
{step : (x : X) → Obs x → X}
{layer : X → X → Set c}
{obs-map : (x y : X) → layer x y → Obs x → Obs y} where
LE-depth : (n : ℕ) → (x y : X) → Set (a ⊔ b ⊔ c)
LE-depth zero x y = ⊤
LE-depth (suc n) x y =
Σ (layer x y) (λ l →
∀ (s : Obs x) → LE-depth n
(step x s)
(step y (obs-map x y l s)))
le→LE-depth : ∀ {x y} → LayeredEqGen Obs step layer obs-map x y
→ ∀ n → LE-depth n x y
le→LE-depth p zero = tt
le→LE-depth p (suc n) =
( p .fst
, λ s → le→LE-depth (p .snd s) n )
LE-depth-mono : ∀ {m n} (m≤n : m ≤ n) {x y : X}
→ LE-depth n x y → LE-depth m x y
LE-depth-mono z≤n p = tt
LE-depth-mono (s≤s m≤n) p =
( proj₁ p
, λ s → LE-depth-mono m≤n (proj₂ p s) )