let int_of_bitvector v = let rec aux pow v = match v with Vector.VEmpty -> 0 | Vector.VCons (_,hd,tl) -> if hd = Bool.True then pow + (aux (pow * 2) tl) else aux (pow * 2) tl in aux 1 (Vector.reverse Nat.O v) let rec int_of_matitapos = function Positive.One -> 1 | Positive.P0 v -> int_of_matitapos v * 2 | Positive.P1 v -> int_of_matitapos v * 2 + 1 let int_of_matitaZ = function Z.OZ -> 0 | Z.Pos p -> int_of_matitapos p | Z.Neg p -> -(int_of_matitapos p) let option_of_matitaoption = function Types.None -> None | Types.Some v -> Some v let rec matitanat_of_int n = if n = 0 then Nat.O else if n < 0 then assert false else Nat.S (matitanat_of_int (n-1)) let rec int_of_matitanat = function Nat.O -> 0 | Nat.S n -> int_of_matitanat n + 1 let int_pair_of_pointer { Pointers.pblock = bl ; Pointers.poff = off } = (int_of_matitaZ bl, int_of_bitvector off)