10,837 Pages

## Part1

A and B are any arrays including empty. The zero in the third rule is the leftmost one.

$HNF(x)=x+1$

$HNF(A,a,b)=HNF(A,a-1,HNF(A,a,b-1))$

$HNF(A,a,0,B)=HNF(A,a-1,HNF(A,a-1,a,B),B)$

$HNF(0,A)=HNF(A)$

Examples:

```HNF(3,2,0)=HNF(3,1,HNF(3,1,2))
HNF(3,0,0,3)=HNF(2,HNF(2,3,0,3),0,3)=HNF(2,HNF(2,2,HNF(2,2,3,3),3),0,3)
HNF(0,2)=HNF(2)=3
```

## Part2(rows)

The rule in part 1 is for the rightmost(last) row. The zero in the second rule is the leftmost one.

A can include (1) in the last and B can include it in the first.

$HNF(Ax(1)y)=HNF(Ax-1(1)HNF(Ax-1(1)y-1))$

$HNF(Ax(1)0B)=HNF(Ax-1(1)HNF(Ax-1(1)xB)B)$

$HNF(A0)=HNF(0)$

Examples:

```HNF(3(1)1)=HNF( 2 (1) HNF(3(1)0) )
HNF(3(1)0)=HNF( 2 (1) HNF(2(1)3) )
HNF(3(1)0(1)0(1)3)=HNF( 2 (1) HNF(2(1)3(1)0(1)3) (1) 0 (1) 3 )
```