MapTm.agda 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module MapTm where
  2. open import Prelude
  3. open import Star
  4. open import Modal
  5. open import Examples
  6. open import Lambda
  7. open Term
  8. eq⟶ : {ty : Set}(T : TyAlg ty){σ₁ σ₂ τ₁ τ₂ : ty} ->
  9. σ₁ == σ₂ -> τ₁ == τ₂ -> TyAlg._⟶_ T σ₁ τ₁ == TyAlg._⟶_ T σ₂ τ₂
  10. eq⟶ T refl refl = refl
  11. mapTm : {ty₁ ty₂ : Set}{T₁ : TyAlg ty₁}{T₂ : TyAlg ty₂}
  12. {Γ : List ty₁}{τ : ty₁}(F : T₁ =Ty=> T₂) ->
  13. Tm T₁ Γ τ -> Tm T₂ (map _ (TyArrow.apply F) Γ) (TyArrow.apply F τ)
  14. mapTm {T₁ = T₁}{T₂}{Γ} F (var x) =
  15. var (mapAny (cong (TyArrow.apply F)) x)
  16. mapTm {T₁ = T₁}{T₂}{Γ} F zz =
  17. subst (\τ -> Tm T₂ (map _ (TyArrow.apply F) Γ) τ)
  18. (TyArrow.respNat F) zz
  19. mapTm {T₁ = T₁}{T₂}{Γ} F ss =
  20. subst Tm₂ (trans (TyArrow.resp⟶ F)
  21. (TyArrow.respNat F -eq⟶ TyArrow.respNat F))
  22. ss
  23. where
  24. _-eq⟶_ = eq⟶ T₂
  25. Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ)
  26. mapTm {T₂ = T₂}{Γ} F (ƛ t) =
  27. subst Tm₂ (TyArrow.resp⟶ F)
  28. (ƛ (mapTm F t))
  29. where Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ)
  30. mapTm {T₂ = T₂}{Γ} F (s $ t) =
  31. subst Tm₂ (sym (TyArrow.resp⟶ F)) (mapTm F s)
  32. $ mapTm F t
  33. where
  34. Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ)