Eta.agda 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. module Eta (Gnd : Set)(U : Set)(El : U -> Set) where
  2. open import Basics
  3. open import Pr
  4. open import Nom
  5. import Kind
  6. open Kind Gnd U El
  7. import Cxt
  8. open Cxt Kind
  9. import Loc
  10. open Loc Kind
  11. import Term
  12. open Term Gnd U El
  13. import Shift
  14. open Shift Gnd U El
  15. data Sawn (G : Cxt)(C : Kind)(L : Loc)(R : Kind) : Kind -> Set where
  16. snil : Sawn G C L R R
  17. scons : {S T : Kind} -> Sawn G C L R (S |> T) ->
  18. G [ L / Term C ]- S ->
  19. Sawn G C L R T
  20. sarg : {A : U}{K : El A -> Kind} ->
  21. Sawn G C L R (Pi A K) -> (a : El A) ->
  22. Sawn G C L R (K a)
  23. stitch : {G : Cxt}{C : Kind}{Z : Gnd}{L : Loc}{R S : Kind} ->
  24. Sawn G C L R S -> G [ L / Args C Z ]- S -> G [ L / Args C Z ]- R
  25. stitch snil s = s
  26. stitch (scons r s) t = stitch r (s G& t)
  27. stitch (sarg r a) t = stitch r (a G^ t)
  28. sawsh : {G : Cxt}{C : Kind}{L M : Loc} ->
  29. ({T : Kind} -> G [ L / Head ]- T -> G [ M / Head ]- T) ->
  30. {R S : Kind} -> Sawn G C L R S -> Sawn G C M R S
  31. sawsh rho snil = snil
  32. sawsh rho (scons r s) = scons (sawsh rho r) (shift rho s)
  33. sawsh rho (sarg r a) = sarg (sawsh rho r) a
  34. long : {G : Cxt}{C : Kind}{L : Loc}(S : Kind){T : Kind} ->
  35. G [ L / Head ]- T ->
  36. Sawn G C L T S ->
  37. G [ L / Term C ]- S
  38. long (Ty Z) h s = h G$ (stitch s Gnil)
  39. long (Pi A K) h s = Gfn A \ a -> long (K a) h (sarg s a)
  40. long (S |> T) h s =
  41. G\\ (long T (popH h) (scons (sawsh popH s) (long S (# top -! _) snil)))
  42. var : {G : Cxt}{C : Kind}(x : Nom){Gx : [| G Has x |]} ->
  43. G [ EL / Term C ]- (wit ((G ?- x) {Gx}))
  44. var {G} x {Gx} with (G ?- x) {Gx}
  45. ... | [ T / g ] = long T (` x -! g) snil