let run_and_prove (main_ui:Design.main_window_extension_points) kf_opt =
  try
  let model = match Register.get_model_option () with Some m -> m 
    | None -> main_ui#annot_window#buffer#insert 
                "[wp] the model is not set : cannot compute\n"; raise Stop
  in
  let bhv = Register.get_behav_option () in
  let fstr = match kf_opt with None -> "all functions"
    | Some kf -> ("function '"^( Kernel_function.get_name kf)^"'")
  in 
  let bstr = match bhv with None -> "all beheviors"
    | Some b -> ("behavior '"^b^"'")
  in
  let mstr = Register.model_name model in
    main_ui#annot_window#buffer#insert 
       ("[wp] compute WP on "^fstr^", "^bstr^", with model "^mstr^"\n");
  let why_file = Register.wp_why_file kf_opt bhv model in
    match why_file with
      | None -> main_ui#annot_window#buffer#insert 
                  "[wp] noting to prove ! (see messages in 'Console')"
      | Some f -> 
          let gwhy = Macros.get_env ~default:"gwhy-bin" "GWHYBIN" in
          main_ui#annot_window#buffer#insert 
            ("[wp] try to run 'gwhy' on "^f^"\n");
          let cmd = gwhy^" -split-user-conj "^f in
            if Sys.command cmd <> 0 then
              main_ui#annot_window#buffer#insert "[wp] couldn't run gwhy\n"
  with Stop -> ()