Skip to content

Examples.Classical.Groups.AbelianGroup

Worked example: (ℤ, +, 0, -) as an abelian group

This is the Examples.Classical.Groups.AbelianGroup module of the Agda Universal Algebra Library.

The integers under addition are the canonical abelian group — the same carrier and operations as the CyclicGroup example, now additionally witnessing commutativity via stdlib's +-comm.

{-# OPTIONS --cubical-compatible --exact-split --safe #-}

module Examples.Classical.Groups.AbelianGroup where

-- Imports from the Agda Standard Library -------------------------------------
open import Data.Integer             using (  ; _+_ ; 0ℤ ; -_ )
open import Data.Integer.Properties  using ( +-assoc ; +-identityˡ ; +-identityʳ
                                           ; +-inverseˡ ; +-inverseʳ ; +-comm )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )

-- Imports from the Agda Universal Algebra Library ----------------------------
open import Classical.Bundles.AbelianGroup           using ( ⟨_⟩ᵃᵍ ; ⟪_⟫ᵃᵍ )
open import Classical.Small.Structures.AbelianGroup  using ( AbelianGroup ; eqsToAbelianGroup )

import Classical.Structures.AbelianGroup as Polymorphic

The abelian group (ℤ, +, 0, -)

ℤ-abelianGroup : AbelianGroup
ℤ-abelianGroup =
  eqsToAbelianGroup  _+_ 0ℤ -_ +-assoc +-identityˡ +-identityʳ +-inverseˡ +-inverseʳ +-comm

open Polymorphic.AbelianGroup-Op ℤ-abelianGroup using ( _∙_ ; ε ; _⁻¹ )

Acceptance checks

∙-is-+-ag :  (a b : )  a  b  a + b
∙-is-+-ag a b = refl

ε-is-0-ag : ε  0ℤ
ε-is-0-ag = refl

⁻¹-is-neg-ag :  (a : )  a ⁻¹  - a
⁻¹-is-neg-ag a = refl

The bundle round-trips pointwise on the operation, the identity, and the inverse.

open Polymorphic.AbelianGroup-Op   ℤ-abelianGroup ⟩ᵃᵍ ⟫ᵃᵍ using ()
  renaming ( _∙_ to _·_ ; ε to ε· ; _⁻¹ to _⁻¹· )

roundtrip-∙-ag :  (a b : )  a · b  a + b
roundtrip-∙-ag a b = refl

roundtrip-ε-ag : ε·  0ℤ
roundtrip-ε-ag = refl

roundtrip-⁻¹-ag :  (a : )  a ⁻¹·  - a
roundtrip-⁻¹-ag a = refl