Frama-C API - Conditions
 Proof Task and Simplifiers
Predicate Introduction
val forall_intro : Lang.F.pred -> Lang.F.pred list * Lang.F.predIntroduce universally quantified formulae: head forall quantifiers are instantiated to fresh variables in current pool and left-implies are extracted, recursively.
val exist_intro : Lang.F.pred -> Lang.F.predIntroduce existential quantified formulae: head exist quantifiers are instantiated to fresh variables, recursively.
Sequent
type step = private {mutable id : int;(*See
*)indexsize : int;vars : Lang.F.Vars.t;stmt : Frama_c_kernel.Cil_types.stmt option;descr : string option;deps : Frama_c_kernel.Property.t list;warn : Wp__.Warning.Set.t;condition : condition;
}and condition = | Type of Lang.F.pred(*Type section, not constraining for filtering
*)| Have of Lang.F.pred(*Normal assumptions section
*)| When of Lang.F.pred(*Assumptions introduced after simplifications
*)| Core of Lang.F.pred(*Common hypotheses gather from parallel branches
*)| Init of Lang.F.pred(*Initializers assumptions
*)| Branch of Lang.F.pred * sequence * sequence(*If-Then-Else
*)| Either of sequence list(*Disjunction
*)| State of Mstate.state(*Memory Model snapshot
*)
type sequent = sequence * Lang.F.predval pretty : (Stdlib.Format.formatter -> sequent -> unit) Stdlib.refval step : ?descr:string -> ?stmt:Frama_c_kernel.Cil_types.stmt -> ?deps:Frama_c_kernel.Property.t list -> ?warn:Wp__.Warning.Set.t -> condition -> stepCreates a single step
val update_cond : ?descr:string -> ?deps:Frama_c_kernel.Property.t list -> ?warn:Wp__.Warning.Set.t -> step -> condition -> stepUpdates the condition of a step and merges descr, deps and warn
val is_true : sequence -> boolContains only true or empty steps
val is_empty : sequence -> boolNo step at all
val vars_hyp : sequence -> Lang.F.Vars.tPre-computed and available in constant time.
val vars_seq : sequent -> Lang.F.Vars.tAt the cost of the union of hypotheses and goal.
val empty : sequenceempty sequence, equivalent to true assumption
val trivial : sequentempty implies true
val seq_branch : ?stmt:Frama_c_kernel.Cil_types.stmt -> Lang.F.pred -> sequence -> sequence -> sequenceCreates an If-Then-Else branch located at the provided stmt, if any.
Iterate only over the head steps of the sequence. Does not go deeper inside branches and disjunctions.
val size : sequence -> intCompute the total number of steps in the sequence, including nested sequences from branches and disjunctions. Pre-computed and available in constant time.
val steps : sequence -> intAttributes unique indices to every step.id in the sequence, starting from zero. Recursively Returns the number of steps in the sequence.
val index : sequent -> unitCompute steps' id of sequent left hand-side. Same as ignore (steps (fst s)).
Retrieve a step by id in the sequence. The index function must have been called on the sequence before retrieving the index properly.
val is_trivial : sequent -> boolGoal is true or hypotheses contains false.
val probes : sequence -> Lang.F.term Wp__.Probe.Map.tCollect all probes in the sequence
Transformations
val map_condition : (Lang.F.pred -> Lang.F.pred) -> condition -> conditionRewrite all root predicates in condition
val map_step : (Lang.F.pred -> Lang.F.pred) -> step -> stepRewrite all root predicates in step
val map_sequence : (Lang.F.pred -> Lang.F.pred) -> sequence -> sequenceRewrite all root predicates in sequence
val map_sequent : (Lang.F.pred -> Lang.F.pred) -> sequent -> sequentRewrite all root predicates in hypotheses and goal
Insert a step in the sequent immediately at the specified position. Parameter at can be size to insert at the end of the sequent (default).
replace a step in the sequent, the one at the specified position.
replace a step in the sequent, the one at the specified position.
val subst : (Lang.F.term -> Lang.F.term) -> sequent -> sequentApply the atomic substitution recursively using Lang.F.p_subst f. Function f should only transform the head of the predicate, and can assume its sub-terms have been already substituted. The atomic substitution is also applied to predicates. f should raise Not_found on terms that must not be replaced
Performs existential, universal and hypotheses introductions
val lemma : loc:Frama_c_kernel.Cil_types.location -> Lang.F.pred -> sequentPerforms existential, universal and hypotheses introductions
val head : step -> Lang.F.predPredicate for Have and such, Condition for Branch, True for Either
val have : step -> Lang.F.predPredicate for Have and such, True for any other
val pred_cond : condition -> Lang.F.predval condition : sequence -> Lang.F.predWith free variables kept.
val property : sequent -> Lang.F.predWith free variables kept.
Bundles
Bundles are mergeable pre-sequences. This the key structure for merging hypotheses with linear complexity during backward weakest pre-condition calculus.
Bundle are constructed in backward order with respect to program control-flow, as driven by the wp calculus.
type 'a attributed = ?descr:string -> ?stmt:Frama_c_kernel.Cil_types.stmt -> ?deps:Frama_c_kernel.Property.t list -> ?warn:Wp__.Warning.Set.t -> 'aval nil : bundleSame as empty
val occurs : Lang.F.var -> bundle -> boolval intersect : Lang.F.pred -> bundle -> boolVariables of predicate and the bundle intersects
Performs a diff-based disjunction, introducing If-Then-Else or Either branches when possible. Linear complexity is achieved by assuming bundle ordering is consistent over the list.
val probe : loc:Frama_c_kernel.Cil_types.location -> ?descr:string -> ?stmt:Frama_c_kernel.Cil_types.stmt -> name:string -> Lang.F.term -> bundle -> bundleInserts probes to a sequent.
val domain : Lang.F.pred list -> bundle -> bundleAssumes a list of predicates in a Type section on top of the bundle.
val intros : Lang.F.pred list -> bundle -> bundleAssumes a list of predicates in a Have section on top of the bundle.
val state : ?descr:string -> ?stmt:Frama_c_kernel.Cil_types.stmt -> Mstate.state -> bundle -> bundleStack a memory model state on top of the bundle.
val assume : (?init:bool -> ?domain:bool -> Lang.F.pred -> bundle -> bundle) attributedAssumes a predicate in the specified section, with the specified decorations. On ~init:true, the predicate is placed in an Init section. On ~domain:true, the predicate is placed in a Type section. Otherwized, it is placed in a standard Have section.
val branch : (Lang.F.pred -> bundle -> bundle -> bundle) attributedConstruct a branch bundle, with merging of all common parts.
val either : (bundle list -> bundle) attributedConstruct a disjunction bundle, with merging of all common parts.
val extract : bundle -> Lang.F.pred listComputes a formulae equivalent to the bundle. For debugging purpose only.
Simplifiers
val simplify : ?solvers:Lang.simplifier list -> ?intros:int -> sequent -> sequentval pruning : ?solvers:Lang.simplifier list -> sequent -> sequent