| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some properties of operations in CancellativeCommutativeSemiring. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Bundles using (CancellativeCommutativeSemiring) |
| 10 |
|
| 11 |
module Algebra.Properties.CancellativeCommutativeSemiring |
| 12 |
{a ℓ} (R : CancellativeCommutativeSemiring a ℓ) |
| 13 |
where |
| 14 |
|
| 15 |
open import Algebra.Definitions using (AlmostRightCancellative) |
| 16 |
open import Data.Sum.Base using (_⊎_; inj₁; inj₂) |
| 17 |
open import Relation.Binary.Definitions using (Decidable) |
| 18 |
open import Relation.Nullary.Decidable using (yes; no) |
| 19 |
open import Relation.Nullary.Negation using (contradiction) |
| 20 |
|
| 21 |
open CancellativeCommutativeSemiring R |
| 22 |
open import Algebra.Consequences.Setoid setoid |
| 23 |
open import Relation.Binary.Reasoning.Setoid setoid |
| 24 |
|
| 25 |
*-almostCancelʳ : AlmostRightCancellative _≈_ 0# _*_ |
| 26 |
*-almostCancelʳ = comm∧almostCancelˡ⇒almostCancelʳ *-comm *-cancelˡ-nonZero |
| 27 |
|
| 28 |
xy≈0⇒x≈0∨y≈0 : Decidable _≈_ → ∀ {x y} → x * y ≈ 0# → x ≈ 0# ⊎ y ≈ 0# |
| 29 |
xy≈0⇒x≈0∨y≈0 _≟_ {x} {y} xy≈0 with x ≟ 0# | y ≟ 0# |
| 30 |
... | yes x≈0 | _ = inj₁ x≈0 |
| 31 |
... | no _ | yes y≈0 = inj₂ y≈0 |
| 32 |
... | no x≉0 | no y≉0 = contradiction y≈0 y≉0 |
| 33 |
where |
| 34 |
xy≈x*0 = trans xy≈0 (sym (zeroʳ x)) |
| 35 |
y≈0 = *-cancelˡ-nonZero _ y 0# x≉0 xy≈x*0 |
| 36 |
|
| 37 |
x≉0∧y≉0⇒xy≉0 : Decidable _≈_ → ∀ {x y} → x ≉ 0# → y ≉ 0# → x * y ≉ 0# |
| 38 |
x≉0∧y≉0⇒xy≉0 _≟_ x≉0 y≉0 xy≈0 with xy≈0⇒x≈0∨y≈0 _≟_ xy≈0 |
| 39 |
... | inj₁ x≈0 = x≉0 x≈0 |
| 40 |
... | inj₂ y≈0 = y≉0 y≈0 |