Skip to content

Instantly share code, notes, and snippets.

@ice1000
Created February 23, 2024 18:39
Show Gist options
  • Save ice1000/0986b84696a70f1630a2bb94ad60928d to your computer and use it in GitHub Desktop.
Save ice1000/0986b84696a70f1630a2bb94ad60928d to your computer and use it in GitHub Desktop.
This version of + sucks
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat using (Nat; suc; zero)
cong : (f : Nat Nat) {a b} a ≡ b f a ≡ f b
cong f refl = refl
trans : {a b c : Nat} a ≡ b b ≡ c a ≡ c
trans refl p = p
sym : {a b : Nat} a ≡ b b ≡ a
sym refl = refl
_+_ : Nat Nat Nat
a + zero = a
a + suc b = suc (b + a)
+-comm : a b a + b ≡ b + a
+-suc : a b suc a + b ≡ suc (b + a)
+-zero : a zero + a ≡ a
+-comm zero b = +-zero b
+-comm (suc a) b = trans (+-suc a b) (cong suc (+-comm b a))
+-zero zero = refl
+-zero (suc a) = refl
+-suc a zero = cong suc (sym (+-zero a))
+-suc a (suc b) = cong suc (sym (+-suc b a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment