module Model_parser:sig
..end
For a given VC, a model is a set of model elements representing CE values for source code elements.
type
model_element_kind =
| |
Result |
(* | Result of a function call (if the counter-example is for postcondition) | *) |
| |
Call_result of |
(* | Result of the function call at the given location | *) |
| |
Old |
(* | Old value of function argument (if the counter-example is for postcondition) | *) |
| |
At of |
(* | Value at label | *) |
| |
Loop_before |
(* | Value from before the loop | *) |
| |
Loop_previous_iteration |
(* | Value from before current loop iteration | *) |
| |
Loop_current_iteration |
(* | Value from current loop iteration | *) |
| |
Error_message |
(* | The model element represents error message, not source-code element. The error message is saved in the name of the model element. | *) |
| |
Other |
val print_model_kind : Stdlib.Format.formatter -> model_element_kind -> unit
Concrete syntax for model element values (which are of type Term.term
),
used for pretty printing and JSON printing.
type
concrete_syntax_int = {
|
int_value : |
(* | Integer value | *) |
|
int_verbatim : |
(* | String verbatim, as given by the SMT solver | *) |
}
Integers
type
concrete_syntax_bv = {
|
bv_value : |
(* | Bitvector value | *) |
|
bv_length : |
(* | Length of the bitvector | *) |
|
bv_verbatim : |
(* | String verbatim, as given by the SMTĀ solver | *) |
}
Bitvectors
Real numbers
type
concrete_syntax_real = {
|
real_value : |
(* | Real value | *) |
|
real_verbatim : |
(* | String verbatim, as given by the SMT solver | *) |
}
type
concrete_syntax_frac = {
|
frac_num : |
(* | Numerator | *) |
|
frac_den : |
(* | Denominator | *) |
|
frac_verbatim : |
(* | String verbatim, as given by the SMT solver | *) |
}
Fractions
type
concrete_syntax_float_value =
| |
Plus_infinity |
||||||||||||||||||||
| |
Minus_infinity |
||||||||||||||||||||
| |
Plus_zero |
||||||||||||||||||||
| |
Minus_zero |
||||||||||||||||||||
| |
NaN |
||||||||||||||||||||
| |
Float_number of |
Floats
type
concrete_syntax_float = {
|
float_exp_size : |
(* | Size of the exponent | *) |
|
float_significand_size : |
(* | Size of the significand | *) |
|
float_val : |
(* | Value of the constant | *) |
}
type
concrete_syntax_constant =
| |
Boolean of |
| |
String of |
| |
Integer of |
| |
Real of |
| |
Float of |
| |
BitVector of |
| |
Fraction of |
Constants
type
concrete_syntax_quant =
| |
Forall |
| |
Exists |
Quantifiers
type
concrete_syntax_binop =
| |
And |
| |
Or |
| |
Implies |
| |
Iff |
Binary operators
type
concrete_syntax_funlit_elts = {
|
elts_index : |
|
elts_value : |
}
type
concrete_syntax_funlit = {
|
elts : |
|
others : |
}
Function literal value
type
concrete_syntax_fun = {
|
args : |
|
body : |
}
Function arguments and body
type
concrete_syntax_term =
| |
Var of |
(* | Variable of the given name | *) |
| |
Const of |
(* | Constant | *) |
| |
Apply of |
(* | Application of the given function symbol to the given list of concrete terms | *) |
| |
If of |
(* |
| *) |
| |
Epsilon of |
(* |
| *) |
| |
Quant of |
(* |
| *) |
| |
Binop of |
(* |
| *) |
| |
Not of |
(* | Negation of a concrete term | *) |
| |
Function of |
(* | Function defined by the given list of arguments and the given body | *) |
| |
FunctionLiteral of |
(* | Special case for function literals, also used for arrays | *) |
| |
Record of |
(* | Record defined by the given list of (field_name,field_value) elements | *) |
| |
Proj of |
(* | Projections represent values that are defined by a type coercion:
the value | *) |
| |
Let of |
(* | A list of let bindings in a term | *) |
Concrete term
val print_concrete_term : Stdlib.Format.formatter -> concrete_syntax_term -> unit
Helper functions to create concrete terms
val concrete_var_from_vs : Term.vsymbol -> concrete_syntax_term
val concrete_const_bool : bool -> concrete_syntax_term
val concrete_apply_from_ls : Term.lsymbol ->
concrete_syntax_term list -> concrete_syntax_term
val concrete_apply_equ : concrete_syntax_term ->
concrete_syntax_term -> concrete_syntax_term
val subst_concrete_term : concrete_syntax_term Wstdlib.Mstr.t ->
concrete_syntax_term -> concrete_syntax_term
val t_and_l_concrete : concrete_syntax_term list -> concrete_syntax_term
type
model_element = {
|
me_kind : |
(* | The kind of model element. | *) |
|
me_value : |
(* | Counterexample value for the element. | *) |
|
me_concrete_value : |
(* | Concrete syntax of the counterexample value. | *) |
|
me_location : |
(* | Source-code location of the element. | *) |
|
me_attrs : |
(* | Attributes of the element. | *) |
|
me_lsymbol : |
(* | Logical symbol corresponding to the element. | *) |
}
Counter-example model elements. Each element represents a counterexample value for a single source code element.
val create_model_element : value:Term.term ->
concrete_value:concrete_syntax_term ->
oloc:Loc.position option ->
attrs:Ident.Sattr.t -> lsymbol:Term.lsymbol -> model_element
Creates a counterexample model element.
value
: counterexample value for the elementconcrete_value
: concrete syntax of the counterexample valueoloc
: (optional) location of the elementattrs
: attributes of the elementlsymbol
: logical symbol corresponding to the elementval get_lsymbol_or_model_trace_name : model_element -> string
Given a model element me
, returns the model_trace attribute if it
exists in me.me_attrs
, otherwise returns the name of the
me.me_lsymbol
.
type
model
val is_model_empty : model -> bool
val empty_model : model
val set_model_files : model ->
model_element list Wstdlib.Mint.t Wstdlib.Mstr.t ->
model
val get_model_elements : model -> model_element list
val get_model_term_loc : model -> Loc.position option
val get_model_term_attrs : model -> Ident.Sattr.t
val search_model_element_for_id : model ->
?loc:Loc.position -> Ident.ident -> model_element option
search_model_element_for_id m ?loc id
searches for a model element for
identifier id
, at the location id.id_loc
, or at loc
, when given.
val search_model_element_call_result : model ->
Expr.expr_id option -> model_element option
search_model_element_call_result m oid
searches for a model element
that holds the return value for a call with id oid
.
val json_model : model -> Json_base.json
Counterexample model in JSON format.
The format is documented in share/ce-models.json
.
val print_model : print_attrs:bool -> Stdlib.Format.formatter -> model -> unit
Prints the counterexample model.
print_attrs
: when set to true, each element is printed together with the
attrs associated to it.val interleave_with_source : print_attrs:bool ->
?start_comment:string ->
?end_comment:string ->
model ->
rel_filename:string ->
source_code:string ->
locations:(Loc.position * 'a) list -> string * (Loc.position * 'a) list
Given a source code and a counterexample model, interleaves the source code with information about the counterexample. That is, for each location in counterexample trace creates a comment in the output source code with information about values of counterexample model elements.
start_comment
: the string that starts a commentend_comment
: the string that ends a commentrel_filename
: the file name of the source relative to the sessionsource_code
: the input source codelocations
: the source locations that are found in the codeval model_for_positions_and_decls : model -> positions:Loc.position list -> model
Given a model and a list of source-code positions returns model that contains only elements from the input model that are on these positions plus for every file in the model, elements that are in the positions of function declarations. Elements with other positions are filtered out.
Assumes that for each file the element on the first line of the model has position of function declaration.
Only filename and line number is used to identify positions.
class clean :object
..end
Helper class which can be inherited by API users to clean a model, for example by removing elements that do not match a given condition, or removing some "useless" fields in records, etc.
val clean_model : #clean -> model -> model
typemodel_parser =
Printer.printing_info -> string -> model
Parses the input string (i.e. the output of the SMT solver) into a model (i.e. a mapping of files and source code lines to model elements).
typeraw_model_parser =
Printer.printing_info -> string -> model_element list
val register_remove_field : (Ident.Sattr.t * Term.term * concrete_syntax_term ->
Ident.Sattr.t * Term.term * concrete_syntax_term) ->
unit
val register_model_parser : desc:Pp.formatted -> string -> raw_model_parser -> unit
val lookup_model_parser : string -> model_parser
val list_model_parsers : unit -> (string * Pp.formatted) list