Skip to content

Instantly share code, notes, and snippets.

@pedrominicz
Created October 14, 2019 01:19
Show Gist options
  • Save pedrominicz/c8b06854911e16409b9c166d33ad43fc to your computer and use it in GitHub Desktop.
Save pedrominicz/c8b06854911e16409b9c166d33ad43fc to your computer and use it in GitHub Desktop.
A trivial proof that `x + x` is equal to `2 * x`.
module Trivial where
data Nat : Set where
zero : Nat
succ : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
data _==_ {A : Set} (x : A) : A -> Set where
refl : x == x
infix 5 _==_
_+_ : Nat -> Nat -> Nat
zero + y = y
succ x + y = succ (x + y)
infixl 6 _+_
_*_ : Nat -> Nat -> Nat
zero * y = zero
succ x * y = (x * y) + y
infixl 7 _*_
trivial : forall (x : Nat) -> x + x == 2 * x
trivial x = refl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment