1 | initial version |

Building on @FrédéricC's comment.

If `a`

is an element in `GF(2)`

, `a.lift()`

is the corresponding element in `ZZ`

.
Using `.lift()`

makes it so that `1 + 1`

will be computed in `ZZ`

and give `2`

instead of being computed in `GF(2)`

and give `0`

.

If `a`

is a matrix over `GF(2)`

, `a.lift()`

is the corresponding matrix over `ZZ`

.

The rows of `a`

can be summed using `sum(a)`

.

Define the matrix space:

```
sage: M = MatrixSpace(GF(2), 2, 2)
```

List its elements:

```
sage: M.list()
[
[0 0] [1 0] [0 1] [0 0] [0 0] [1 1] [1 0] [1 0]
[0 0], [0 0], [0 0], [1 0], [0 1], [0 0], [1 0], [0 1],
[0 1] [0 1] [0 0] [1 1] [1 1] [1 0] [0 1] [1 1]
[1 0], [0 1], [1 1], [1 0], [0 1], [1 1], [1 1], [1 1]
]
```

How many 1's in each column of each matrix in `M`

:

```
sage: [sum(a.lift()) for a in M]
[(0, 0),
(1, 0),
(0, 1),
(1, 0),
(0, 1),
(1, 1),
(2, 0),
(1, 1),
(1, 1),
(0, 2),
(1, 1),
(2, 1),
(1, 2),
(2, 1),
(1, 2),
(2, 2)]
```

Sum over all matrices in `M`

:

```
sage: sum(sum(a.lift()) for a in M)
(16, 16)
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.