File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ module Cubical.Data.Int.Fast.Base where
2+
3+ open import Cubical.Foundations.Prelude
4+ open import Cubical.Data.Nat as ℕ hiding (_+_ ; _·_)
5+ open import Cubical.Data.Int.Base hiding (_ℕ-_ ; _+_ ; _-_ ; _·_) public
6+
7+ infixl 7 _·_
8+ infixl 6 _+_ _-_
9+
10+ ℕ-hlp : ℕ → ℕ → ℤ
11+ ℕ-hlp m-n@zero n-m = - (pos n-m)
12+ ℕ-hlp m-n@(suc _) n-m = pos m-n
13+
14+ _ℕ-_ : ℕ → ℕ → ℤ
15+ m ℕ- n = ℕ-hlp (m ℕ.∸ n) (n ℕ.∸ m)
16+
17+ _+_ : ℤ → ℤ → ℤ
18+ pos n + pos n₁ = pos (n ℕ.+ n₁)
19+ negsuc n + negsuc n₁ = negsuc (suc (n ℕ.+ n₁))
20+ pos n + negsuc n₁ = n ℕ- (suc n₁)
21+ negsuc n + pos n₁ = n₁ ℕ- (suc n)
22+
23+ _-_ : ℤ → ℤ → ℤ
24+ m - n = m + (- n)
25+
26+ _·_ : ℤ → ℤ → ℤ
27+ pos n · pos n₁ = pos (n ℕ.· n₁)
28+ pos zero · negsuc n₁ = pos zero
29+ pos (suc n) · negsuc n₁ = negsuc (predℕ (suc n ℕ.· suc n₁))
30+ negsuc n · pos zero = pos zero
31+ negsuc n · pos (suc n₁) = negsuc (predℕ (suc n ℕ.· suc n₁))
32+ negsuc n · negsuc n₁ = pos (suc n ℕ.· suc n₁)
You can’t perform that action at this time.
0 commit comments