Module WpFroms

module WpFroms: sig .. end
This file groups functions needed to check the fonctional dependencies

Build a strategy for each of the \from property of the function behavior


val dkey : Wp_parameters.category

This file groups functions needed to check the fonctional dependencies
exception NoFromForBhv
exception NoFromForLoop of Cil_types.stmt
exception NoFromForCall of Cil_types.stmt
val mk_name : string ->
Kernel_function.t ->
Cil_types.kinstr -> ('a, 'b) Cil_types.behavior -> int -> string -> string
Build a full qualified name for logic_info about the nth from in the b behavior of the kf function.
val mk_linfo_type : Cil_types.logic_type option * Cil_types.logic_type list ->
Cil_types.logic_type
Build the logic type of the function that takes parameters of in_types and return an out_type result (None for a predicate)
val make_logic_info : string ->
Cil_types.logic_type option * Cil_types.logic_type list ->
Cil_types.logic_info
Build a logic_info with fname and the signature given by (out_type, in_types) (see WpFroms.mk_linfo_type) TODO: should be Cil_const.make_logic_info when it be finished.
val get_linfo : string ->
Cil_types.logic_type option * Cil_types.logic_type list ->
Cil_types.logic_info
Find the logic_info for the given name and signature. Build and register it if it doesn't exist yet.
val mk_bhv_implicit_fun_name : Kernel_function.t ->
Cil_types.kinstr -> ('a, 'b) Cil_types.behavior -> int -> string
val mk_loop_implicit_fun_name : Cil_types.stmt -> int -> string
val get_pred_linfo : Kernel_function.t ->
Cil_types.kinstr ->
('a, 'b) Cil_types.behavior ->
int -> Cil_types.logic_type -> Cil_types.logic_info
val get_init_linfo : Kernel_function.t ->
Cil_types.kinstr ->
('a, 'b) Cil_types.behavior ->
int -> int -> Cil_types.logic_type -> Cil_types.logic_info
val get_implicit_fun : string ->
Cil_types.logic_type * Cil_types.logic_type list -> Cil_types.logic_info
Build the implicit function for the nth assign clause of behavior b in the ki element of function kf.
val build_elem_opt : addrlab:Cil_types.logic_label ->
mlab:Cil_types.logic_label -> Cil_types.term -> Cil_types.term option
Build the lvalue \at (mlab, * (\at (addrlab, & elem))) . This is needed because the left part of assigns properties is an lvalue which address has to be interpreted in the pre-state (addrlab), but its value is to be considered in the post-state (mlab).
val build_elem : addrlab:Cil_types.logic_label ->
mlab:Cil_types.logic_label -> Cil_types.term -> Cil_types.term
see build_elem_opt above.
val build_post_output : Cil_types.termination_kind ->
Cil_types.identified_term -> Cil_types.term option
Build the left part of a contract assigns property Process \result and \exit_status according to termination_kind. Returns None if out is not compatible with termination_kind.
val mk_assign_post : Kernel_function.t ->
('a, 'b) Cil_types.behavior ->
int ->
Cil_types.termination_kind ->
Cil_types.identified_term * 'c -> Cil_types.identified_predicate option
Build P(out) where out is the left part of the assigns property. Process \result and \exit_status according to termination_kind. Returns None if out is not compatible with termination_kind.
module Vars: sig .. end
val build_fimpl_eq : string ->
Cil_types.term ->
Cil_types.term list option -> Cil_types.predicate Cil_types.named
Build out = f_n (inputs). The correct label \at should already be in output and inputs.
Raises NoFromForBhv if inputs = None meaning FromAny.
val bhv_from_hyps : Kernel_function.t ->
Cil_types.kinstr ->
('a, 'b) Cil_types.behavior ->
(Cil_types.identified_term * Cil_types.identified_term Cil_types.deps) list ->
Cil_types.termination_kind ->
((Cil_types.identified_term * Cil_types.identified_term Cil_types.deps) *
Cil_types.predicate Cil_types.named)
list
Returns the list of pair from, out_i = implicit_fun_i (inputs) for each out_i \from inputs assigns property of the behavior. The from part is for identification purpose later on. implicit_fun_i is the implicit fonction for the output. kf and ki give information to know there the specification comes from in order to build the names for the implicit functions. termination_kind is used to filter \result and \exit_status when needed.
val post_of_spec_assigns : Kernel_function.t ->
Cil_types.kinstr ->
Cil_types.funspec ->
Cil_types.termination_kind ->
(Cil_types.funbehavior *
(Cil_types.identified_term * Cil_types.identified_term Cil_types.deps) *
Cil_types.predicate Cil_types.named)
list
For each behavior of the specification, and for each \from in the behavior, return a predicate which is assumes => out_i = implicit_fun_i (inputs). If the assigns information is missing from a behavior, try to use the whole assigns information of the spec.
Raises NoFromForBhv if we don't manage to compute the assigns information. See bhv_from_hyps above.
val inv_of_loop_from : Cil_types.stmt ->
int ->
Cil_types.identified_term * Cil_types.identified_term Cil_types.deps ->
Cil_types.predicate Cil_types.named
Build the from hyp for the loop assigns
val mk_assign_pre : Kernel_function.t ->
Cil_types.kinstr ->
('a, 'b) Cil_types.behavior ->
int -> Cil_types.identified_term list -> Cil_types.identified_predicate
Build xi = Init (i) /\ ... forall inputs part of the assigns property.

