Files
agdaproofs/Numbers/Modulo/Group.agda
2020-04-18 17:47:27 +01:00

59 lines
3.0 KiB
Agda
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Groups.Abelian.Definition
open import Groups.FiniteGroups.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.Lemmas
open import Setoids.Setoids
open import Sets.FinSet.Definition
open import Sets.FinSet.Lemmas
open import Functions.Definition
open import Functions.Lemmas
open import Semirings.Definition
open import Numbers.Modulo.Definition
open import Numbers.Modulo.Addition
open import Orders.Total.Definition
open import Numbers.Modulo.ModuloFunction
module Numbers.Modulo.Group where
open TotalOrder TotalOrder
open Semiring Semiring
private
0<s : {n : } 0 <N succ n
0<s {n} = le n (applyEquality succ (Semiring.sumZeroRight Semiring n))
inverseN : {n : } .(0<n : 0 <N n) (x : n n 0<n) n n 0<n
inverseN 0<n record { x = 0 ; xLess = _ } = record { x = 0 ; xLess = 0<n }
inverseN 0<n record { x = succ x ; xLess = xLess } with <NProp xLess
... | le subtr pr = record { x = succ subtr ; xLess = le x (transitivity (commutative (succ x) (succ subtr)) pr) }
invLeft : {n : } .(0<n : 0 <N n) (x : n n 0<n) _+n_ 0<n (inverseN 0<n x) x record { x = 0 ; xLess = 0<n }
invLeft {n} 0<n record { x = 0 ; xLess = xLess } = plusZnIdentityLeft 0<n (record { x = 0 ; xLess = 0<n })
invLeft {n} 0<n record { x = (succ x) ; xLess = xLess } with <NProp xLess
... | le subtr pr rewrite pr = equalityZn (modN 0<n)
nGroup : (n : ) .(pr : 0 <N n) Group (reflSetoid (n n pr)) (_+n_ pr)
Group.+WellDefined (nGroup n 0<n) refl refl = refl
Group.0G (nGroup n 0<n) = record { x = 0 ; xLess = 0<n }
Group.inverse (nGroup n 0<n) = inverseN 0<n
Group.+Associative (nGroup n 0<n) {a} {b} {c} = equalityCommutative (plusZnAssociative 0<n a b c)
Group.identRight (nGroup n 0<n) {a} = plusZnIdentityRight 0<n a
Group.identLeft (nGroup n 0<n) {a} = plusZnIdentityLeft 0<n a
Group.invLeft (nGroup n 0<n) {a} = invLeft 0<n a
Group.invRight (nGroup n 0<n) {a} = transitivity (plusZnCommutative 0<n a (inverseN 0<n a)) (invLeft 0<n a)
nAbGroup : (n : ) (pr : 0 <N n) AbelianGroup (nGroup n pr)
AbelianGroup.commutative (nAbGroup n pr) {a} {b} = plusZnCommutative pr a b
nFinite : (n : ) (pr : 0 <N n) FiniteGroup (nGroup n pr) (FinSet n)
SetoidToSet.project (FiniteGroup.toSet (nFinite (succ n) 0<n)) record { x = x ; xLess = xLess } = ofNat x xLess
SetoidToSet.wellDefined (FiniteGroup.toSet (nFinite (succ n) 0<n)) x y x=y rewrite x=y = refl
SetoidToSet.surj (FiniteGroup.toSet (nFinite (succ n) 0<n)) b = record { x = toNat b ; xLess = toNatSmaller b } , ofNatToNat b
SetoidToSet.inj (FiniteGroup.toSet (nFinite (succ n) 0<n)) record { x = x ; xLess = xLess } record { x = y ; xLess = yLess } eq = equalityZn (ofNatInjective x y xLess yLess eq)
FiniteGroup.finite (nFinite n pr) = record { size = n ; mapping = id ; bij = idIsBijective }