help.agda 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module help where
  2. open import univ
  3. open import Base
  4. -- Prelims
  5. infixl 150 _#_
  6. K : {A : S} -> S -> Fam A
  7. K B = fam (\_ -> B) (\_ -> refS)
  8. _#_ : {A : S}{F : Fam A} -> El (pi A F) -> (x : El A) -> El (F ! x)
  9. el < f , _ > # x = f x
  10. pFun : {A : S}{F : Fam A}(f : El (pi A F)){x y : El A}(x=y : x == y) ->
  11. f # x == pFam F x=y << f # y
  12. pFun (el < f , pf >) x=y = pf x=y
  13. p# : {A : S}{F : Fam A}{f g : El (pi A F)}{x : El A} -> f == g -> f # x == g # x
  14. p# {A}{F}{el < f , _ >}{el < g , _ >} (eq f=g) = f=g _
  15. eqDom : {A B : S}{F : Fam A}{G : Fam B} ->
  16. pi A F =S pi B G -> B =S A
  17. eqDom (eqS < B=A , _ >) = B=A
  18. eqCod : {A B : S}{F : Fam A}{G : Fam B} ->
  19. (AF=BG : pi A F =S pi B G)(x : El A) ->
  20. F ! x =S G ! (eqDom AF=BG << x)
  21. eqCod (eqS < B=A , F=G >) = F=G
  22. distr<<# : {A B : S}{F : Fam A}{G : Fam B}(f : El (pi A F)){x : El B}
  23. (BG=AF : pi B G =S pi A F) ->
  24. (BG=AF << f) # x == eqCod BG=AF x << f # (eqDom BG=AF << x)
  25. distr<<# (el < f , pf >) {x} (eqS < A=B , G=F >) = ref
  26. eqSnd : {A : S}{F : Fam A}{x : El A}{y z : El (F ! x)} ->
  27. y == z -> _==_ {sigma A F} (el < x , y >) (el < x , z >)
  28. eqSnd {A}{F}{x}{y}{z} y=z = eq < ref , y=cz >
  29. where
  30. y=cz : y == pFam F ref << z
  31. y=cz = trans y=z (sym (castref _ _))
  32. IsFun : {A : S}{F : Fam A}(f : (x : El A) -> El (F ! x)) -> Set
  33. IsFun {A}{F} f = {x y : El A}(p : F ! x =S F ! y)(x=y : x == y) ->
  34. f x == p << f y
  35. mkFun : {A : S}{F : Fam A}(f : (x : El A) -> El (F ! x)) ->
  36. IsFun {A}{F} f -> El (pi A F)
  37. mkFun {A}{F} f pf = el < f , (\{x}{y} x=y -> pf (pFam F x=y) x=y) >
  38. curryFam : {A : S}{F : Fam A} -> Fam (sigma A F) -> (x : El A) -> Fam (F ! x)
  39. curryFam {A}{F} G x = fam H pH
  40. where
  41. H : El (F ! x) -> S
  42. H y = G ! el < x , y >
  43. pH : Map _==_ _=S_ H
  44. pH y=z = pFam G (eq < ref , trans y=z (sym (castref _ _)) >)