Cxt.agda 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module Cxt (K : Set) where
  2. open import Basics
  3. open import Pr
  4. open import Nom
  5. mutual
  6. data Cxt : Set where
  7. EC : Cxt
  8. _[_-_] : (G : Cxt)(x : Nom) -> K -> {p : [| G Hasn't x |]} -> Cxt
  9. HAS : Cxt -> Nom -> Bool
  10. HAS EC x = false
  11. HAS (G [ y - S ]) x with nomEq y x
  12. HAS (G [ y - S ]) .y | yes refl = true
  13. ... | no n = HAS G x
  14. _Has_ : Cxt -> Nom -> Pr
  15. G Has x = So (HAS G x)
  16. _Hasn't_ : Cxt -> Nom -> Pr
  17. G Hasn't x = So (not (HAS G x))
  18. GooN : (G : Cxt)(T : K) -> Nom -> Pr
  19. GooN EC T y = ff
  20. GooN (G [ x - S ]) T y with nomEq x y
  21. GooN (G [ x - S ]) T .x | yes refl = S eq T
  22. GooN (G [ x - S ]) T y | no n = GooN G T y
  23. _?-_ : (G : Cxt)(x : Nom){p : [| G Has x |]} -> K :- \ T -> GooN G T x
  24. (EC ?- y) {}
  25. ((G [ x - S ]) ?- y) {_} with nomEq x y
  26. ((G [ x - S ]) ?- .x) {_} | yes refl = [ S / refl ]
  27. ((G [ x - S ]) ?- y) {p} | no n = (G ?- y) {p}
  28. topGooN : (G : Cxt)(x : Nom){p : [| G Hasn't x |]}(S : K) ->
  29. [| GooN ((G [ x - S ]) {p}) S x |]
  30. topGooN G x S with nomEq x x
  31. topGooN G x S | yes refl = refl
  32. topGooN G x S | no n = magic (n refl)