You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Data/Integer/IntConstruction/Properties.agda
+37-32Lines changed: 37 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -46,16 +46,18 @@ private
46
46
-- Properties of _≃_
47
47
48
48
≃-refl : Reflexive _≃_
49
-
≃-refl = refl
49
+
≃-refl =mk≃ refl
50
50
51
51
≃-sym : Symmetric _≃_
52
-
≃-sym =sym
52
+
≃-sym (mk≃ eq) = mk≃ (sym eq)
53
53
54
54
≃-trans : Transitive _≃_
55
-
≃-trans {a ⊖ b} {c ⊖ d} {e ⊖ f} i≃jj≃k = ℕ.+-cancelʳ-≡ (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper _≡_ a b c d e f (cong₂ ℕ._+_ i≃j j≃k)
55
+
≃-trans {a ⊖ b} {c ⊖ d} {e ⊖ f} (mk≃ i≃j) (mk≃ j≃k)=mk≃ (ℕ.+-cancelʳ-≡ (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper _≡_ a b c d e f (cong₂ ℕ._+_ i≃j j≃k))
56
56
57
57
_≃?_ : Decidable _≃_
58
-
(a ⊖ b) ≃? (c ⊖ d) = a ℕ.+ d ℕ.≟ c ℕ.+ b
58
+
(a ⊖ b) ≃? (c ⊖ d) with a ℕ.+ d ℕ.≟ c ℕ.+ b
59
+
... | no a+d≢c+b = no λ (mk≃ a+d≡c+b) → a+d≢c+b a+d≡c+b
≤-trans {a ⊖ b} {c ⊖ d} {e ⊖ f} i≤j j≤k = ℕ.+-cancelʳ-≤ (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper ℕ._≤_ a b c d e f (ℕ.+-mono-≤ i≤j j≤k)
71
73
72
74
≤-antisym : Antisymmetric _≃_ _≤_
73
-
≤-antisym i≤j j≤i = ℕ.≤-antisym i≤j j≤i
75
+
≤-antisym i≤j j≤i =mk≃ (ℕ.≤-antisym i≤j j≤i)
74
76
75
77
≤-total : Total _≤_
76
78
≤-total (a ⊖ b) (c ⊖ d) = ℕ.≤-total (a ℕ.+ d) (c ℕ.+ b)
@@ -82,28 +84,31 @@ _≤?_ : Decidable _≤_
82
84
-- Properties of _<_
83
85
84
86
<-irrefl : Irreflexive _≃_ _<_
85
-
<-irrefl = ℕ.<-irrefl
87
+
<-irrefl (mk≃ eq) = ℕ.<-irrefl eq
86
88
87
89
<-trans : Transitive _<_
88
90
<-trans {a ⊖ b} {c ⊖ d} {e ⊖ f} i<j j<k = ℕ.+-cancelʳ-< (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper ℕ._<_ a b c d e f (ℕ.+-mono-< i<j j<k)
89
91
90
92
<-respˡ-≃ : _<_ Respectsˡ _≃_
91
-
<-respˡ-≃ {a ⊖ b} {c ⊖ d} {e ⊖ f} j≃k i>j = ℕ.+-cancelʳ-< (d ℕ.+ c) (e ℕ.+ b) (a ℕ.+ f) $ trans-helper ℕ._>_ a b c d e f (ℕ.+-mono-<-≤ i>j (ℕ.≤-reflexive (sym j≃k)))
93
+
<-respˡ-≃ {a ⊖ b} {c ⊖ d} {e ⊖ f} (mk≃ j≃k) i>j = ℕ.+-cancelʳ-< (d ℕ.+ c) (e ℕ.+ b) (a ℕ.+ f) $ trans-helper ℕ._>_ a b c d e f (ℕ.+-mono-<-≤ i>j (ℕ.≤-reflexive (sym j≃k)))
92
94
93
95
<-respʳ-≃ : _<_ Respectsʳ _≃_
94
-
<-respʳ-≃ {a ⊖ b} {c ⊖ d} {e ⊖ f} j≃k i<j = ℕ.+-cancelʳ-< (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper ℕ._<_ a b c d e f (ℕ.+-mono-<-≤ i<j (ℕ.≤-reflexive j≃k))
96
+
<-respʳ-≃ {a ⊖ b} {c ⊖ d} {e ⊖ f} (mk≃ j≃k) i<j = ℕ.+-cancelʳ-< (d ℕ.+ c) (a ℕ.+ f) (e ℕ.+ b) $ trans-helper ℕ._<_ a b c d e f (ℕ.+-mono-<-≤ i<j (ℕ.≤-reflexive j≃k))
95
97
96
98
_<?_ : Decidable _<_
97
99
(a ⊖ b) <? (c ⊖ d) = a ℕ.+ d ℕ.<? c ℕ.+ b
98
100
99
101
<-cmp : Trichotomous _≃_ _<_
100
-
<-cmp (a ⊖ b) (c ⊖ d) = ℕ.<-cmp (a ℕ.+ d) (c ℕ.+ b)
102
+
<-cmp (a ⊖ b) (c ⊖ d) with ℕ.<-cmp (a ℕ.+ d) (c ℕ.+ b)
((a ℕ.* e ℕ.+ b ℕ.* f) ℕ.+ (c ℕ.* h ℕ.+ d ℕ.* g)) ℕ.+ d ℕ.* e ≡⟨ ℕ.+-assoc (a ℕ.* e ℕ.+ b ℕ.* f) (c ℕ.* h ℕ.+ d ℕ.* g) (d ℕ.* e) ⟩
174
179
(a ℕ.* e ℕ.+ b ℕ.* f) ℕ.+ ((c ℕ.* h ℕ.+ d ℕ.* g) ℕ.+ d ℕ.* e) ≡⟨ cong (a ℕ.* e ℕ.+ b ℕ.* f ℕ.+_) (ℕ.+-comm (c ℕ.* h ℕ.+ d ℕ.* g) (d ℕ.* e)) ⟩
175
180
(a ℕ.* e ℕ.+ b ℕ.* f) ℕ.+ (d ℕ.* e ℕ.+ (c ℕ.* h ℕ.+ d ℕ.* g)) ≡⟨ medial (a ℕ.* e) (b ℕ.* f) (d ℕ.* e) (c ℕ.* h ℕ.+ d ℕ.* g) ⟩
@@ -197,7 +202,7 @@ _<?_ : Decidable _<_
197
202
openCommSemigroupProps ℕ.+-commutativeSemigroup
198
203
199
204
*-assoc : Associative _*_
200
-
*-assoc (a ⊖ b) (c ⊖ d) (e ⊖ f) = cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma a b c d f e))
205
+
*-assoc (a ⊖ b) (c ⊖ d) (e ⊖ f) =mk≃ $ cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma a b c d f e))
201
206
where
202
207
open≡-Reasoning
203
208
openCommSemigroupProps ℕ.+-commutativeSemigroup
@@ -212,27 +217,27 @@ _<?_ : Decidable _<_
212
217
u ℕ.* (w ℕ.* y ℕ.+ x ℕ.* z) ℕ.+ v ℕ.* (w ℕ.* z ℕ.+ x ℕ.* y) ∎
213
218
214
219
*-zeroˡ : LeftZero 0ℤ _*_
215
-
*-zeroˡ _ = refl
220
+
*-zeroˡ _ =mk≃ refl
216
221
217
222
*-zeroʳ : RightZero 0ℤ _*_
218
-
*-zeroʳ _ = ℕ.+-identityʳ _
223
+
*-zeroʳ _ =mk≃ $ ℕ.+-identityʳ _
219
224
220
225
*-identityˡ : LeftIdentity 1ℤ _*_
221
-
*-identityˡ (a ⊖ b) = cong₂ ℕ._+_ (lemma a) (sym (lemma b))
226
+
*-identityˡ (a ⊖ b) =mk≃ $ cong₂ ℕ._+_ (lemma a) (sym (lemma b))
222
227
where
223
228
lemma :∀ n → n ℕ.+ 0 ℕ.+ 0 ≡ n
224
229
lemma n = trans (ℕ.+-identityʳ (n ℕ.+ 0)) (ℕ.+-identityʳ n)
225
230
226
231
*-identityʳ : RightIdentity 1ℤ _*_
227
-
*-identityʳ (a ⊖ b) = cong₂ ℕ._+_ l (sym r)
232
+
*-identityʳ (a ⊖ b) =mk≃ $ cong₂ ℕ._+_ l (sym r)
228
233
where
229
234
l : a ℕ.* 1 ℕ.+ b ℕ.* 0 ≡ a
230
235
l = trans (cong₂ ℕ._+_ (ℕ.*-identityʳ a) (ℕ.*-zeroʳ b)) (ℕ.+-identityʳ a)
231
236
r : a ℕ.* 0 ℕ.+ b ℕ.* 1 ≡ b
232
237
r = trans (cong₂ ℕ._+_ (ℕ.*-zeroʳ a) (ℕ.*-identityʳ b)) (ℕ.+-identityˡ b)
233
238
234
239
*-distribˡ-+ : _*_ DistributesOverˡ _+_
235
-
*-distribˡ-+ (a ⊖ b) (c ⊖ d) (e ⊖ f) = cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma a b d c f e))
240
+
*-distribˡ-+ (a ⊖ b) (c ⊖ d) (e ⊖ f) =mk≃ $ cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma a b d c f e))
236
241
where
237
242
open≡-Reasoning
238
243
openCommSemigroupProps ℕ.+-commutativeSemigroup
@@ -244,7 +249,7 @@ _<?_ : Decidable _<_
244
249
(u ℕ.* w ℕ.+ v ℕ.* x) ℕ.+ (u ℕ.* y ℕ.+ v ℕ.* z) ∎
245
250
246
251
*-distribʳ-+ : _*_ DistributesOverʳ _+_
247
-
*-distribʳ-+ (a ⊖ b) (c ⊖ d) (e ⊖ f) = cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma b a c d e f))
252
+
*-distribʳ-+ (a ⊖ b) (c ⊖ d) (e ⊖ f) =mk≃ $ cong₂ ℕ._+_ (lemma a b c d e f) (sym (lemma b a c d e f))
248
253
where
249
254
open≡-Reasoning
250
255
openCommSemigroupProps ℕ.+-commutativeSemigroup
@@ -256,16 +261,16 @@ _<?_ : Decidable _<_
256
261
(w ℕ.* u ℕ.+ x ℕ.* v) ℕ.+ (y ℕ.* u ℕ.+ z ℕ.* v) ∎
257
262
258
263
*-comm : Commutative _*_
259
-
*-comm (a ⊖ b) (c ⊖ d) = cong₂ ℕ._+_ (cong₂ ℕ._+_ (ℕ.*-comm a c) (ℕ.*-comm b d)) (trans (ℕ.+-comm (c ℕ.* b) (d ℕ.* a)) (cong₂ ℕ._+_ (ℕ.*-comm d a) (ℕ.*-comm c b)))
264
+
*-comm (a ⊖ b) (c ⊖ d) =mk≃ $ cong₂ ℕ._+_ (cong₂ ℕ._+_ (ℕ.*-comm a c) (ℕ.*-comm b d)) (trans (ℕ.+-comm (c ℕ.* b) (d ℕ.* a)) (cong₂ ℕ._+_ (ℕ.*-comm d a) (ℕ.*-comm c b)))
0 commit comments