{-# OPTIONS --allow-unsolved-metas #-}
data Bool : Set where
false : Bool
true : Bool
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + b = b
succ a + b = succ (a + b)
eq? : ℕ → ℕ → Bool
eq? zero zero = true
eq? zero (succ b) = false
eq? (succ a) zero = false
eq? (succ a) (succ b) with eq? a b
... | false = false
... | true = true
! : Bool → Bool
! false = true
! true = false
even? : ℕ → Bool
even? zero = true
even? (succ n) = ! (even? n)
even?' : ℕ → Bool
even?' zero = true
even?' (succ zero) = false
even?' (succ (succ n)) = even? n
exampleEq? : Bool
exampleEq? = eq? (succ (succ (succ zero))) (succ zero)
exampleEven? : Bool
exampleEven? = even? (succ (succ (succ zero)))
data Even : ℕ → Set where
base : Even zero
step : {n : ℕ} → Even n → Even (succ (succ n))
fact-zero-is-even : Even zero
fact-zero-is-even = base
fact-two-is-even : Even (succ (succ zero))
fact-two-is-even = step {zero} base
fact-six-is-even : Even (succ (succ (succ (succ (succ (succ zero))))))
fact-six-is-even = step (step (step base))
failed-attempt-at-proving-that-one-is-even : Even (succ zero)
failed-attempt-at-proving-that-one-is-even = {!!}
data ⊥ : Set where
fact-if-n-is-even-then-n-is-even : {n : ℕ} → Even n → Even n
fact-if-n-is-even-then-n-is-even p = p
fact-one-is-not-even : Even (succ zero) → ⊥
fact-one-is-not-even ()
foo : ℕ → Set
foo zero = ℕ
foo (succ zero) = Bool
foo (succ (succ n)) = Even (succ zero)
Even' : ℕ → Set
Even' zero = Unit
where
data Unit : Set where
tt : Unit
Even' (succ zero) = ⊥
Even' (succ (succ n)) = Even' n
lemma-sum-even : {a b : ℕ} → Even a → Even b → Even (a + b)
lemma-sum-even base q = q
lemma-sum-even (step p) q = step (lemma-sum-even p q)