| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of Heyting Commutative Rings |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Apartness.Bundles using (HeytingCommutativeRing) |
| 10 |
|
| 11 |
module Algebra.Apartness.Properties.HeytingCommutativeRing |
| 12 |
{c ℓ₁ ℓ₂} (HCR : HeytingCommutativeRing c ℓ₁ ℓ₂) where |
| 13 |
|
| 14 |
open import Function.Base using (_∘_) |
| 15 |
open import Data.Product.Base using (_,_; proj₁; proj₂) |
| 16 |
open import Algebra using (CommutativeRing; RightIdentity; Invertible; LeftInvertible; RightInvertible) |
| 17 |
|
| 18 |
open HeytingCommutativeRing HCR |
| 19 |
open CommutativeRing commutativeRing using (ring; *-commutativeMonoid) |
| 20 |
|
| 21 |
open import Algebra.Properties.Ring ring |
| 22 |
using (-0#≈0#; -‿distribˡ-*; -‿distribʳ-*; -‿anti-homo-+; -‿involutive) |
| 23 |
open import Relation.Binary.Definitions using (Symmetric) |
| 24 |
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning |
| 25 |
open import Algebra.Properties.CommutativeMonoid *-commutativeMonoid |
| 26 |
|
| 27 |
private variable |
| 28 |
x y z : Carrier |
| 29 |
|
| 30 |
invertibleˡ⇒# : LeftInvertible _≈_ 1# _*_ (x - y) → x # y |
| 31 |
invertibleˡ⇒# = invertible⇒# ∘ invertibleˡ⇒invertible |
| 32 |
|
| 33 |
invertibleʳ⇒# : RightInvertible _≈_ 1# _*_ (x - y) → x # y |
| 34 |
invertibleʳ⇒# = invertible⇒# ∘ invertibleʳ⇒invertible |
| 35 |
|
| 36 |
x-0≈x : RightIdentity _≈_ 0# _-_ |
| 37 |
x-0≈x x = trans (+-congˡ -0#≈0#) (+-identityʳ x) |
| 38 |
|
| 39 |
1#0 : 1# # 0# |
| 40 |
1#0 = invertibleˡ⇒# (1# , 1*[x-0]≈x) |
| 41 |
where |
| 42 |
1*[x-0]≈x : 1# * (x - 0#) ≈ x |
| 43 |
1*[x-0]≈x {x} = trans (*-identityˡ (x - 0#)) (x-0≈x x) |
| 44 |
|
| 45 |
x#0y#0→xy#0 : x # 0# → y # 0# → x * y # 0# |
| 46 |
x#0y#0→xy#0 {x} {y} x#0 y#0 = helper (#⇒invertible x#0) (#⇒invertible y#0) |
| 47 |
where |
| 48 |
|
| 49 |
helper : Invertible _≈_ 1# _*_ (x - 0#) → Invertible _≈_ 1# _*_ (y - 0#) → x * y # 0# |
| 50 |
helper (x⁻¹ , x⁻¹*x≈1 , x*x⁻¹≈1) (y⁻¹ , y⁻¹*y≈1 , y*y⁻¹≈1) |
| 51 |
= invertibleˡ⇒# (y⁻¹ * x⁻¹ , y⁻¹*x⁻¹*x*y≈1) |
| 52 |
where |
| 53 |
open ≈-Reasoning setoid |
| 54 |
|
| 55 |
y⁻¹*x⁻¹*x*y≈1 : y⁻¹ * x⁻¹ * (x * y - 0#) ≈ 1# |
| 56 |
y⁻¹*x⁻¹*x*y≈1 = begin |
| 57 |
y⁻¹ * x⁻¹ * (x * y - 0#) ≈⟨ *-congˡ (x-0≈x (x * y)) ⟩ |
| 58 |
y⁻¹ * x⁻¹ * (x * y) ≈⟨ *-assoc y⁻¹ x⁻¹ (x * y) ⟩ |
| 59 |
y⁻¹ * (x⁻¹ * (x * y)) ≈⟨ *-congˡ (*-assoc x⁻¹ x y) ⟨ |
| 60 |
y⁻¹ * ((x⁻¹ * x) * y) ≈⟨ *-congˡ (*-congʳ (*-congˡ (x-0≈x x))) ⟨ |
| 61 |
y⁻¹ * ((x⁻¹ * (x - 0#)) * y) ≈⟨ *-congˡ (*-congʳ x⁻¹*x≈1) ⟩ |
| 62 |
y⁻¹ * (1# * y) ≈⟨ *-congˡ (*-identityˡ y) ⟩ |
| 63 |
y⁻¹ * y ≈⟨ *-congˡ (x-0≈x y) ⟨ |
| 64 |
y⁻¹ * (y - 0#) ≈⟨ y⁻¹*y≈1 ⟩ |
| 65 |
1# ∎ |
| 66 |
|
| 67 |
#-congʳ : x ≈ y → x # z → y # z |
| 68 |
#-congʳ {x} {y} {z} x≈y x#z = helper (#⇒invertible x#z) |
| 69 |
where |
| 70 |
|
| 71 |
helper : Invertible _≈_ 1# _*_ (x - z) → y # z |
| 72 |
helper (x-z⁻¹ , x-z⁻¹*x-z≈1# , x-z*x-z⁻¹≈1#) |
| 73 |
= invertibleˡ⇒# (x-z⁻¹ , x-z⁻¹*y-z≈1) |
| 74 |
where |
| 75 |
open ≈-Reasoning setoid |
| 76 |
|
| 77 |
x-z⁻¹*y-z≈1 : x-z⁻¹ * (y - z) ≈ 1# |
| 78 |
x-z⁻¹*y-z≈1 = begin |
| 79 |
x-z⁻¹ * (y - z) ≈⟨ *-congˡ (+-congʳ x≈y) ⟨ |
| 80 |
x-z⁻¹ * (x - z) ≈⟨ x-z⁻¹*x-z≈1# ⟩ |
| 81 |
1# ∎ |
| 82 |
|
| 83 |
#-congˡ : y ≈ z → x # y → x # z |
| 84 |
#-congˡ y≈z x#y = #-sym (#-congʳ y≈z (#-sym x#y)) |