IIRDg.agda 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. {-# OPTIONS --no-positivity-check #-}
  2. module IIRDg where
  3. import LF
  4. import DefinitionalEquality
  5. import IIRD
  6. open LF
  7. open DefinitionalEquality
  8. open IIRD
  9. mutual
  10. data Ug {I : Set}{D : I -> Set1}(γ : OPg I D) : I -> Set where
  11. introg : (a : Gu γ (Ug γ) (Tg γ)) -> Ug γ (Gi γ (Ug γ) (Tg γ) a)
  12. Tg : {I : Set}{D : I -> Set1}(γ : OPg I D)(i : I) -> Ug γ i -> D i
  13. Tg γ .(Gi γ (Ug γ) (Tg γ) a) (introg a) = Gt γ (Ug γ) (Tg γ) a
  14. Arg : {I : Set}{D : I -> Set1}(γ : OPg I D) -> Set
  15. Arg γ = Gu γ (Ug γ) (Tg γ)
  16. index : {I : Set}{D : I -> Set1}(γ : OPg I D) -> Arg γ -> I
  17. index γ a = Gi γ (Ug γ) (Tg γ) a
  18. IH : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1) -> Arg γ -> Set1
  19. IH γ = KIH γ (Ug γ) (Tg γ)
  20. -- Elimination rule
  21. Rg : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1) ->
  22. (h : (a : Arg γ) -> IH γ F a -> F (index γ a) (introg a)) ->
  23. (i : I)(u : Ug γ i) -> F i u
  24. Rg γ F h .(index γ a) (introg a) = h a (Kmap γ (Ug γ) (Tg γ) F (Rg γ F h) a)
  25. {-
  26. -- We don't have general IIRDs so we have to postulate Ug/Tg
  27. postulate
  28. Ug : {I : Set}{D : I -> Set1} -> OPg I D -> I -> Set
  29. Tg : {I : Set}{D : I -> Set1}(γ : OPg I D)(i : I) -> Ug γ i -> D i
  30. introg : {I : Set}{D : I -> Set1}(γ : OPg I D)(a : Gu γ (Ug γ) (Tg γ)) ->
  31. Ug γ (Gi γ (Ug γ) (Tg γ) a)
  32. Tg-equality : {I : Set}{D : I -> Set1}(γ : OPg I D)(a : Gu γ (Ug γ) (Tg γ)) ->
  33. Tg γ (Gi γ (Ug γ) (Tg γ) a) (introg γ a) ≡₁ Gt γ (Ug γ) (Tg γ) a
  34. Rg : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1)
  35. (h : (a : Gu γ (Ug γ) (Tg γ)) -> KIH γ (Ug γ) (Tg γ) F a -> F (Gi γ (Ug γ) (Tg γ) a) (introg γ a))
  36. (i : I)(u : Ug γ i) -> F i u
  37. Rg-equality : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1)
  38. (h : (a : Gu γ (Ug γ) (Tg γ)) -> KIH γ (Ug γ) (Tg γ) F a -> F (Gi γ (Ug γ) (Tg γ) a) (introg γ a))
  39. (a : Gu γ (Ug γ) (Tg γ)) ->
  40. Rg γ F h (Gi γ (Ug γ) (Tg γ) a) (introg γ a)
  41. ≡₁ h a (Kmap γ (Ug γ) (Tg γ) F (Rg γ F h) a)
  42. -- Helpers
  43. ι★g : {I : Set}(i : I) -> OPg I (\_ -> One')
  44. ι★g i = ι < i | ★' >'
  45. -- Examples
  46. module Martin-Löf-Identity where
  47. IdOP : {A : Set} -> OPg (A * A) (\_ -> One')
  48. IdOP {A} = σ A \a -> ι★g < a | a >
  49. _==_ : {A : Set}(x y : A) -> Set
  50. x == y = Ug IdOP < x | y >
  51. refl : {A : Set}(x : A) -> x == x
  52. refl x = introg IdOP < x | ★ >
  53. -- We have to work slightly harder than desired since we don't have η for × and One.
  54. private
  55. -- F C is just uncurry C but dependent and at high universes.
  56. F : {A : Set}(C : (x y : A) -> x == y -> Set1)(i : A * A) -> Ug IdOP i -> Set1
  57. F C < x | y > p = C x y p
  58. h' : {A : Set}(C : (x y : A) -> x == y -> Set1)
  59. (h : (x : A) -> C x x (refl x))
  60. (a : Gu IdOP (Ug IdOP) (Tg IdOP)) -> KIH IdOP (Ug IdOP) (Tg IdOP) (F C) a ->
  61. F C (Gi IdOP (Ug IdOP) (Tg IdOP) a) (introg IdOP a)
  62. h' C h < x | ★ > _ = h x
  63. J : {A : Set}(C : (x y : A) -> x == y -> Set1)
  64. (h : (x : A) -> C x x (refl x))
  65. (x y : A)(p : x == y) -> C x y p
  66. J {A} C h x y p = Rg IdOP (F C) (h' C h) < x | y > p
  67. J-equality : {A : Set}(C : (x y : A) -> x == y -> Set1)
  68. (h : (x : A) -> C x x (refl x))(x : A) ->
  69. J C h x x (refl x) ≡₁ h x
  70. J-equality {A} C h x = Rg-equality IdOP (F C) (h' C h) < x | ★ >
  71. module Christine-Identity where
  72. IdOP : {A : Set}(a : A) -> OPg A (\_ -> One')
  73. IdOP {A} a = ι★g a
  74. _==_ : {A : Set}(x y : A) -> Set
  75. x == y = Ug (IdOP x) y
  76. refl : {A : Set}(x : A) -> x == x
  77. refl x = introg (IdOP x) ★
  78. private
  79. h' : {A : Set}(x : A)(C : (y : A) -> x == y -> Set1)
  80. (h : C x (refl x))(a : Gu (IdOP x) (Ug (IdOP x)) (Tg (IdOP x))) ->
  81. KIH (IdOP x) (Ug (IdOP x)) (Tg (IdOP x)) C a ->
  82. C (Gi (IdOP x) (Ug (IdOP x)) (Tg (IdOP x)) a) (introg (IdOP x) a)
  83. h' x C h ★ _ = h
  84. H : {A : Set}(x : A)(C : (y : A) -> x == y -> Set1)
  85. (h : C x (refl x))
  86. (y : A)(p : x == y) -> C y p
  87. H x C h y p = Rg (IdOP x) C (h' x C h) y p
  88. H-equality : {A : Set}(x : A)(C : (y : A) -> x == y -> Set1)
  89. (h : C x (refl x)) ->
  90. H x C h x (refl x) ≡₁ h
  91. H-equality x C h = Rg-equality (IdOP x) C (h' x C h) ★
  92. open Christine-Identity
  93. -}