Skip to content

Rectifies the negated equality symbol in Data.Rational.Unnormalised.* #2118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ Non-backwards compatible changes
(issue #1437) to conform with the defined setoid equality `_≃_` on `Rational`s:
```agda
step-≈ ↦ step-≃
step-˘ ↦ step-≃˘
step-˘ ↦ step-≃˘
```
with corresponding associated syntax:
```agda
Expand Down Expand Up @@ -1399,6 +1399,13 @@ Deprecated names
<-step ↦ m<n⇒m<1+n
```

* In `Data.Rational.Unnormalised.Base`:
```
_≠_ ↦ _≄_
+-rawMonoid ↦ +-0-rawMonoid
*-rawMonoid ↦ *-1-rawMonoid
```

* In `Data.Rational.Unnormalised.Properties`:
```
↥[p/q]≡p ↦ ↥[n/d]≡n
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Rational/Base.agda
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ open import Data.Rational.Unnormalised.Base as ℚᵘ using (ℚᵘ; mkℚᵘ)
open import Data.Sum.Base using (inj₂)
open import Function.Base using (id)
open import Level using (0ℓ)
open import Relation.Nullary using (¬_; recompute)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Nullary.Decidable.Core using (recompute)
open import Relation.Nullary.Negation.Core using (¬_; contradiction)
open import Relation.Unary using (Pred)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.PropositionalEquality.Core
Expand Down
6 changes: 3 additions & 3 deletions src/Data/Rational/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ open import Relation.Binary.Definitions
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Morphism.Structures
import Relation.Binary.Morphism.OrderMonomorphism as OrderMonomorphisms
open import Relation.Nullary.Decidable as Dec
using (True; False; fromWitness; fromWitnessFalse; toWitnessFalse; yes; no; recompute; map′; _×-dec_)
open import Relation.Nullary.Negation using (¬_; contradiction; contraposition)
open import Relation.Nullary.Decidable.Core as Dec
using (yes; no; recompute; map′; _×-dec_)
open import Relation.Nullary.Negation.Core using (¬_; contradiction)

open import Algebra.Definitions {A = ℚ} _≡_
open import Algebra.Structures {A = ℚ} _≡_
Expand Down
14 changes: 9 additions & 5 deletions src/Data/Rational/Unnormalised/Base.agda
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ open import Data.Integer.Base as ℤ
using (ℤ; +_; +0; +[1+_]; -[1+_]; +<+; +≤+)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc)
open import Level using (0ℓ)
open import Relation.Nullary.Negation using (¬_)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Nullary.Negation.Core using (¬_; contradiction)
open import Relation.Unary using (Pred)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.PropositionalEquality.Core
Expand Down Expand Up @@ -66,8 +65,8 @@ infix 4 _≃_ _≠_
data _≃_ : Rel ℚᵘ 0ℓ where
*≡* : ∀ {p q} → (↥ p ℤ.* ↧ q) ≡ (↥ q ℤ.* ↧ p) → p ≃ q

__ : Rel ℚᵘ 0ℓ
p q = ¬ (p ≃ q)
__ : Rel ℚᵘ 0ℓ
p q = ¬ (p ≃ q)

------------------------------------------------------------------------
-- Ordering of rationals
Expand Down Expand Up @@ -156,7 +155,7 @@ NonNegative p = ℤ.NonNegative (↥ p)
-- from ℤ but it requires importing `Data.Integer.Properties` which
-- we would like to avoid doing.

≢-nonZero : ∀ {p} → p 0ℚᵘ → NonZero p
≢-nonZero : ∀ {p} → p 0ℚᵘ → NonZero p
≢-nonZero {mkℚᵘ -[1+ _ ] _ } _ = _
≢-nonZero {mkℚᵘ +[1+ _ ] _ } _ = _
≢-nonZero {mkℚᵘ +0 zero } p≢0 = contradiction (*≡* refl) p≢0
Expand Down Expand Up @@ -378,3 +377,8 @@ Please use +-0-rawMonoid instead."
"Warning: *-rawMonoid was deprecated in v2.0
Please use *-1-rawMonoid instead."
#-}
_≠_ = _≄_
{-# WARNING_ON_USAGE _≠_
"Warning: _≠_ was deprecated in v2.0
Please use _≄_ instead."
#-}
66 changes: 32 additions & 34 deletions src/Data/Rational/Unnormalised/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ open import Data.Sum.Base using (_⊎_; [_,_]′; inj₁; inj₂)
import Data.Sign as Sign
open import Function.Base using (_on_; _$_; _∘_; flip)
open import Level using (0ℓ)
open import Relation.Nullary using (¬_; yes; no)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Negation using (contradiction; contraposition)
open import Relation.Nullary.Decidable.Core as Dec using (yes; no)
open import Relation.Nullary.Negation.Core using (¬_; contradiction)
open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
open import Relation.Binary.Bundles
using (Setoid; DecSetoid; Preorder; TotalPreorder; Poset; TotalOrder; DecTotalOrder; StrictPartialOrder; StrictTotalOrder; DenseLinearOrder)
Expand All @@ -43,7 +42,6 @@ open import Relation.Binary.Definitions
import Relation.Binary.Consequences as BC
open import Relation.Binary.PropositionalEquality
import Relation.Binary.Properties.Poset as PosetProperties
open import Relation.Nullary using (yes; no)
import Relation.Binary.Reasoning.Setoid as SetoidReasoning

open import Algebra.Properties.CommutativeSemigroup ℤ.*-commutativeSemigroup
Expand Down Expand Up @@ -105,20 +103,20 @@ infix 4 _≃?_
_≃?_ : Decidable _≃_
p ≃? q = Dec.map′ *≡* drop-*≡* (↥ p ℤ.* ↧ q ℤ.≟ ↥ q ℤ.* ↧ p)

01 : 0ℚᵘ 1ℚᵘ
01 = Dec.from-no (0ℚᵘ ≃? 1ℚᵘ)
01 : 0ℚᵘ 1ℚᵘ
01 = Dec.from-no (0ℚᵘ ≃? 1ℚᵘ)

≃--irreflexive : Irreflexive _≃_ __
≃--irreflexive x≃y xy = xy x≃y
≃--irreflexive : Irreflexive _≃_ __
≃--irreflexive x≃y xy = xy x≃y

-symmetric : Symmetric __
-symmetric xy y≃x = xy (≃-sym y≃x)
-symmetric : Symmetric __
-symmetric xy y≃x = xy (≃-sym y≃x)

-cotransitive : Cotransitive __
-cotransitive {x} {y} xy z with x ≃? z | z ≃? y
... | no xz | _ = inj₁ xz
... | yes _ | no zy = inj₂ zy
... | yes x≃z | yes z≃y = contradiction (≃-trans x≃z z≃y) xy
-cotransitive : Cotransitive __
-cotransitive {x} {y} xy z with x ≃? z | z ≃? y
... | no xz | _ = inj₁ xz
... | yes _ | no zy = inj₂ zy
... | yes x≃z | yes z≃y = contradiction (≃-trans x≃z z≃y) xy

≃-isEquivalence : IsEquivalence _≃_
≃-isEquivalence = record
Expand All @@ -133,16 +131,16 @@ p ≃? q = Dec.map′ *≡* drop-*≡* (↥ p ℤ.* ↧ q ℤ.≟ ↥ q ℤ.*
; _≟_ = _≃?_
}

-isApartnessRelation : IsApartnessRelation _≃_ __
-isApartnessRelation = record
{ irrefl = ≃--irreflexive
; sym = -symmetric
; cotrans = -cotransitive
-isApartnessRelation : IsApartnessRelation _≃_ __
-isApartnessRelation = record
{ irrefl = ≃--irreflexive
; sym = -symmetric
; cotrans = -cotransitive
}

-tight : Tight _≃_ __
proj₁ (-tight p q) ¬pq = Dec.decidable-stable (p ≃? q) ¬pq
proj₂ (-tight p q) p≃q pq = pq p≃q
-tight : Tight _≃_ __
proj₁ (-tight p q) ¬pq = Dec.decidable-stable (p ≃? q) ¬pq
proj₂ (-tight p q) p≃q pq = pq p≃q

≃-setoid : Setoid 0ℓ 0ℓ
≃-setoid = record
Expand Down Expand Up @@ -1127,11 +1125,11 @@ p≤q⇒0≤q-p {p} {q} p≤q = begin
*-inverseʳ : ∀ p .{{_ : NonZero p}} → p * 1/ p ≃ 1ℚᵘ
*-inverseʳ p = ≃-trans (*-comm p (1/ p)) (*-inverseˡ p)

⇒invertible : p q → Invertible _≃_ 1ℚᵘ _*_ (p - q)
⇒invertible {p} {q} pq = _ , *-inverseˡ (p - q) , *-inverseʳ (p - q)
⇒invertible : p q → Invertible _≃_ 1ℚᵘ _*_ (p - q)
⇒invertible {p} {q} pq = _ , *-inverseˡ (p - q) , *-inverseʳ (p - q)
where instance
_ : NonZero (p - q)
_ = ≢-nonZero (pq ∘ p-q≃0⇒p≃q p q)
_ = ≢-nonZero (pq ∘ p-q≃0⇒p≃q p q)

*-zeroˡ : LeftZero _≃_ 0ℚᵘ _*_
*-zeroˡ p@record{} = *≡* refl
Expand All @@ -1142,8 +1140,8 @@ p≤q⇒0≤q-p {p} {q} p≤q = begin
*-zero : Zero _≃_ 0ℚᵘ _*_
*-zero = *-zeroˡ , *-zeroʳ

invertible⇒ : Invertible _≃_ 1ℚᵘ _*_ (p - q) → p q
invertible⇒ {p} {q} (1/p-q , 1/x*x≃1 , x*1/x≃1) p≃q = 01 (begin
invertible⇒ : Invertible _≃_ 1ℚᵘ _*_ (p - q) → p q
invertible⇒ {p} {q} (1/p-q , 1/x*x≃1 , x*1/x≃1) p≃q = 01 (begin
0ℚᵘ ≈˘⟨ *-zeroˡ 1/p-q ⟩
0ℚᵘ * 1/p-q ≈˘⟨ *-congʳ (p≃q⇒p-q≃0 p q p≃q) ⟩
(p - q) * 1/p-q ≈⟨ x*1/x≃1 ⟩
Expand Down Expand Up @@ -1390,18 +1388,18 @@ nonNeg*nonNeg⇒nonNeg p q = nonNegative
; *-comm = *-comm
}

+-*-isHeytingCommutativeRing : IsHeytingCommutativeRing _≃_ __ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
+-*-isHeytingCommutativeRing : IsHeytingCommutativeRing _≃_ __ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
+-*-isHeytingCommutativeRing = record
{ isCommutativeRing = +-*-isCommutativeRing
; isApartnessRelation = -isApartnessRelation
; #⇒invertible = ⇒invertible
; invertible⇒# = invertible⇒
; isApartnessRelation = -isApartnessRelation
; #⇒invertible = ⇒invertible
; invertible⇒# = invertible⇒
}

+-*-isHeytingField : IsHeytingField _≃_ __ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
+-*-isHeytingField : IsHeytingField _≃_ __ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
+-*-isHeytingField = record
{ isHeytingCommutativeRing = +-*-isHeytingCommutativeRing
; tight = -tight
; tight = -tight
}

------------------------------------------------------------------------
Expand Down