# module homomorphisms

A homomorphism f : M --> N is represented as a matrix from the generators of M to the generators of N.
 `i1 : R = QQ[x,y]/(y^2-x^3);` ```i2 : M = module ideal(x,y) o2 = image | x y | 1 o2 : R-module, submodule of R```
One homomorphism F : M --> R is x |--> y, y |--> x^2 (this is multiplication by the fraction y/x). We write this in the following way.
 ```i3 : F = map(R^1,M,matrix{{y,x^2}}) o3 = | y x2 | o3 : Matrix```
Notice that as is usual in Macaulay2, the target comes before the source.

Macaulay2 doesn't display the source and target, unless they are both free modules. Use target and source to get them. The matrix routine recovers the matrix of free modules between the generators of the source and target.

 ```i4 : source F o4 = image | x y | 1 o4 : R-module, submodule of R``` ```i5 : target F == R^1 o5 = true``` ```i6 : matrix F o6 = | y x2 | 1 2 o6 : Matrix R <--- R```
Macaulay2 also does not check that the homomorphism is well defined (i.e. the relations of the source map into the relations of the target). Use isWellDefined to check. This generally requires a Gröbner basis computation (which is performed automatically, if it is required and has not already been done).
 ```i7 : isWellDefined F o7 = true``` ```i8 : isIsomorphism F o8 = false```
The image of F lies in the submodule M of R^1. Suppose we wish to define this new map G : M --> M. How does one do this?

To obtain the map M --> M, we use Matrix // Matrix. In order to do this, we need the inclusion map of M into R^1.

 ```i9 : inc = inducedMap(R^1, M) o9 = | x y | o9 : Matrix```
Now we use // to lift F : M --> R^1 along inc : M --> R^1, to obtain a map G : M --> M, such that inc * G == F.
 ```i10 : G = F // inc o10 = {1} | 0 x | {1} | 1 0 | o10 : Matrix``` ```i11 : target G == M and source G == M o11 = true``` ```i12 : inc * G == F o12 = true```
Let's make sure that this map G is well defined.
 ```i13 : isWellDefined G o13 = true``` ```i14 : isIsomorphism G o14 = false``` ```i15 : prune coker G o15 = cokernel | y x | 1 o15 : R-module, quotient of R``` ```i16 : kernel G == 0 o16 = true```