Skip to content

Instantly share code, notes, and snippets.

@effectfully
Created July 21, 2018 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save effectfully/9ebd95e43c3a562e233e779269e3f241 to your computer and use it in GitHub Desktop.
Save effectfully/9ebd95e43c3a562e233e779269e3f241 to your computer and use it in GitHub Desktop.
open import Agda.Primitive using (Level; lsuc ; _⊔_)
open import Function
open import Relation.Binary.PropositionalEquality
open import Data.Product
record Magma l : Set (lsuc l) where
field
Carrier : Set l
eq : Carrier → Carrier → Set l
plus : Carrier → Carrier → Carrier
open Magma
record _⇒_ {l} (M : Magma l) {l′} (N : Magma l′) : Set (l ⊔ l′) where
field
arr : Carrier M → Carrier N
resp : ∀ {x y}
→ eq M x y → eq N (arr x) (arr y)
plus : ∀ {x y}
→ eq N (plus N (arr x) (arr y)) (arr (plus M x y))
open _⇒_
_≤ℓ_ : Level -> Level -> Set
α ≤ℓ β = α ⊔ β ≡ β
data Coerce {β} : ∀ {α} -> α ≡ β -> Set α -> Set β where
coerce : ∀ {A} -> A -> Coerce refl A
{-# NO_POSITIVITY_CHECK #-}
data Tm {l} (N : Magma l) : Set (lsuc l) where
var : (x : Carrier N) → Tm N
_+_ : (x y : Tm N) → Tm N
hom : ∀ {l'} {q : lsuc l' ≤ℓ l} -> Coerce q (∃ λ (M : Magma l') → M ⇒ N × Tm M) → Tm N
mutual
⟦_⟧ʰ : ∀ {l l' k} {N : Magma l} {q : _ ≡ k} → Coerce q (∃ λ (M : Magma l') → M ⇒ N × Tm M) → Carrier N
⟦ coerce (_ , f , x) ⟧ʰ = arr f ⟦ x ⟧
⟦_⟧ : ∀ {l} {M : Magma l} → Tm M → Carrier M
⟦ var x ⟧ = x
⟦_⟧ {M = M} (x + y) = plus M ⟦ x ⟧ ⟦ y ⟧
⟦ hom p ⟧ = ⟦ p ⟧ʰ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment