Module Fol


module Fol: sig .. end

Constants

Fol Variable definition



Constants



type constant =
| ConstInt of string
| ConstBool of bool
| ConstUnit
| ConstFloat of string
val c_bool : bool -> constant
val c_int_of_str : string -> constant
val c_int : int -> constant
val c_float_of_str : string -> constant
val c_float : float -> constant

Variables


module Var: sig .. end
Fol Variable definition
module Vset: Set.Make(Var)
module Vmap: Map.Make(Var)

Terms



type 'a d_term =
| Tconst of constant
| Tvar of Var.t
| Tdata of 'a
| Tapp of string * 'a d_term list
| Tif of 'a d_term * 'a d_term * 'a d_term
| Tlet of Var.t * 'a d_term * 'a d_term

Term comparison


val bad_eq_terms : 'a d_term -> 'a d_term -> bool
compare terms without knowing how to compare data : better than something for smart constructors (see eq_terms)

in bad_eq_terms, we don't know how to compare data.

val eq_terms : ('a -> 'b -> bool) -> 'a d_term -> 'b d_term -> bool

Term visitors


val e_has_var : (Var.t list -> 'a -> bool) -> Var.t list -> 'a d_term -> bool
val bad_term_has_var : Var.t list -> 'a d_term -> bool
val e_closed : (Var.t list -> 'a -> bool) -> Var.t list -> 'a d_term -> bool
val bad_term_closed : Var.t list -> 'a d_term -> bool
val fold_data_in_exp : ('a -> Var.t -> 'a) -> ('a -> 'b -> 'a) -> 'a -> 'b d_term -> 'a
fold_data_in_exp do_var do_data acc exp

Term smart constructors


val e_true : 'a d_term
val e_false : 'a d_term
val e_int : int -> 'a d_term
val e_int64 : int64 -> 'a d_term
val e_float : float -> 'a d_term
val e_cnst : constant -> 'a d_term
val e_var : Var.t -> 'a d_term
val e_data : 'a -> 'a d_term
val e_if : 'a d_term -> 'a d_term -> 'a d_term -> 'a d_term
val i_compute : (Big_int.big_int -> Big_int.big_int -> Big_int.big_int) ->
string -> string -> 'a d_term
val simpl : unit -> Wp_parameters.Simpl.t
val e_app : string -> 'a d_term list -> 'a d_term
val e_let : Var.t -> 'a d_term -> 'a d_term -> 'a d_term
val case_of : 'a d_term -> string option

Term transformation


val change_in_exp : (Var.t -> 'a d_term option) ->
('b -> 'a d_term) -> 'b d_term -> 'a d_term
Apply do_var and do_data in term subexpressions. Notice that do_data is in charge of propagating recursively in its own subexpressions if any, and that it returns a new expression instead of a new data because there can be data transformation.
val change_data_in_exp : (('a d_term -> 'b d_term) -> 'a -> 'b) ->
'a d_term -> 'b d_term
Similar to change_in_exp but only transforms data into data. do_data_rec is supposed to process the data d, to propagate recursively in the subdata, and to call do_exp in the subexpressions.
val term_replace : (Var.t -> Var.t option) ->
Var.t -> 'a d_term -> 'a d_term -> 'a d_term
This one doesn't know how to substitute in data, so it builds a let if needed. alpha is used
val alpha_bound_var : Vmap.key Vmap.t ->
Vmap.key -> Vmap.key option * Vmap.key Vmap.t
val alpha_unbound : 'a Vmap.t -> Vmap.key -> 'a option -> 'a Vmap.t
val apply_alpha : Var.t Vmap.t -> Vmap.key -> Var.t Vmap.t * Var.t
val term_alpha_cv : (Vmap.key Vmap.t -> 'a -> Vmap.key Vmap.t * 'a) ->
Vmap.key Vmap.t ->
'a d_term -> Vmap.key Vmap.t * 'a d_term
val terms_alpha_cv : (Vmap.key Vmap.t -> 'a -> Vmap.key Vmap.t * 'a) ->
Vmap.key Vmap.t ->
'a d_term list -> Vmap.key Vmap.t * 'a d_term list

Predicates



type 'a t_pred =
| Papp of string * 'a list
| Ptrue
| Pfalse
| Pimplies of 'a t_pred * 'a t_pred
| Pif of 'a * 'a t_pred * 'a t_pred
| Pand of 'a t_pred * 'a t_pred
| Por of 'a t_pred * 'a t_pred
| Piff of 'a t_pred * 'a t_pred
| Pnot of 'a t_pred
| Pforall of Var.t * 'a t_pred
| Pexists of Var.t * 'a t_pred
| Plet of Var.t * 'a * 'a t_pred
| Pnamed of string * 'a t_pred
type 'a d_pred = 'a d_term t_pred 

Predicates smart constructors


val i_compare : (Big_int.big_int -> Big_int.big_int -> bool) ->
string -> string -> 'a t_pred
val p_app : string -> 'a d_term list -> 'a d_term t_pred
val val_of : 'a t_pred -> 'a t_pred
val cut : 'a t_pred -> 'b t_pred -> 'a t_pred
val p_not : 'a d_term t_pred -> 'a d_term t_pred
val p_and : 'a t_pred -> 'a t_pred -> 'a t_pred
val p_or : 'a t_pred -> 'a t_pred -> 'a t_pred
val p_xor : 'a t_pred -> 'a t_pred -> 'a t_pred
val p_implies : 'a t_pred -> 'a t_pred -> 'a t_pred
val p_conj : 'a t_pred list -> 'a t_pred
val p_disj : 'a t_pred list -> 'a t_pred
val p_if : 'a -> 'a t_pred -> 'a t_pred -> 'a t_pred
val p_iff : 'a d_term t_pred ->
'a d_term t_pred -> 'a d_term t_pred
val p_eq : 'a d_term -> 'a d_term -> 'a d_term t_pred
val p_neq : 'a d_term -> 'a d_term -> 'a d_term t_pred
val p_forall : Var.t -> 'a t_pred -> 'a t_pred
val p_exists : Var.t -> 'a t_pred -> 'a t_pred
val p_let : Var.t -> 'a -> 'a t_pred -> 'a t_pred
val p_named : string -> 'a t_pred -> 'a t_pred

Predicates visitors


val p_has_var : (Var.t list -> 'a -> bool) -> Var.t list -> 'a t_pred -> bool
val bad_pred_has_var : Var.t list -> 'a d_term t_pred -> bool
val p_closed : (Var.t list -> 'a -> bool) -> Var.t list -> 'a t_pred -> bool
val bad_pred_closed : Var.t list -> 'a d_term t_pred -> bool
val fold_exp_in_pred : ('a -> 'b -> 'a) -> 'a -> 'b t_pred -> 'a
TODO: this function is probably not exactly the good one since bounded variables might escape.

fold_exp_in_pred do_exp acc p

val fold_data_in_pred : ('a -> Var.t -> 'a) ->
(('a -> 'b d_term -> 'a) -> 'a -> 'b -> 'a) ->
'a -> 'b d_term t_pred -> 'a

Predicates transformation


val change_exp_in_pred : ('a d_term -> 'b d_term) ->
'a d_term t_pred -> 'b d_term t_pred
apply do_exp on each sub expression of the predicate. quantif_do_exp is called to change do_exp if needed when we go under a quantification. This version makes possible to have a different flavor of term, ie. it can be used for translation. TODOopt: we could have another optimized version if the types of terms are the same in order to avoid building new terms when there is no modification.
val no_quantif_do_exp : ('a d_term -> 'b d_term) ->
Var.t -> 'a d_term -> 'b d_term
val change_data_in_pred : (('a d_term -> 'b d_term) -> 'a -> 'b) ->
'a d_term t_pred -> 'b d_term t_pred
change_data_in_pred do_data_rec p where do_data_rec do_exp d
val pred_alpha_cv : (Vmap.key Vmap.t -> 'a -> Vmap.key Vmap.t * 'a) ->
Vmap.key Vmap.t ->
'a d_term t_pred ->
Vmap.key Vmap.t * 'a d_term t_pred
pred_alpha_c data_alpha alpha p -> alpha', p'
val p_alpha_cv : (Vmap.key Vmap.t -> 'a -> Vmap.key Vmap.t * 'a) ->
'a d_term t_pred -> Vmap.key list * 'a d_term t_pred
val translate_data_in_term : ('a -> 'b d_term) -> 'a d_term -> 'b d_term
translate_data_in_term do_data exp
val translate_data_in_pred : ('a -> 'b d_term) -> 'a d_pred -> 'b d_pred
translate_data_in_pred do_data pred
val translate_pred_in_item : ('a -> 'b d_pred) -> 'a Formula.item -> 'b d_pred Formula.item
translate_pred_in_item do_pred item
val translate_pred_in_decl : ('a -> 'b d_pred) ->
'a Formula.declaration -> 'b d_pred Formula.declaration
translate_pred_in_decl do_pred item
val change_exp_in_pred : ('a d_term -> 'b d_term) ->
'a d_term t_pred -> 'b d_term t_pred
val subst_vars_in_pred : (('a d_term -> 'b d_term) -> 'a -> 'b d_term) ->
(Var.t -> 'b d_term option) ->
'a d_term t_pred -> 'b d_term t_pred
Similar to change_vars_in_exp but on predicates. Notice that we assume (and check) that var_subst only works on free variables (and that they are different from bounded ones).
val subst_in_pred : (('a d_term -> 'b d_term) -> 'a -> 'b d_term) ->
Var.t ->
'b d_term -> 'a d_term t_pred -> 'b d_term t_pred
Specialized version of subst_vars_in_pred to substitute one variable v by and expression exp in a predicate p.
val let_pred : (('a d_term -> 'a d_term) -> 'a -> 'a d_term) ->
fresh:bool ->
Var.t ->
'a d_term -> 'a d_term t_pred -> 'a d_term t_pred
Build a predicate equivalent to let v = e in p but may use the substitution in some simple cases (like substitute a variable by another variable for instance). fresh is only meaningfull when the let is actually built: it tells if we have to build a new variable for v.
val pred_replace : (Var.t -> Var.t option) ->
Var.t ->
'a d_term -> 'a d_term t_pred -> 'a d_term t_pred
val fresh_vars_in_pred : (('a d_term -> 'a d_term) -> 'a -> 'a d_term) ->
Var.t list ->
'a d_term t_pred -> Var.t list * 'a d_term t_pred
val p_forall_vars : (('a d_term -> 'a d_term) -> 'a -> 'a d_term) ->
Var.t list -> 'a d_pred -> 'a d_pred
val p_exists_vars : (('a d_term -> 'a d_term) -> 'a -> 'a d_term) ->
Var.t list -> 'a d_pred -> 'a d_pred
exception Huge
val check_term : int -> 'a d_term -> int
val check_pred : int -> 'a d_term t_pred -> int
val huge_term : int -> 'a d_term -> bool
val huge_pred : int -> 'a d_term t_pred -> bool