Skip to content

Instantly share code, notes, and snippets.

@googleson78
Last active March 30, 2021 15:13
Show Gist options
  • Save googleson78/7400f480a60f11fdebd61fff3216b5c0 to your computer and use it in GitHub Desktop.
Save googleson78/7400f480a60f11fdebd61fff3216b5c0 to your computer and use it in GitHub Desktop.
{-# OPTIONS --no-unicode #-}
module BV where
data Two : Set where
ff tt : Two
data BV : Set where
end : BV
_-,_ : BV -> Two -> BV
infixl 10 _-,_
suc : BV -> BV
suc end = end -, tt
suc (xs -, ff) = xs -, tt
suc (xs -, tt) = suc xs -, ff
idOrSuc : Two -> Two -> BV -> BV
idOrSuc tt tt xs = suc xs
idOrSuc _ _ xs = xs
xor : Two -> Two -> Two
xor ff ff = ff
xor ff tt = tt
xor tt ff = tt
xor tt tt = ff
_+B_ : BV -> BV -> BV
end +B ys = ys
xs@(_ -, _) +B end = xs
(xs -, x) +B (ys -, y) = idOrSuc x y (xs +B ys) -, xor x y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment