Skip to content

Commit

Permalink
Add GroupHomomorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Apr 30, 2020
1 parent 63bc631 commit 553abe6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions libs/contrib/Control/Algebra/GroupHomomorphism.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Prelude.Algebra as A
import Control.Algebra
import Control.Algebra.Laws

||| A homomorphism is a mapping that preserves group structure.
interface (VerifiedGroup a, VerifiedGroup b) => GroupHomomorphism a b where
to : a -> b
toGroup : (x, y : a) ->
to (x <+> y) = (to x) <+> (to y)

||| Homomorphism preserves neutral.
homoNeutral : GroupHomomorphism a b =>
to (the a A.neutral) = the b A.neutral
homoNeutral {a} =
let ae = the a A.neutral in
selfSquareId (to ae) $
trans (sym $ toGroup ae ae) $
cong {f = to} $ monoidNeutralIsNeutralL ae

||| Homomorphism preserves inverses.
homoInverse : GroupHomomorphism a b => (x : a) ->
the b (to $ inverse x) = the b (inverse $ to x)
homoInverse {a} {b} x =
cancelRight (to x) (to $ inverse x) (inverse $ to x) $
trans (sym $ toGroup (inverse x) x) $
trans (cong {f = to} $ groupInverseIsInverseR x) $
trans (homoNeutral {a=a} {b=b}) $
sym $ groupInverseIsInverseR (to x)
1 change: 1 addition & 0 deletions libs/contrib/contrib.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ modules = CFFI
, Control.Algebra.NumericImplementations
, Control.Algebra.ComplexImplementations
, Control.Algebra.VectorSpace
, Control.Algebra.GroupHomomorphism

, Control.Delayed

Expand Down

0 comments on commit 553abe6

Please sign in to comment.