Build Strategy


val annot_for_asked_bhv : 'a list -> 'a -> bool
val get_loop_assigns_for_froms : string ->
Cil_types.stmt ->
(Cil_types.code_annotation * Cil_types.identified_term Cil_types.from list)
option
val add_loop_assigns_hyp : Cil_types.kernel_function ->
string -> Cil_types.stmt -> WpStrategy.t_annots -> WpStrategy.t_annots
val add_stmt_spec_assigns_hyp : WpStrategy.t_annots * 'a ->
Cil_types.kernel_function ->
Cil_types.stmt ->
Cil_types.logic_label option -> Cil_types.funspec -> WpStrategy.t_annots * 'a
val add_call_assigns_hyp : WpStrategy.t_annots * 'a ->
Cil_types.kernel_function ->
Cil_types.stmt ->
Cil_types.logic_label option -> Cil_types.funspec -> WpStrategy.t_annots * 'a
val add_spec_annots : Kernel_function.t ->
Cil_types.stmt ->
Cil_types.logic_label option ->
Cil_types.funspec ->
WpStrategy.t_annots * (WpStrategy.t_annots * WpStrategy.t_annots) ->
WpStrategy.t_annots * (WpStrategy.t_annots * WpStrategy.t_annots)
Raises NoFromForBhv is the assigns information is missing.
val get_stmt_hyp : Kernel_function.t ->
string ->
Cil_types.stmt ->
Cil_types.logic_label option ->
WpStrategy.t_annots * (WpStrategy.t_annots * WpStrategy.t_annots)
val get_called_post : Kernel_function.t -> Cil_types.termination_kind -> WpStrategy.t_annots
Collect the \from hypotheses of the function spectication. TODO: maybe we should also take the ensures properties ?
Raises NoFromForBhv is the assigns information is missing.
val get_call_hyp : Cil_types.kernel_function ->
Cil_types.stmt ->
Cil_types.logic_label option ->
Cil_types.exp ->
WpStrategy.t_annots * (WpStrategy.t_annots * WpStrategy.t_annots)
val get_fct_bhv_from_annots : Cil2cfg.t ->
Cil_types.funbehavior ->
int -> Cil_types.identified_term Cil_types.from -> WpStrategy.annots_tbl
Collect all the annotations to be used to prove one \from property of the function behavior *
val mk_strategy_for_fct_from : Cil2cfg.t ->
Cil_types.funbehavior ->
WpStrategy.t_annots ->
Cil_types.identified_term * Cil_types.identified_term Cil_types.deps ->
WpStrategy.strategy
val pp_err : Format.formatter -> exn -> unit
val get_bhv_pre : Cil_types.kernel_function -> Cil_types.funbehavior -> WpStrategy.t_annots
val get_strategy_for_from : Kernel_function.t * Cil_types.kinstr * Property.behavior_or_loop *
(Cil_types.identified_term * Cil_types.identified_term Cil_types.deps) ->
WpStrategy.strategy
val get_strategies_for_froms : Kernel_function.t -> WpStrategy.strategy list
Build strategies to prove the from properties of the function. At the moment, only the function behaviors are handled, but the strategies make use of the from properties of stmt spec, loops and called functions.