Definition qif (f : function) args := match f with
  | main => Nat.max (Nat.max (5*(suml args)) (8+(suml args)) + 1) 2 + 1 (* max(max(5X,X+8) + 1, 2) + 1 *)
            (* args here has only one element, X, so suml args = X *)
  | mult => suml args + (hd 0 args)  (* 2X+Y *)
            (* args here has only two elements, X and Y, so suml args = X+Y *)
  | addf => maxl args + 1
  | addt => maxl args + 1
  | succ => suml args + 1
  | errF => suml args
  end.

Lemma qif_subterm : subterm qif.