Section ZpolyScale.
Definition zcontents p :=
sgz (lead_coef p) * \big[gcdn/0%N]_(i < size p) `|(p`_i)%R|%N.
Definition zprimitive p := map_poly (divz^~ (zcontents p)) p.
Local Notation pZtoQ := (map_poly (intr : int -> rat)).
End ZpolyScale.
(* Integral spans. *)

Lemma int_Smith_normal_form m n (M : 'M[int]_(m, n)) :
{L : 'M[int]_m & L \in unitmx &
{R : 'M[int]_n & R \in unitmx &
{d : seq int | sorted dvdz d &
M = L *m (\matrix_(i, j) (d`_i *+ (i == j :> nat))) *m R}}}.