annotate Paper/src/Reasoning.agda @ 1:a72446879486

Init paper
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Thu, 12 Jan 2023 20:28:50 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 open import Relation.Binary.PropositionalEquality
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 open import nat
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import nat_add
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open ≡-Reasoning
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 module nat_add_sym_reasoning where
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 addToRight : (n m : Nat) -> S (n + m) ≡ n + (S m)
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 addToRight O m = refl
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 addToRight (S n) m = cong S (addToRight n m)
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 addSym : (n m : Nat) -> n + m ≡ m + n
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 addSym O O = refl
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 addSym O (S m) = cong S (addSym O m)
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 addSym (S n) O = cong S (addSym n O)
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 addSym (S n) (S m) = begin
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 (S n) + (S m) ≡⟨ refl ⟩
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 S (n + S m) ≡⟨ cong S (addSym n (S m)) ⟩
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 S ((S m) + n) ≡⟨ addToRight (S m) n ⟩
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 S (m + S n) ≡⟨ refl ⟩
a72446879486 Init paper
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 (S m) + (S n) ∎