Sets.agda 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. module Sets where
  2. import Equality
  3. open Equality public
  4. infixr 10 _$_
  5. infixr 40 _[+]_ _<+>_ _>+<_
  6. infixr 60 _[×]_ _<×>_ _>×<_
  7. infixr 90 _∘_
  8. id : {A : Set} -> A -> A
  9. id x = x
  10. _∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C
  11. f ∘ g = \x -> f (g x)
  12. _$_ : {A B : Set} -> (A -> B) -> A -> B
  13. f $ x = f x
  14. data _[+]_ (A B : Set) : Set where
  15. inl : A -> A [+] B
  16. inr : B -> A [+] B
  17. _<+>_ : {A₁ A₂ B₁ B₂ : Set} -> (A₁ -> A₂) -> (B₁ -> B₂) -> A₁ [+] B₁ -> A₂ [+] B₂
  18. (f <+> g) (inl x) = inl (f x)
  19. (f <+> g) (inr y) = inr (g y)
  20. _>+<_ : {A B C : Set} -> (A -> C) -> (B -> C) -> A [+] B -> C
  21. (f >+< g) (inl x) = f x
  22. (f >+< g) (inr y) = g y
  23. data _[×]_ (A B : Set) : Set where
  24. <_,_> : A -> B -> A [×] B
  25. -- sections
  26. <∙,_> : {A B : Set} -> B -> A -> A [×] B
  27. <∙, x > = \y -> < y , x >
  28. <_,∙> : {A B : Set} -> A -> B -> A [×] B
  29. < x ,∙> = \y -> < x , y >
  30. _<×>_ : {A₁ A₂ B₁ B₂ : Set} -> (A₁ -> A₂) -> (B₁ -> B₂) -> A₁ [×] B₁ -> A₂ [×] B₂
  31. (f <×> g) < x , y > = < f x , g y >
  32. _>×<_ : {A B C : Set} -> (A -> B) -> (A -> C) -> A -> B [×] C
  33. (f >×< g) x = < f x , g x >
  34. fst : {A B : Set} -> A [×] B -> A
  35. fst < a , b > = a
  36. snd : {A B : Set} -> A [×] B -> B
  37. snd < a , b > = b
  38. η-[×] : {A B : Set}(p : A [×] B) -> p == < fst p , snd p >
  39. η-[×] < a , b > = refl
  40. data [1] : Set where
  41. <> : [1]
  42. data [0] : Set where
  43. data List (A : Set) : Set where
  44. [] : List A
  45. _::_ : A -> List A -> List A