Skip to content

Instantly share code, notes, and snippets.

View siddhartha-gadgil's full-sized avatar

Siddhartha Gadgil siddhartha-gadgil

View GitHub Profile
@siddhartha-gadgil
siddhartha-gadgil / BoolType.agda
Created March 17, 2014 04:18
Definition of Booleans
data Bool : Set where
true : Bool
false : Bool
not : Bool -> Bool
not true = false
not false = true
_&_ : Bool → Bool → Bool
true & true = true
false & _ = false
true & false = false
notnot : Bool -> Bool
notnot x = not (not x)
verytrue : Bool → Bool
verytrue = λ x → x & x
_xor_ : Bool → Bool → Bool
_xor_ = λ x y → (x & (not y)) || ((not x) & y)
_*_ : ℕ → ℕ → ℕ
zero * n = zero
(succ m) * n = n + (m * n)
factorial : ℕ → ℕ
factorial zero = succ zero
factorial (succ n) = (succ n) * (factorial n)
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = n
(succ m) + n = succ (m + n)
forever : ℕ → ℕ
forever zero = zero
forever (succ n) = forever (succ (succ n))