Created
August 24, 2019 23:36
-
-
Save Blaisorblade/f246426269486d5b296cb312094c312b to your computer and use it in GitHub Desktop.
Numbers are even or odd — reusing mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open import Data.Fin | |
| open import Data.Nat | |
| open import Data.Nat.DivMod | |
| open import Data.Sum | |
| open import Relation.Binary.PropositionalEquality | |
| even : ℕ → Set | |
| even n = (n mod 2) ≡ 0F | |
| odd : ℕ → Set | |
| odd n = (n mod 2) ≡ 1F | |
| evenodd : ∀ n → even n ⊎ odd n | |
| evenodd n with n mod 2 | |
| evenodd n | 0F = inj₁ refl | |
| evenodd n | 1F = inj₂ refl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment