From 589e548c64357c09a731d8ef0b3fec1ea805cc1b Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Thu, 19 Dec 2019 14:38:07 +0100 Subject: [PATCH] [WP] Use driver to tell about Why3 WP-specific libraries --- src/plugins/wp/ProverWhy3.ml | 27 +++++++++++++++++++++------ src/plugins/wp/share/wp.driver | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/plugins/wp/ProverWhy3.ml b/src/plugins/wp/ProverWhy3.ml index 488d62b73e3..1bc6f5ec06b 100644 --- a/src/plugins/wp/ProverWhy3.ml +++ b/src/plugins/wp/ProverWhy3.ml @@ -34,6 +34,11 @@ let option_import = LogicBuiltins.create_option (fun ~driver_dir:_ x -> x) "why3" "import" +let option_qual = + LogicBuiltins.create_option + (fun ~driver_dir:_ x -> x) + "why3" "qualifier" + let why3_failure msg = Pretty_utils.ksfprintf failwith msg @@ -227,6 +232,16 @@ let regexp_dot = Str.regexp_string "." let cut_path s = Str.split_delim regexp_dot s +let wp_why3_lib library = + match LogicBuiltins.get_option option_qual ~library with + | [] -> [library] + | [ lib ] -> Str.split_delim regexp_dot lib + | l -> + let pp_sep fmt () = Format.pp_print_string fmt ", " in + Wp_parameters.fatal + "too many bindings for WP-specific Why3 theory file %s:@\n%a" + library Format.(pp_print_list ~pp_sep pp_print_string) l + (* conversion *) let rec of_tau ~cnv (t:Lang.F.tau) = @@ -364,13 +379,13 @@ let rec of_term ~cnv expected t : Why3.Term.term = a b | Leq (a,b), _, Bool -> int_or_real ~cnv - ~fint:["frama_c_wp"; "qed"] ~lint:"Qed" ~pint:["zleq"] - ~freal:["frama_c_wp"; "qed"] ~lreal:"Qed" ~preal:["rleq"] + ~fint:(wp_why3_lib "qed") ~lint:"Qed" ~pint:["zleq"] + ~freal:(wp_why3_lib "qed") ~lreal:"Qed" ~preal:["rleq"] a b | Lt (a,b), _, Bool -> int_or_real ~cnv - ~fint:["frama_c_wp"; "qed"] ~lint:"Qed" ~pint:["zlt"] - ~freal:["frama_c_wp"; "qed"] ~lreal:"Qed" ~preal:["rlt"] + ~fint:(wp_why3_lib "qed") ~lint:"Qed" ~pint:["zlt"] + ~freal:(wp_why3_lib "qed") ~lreal:"Qed" ~preal:["rlt"] a b | And l, _, Bool -> t_app_fold ~f:["bool"] ~l:"Bool" ~p:["andb"] ~cnv expected l @@ -420,9 +435,9 @@ let rec of_term ~cnv expected t : Why3.Term.term = | _ -> Why3.Term.t_neq (of_term' cnv a) (of_term' cnv b) end | Eq (a,b), _, Bool -> - t_app ~cnv ~f:["frama_c_wp"; "qed"] ~l:"Qed" ~p:["eqb"] [of_term' cnv a; of_term' cnv b] + t_app ~cnv ~f:(wp_why3_lib "qed") ~l:"Qed" ~p:["eqb"] [of_term' cnv a; of_term' cnv b] | Neq (a,b), _, Bool -> - t_app ~cnv ~f:["frama_c_wp"; "qed"] ~l:"Qed" ~p:["neqb"] [of_term' cnv a; of_term' cnv b] + t_app ~cnv ~f:(wp_why3_lib "qed") ~l:"Qed" ~p:["neqb"] [of_term' cnv a; of_term' cnv b] | If(a,b,c), _, _ -> let cnv' = {cnv with polarity = `NoPolarity} in Why3.Term.t_if (of_term cnv' Prop a) (of_term cnv expected b) (of_term cnv expected c) diff --git a/src/plugins/wp/share/wp.driver b/src/plugins/wp/share/wp.driver index 84cccb44f4c..1b6b435d6c0 100644 --- a/src/plugins/wp/share/wp.driver +++ b/src/plugins/wp/share/wp.driver @@ -38,6 +38,7 @@ coq.file += "coqwp/Qedlib.v"; coq.file += "coqwp/Qed.v"; why3.import += "int.Abs:IAbs"; why3.import += "frama_c_wp.qed.Qed"; +why3.qualifier := "frama_c_wp.qed"; altergo.file += "ergo/int.Int.mlw"; altergo.file += "ergo/int.Abs.mlw"; altergo.file += "ergo/int.ComputerDivision.mlw"; -- GitLab