IIDg.agda 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. module IIDg where
  2. open import LF
  3. -- Codes for indexed inductive types
  4. data OPg (I : Set) : Set1 where
  5. ι : I -> OPg I
  6. σ : (A : Set)(γ : A -> OPg I) -> OPg I
  7. δ : (H : Set)(i : H -> I)(γ : OPg I) -> OPg I
  8. -- The top-level structure of values in an IIDg
  9. Args : {I : Set}(γ : OPg I)(U : I -> Set) -> Set
  10. Args (ι _) U = One
  11. Args (σ A γ) U = A × \a -> Args (γ a) U
  12. Args (δ H i γ) U = ((x : H) -> U (i x)) × \_ -> Args γ U
  13. -- The index of a value in an IIDg
  14. Index : {I : Set}(γ : OPg I)(U : I -> Set) -> Args γ U -> I
  15. Index (ι i) U _ = i
  16. Index (σ A γ) U < a | b > = Index (γ a) U b
  17. Index (δ _ _ γ) U < _ | b > = Index γ U b
  18. -- The assumptions of a particular inductive occurrence.
  19. IndArg : {I : Set}(γ : OPg I)(U : I -> Set) -> Args γ U -> Set
  20. IndArg (ι _) U _ = Zero
  21. IndArg (σ A γ) U < a | b > = IndArg (γ a) U b
  22. IndArg (δ H i γ) U < _ | b > = H + IndArg γ U b
  23. -- The index of an inductive occurrence.
  24. IndIndex : {I : Set}(γ : OPg I)(U : I -> Set)(a : Args γ U) -> IndArg γ U a -> I
  25. IndIndex (ι _) U _ ()
  26. IndIndex (σ A γ) U < a | b > h = IndIndex (γ a) U b h
  27. IndIndex (δ A i γ) U < g | b > (inl h) = i h
  28. IndIndex (δ A i γ) U < g | b > (inr h) = IndIndex γ U b h
  29. -- An inductive occurrence.
  30. Ind : {I : Set}(γ : OPg I)(U : I -> Set)(a : Args γ U)(h : IndArg γ U a) -> U (IndIndex γ U a h)
  31. Ind (ι _) U _ ()
  32. Ind (σ A γ) U < a | b > h = Ind (γ a) U b h
  33. Ind (δ H i γ) U < g | b > (inl h) = g h
  34. Ind (δ H i γ) U < _ | b > (inr h) = Ind γ U b h
  35. -- The type of induction hypotheses.
  36. IndHyp : {I : Set}(γ : OPg I)(U : I -> Set)(C : (i : I) -> U i -> Set)(a : Args γ U) -> Set
  37. IndHyp γ U C a = (hyp : IndArg γ U a) -> C (IndIndex γ U a hyp) (Ind γ U a hyp)
  38. -- Large induction hypostheses.
  39. IndHyp₁ : {I : Set}(γ : OPg I)(U : I -> Set)(C : (i : I) -> U i -> Set1)(a : Args γ U) -> Set1
  40. IndHyp₁ γ U C a = (hyp : IndArg γ U a) -> C (IndIndex γ U a hyp) (Ind γ U a hyp)