Skip to content

Instantly share code, notes, and snippets.

@pnlph
Last active February 7, 2020 11:21
Show Gist options
  • Save pnlph/482d79bceef21f93775c2828771230ac to your computer and use it in GitHub Desktop.
Save pnlph/482d79bceef21f93775c2828771230ac to your computer and use it in GitHub Desktop.
Mutually defined indexed datatypes Even and Odd
module Even where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
-- Declare _Odd datatype first
-- is to be used by _Even datatype
data _Odd : ℕ → Set
-- Declare and define _Even
data _Even : ℕ → Set where
0-is-even : _Even 0
suc_is-even-if : (n : ℕ) → _Odd n → _Even (suc n)
-- Define _Odd
data _Odd where
suc_is-odd-if : (n : ℕ) → _Even n → _Odd (suc n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment