CurryHoward.agda 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {-
  2. Types Summer School 2007
  3. Bertinoro
  4. Aug 19 - 31, 2007
  5. Agda
  6. Ulf Norell
  7. -}
  8. module CurryHoward where
  9. -- Propositions as types!
  10. data True : Set where
  11. tt : True
  12. data False : Set where
  13. data _∧_ (P Q : Set) : Set where
  14. _,_ : P -> Q -> P ∧ Q
  15. data _∨_ (P Q : Set) : Set where
  16. inl : P -> P ∨ Q
  17. inr : Q -> P ∨ Q
  18. data ∃ (A : Set)(P : A -> Set) : Set where
  19. ex : (x : A) -> P x -> ∃ A P
  20. ¬_ : Set -> Set
  21. ¬ A = A -> False
  22. ∏ : (A : Set)(P : A -> Set) -> Set
  23. ∏ A P = (x : A) -> P x
  24. -- Some simple examples
  25. const : {A B : Set} -> A -> (B -> A)
  26. const = \x y -> x
  27. swap : {P Q : Set} -> P ∧ Q -> Q ∧ P
  28. swap (p , q) = (q , p)
  29. notNotEM : (P : Set) -> ¬ ¬ (P ∨ ¬ P)
  30. notNotEM P = \f -> f (inr (\p -> f (inl p)))