view paper/src/agda-term.agda @ 19:046b2b20d6c7 default tip

fix
author ryokka
date Mon, 09 Mar 2020 11:25:49 +0900
parents
children
line wrap: on
line source

module agda-term where

open import Data.Nat.Base
open import Relation.Binary.PropositionalEquality

+zero : {y : ℕ} → y + zero ≡ y
+zero {zero} = refl
+zero {suc y} = cong (λ yy → suc yy) (+zero {y})

+-suc : {x y : ℕ} → x + suc y ≡ suc (x + y)
+-suc {zero} {y} = refl
+-suc {suc x} {y} = cong suc (+-suc {x} {y})

+-comm : (x y : ℕ) → x + y ≡ y + x
+-comm zero y rewrite (+zero {y}) = refl
+-comm (suc x) y = let open ≡-Reasoning in
  begin
  suc (x + y) ≡⟨⟩
  suc (x + y) ≡⟨ cong suc (+-comm x y) ⟩
  suc (y + x) ≡⟨ sym (+-suc {y} {x}) ⟩
  y + suc x ∎

+-come : (x y : ℕ) → x + y ≡ y + x
+-come zero y rewrite (+zero {y}) = refl
+-come (suc x) y
  rewrite (cong suc (+-come x y)) | sym (+-suc {y} {x}) = refl