Proof.agda 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. module Proof where
  2. open import Prelude
  3. open import Lambda
  4. open import Subst
  5. open import Trans
  6. open import Reduction
  7. import Chain
  8. open module C = Chain _≤_ (\x -> refl-≤) (\x y z -> trans-≤)
  9. renaming (_===_by_ to _<≤>_by_)
  10. data SN {Γ : Ctx}{τ : Type}(t : Term Γ τ) : Set where
  11. bound : (n : Nat) ->
  12. ({u : Term Γ τ}(r : t ⟶β* u) -> length r ≤ n) -> SN t
  13. SNˢ : forall {Γ Δ} -> Terms Γ Δ -> Set
  14. SNˢ ts = All² SN ts
  15. -- Let's prove a simple lemma
  16. lem-SN⟶β : {Γ : Ctx}{τ : Type}{t u : Term Γ τ} ->
  17. SN t -> t ⟶β* u -> SN u
  18. lem-SN⟶β {Γ}{τ}{t}{u}(bound n cap) r = bound n \r' ->
  19. chain> length r'
  20. <≤> length r + length r' by lem-≤+L (length r)
  21. <≤> length (r ▹◃ r') by refl-≤' (lem-length▹◃ r r')
  22. <≤> n by cap (r ▹◃ r')
  23. qed
  24. lem-SN-map : {Γ Δ : Ctx}{σ τ : Type}
  25. (tm : Term Γ σ -> Term Δ τ) ->
  26. (f : {t u : Term Γ σ} -> t ⟶β u -> tm t ⟶β tm u)
  27. {t : Term Γ σ} -> SN (tm t) -> SN t
  28. lem-SN-map tm f (bound n p) = bound n \r ->
  29. chain> length r
  30. <≤> length {R = _⟶β_} (map tm f r)
  31. by refl-≤' (lem-length-map tm f r)
  32. <≤> n by p (map tm f r)
  33. qed
  34. lem-SN•L : {Γ : Ctx}{σ τ : Type}{t : Term Γ (σ ⟶ τ)}{u : Term Γ σ} ->
  35. SN (t • u) -> SN t
  36. lem-SN•L {u = u} = lem-SN-map (\v -> v • u) •⟶L
  37. lem-SN↑ : {Γ : Ctx}(Δ : Ctx){σ : Type}{t : Term Γ σ} ->
  38. SN (t ↑ Δ) -> SN t
  39. lem-SN↑ Δ = lem-SN-map (\v -> v ↑ Δ) (↑⟶β Δ)
  40. lem-SN-x : {Γ Δ : Ctx}{σ : Type}(x : Var Γ (Δ ⇒ σ))
  41. {ts : Terms Γ Δ} -> SNˢ ts -> SN (var x •ˢ ts)
  42. lem-SN-x x ∅² = bound zero red-var
  43. where
  44. red-var : forall {u} -> (r : var x ⟶β* u) -> length r ≤ 0
  45. red-var ()
  46. lem-SN-x x (_◄²_ {x = t}{xs = ts} snts snt) = {! !}
  47. where
  48. sn-xts : SN (var x •ˢ ts)
  49. sn-xts = lem-SN-x x snts
  50. infix 30 ⟦_⟧ ∋_
  51. ⟦_⟧ ∋_ : (τ : Type){Γ : Ctx} -> Term Γ τ -> Set
  52. ⟦ ι ⟧ ∋ t = SN t
  53. ⟦ σ ⟶ τ ⟧ ∋ t = forall {Δ}(u : Term (_ ++ Δ) σ) ->
  54. ⟦ σ ⟧ ∋ u -> ⟦ τ ⟧ ∋ t ↑ Δ • u
  55. mutual
  56. lem-⟦⟧⊆SN : (σ : Type){Γ : Ctx}{t : Term Γ σ} ->
  57. ⟦ σ ⟧ ∋ t -> SN t
  58. lem-⟦⟧⊆SN ι okt = okt
  59. lem-⟦⟧⊆SN (σ ⟶ τ) {Γ}{t} okt = lem-SN↑ (ε , σ) sn-t↑
  60. where
  61. ih : {Δ : Ctx}{u : Term Δ τ} -> ⟦ τ ⟧ ∋ u -> SN u
  62. ih = lem-⟦⟧⊆SN τ
  63. sn• : (Δ : Ctx)(u : Term (Γ ++ Δ) σ) -> ⟦ σ ⟧ ∋ u -> SN (t ↑ Δ • u)
  64. sn• Δ u h = ih (okt {Δ} u h)
  65. sn-t↑ : SN (wk t)
  66. sn-t↑ = lem-SN•L (sn• (ε , σ) vz (lem-⟦⟧ˣ σ vzero ∅²))
  67. lem-⟦⟧ˣ : (σ : Type){Γ Δ : Ctx}(x : Var Γ (Δ ⇒ σ)){ts : Terms Γ Δ} ->
  68. SNˢ ts -> ⟦ σ ⟧ ∋ var x •ˢ ts
  69. lem-⟦⟧ˣ ι x snts = lem-SN-x x snts
  70. lem-⟦⟧ˣ (σ ⟶ τ) {Γ}{Δ} x {ts} snts = \u oku -> {! !}
  71. where
  72. snts↑ : (Δ : Ctx) -> SNˢ (ts ↑ˢ Δ)
  73. snts↑ Δ = {! !}
  74. rem : (Δ : Ctx)(u : Term (Γ ++ Δ) σ) ->
  75. ⟦ σ ⟧ ∋ u -> ⟦ τ ⟧ ∋ var (x ↑ˣ Δ) •ˢ ts ↑ˢ Δ • u
  76. rem Δ u oku = lem-⟦⟧ˣ τ (x ↑ˣ Δ) (snts↑ Δ ◄² lem-⟦⟧⊆SN σ oku)
  77. lem-⟦⟧subst : {Γ Δ : Ctx}{τ : Type}(σ : Type)
  78. {t : Term (Γ , τ) (Δ ⇒ σ)}{u : Term Γ τ}{vs : Terms Γ Δ} ->
  79. ⟦ σ ⟧ ∋ (t / [ u ]) •ˢ vs -> ⟦ σ ⟧ ∋ (ƛ t) • u •ˢ vs
  80. lem-⟦⟧subst ι h = {!h !}
  81. lem-⟦⟧subst (σ₁ ⟶ σ₂) h = {! !}