0
|
1 module agda-term where
|
|
2
|
|
3 open import Data.Nat.Base
|
|
4 open import Relation.Binary.PropositionalEquality
|
|
5
|
|
6 +zero : {y : @$\mathbb{N}$@} @$\rightarrow$@ y + zero @$\equiv$@ y
|
|
7 +zero {zero} = refl
|
|
8 +zero {suc y} = cong (@$\lambda$@ yy @$\rightarrow$@ suc yy) (+zero {y})
|
|
9
|
|
10 +-suc : {x y : @$\mathbb{N}$@} @$\rightarrow$@ x + suc y @$\equiv$@ suc (x + y)
|
|
11 +-suc {zero} {y} = refl
|
|
12 +-suc {suc x} {y} = cong suc (+-suc {x} {y})
|
|
13
|
|
14 +-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x
|
|
15 +-comm zero y rewrite (+zero {y}) = refl
|
|
16 +-comm (suc x) y = let open @$\equiv$@-Reasoning in
|
|
17 begin
|
|
18 suc (x + y) @$\equiv$@@$\langle$@@$\rangle$@
|
|
19 suc (x + y) @$\equiv$@@$\langle$@ cong suc (+-comm x y) @$\rangle$@
|
|
20 suc (y + x) @$\equiv$@@$\langle$@ sym (+-suc {y} {x}) @$\rangle$@
|
|
21 y + suc x @$\blacksquare$@
|
|
22
|
|
23 +-come : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x
|
|
24 +-come zero y rewrite (+zero {y}) = refl
|
|
25 +-come (suc x) y
|
|
26 rewrite (cong suc (+-come x y)) | sym (+-suc {y} {x}) = refl
|
|
27
|
|
28
|