let proof logs w script =
    let gid = w.po_gid in
    let env = w.po_env in
    let model = w.po_model in
    let goal = Wpo.file_for_goal ~gid L_coq in
    let proof = Wpo.file_for_po ~gid L_coq in
    Command.pp_to_file proof
      (fun fmt ->
         Format.fprintf fmt "Require Import Reals.@\n";
         Format.fprintf fmt "Require Import wp.@\n";
         Format.fprintf fmt "Require Import %s.@\n" (Wpo.coq_for_model ~model);
         Format.fprintf fmt "Require Import %s.@\n" (Wpo.coq_for_env ~env);
         Command.pp_from_file fmt goal ;
         begin
           match script with
             | Some script ->
                 Format.fprintf fmt "Proof.@\n%sQed.@\n@." script ;
             | None -> (* This case is for check*)
                 Format.fprintf fmt "Proof.@\nAdmitted.@\n@." ;
         end
      ) ;
    Logs.add_file logs proof ;
    Task.return proof