Skip to content
Permalink
Browse files

scoped renaming

  • Loading branch information...
jmchapman committed Mar 15, 2019
1 parent f02a92d commit 7ba1184d9ad51ec4e5b94d29e69d025bcd54c8cf
Showing with 39 additions and 0 deletions.
  1. +39 −0 Scoped/RenamingSubstitution.lagda
@@ -4,9 +4,48 @@ module Scoped.RenamingSubstitution where

\begin{code}
open import Scoped

open import Data.Nat
open import Data.Fin hiding (lift)
\end{code}

\begin{code}
Ren⋆ : ℕ → ℕ → Set
Ren⋆ m n = Fin m → Fin n

lift⋆ : ∀{m n} → Ren⋆ m n → Ren⋆ (suc m) (suc n)
lift⋆ ρ zero = zero
lift⋆ ρ (suc α) = suc (ρ α)

ren⋆ : ∀{m n} → Ren⋆ m n → ScopedTy m → ScopedTy n
ren⋆ ρ (` α) = ` (ρ α)
ren⋆ ρ (A ⇒ B) = ren⋆ ρ A ⇒ ren⋆ ρ B
ren⋆ ρ (Π K A) = Π K (ren⋆ (lift⋆ ρ) A)
ren⋆ ρ (ƛ K A) = ƛ K (ren⋆ (lift⋆ ρ) A)
ren⋆ ρ (A · B) = ren⋆ ρ A · ren⋆ ρ B
ren⋆ ρ (con x) = con x
ren⋆ ρ (size x) = size x

Ren : (m n : Weirdℕ) → Set
Ren m n = WeirdFin m → WeirdFin n

lift : ∀{m n} → Ren m n → Ren (S m) (S n)
lift ρ Z = Z
lift ρ (S x) = S (ρ x)

⋆lift : ∀{m n} → Ren m n → Ren (T m) (T n)
⋆lift ρ (T x) = T (ρ x)

ren : ∀{m n} → Ren⋆ ∥ m ∥ ∥ n ∥ → Ren m n → ScopedTm m → ScopedTm n
ren ρ⋆ ρ (` x) = ` (ρ x)
ren ρ⋆ ρ (Λ K t) = Λ K (ren (lift⋆ ρ⋆) (⋆lift ρ) t)
ren ρ⋆ ρ (t ·⋆ A) = ren ρ⋆ ρ t ·⋆ ren⋆ ρ⋆ A
ren ρ⋆ ρ (ƛ A t) = ƛ (ren⋆ ρ⋆ A) (ren ρ⋆ (lift ρ) t)
ren ρ⋆ ρ (t · u) = ren ρ⋆ ρ t · ren ρ⋆ ρ u
ren ρ⋆ ρ (con x) = con x
ren ρ⋆ ρ (error A) = error (ren⋆ ρ⋆ A)
ren ρ⋆ ρ (builtin x) = builtin x

postulate _[_] : ∀{n} → ScopedTm (S n) → ScopedTm n → ScopedTm n
postulate _[_]⋆ : ∀{n} → ScopedTm (T n) → ScopedTy ∥ n ∥ → ScopedTm n
\end{code}

0 comments on commit 7ba1184

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.