let print_section_rulesA (role_instances : role_instance list)
                         (s_ids : Types.term list) (a_ids :  Types.term list) 
                         (wa_ids :  Types.term list) : (string * int * 'd list Pervasives.ref *
                                                        ((string * string) *
                                                                ((string list * string list) * (string list * string list)) *
                                                             (string * string)) list) list =
  let filter_wanted_goals =
    let check_warning cond nid c_id =
      cond
        or (not(!Globals.flag_split)
              && (Error_handler.displayWarning 11 (nid^" goal predicate ("
                                                   ^(term_to_string c_id)
                                                   ^") without corresp. goal property; dropped");
                  false))
    in
    List.filter (function
        Unknown(Base(Const(id)),lt) ->
          let nid = Globals.string_id#get_name id in
          if (nid = "request"then
(*            List.mem (List.hd (List.tl (List.tl lt))) a_ids*)
            let a_id = List.hd (List.tl (List.tl lt)) in
            check_warning (List.mem a_id a_ids) nid a_id
          else if (nid = "wrequest"then
(*            List.mem (List.hd (List.tl (List.tl lt))) wa_ids*)
            let wa_id = List.hd (List.tl (List.tl lt)) in
            check_warning (List.mem wa_id wa_ids) nid wa_id
          else if (nid = "witness"then
(*            (List.mem (List.hd (List.tl (List.tl lt))) a_ids)
              or (List.mem (List.hd (List.tl (List.tl lt))) wa_ids)*)

            let a_id = List.hd (List.tl (List.tl lt)) in
            check_warning ((List.mem a_id a_ids)
                             or (List.mem a_id wa_ids))
              nid a_id
          else if (nid = "secret"then
(*            List.mem (List.hd (List.tl lt)) s_ids*)
            let s_id = List.hd (List.tl lt) in
            check_warning (List.mem s_id s_ids) nid s_id
          else true
      | _ -> true)
  in
  let role_list = ref [] in
(*************)

  let stepcounter = ref 0 in
  prout_string "section rules:\n\n";
  List.iter
    (fun role_instance ->
      if not (List.exists 
                (fun role -> role=role_instance#get_name) 
                !role_list) then
        (role_list:=(role_instance#get_name)::(!role_list);
         List.iter
           (function
               (_,(_, basic_r)) ->
                 let if_var_list = basic_r#get_var_list in
                 prout_string ("step step_");
                 prout_int !stepcounter; incr stepcounter;
                 prout_string " (" ; 
                 print_list term_to_string "," if_var_list; 
                 prout_string ")";
                 prout_string (" :=\n");
                 print_if_states_list ".\n" basic_r#get_lhs;
                 if (basic_r#get_cond <> []) then
                   (prout_string " &\n";
                    print_if_states_list " &\n" basic_r#get_cond);

                 let if_exists_list=basic_r#get_exists_list in
                 if (if_exists_list <> []) then
                   (prout_string "\n=[exists ";
                    print_list term_to_string "," if_exists_list;
                    prout_string "]=>\n")
                 else
                   prout_string "\n =>\n";
                 print_if_states_list ".\n"
                   (if (s_ids<>[]) or (a_ids<>[]) or (wa_ids<>[]) then
                     filter_wanted_goals basic_r#get_rhs
                   else basic_r#get_rhs);
                 prout_string "\n\n")
         role_instance#get_actions))
    role_instances;
  prout_newline();
(***************)


   List.map
    (fun role_instance ->
      role_list:=(role_instance#get_name)::(!role_list);
       ((Globals.string_id#get_name role_instance#get_name),
        (role_instance#get_session_Id), ref [],
        List.flatten
        (List.map
           (function
               (_,(_, basic_r)) ->
                (multi_transition
                 (print_if_states_listA "" basic_r#get_lhs)

                 (List.map (fun e -> if_term_to_string "" e) basic_r#get_cond)
                 
                 (List.map term_to_string basic_r#get_exists_list)
                 
                (print_if_states_listA ""
                   (if (s_ids<>[]) or (a_ids<>[]) or (wa_ids<>[]) then
                     filter_wanted_goals basic_r#get_rhs
                    else basic_r#get_rhs)))
            ) role_instance#get_actions)))
    role_instances