let export_wpo export kf bhv wrn dep propid gpred =
let gname = WpAnnot.prop_txt propid in
let gid = Wpo.gid ~context:Descr.context ~kf ~bhv ~propid in
Command.pp_to_file (Wpo.file_for_head ~gid)
(fun fmt ->
Format.fprintf fmt "@[<v 0>Proof Obligation %s:@]@\n" gname ;
Format.fprintf fmt "Environment: %s@\n" export.env ;
List.iter (fun d -> Format.fprintf fmt "%a@\n" Wpo.pp_dependency d) dep ;
List.iter (fun w -> Format.fprintf fmt "%a@\n" Wpo.pp_warning w) wrn ;
) ;
Command.pp_to_file (Wpo.file_for_body ~gid)
(fun fmt ->
Format.fprintf fmt "@[<v 2>Goal %s:@\n%a@]" gid F.pp_pred gpred ;
) ;
Command.pp_to_file (Wpo.file_for_goal ~gid Wpo.L_why)
(fun fmt ->
Why.export_goal fmt gid gpred ;
) ;
Command.pp_to_file (Wpo.file_for_goal ~gid Wpo.L_coq)
(fun fmt ->
Coq.export_goal fmt gid gpred ;
) ;
Command.pp_to_file (Wpo.file_for_goal ~gid Wpo.L_ergo91)
(fun fmt ->
Ergo91.export_goal fmt gid gpred ;
) ;
Command.pp_to_file (Wpo.file_for_goal ~gid Wpo.L_ergo92)
(fun fmt ->
Ergo92.export_goal fmt gid gpred ;
) ;
if wrn <> [] then
begin
let pp_warnings fmt ws =
let n = List.length ws in if n = 1
then Format.pp_print_string fmt "1 warning"
else Format.fprintf fmt "%d warnings" n
in
if List.exists (fun w -> w.Wpo.wrn_severe) wrn then
Wp_parameters.warning ~current:false
"Degenerated goal %s (%a)"
gid pp_warnings wrn
else
Wp_parameters.warning ~current:false
"Stronger goal %s (%a)"
gid pp_warnings wrn ;
end ;
let wpo = {
Wpo.po_fun = kf ;
Wpo.po_bhv = bhv ;
Wpo.po_name = gname ;
Wpo.po_gid = gid ;
Wpo.po_model = Descr.shared ;
Wpo.po_env = export.env ;
Wpo.po_pid = propid ;
Wpo.po_dep = dep ;
Wpo.po_warn = wrn ;
Wpo.po_updater = Descr.updater ;
} in
Wpo.add wpo ;
if F.is_true gpred then
Wpo.set_result wpo Wpo.WP Wpo.Valid ;
export.goals <- wpo :: export.goals