apply BC_to_TRS_main_has_unique_max_rank with (n:=n0) (s:=s0).
      now apply H1.
Qed.

(*****************************************************************************)
(*                                                                           *)
(*                     Translation produces a QI                             *)
(*                                                                           *)
(*****************************************************************************)
Definition  valid_QI_prog trs := valid_QI variable function constructor
  trs.(rules) mcs qic (qif trs) cs.Definition subterm_QI_prog trs := subterm function (qif trs).
Definition monotonicity_QI_prog trs := monotonicity_qif function (qif trs).
Definition compatible_QI_prog trs := compatible_QI variable function constructor 
  trs.(rules) qic (qif trs).

(* Compatibility of QIs *) Lemma BC_to_TRS_comp_rec_rec_aux g h0 h1 st n s sub h mh ps: let myqif := qif (snd ((BC_to_TRS g >>+ BC_to_TRS h0 >>++ BC_to_TRS h1 >>+ Mnew_fun >>== Mmr (S n) s) st)) in arities h0 = ok_arities (S n) (S s) → arities h1 = ok_arities (S n) (S s) → mh = asg_main (snd (BC_to_TRS h0 (fst (BC_to_TRS g st)))) ∨ mh = asg_main (snd (BC_to_TRS h1 (fst (BC_to_TRS h0 (fst (BC_to_TRS g st)))))) → (∀ l, myqif h l = mh (firstn (n+1) l) + maxl (skipn (n+1) l)) → term_assignment variable function constructor qic noqif (subst sub (term_from_pattern (ps px))) = (term_assignment variable function constructor qic noqif (subst sub (term_from_pattern px))) +1 → term_assignment variable function constructor qic myqif (subst sub (fapply h (mk_args_h (S n) s (mk_call (S (n + s)) (S (fst (BC_to_TRS h1 (fst (BC_to_TRS h0 (fst (BC_to_TRS g st))))))))))) ≤ myqif (S (fst (BC_to_TRS h1 (fst (BC_to_TRS h0 (fst (BC_to_TRS g st)))))))