view final_pre/src/Reasoning.agda @ 7:28f900230c26

add final_pre
author ryokka
date Mon, 19 Feb 2018 23:32:24 +0900
parents
children
line wrap: on
line source

open import Relation.Binary.PropositionalEquality
open import nat
open import nat_add
open ≡-Reasoning

module nat_add_sym_reasoning where

addToRight : (n m : Nat) -> S (n + m) ≡ n + (S m)
addToRight O m     = refl
addToRight (S n) m = cong S (addToRight n m)

addSym : (n m : Nat) -> n + m ≡ m + n
addSym O       O   = refl
addSym O    (S m)  = cong S (addSym O m)
addSym (S n)   O   = cong S (addSym n O)
addSym (S n) (S m) = begin
  (S n) + (S m)  ≡⟨ refl ⟩
  S (n + S m)    ≡⟨ cong S (addSym n (S m)) ⟩
  S ((S m) + n)  ≡⟨ addToRight (S m) n ⟩
  S (m + S n)    ≡⟨ refl ⟩
  (S m) + (S n)  ∎