Last active
February 7, 2020 11:21
-
-
Save pnlph/482d79bceef21f93775c2828771230ac to your computer and use it in GitHub Desktop.
Mutually defined indexed datatypes Even and Odd
This file contains 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
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