PreludeBool.agda 824 B

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