let rec cnst_mult i ai =
if compute then match ai with
| AIcnst i' -> AIcnst (Int64.mul i i')
| AImult (i', t) -> AImult (Int64.mul i i', t)
| _ when cnst_is_zero i -> AIcnst Int64.zero
| AIadd (t, i') ->
add_cnst (cnst_mult i t) (Int64.mul i i')
| AIterm t -> AImult (i, t)
else of_term (term_of_mult (term_of_cnst i) (to_term ai))