let rec collect_apps_rec = function 
  | [],[] -> () 
  | [], _ | _, [] -> () (*TODO: check correctness for variadyc functions *)
  | t::args, p::fmls -> 
      let s = "collect_app" in
      (match by_array_reference_pattern_term t.term_node with 
         | Ok (x,b,n) -> 
             debug "(%a,%b,%d) by_array in apps_rec" 
               !Ast_printer.d_logic_var x b n;
             ok_array_term s (var_type_of_lvar x) n b (var_type_of_lvar p )
         | Ko (x,_,_) -> 
             let x = var_type_of_lvar x in
             if is_formal_var_type x 
             then  remove_array_reference_param x
             else ArgAReference.remove x
               
         | Any -> 
             ( match by_pointer_reference_pattern_term t.term_node with 
                 | Ok (x,b,n) -> 
                     let p = var_type_of_lvar p in
                     let x = var_type_of_lvar x in 
                     ok_pointer_term s x n b p
                 | Ko (x,_,_) ->
                     let x = var_type_of_lvar x in
                     if is_formal_var_type x 
                     then remove_ptr_reference_param x
                     else ArgPReference.remove x    
                 | Any ->()
             )
      ); collect_apps_rec (args,fmls)