a bit more basics of arithmetic

This commit is contained in:
Philip Wadler 2017-10-01 21:46:17 +01:00
parent 9067c7a317
commit 4d04279d04

View file

@ -6,14 +6,19 @@ permalink : /Basics
--- ---
\begin{code} \begin{code}
open import Data.Nat using (; zero; suc)
open import Data.Empty using (⊥; ⊥-elim) open import Data.Empty using (⊥; ⊥-elim)
open import Relation.Nullary using (¬_; Dec; yes; no) open import Relation.Nullary using (¬_; Dec; yes; no)
open import Relation.Binary.PropositionalEquality open import Relation.Binary.PropositionalEquality
using (_≡_; refl; _≢_; trans; sym) using (_≡_; refl; _≢_; trans; sym)
\end{code} \end{code}
# Addition and its properties # Natural numbers
\begin{code}
data : Set where
zero :
suc :
\end{code}
\begin{code} \begin{code}
congruent : ∀ {m n} → m ≡ n → suc m ≡ suc n congruent : ∀ {m n} → m ≡ n → suc m ≡ suc n
@ -21,8 +26,13 @@ congruent refl = refl
injective : ∀ {m n} → suc m ≡ suc n → m ≡ n injective : ∀ {m n} → suc m ≡ suc n → m ≡ n
injective refl = refl injective refl = refl
distinct : ∀ {m} → zero ≢ suc m
distinct ()
\end{code} \end{code}
# Addition and its properties
\begin{code} \begin{code}
_+_ : _+_ :
zero + n = n zero + n = n