Skip to content

Instantly share code, notes, and snippets.

@appositum
Last active August 5, 2021 16:00
Show Gist options
  • Save appositum/2eb7dc833c49fb4aea4160a07f9d5658 to your computer and use it in GitHub Desktop.
Save appositum/2eb7dc833c49fb4aea4160a07f9d5658 to your computer and use it in GitHub Desktop.
infixr 5 <>
interface VerifiedMonoid (a : Type) where
mempty : a
(<>) : a -> a -> a
leftId : (x : a) -> mempty <> x = x
rightId : (x : a) -> x <> mempty = x
assoc : (x : a) -> (y : a) -> (z : a) -> x <> (y <> z) = (x <> y) <> z
[MonoidSum] VerifiedMonoid Nat where
mempty = 0
(<>) = (+)
leftId n = Refl
rightId Z = Refl
rightId (S n) = cong (rightId n)
assoc Z y z = Refl
assoc (S x) y z = cong (assoc x y z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment