Skip to content

Instantly share code, notes, and snippets.

@pedrominicz
Created April 19, 2020 02:56
Show Gist options
  • Save pedrominicz/b095096a9ee4881694de22e2e93453db to your computer and use it in GitHub Desktop.
Save pedrominicz/b095096a9ee4881694de22e2e93453db to your computer and use it in GitHub Desktop.
Linear lambda calculus in Agda.
{-# OPTIONS --safe --without-K #-}
module Linear where
open import Data.Bool
open import Data.List
open import Data.Product
Ctx : Set
Ctx = List Bool × List Bool
ε : Ctx
ε = [] , []
ext : Ctx → Ctx
ext (Γ , Γ′) = true ∷ Γ , false ∷ Γ′
data Var : Ctx → Set where
zero : ∀ {Γ} → Var (true ∷ Γ , false ∷ Γ)
suc : ∀ {b Γ Γ′} → Var (Γ , Γ′) → Var (b ∷ Γ , b ∷ Γ′)
data Term : Ctx → Set where
` : ∀ {Γ} → Var Γ → Term Γ
ƛ : ∀ {Γ} → Term (ext Γ) → Term Γ
_·_ : ∀ {Γ Γ′ Γ″} → Term (Γ , Γ′) → Term (Γ′ , Γ″) → Term (Γ , Γ″)
infixl 5 _·_
ex₁ : Term ε
ex₁ = ƛ (` zero)
ex₂ : Term ε
ex₂ = ƛ (ƛ (ƛ (` (suc (suc zero)) · ` zero · ` (suc zero))))
_⊆_ : Ctx → Ctx → Set
Γ ⊆ Δ = Var Γ → Var Δ
infix 4 _⊆_
ext-ρ : ∀ {Γ Δ} → Γ ⊆ Δ → ext Γ ⊆ ext Δ
ext-ρ ρ zero = {!!}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment