diff --git a/Cubical/Algebra/AbGroup/Instances/Fast/Int.agda b/Cubical/Algebra/AbGroup/Instances/Fast/Int.agda new file mode 100644 index 0000000000..262535dcb3 --- /dev/null +++ b/Cubical/Algebra/AbGroup/Instances/Fast/Int.agda @@ -0,0 +1,9 @@ +module Cubical.Algebra.AbGroup.Instances.Fast.Int where + +open import Cubical.Foundations.Prelude +open import Cubical.Data.Fast.Int +open import Cubical.Algebra.AbGroup.Base +open import Cubical.Algebra.Group.Instances.Fast.Int + +ℤAbGroup : AbGroup ℓ-zero +ℤAbGroup = Group→AbGroup ℤGroup +Comm diff --git a/Cubical/Algebra/CommRing/Instances/Fast/Int.agda b/Cubical/Algebra/CommRing/Instances/Fast/Int.agda new file mode 100644 index 0000000000..e01dde2d62 --- /dev/null +++ b/Cubical/Algebra/CommRing/Instances/Fast/Int.agda @@ -0,0 +1,23 @@ +module Cubical.Algebra.CommRing.Instances.Fast.Int where + +open import Cubical.Foundations.Prelude + +open import Cubical.Algebra.CommRing +open import Cubical.Data.Fast.Int as Int renaming (_+_ to _+ℤ_; _·_ to _·ℤ_ ; -_ to -ℤ_) + +open CommRingStr using (0r ; 1r ; _+_ ; _·_ ; -_ ; isCommRing) + +ℤCommRing : CommRing ℓ-zero +fst ℤCommRing = ℤ +0r (snd ℤCommRing) = pos 0 +1r (snd ℤCommRing) = pos 1 +_+_ (snd ℤCommRing) = _+ℤ_ +_·_ (snd ℤCommRing) = _·ℤ_ +- snd ℤCommRing = -ℤ_ +isCommRing (snd ℤCommRing) = isCommRingℤ + where + abstract + isCommRingℤ : IsCommRing (pos 0) (pos 1) _+ℤ_ _·ℤ_ -ℤ_ + isCommRingℤ = makeIsCommRing isSetℤ Int.+Assoc +IdR + -Cancel Int.+Comm Int.·Assoc + Int.·IdR ·DistR+ Int.·Comm diff --git a/Cubical/Algebra/Group/Instances/Fast/Int.agda b/Cubical/Algebra/Group/Instances/Fast/Int.agda new file mode 100644 index 0000000000..60cdc00788 --- /dev/null +++ b/Cubical/Algebra/Group/Instances/Fast/Int.agda @@ -0,0 +1,56 @@ +module Cubical.Algebra.Group.Instances.Fast.Int where + +open import Cubical.Foundations.Prelude +open import Cubical.Foundations.Isomorphism +open import Cubical.Foundations.Function + +open import Cubical.Data.Fast.Int renaming (_+_ to _+ℤ_ ; _-_ to _-ℤ_ ; _·_ to _·ℤ_ ; -_ to -ℤ_) + +open import Cubical.Data.Nat using (ℕ ; zero ; suc) +open import Cubical.Data.Fin.Base + +open import Cubical.Algebra.Group.Base +open import Cubical.Algebra.Group.Properties +open import Cubical.Algebra.Group.Morphisms +open import Cubical.Algebra.Group.MorphismProperties + + +open GroupStr + +ℤGroup : Group₀ +fst ℤGroup = ℤ +1g (snd ℤGroup) = 0 +_·_ (snd ℤGroup) = _+ℤ_ +inv (snd ℤGroup) = -ℤ_ +isGroup (snd ℤGroup) = isGroupℤ + where + abstract + isGroupℤ : IsGroup (pos 0) (_+ℤ_) (-ℤ_) + isGroupℤ = makeIsGroup isSetℤ + +Assoc +IdR +IdL + -Cancel -Cancel' + +ℤHom : (n : ℤ) → GroupHom ℤGroup ℤGroup +fst (ℤHom n) x = n ·ℤ x +snd (ℤHom n) = + makeIsGroupHom λ x y → ·DistR+ n x y + +negEquivℤ : GroupEquiv ℤGroup ℤGroup +fst negEquivℤ = + isoToEquiv + (iso (GroupStr.inv (snd ℤGroup)) + (GroupStr.inv (snd ℤGroup)) + (GroupTheory.invInv ℤGroup) + (GroupTheory.invInv ℤGroup)) +snd negEquivℤ = + makeIsGroupHom -Dist+ + +sumFinGroupℤComm : (G : Group₀) (h : GroupIso G ℤGroup) {n : ℕ} + (f : Fin n → fst G) → sumFinℤ {n = n} (λ a → Iso.fun (fst h) (f a)) + ≡ Iso.fun (fst h) (sumFinGroup G {n = n} f) +sumFinGroupℤComm G h {n = zero} f = sym (IsGroupHom.pres1 (snd h)) +sumFinGroupℤComm G h {n = suc n} f = + cong₂ _+ℤ_ (λ _ → Iso.fun (fst h) (f flast)) + (sumFinGroupℤComm G h {n = n} (f ∘ injectSuc {n = n})) + ∙ sym (IsGroupHom.pres· (snd h) (f flast) + (sumFinGroup G {n = n} (λ x → f (injectSuc {n = n} x)))) diff --git a/Cubical/Algebra/OrderedCommRing/Instances/Fast/Int.agda b/Cubical/Algebra/OrderedCommRing/Instances/Fast/Int.agda new file mode 100644 index 0000000000..45a38d41c6 --- /dev/null +++ b/Cubical/Algebra/OrderedCommRing/Instances/Fast/Int.agda @@ -0,0 +1,66 @@ +module Cubical.Algebra.OrderedCommRing.Instances.Fast.Int where + +open import Cubical.Foundations.Prelude +open import Cubical.Foundations.Function +open import Cubical.Foundations.Equiv + +open import Cubical.Data.Empty as ⊥ + +open import Cubical.HITs.PropositionalTruncation + +open import Cubical.Data.Fast.Int as ℤ + renaming (_+_ to _+ℤ_ ; _-_ to _-ℤ_; -_ to -ℤ_ ; _·_ to _·ℤ_) +open import Cubical.Data.Fast.Int.Order + renaming (_<_ to _<ℤ_ ; _≤_ to _≤ℤ_) + +open import Cubical.Algebra.CommRing +open import Cubical.Algebra.CommRing.Instances.Fast.Int + +open import Cubical.Algebra.OrderedCommRing + +open import Cubical.Relation.Nullary + +open import Cubical.Relation.Binary.Order.StrictOrder +open import Cubical.Relation.Binary.Order.StrictOrder.Instances.Fast.Int + +open import Cubical.Relation.Binary.Order.Pseudolattice +open import Cubical.Relation.Binary.Order.Pseudolattice.Instances.Fast.Int + +open import Cubical.Relation.Binary +open BinaryRelation + +open CommRingStr +open OrderedCommRingStr +open PseudolatticeStr +open StrictOrderStr + +ℤOrderedCommRing : OrderedCommRing ℓ-zero ℓ-zero +fst ℤOrderedCommRing = ℤ +0r (snd ℤOrderedCommRing) = 0 +1r (snd ℤOrderedCommRing) = 1 +_+_ (snd ℤOrderedCommRing) = _+ℤ_ +_·_ (snd ℤOrderedCommRing) = _·ℤ_ +-_ (snd ℤOrderedCommRing) = -ℤ_ +_<_ (snd ℤOrderedCommRing) = _<ℤ_ +_≤_ (snd ℤOrderedCommRing) = _≤ℤ_ +isOrderedCommRing (snd ℤOrderedCommRing) = isOrderedCommRingℤ + where + open IsOrderedCommRing + + isOrderedCommRingℤ : IsOrderedCommRing 0 1 _+ℤ_ _·ℤ_ -ℤ_ _<ℤ_ _≤ℤ_ + isOrderedCommRingℤ .isCommRing = ℤCommRing .snd .isCommRing + isOrderedCommRingℤ .isPseudolattice = ℤ≤Pseudolattice .snd .is-pseudolattice + isOrderedCommRingℤ .isStrictOrder = ℤ = λ x y → + propBiimpl→Equiv isProp≤ (isProp¬ (y <ℤ x)) + (λ x≤y y_ + +data _≤_ : ℤ → ℤ → Type where + pos≤pos : ∀ {x y} → x ℕ.≤ᵗ y → pos x ≤ pos y + negsuc≤negsuc : ∀ {x y} → x ℕ.≥ᵗ y → negsuc x ≤ negsuc y + negsuc≤pos : ∀ {x y} → negsuc x ≤ pos y + +data _<_ : ℤ → ℤ → Type where + posᵗ y → negsuc x < negsuc y + negsuc_ : ℤ → ℤ → Type +_≥_ = flip _≤_ +_>_ = flip _<_ + +¬pos≤negsuc : ∀ {x y} → ¬ pos x ≤ negsuc y +¬pos≤negsuc () + +¬posℕ→¬negsucᵗ y) → ¬ negsuc x < negsuc y +¬>ℕ→¬negsucℕ→¬negsucℕ→¬negsucnegsuc : pos k < pos l → negsuc k > negsuc l +posnegsuc (pospos : negsuc k < negsuc l → pos k > pos l +negsucpos (negsucneg : pos k < pos l → neg k > neg l +posneg {zero} {suc l} (posneg {suc k} {suc l} (posnegsuc + (subst (_< pos k ℤ.+ pos (suc m ℕ.· suc k)) (sym (ℤ.+IdR (pos k))) ℕ→¬negsuc