Equality.agda 868 B

1234567891011121314151617181920212223242526272829
  1. module Equality where
  2. postulate _==_ : {A : Set} -> A -> A -> Set
  3. refl : {A : Set}{x : A} -> x == x
  4. {-# BUILTIN EQUAL _==_ #-}
  5. {-# BUILTIN REFL refl #-}
  6. private
  7. primitive
  8. primEqElim : {A : Set}(x : A)(C : (y : A) -> x == y -> Set) ->
  9. C x refl -> (y : A) -> (p : x == y) -> C y p
  10. elim-== = \{A : Set} -> primEqElim {A}
  11. subst : {A : Set}(C : A -> Set){x y : A} -> x == y -> C y -> C x
  12. subst C {x}{y} p Cy = elim-== x (\z _ -> C z -> C x) (\Cx -> Cx) y p Cy
  13. sym : {A : Set}{x y : A} -> x == y -> y == x
  14. sym {x = x}{y = y} p = subst (\z -> y == z) p refl
  15. trans : {A : Set}{x y z : A} -> x == y -> y == z -> x == z
  16. trans {x = x}{y = y}{z = z} xy yz = subst (\w -> w == z) xy yz
  17. cong : {A B : Set}{x y : A}(f : A -> B) -> x == y -> f x == f y
  18. cong {y = y} f xy = subst (\ ∙ -> f ∙ == f y) xy refl