let rec to_term (ai: 'a t) : 'a tint = match ai with
      | AIcnst i -> term_of_cnst i
      | AImult (i, t) -> term_of_mult (term_of_cnst i) t
      | AIadd (t, i) -> term_of_add (to_term t) (term_of_cnst i)
      | AIterm t -> t