Pat.agda 891 B

12345678910111213141516171819202122232425262728293031323334
  1. module Pat (BaseType : Set) where
  2. data Ty : Set where
  3. ι : BaseType -> Ty
  4. _⟶_ : Ty -> Ty -> Ty
  5. data Bwd (A : Set) : Set where
  6. • : Bwd A
  7. _◄_ : Bwd A -> A -> Bwd A
  8. infixl 30 _◄_
  9. Ctx = Bwd Ty
  10. data Take {A : Set} : Bwd A -> A -> Bwd A -> Set where
  11. hd : forall {x xs} -> Take (xs ◄ x) x xs
  12. tl : forall {x y xs ys} -> Take xs x ys -> Take (xs ◄ y) x (ys ◄ y)
  13. data Pat : Ctx -> Ctx -> Ty -> Ctx -> Set
  14. data Pats : Ctx -> Ty -> Ctx -> Ty -> Set where
  15. ε : forall {Θ τ} -> Pats Θ τ Θ τ
  16. _,_ : forall {Θ₁ Θ₂ Θ₃ ρ σ τ} ->
  17. Pat • Θ₁ ρ Θ₂ -> Pats Θ₂ σ Θ₃ τ ->
  18. Pats Θ₁ (ρ ⟶ σ) Θ₃ τ
  19. data Pat where
  20. ƛ : forall {Δ Θ Θ' σ τ} -> Pat (Δ ◄ σ) Θ τ Θ' ->
  21. Pat Δ Θ (σ ⟶ τ) Θ'
  22. _[_] : forall {Θ Θ' Δ σ τ} ->
  23. Take Θ σ Θ' -> Pats Δ σ • τ -> Pat Δ Θ τ Θ'