Skip to content

Instantly share code, notes, and snippets.

@righ1113
Last active July 5, 2023 19:57
Show Gist options
  • Save righ1113/7f05fc52938488766289b3944ccd321f to your computer and use it in GitHub Desktop.
Save righ1113/7f05fc52938488766289b3944ccd321f to your computer and use it in GitHub Desktop.
自然数の加法の交換法則 in Idris
-- $ chcp 65001
-- $ idris
-- > :l Comm
module Comm
%default total
comm : (x, y : Nat) -> x + y = y + x
comm Z Z = Refl
comm (S x) Z = rewrite plusZeroRightNeutral x in Refl
comm Z (S y) = rewrite plusZeroRightNeutral y in Refl
comm (S x) (S y) =
rewrite sym (plusSuccRightSucc x y) in
rewrite sym (plusSuccRightSucc y x) in cong {f = S . S} (comm x y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment