module Algebra.Group.Instances.Integers where
The group of integersπ
The fundamental example of an abelian group is the group of integers, under addition.
β€-ab : Abelian-group lzero β€-ab = to-ab mk-β€ where open make-abelian-group mk-β€ : make-abelian-group Int mk-β€ .ab-is-set = hlevel 2 mk-β€ .mul x y = x +β€ y mk-β€ .inv x = negβ€ x mk-β€ .1g = 0 mk-β€ .idl x = +β€-zerol x mk-β€ .assoc x y z = +β€-assoc x y z mk-β€ .invl x = +β€-invl x mk-β€ .comm x y = +β€-commutative x y β€ : Group lzero β€ = AbelianβGroup β€-ab
We show that
is the free
group on one generator, i.e.Β the free object on
relative to the forgetful functor from groups to sets, GrpβͺSets
.
We start by defining the group homomorphism that sends to (or, in additive notation, where is a group and is an element of using the universal property of the integers.
module pow (x : β G β) where pow : Int β β G β pow = β€.map-out unit ((_β x) , β-equivr x) pow-sucr : β a β pow (sucβ€ a) β‘ pow a β x pow-sucr = β€.map-out-rotate _ _ pow-+ : β a b β pow (a +β€ b) β‘ pow a β pow b pow-+ a = β€.induction (ap pow (+β€-zeror a) β sym idr) Ξ» b β pow (a +β€ b) β‘ pow a β pow b ββ¨ ap (_β x) , equivβcancellable (β-equivr x) β©β pow (a +β€ b) β x β‘ (pow a β pow b) β x ββ¨ β-post-equiv (sym associative) β©β pow (a +β€ b) β x β‘ pow a β pow b β x ββ¨ β-post-equiv (ap (pow a β_) (sym (pow-sucr b))) β©β pow (a +β€ b) β x β‘ pow a β pow (sucβ€ b) ββ¨ β-pre-equiv (pow-sucr (a +β€ b)) β©β pow (sucβ€ (a +β€ b)) β‘ pow a β pow (sucβ€ b) ββ¨ β-pre-equiv (ap pow (+β€-sucr a b)) β©β pow (a +β€ sucβ€ b) β‘ pow a β pow (sucβ€ b) ββ
A type-theoretic interjection is necessary: the integers live on the zeroth universe, so to have an group of integers, we must lift it.
pow-hom : Groups.Hom (LiftGroup β β€) G pow-hom .hom (lift i) = pow i pow-hom .preserves .pres-β (lift a) (lift b) = pow-+ a b
This is the unique group homomorphism that sends to
pow-unique : (g : Groups.Hom (LiftGroup β β€) G) β g # 1 β‘ x β g β‘ pow-hom pow-unique g g1β‘x = ext $ β€.map-out-unique (Ξ» i β g # lift i) (pres-id (g .preserves)) Ξ» y β g # lift β sucβ€ y β β‘β¨ ap! (sym (+β€-oner y)) β©β‘ g # lift (y +β€ 1) β‘β¨ g .preserves .pres-β (lift y) 1 β©β‘ g # lift y β g # 1 β‘β¨ ap (g # lift y β_) g1β‘x β©β‘ g # lift y β x β open pow public
We prove some other useful basic properties of exponentiation. 1
pow-sucl : β x a β pow x (sucβ€ a) β‘ x β pow x a
pow-0 : β x β pow x 0 β‘ unit
pow-1 : β x β pow x 1 β‘ x
pow-* : β x a b β pow x (a *β€ b) β‘ pow (pow x a) b
pow-unit : β n β pow unit n β‘ unit
pow-inverse : β x n β pow (x β»ΒΉ) n β‘ pow x n β»ΒΉ
pow-sucl x a = pow x (sucβ€ a) β‘Λβ¨ ap (pow x) (+β€-onel a) β©β‘Λ pow x (1 +β€ a) β‘β¨ pow-+ x 1 a β©β‘ pow x 1 β pow x a β‘β¨ ap (_β pow x a) (pow-1 x) β©β‘ x β pow x a β pow-0 x = refl pow-1 x = idl pow-* x a = β€.induction (ap (pow x) (*β€-zeror a)) Ξ» b β pow x (a *β€ b) β‘ pow (pow x a) b ββ¨ _ , equivβcancellable (β-equivr _) β©β pow x (a *β€ b) β pow x a β‘ pow (pow x a) b β pow x a ββ¨ β-pre-equiv (pow-+ x (a *β€ b) a) β©β pow x (a *β€ b +β€ a) β‘ pow (pow x a) b β pow x a ββ¨ β-pre-equiv (ap (pow x) (*β€-sucr a b)) β©β pow x (a *β€ sucβ€ b) β‘ pow (pow x a) b β pow x a ββ¨ β-post-equiv (sym (pow-sucr (pow x a) b)) β©β pow x (a *β€ sucβ€ b) β‘ pow (pow x a) (sucβ€ b) ββ pow-unit = β€.induction refl (Ξ» x β β-pre-equiv (pow-sucr unit x β idr)) pow-inverse x = β€.induction (sym inv-unit) Ξ» n β pow (x β»ΒΉ) n β‘ pow x n β»ΒΉ ββ¨ _ , equivβcancellable (β-equivr (x β»ΒΉ)) β©β pow (x β»ΒΉ) n β x β»ΒΉ β‘ pow x n β»ΒΉ β x β»ΒΉ ββ¨ β-pre-equiv (pow-sucr (x β»ΒΉ) n) β©β pow (x β»ΒΉ) (sucβ€ n) β‘ pow x n β»ΒΉ β x β»ΒΉ ββ¨ β-post-equiv (sym inv-comm) β©β pow (x β»ΒΉ) (sucβ€ n) β‘ (x β pow x n) β»ΒΉ ββ¨ β-post-equiv (ap _β»ΒΉ (sym (pow-sucl x n))) β©β pow (x β»ΒΉ) (sucβ€ n) β‘ pow x (sucβ€ n) β»ΒΉ ββ
Finally, the properties above imply that is the free group on one generator.
β€-free : Free-object GrpβͺSets (el! β€) β€-free .Free-object.free = LiftGroup lzero β€ β€-free .Free-object.unit _ = 1 β€-free .Free-object.fold {G} x = pow-hom G (x _) β€-free .Free-object.commute {G} {x} = ext Ξ» _ β pow-1 G (x _) β€-free .Free-object.unique {G} {x} g comm = pow-unique G (x _) g (unext comm _)
While the notation
for pow
makes sense in multiplicative
notation, we would instead write
in additive notation. In fact, we can show that
coincides with the multiplication
in the group of integers itself.
pow-β€ : β a b β pow β€ a b β‘ a *β€ b
pow-β€ a = β€.induction (sym (*β€-zeror a)) Ξ» b β
pow β€ a b β‘ a *β€ b ββ¨ ap (_+β€ a) , equivβcancellable (Group-on.β-equivr (β€ .snd) a) β©β
pow β€ a b +β€ a β‘ a *β€ b +β€ a ββ¨ β-pre-equiv (pow-sucr β€ a b) β©β
pow β€ a (sucβ€ b) β‘ a *β€ b +β€ a ββ¨ β-post-equiv (sym (*β€-sucr a b)) β©β
pow β€ a (sucβ€ b) β‘ a *β€ sucβ€ b ββ
Order of an elementπ
We define the order of an element of a group as the minimal positive2 integer such that if it exists.
In particular, if then we have that the order of divides We define this notion first in the code, then use it to define the order of
order-divides : β G β β Nat β Type β order-divides x n = pow G x (pos n) β‘ unit has-finite-order : β G β β Type β has-finite-order x = minimal-solution Ξ» n β Positive n Γ order-divides x n order : (x : β G β) β has-finite-order x β Nat order x (n , _) = n
An element with finite order is also called a torsion element. A group all of whose elements are torsion is called a torsion group, while a group whose only torsion element is the unit is called torsion-free.
is-torsion-group : Type β is-torsion-group = β g β has-finite-order g is-torsion-free : Type β is-torsion-free = β g β has-finite-order g β g β‘ unit
Our definition of torsion groups requires being able to compute the order of every element of the group. There is a weaker definition that only requires every element to have some such that the two definitions are equivalent if the group is discrete, since is well-ordered.
We quickly note that is torsion-free, since multiplication by a nonzero integer is injective.
β€-torsion-free : is-torsion-free β€ β€-torsion-free n (k , (k>0 , nkβ‘0) , _) = *β€-injectiver (pos k) n 0 (Ξ» p β <-not-equal k>0 (pos-injective (sym p))) (sym (pow-β€ n (pos k)) β nkβ‘0)
Pedantically, these properties say that
pow
is the unique near-ring homomorphism from the initial near-ring, to the near-ring of (pointed) endofunctions of a generalisation of endomorphism rings to non-abelian groups.β©οΈWithout this requirement, every element would trivially have order β©οΈ