9
9
10
10
module Data.Rational.Properties where
11
11
12
+ open import Algebra.Apartness
12
13
open import Algebra.Construct.NaturalChoice.Base
13
14
import Algebra.Construct.NaturalChoice.MinMaxOp as MinMaxOp
14
15
import Algebra.Lattice.Construct.NaturalChoice.MinMaxOp as LatticeMinMaxOp
@@ -21,6 +22,7 @@ import Algebra.Morphism.GroupMonomorphism as GroupMonomorphisms
21
22
import Algebra.Morphism.RingMonomorphism as RingMonomorphisms
22
23
import Algebra.Lattice.Morphism.LatticeMonomorphism as LatticeMonomorphisms
23
24
import Algebra.Properties.CommutativeSemigroup as CommSemigroupProperties
25
+ import Algebra.Properties.Group as GroupProperties
24
26
open import Data.Bool.Base using (T; true; false)
25
27
open import Data.Integer.Base as ℤ using (ℤ; +_; -[1+_]; +[1+_]; +0; 0ℤ; 1ℤ; _◃_)
26
28
open import Data.Integer.Coprimality using (coprime-divisor)
@@ -49,16 +51,18 @@ open import Function.Base using (_∘_; _∘′_; _∘₂_; _$_; flip)
49
51
open import Function.Definitions using (Injective)
50
52
open import Level using (0ℓ)
51
53
open import Relation.Binary
54
+ open import Relation.Binary.Morphism.Structures
55
+ import Relation.Binary.Morphism.OrderMonomorphism as OrderMonomorphisms
56
+ import Relation.Binary.Properties.DecSetoid as DecSetoidProperties
52
57
open import Relation.Binary.PropositionalEquality.Core
53
58
using (_≡_; refl; cong; cong₂; sym; trans; _≢_; subst; subst₂; resp₂)
54
59
open import Relation.Binary.PropositionalEquality.Properties
55
60
using (setoid; decSetoid; module ≡-Reasoning ; isEquivalence)
56
- open import Relation.Binary.Morphism.Structures
57
- import Relation.Binary.Morphism.OrderMonomorphism as OrderMonomorphisms
61
+ import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
62
+ open import Relation.Binary.Reasoning.Syntax using ( module ≃-syntax )
58
63
open import Relation.Nullary.Decidable.Core as Dec
59
64
using (yes; no; recompute; map′; _×-dec_)
60
65
open import Relation.Nullary.Negation.Core using (¬_; contradiction)
61
- open import Relation.Binary.Reasoning.Syntax using (module ≃-syntax )
62
66
63
67
open import Algebra.Definitions {A = ℚ} _≡_
64
68
open import Algebra.Structures {A = ℚ} _≡_
@@ -97,6 +101,9 @@ mkℚ n₁ d₁ _ ≟ mkℚ n₂ d₂ _ = map′
97
101
≡-decSetoid : DecSetoid 0ℓ 0ℓ
98
102
≡-decSetoid = decSetoid _≟_
99
103
104
+ 1≢0 : 1ℚ ≢ 0ℚ
105
+ 1≢0 = λ ()
106
+
100
107
------------------------------------------------------------------------
101
108
-- mkℚ+
102
109
------------------------------------------------------------------------
@@ -1239,6 +1246,53 @@ neg-distribʳ-* = +-*-Monomorphism.neg-distribʳ-* ℚᵘ.+-0-isGroup ℚᵘ.*-i
1239
1246
{ isCommutativeRing = +-*-isCommutativeRing
1240
1247
}
1241
1248
1249
+
1250
+ ------------------------------------------------------------------------
1251
+ -- HeytingField structures and bundles
1252
+
1253
+ module _ where
1254
+ open CommutativeRing +-*-commutativeRing
1255
+ using (+-group; zeroˡ; *-congʳ; isCommutativeRing)
1256
+
1257
+ open GroupProperties +-group
1258
+ open DecSetoidProperties ≡-decSetoid
1259
+
1260
+ #⇒invertible : p ≢ q → Invertible 1ℚ _*_ (p - q)
1261
+ #⇒invertible {p} {q} p≢q = let r = p - q in 1/ r , *-inverseˡ r , *-inverseʳ r
1262
+ where instance _ = ≢-nonZero (p≢q ∘ (x∙y⁻¹≈ε⇒x≈y p q))
1263
+
1264
+ invertible⇒# : Invertible 1ℚ _*_ (p - q) → p ≢ q
1265
+ invertible⇒# {p} {q} (1/[p-q] , _ , [p-q]/[p-q]≡1) p≡q = contradiction 1≡0 1≢0
1266
+ where
1267
+ open ≈-Reasoning ≡-setoid
1268
+ 1≡0 : 1ℚ ≡ 0ℚ
1269
+ 1≡0 = begin
1270
+ 1ℚ ≈⟨ [p-q]/[p-q]≡1 ⟨
1271
+ (p - q) * 1/[p-q] ≈⟨ *-congʳ (x≈y⇒x∙y⁻¹≈ε p≡q) ⟩
1272
+ 0ℚ * 1/[p-q] ≈⟨ zeroˡ 1/[p-q] ⟩
1273
+ 0ℚ ∎
1274
+
1275
+ isHeytingCommutativeRing : IsHeytingCommutativeRing _≡_ _≢_ _+_ _*_ -_ 0ℚ 1ℚ
1276
+ isHeytingCommutativeRing = record
1277
+ { isCommutativeRing = isCommutativeRing
1278
+ ; isApartnessRelation = ≉-isApartnessRelation
1279
+ ; #⇒invertible = #⇒invertible
1280
+ ; invertible⇒# = invertible⇒#
1281
+ }
1282
+
1283
+ isHeytingField : IsHeytingField _≡_ _≢_ _+_ _*_ -_ 0ℚ 1ℚ
1284
+ isHeytingField = record
1285
+ { isHeytingCommutativeRing = isHeytingCommutativeRing
1286
+ ; tight = ≉-tight
1287
+ }
1288
+
1289
+ heytingCommutativeRing : HeytingCommutativeRing 0ℓ 0ℓ 0ℓ
1290
+ heytingCommutativeRing = record { isHeytingCommutativeRing = isHeytingCommutativeRing }
1291
+
1292
+ heytingField : HeytingField 0ℓ 0ℓ 0ℓ
1293
+ heytingField = record { isHeytingField = isHeytingField }
1294
+
1295
+
1242
1296
------------------------------------------------------------------------
1243
1297
-- Properties of _*_ and _≤_
1244
1298
0 commit comments