Bool.agda 976 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. module Data.Bool where
  2. import Logic.Base
  3. infixr 10 _=>_!_
  4. infix 5 !_
  5. infix 12 otherwise_
  6. infixr 20 _||_
  7. infixr 30 _&&_
  8. data Bool : Set where
  9. true : Bool
  10. false : Bool
  11. {-# BUILTIN BOOL Bool #-}
  12. {-# BUILTIN TRUE true #-}
  13. {-# BUILTIN FALSE false #-}
  14. _&&_ : Bool -> Bool -> Bool
  15. true && x = x
  16. false && _ = false
  17. _||_ : Bool -> Bool -> Bool
  18. true || _ = true
  19. false || x = x
  20. not : Bool -> Bool
  21. not true = false
  22. not false = true
  23. open Logic.Base
  24. IsTrue : Bool -> Set
  25. IsTrue true = True
  26. IsTrue false = False
  27. IsFalse : Bool -> Set
  28. IsFalse x = IsTrue (not x)
  29. if_then_else_ : {A : Set} -> Bool -> A -> A -> A
  30. if true then x else y = x
  31. if false then x else y = y
  32. if'_then_else_ : {A : Set} -> (x : Bool) -> (IsTrue x -> A) -> (IsFalse x -> A) -> A
  33. if' true then f else g = f tt
  34. if' false then f else g = g tt
  35. _=>_!_ : {A : Set} -> Bool -> A -> A -> A
  36. _=>_!_ = if_then_else_
  37. !_ : {A : Set} -> A -> A
  38. ! x = x
  39. otherwise_ : {A : Set} -> A -> A
  40. otherwise x = x