Created
June 8, 2017 14:21
-
-
Save gallais/796aff629670f4d64c0da3a6dff72d3b to your computer and use it in GitHub Desktop.
Structural equality for inductive types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Zippy where | |
data Desc : Set₁ where | |
`σ : (A : Set) (d : A → Desc) → Desc | |
`r : Desc → Desc | |
`q : Desc | |
open import Size | |
open import Data.Unit | |
open import Data.Product | |
open import Relation.Binary.PropositionalEquality | |
⟦_⟧_ : Desc → Set → Set | |
⟦ `σ A d ⟧ X = Σ[ a ∈ A ] ⟦ d a ⟧ X | |
⟦ `r d ⟧ X = X × ⟦ d ⟧ X | |
⟦ `q ⟧ X = ⊤ | |
Zip : (d : Desc) {X Y : Set} (R : X → Y → Set) → ⟦ d ⟧ X → ⟦ d ⟧ Y → Set | |
Zip (`σ A d) R (a , t) (b , u) = Σ[ eq ∈ b ≡ a ] | |
Zip (d a) R t (subst (λ a → ⟦ d a ⟧ _) eq u) | |
Zip (`r d) R (x , t) (y , u) = R x y × Zip d R t u | |
Zip `q R t u = ⊤ | |
data μ (d : Desc) : Size → Set where | |
con : {i : Size} → ⟦ d ⟧ (μ d) i → μ d (↑ i) | |
Eq : (d : Desc) → {i : Size} → μ d i → μ d i → Set | |
Eq d (con t) (con u) = Zip d (Eq d) t u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment