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).

Qed. Lemma BC_to_TRS_comp_rec_rec g h0 h1 st n s sub trs_h 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) → trs_h=snd (BC_to_TRS h0 (fst (BC_to_TRS g st))) ∨ trs_h=snd (BC_to_TRS h1 (fst (BC_to_TRS h0 (fst (BC_to_TRS g st))))) → ps=ps0 ∨ ps=ps1 → term_assignment variable function constructor qic myqif (subst sub (fapply trs_h.(main) (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)))))))