AltErgoLib.Expr
Data structures
type term_view = private {
f : Symbols.t;
xs : t list;
ty : Ty.t;
bind : bind_kind;
tag : int;
vars : (Ty.t * int) Var.Map.t;
Map of free term variables in the term to their type and number of occurrences.
*)vty : AltErgoLib.Ty.Svty.t;
Map of free type variables in the term.
*)depth : int;
nb_nodes : int;
pure : bool;
mutable neg : t option;
}
and quantified = private {
name : string;
Name of the lemma. This field is used by printers.
*)main : t;
The underlying formula.
*)toplevel : bool;
Determine if the quantified formula is at the top level of an asserted formula.
An asserted formula is a formula introduced by (assert ...)
or generated by a function definition with (define-fun ...)
.
By top level, we mean that the quantified formula is not a subformula of another quantified formula.
For instance, the subformula ∀y:int. ¬G(y) of the asserted formula ¬(∀y:int. ¬G(y)) is also considered at the top level.
Notice that quantifiers of the same kind are packed as much as possible. For instance, if we assert the formula: ∀α. ∀x:list α. ∃y:α. F(x, y) Then the two universal quantifiers are packed in a same top level formula but the subformula ∃y:α. F(x, y) is not at the top level.
This flag is important for the prenex polymorphism.
true
, all the free type variables of main
are implicitely considered as quantified.main
and are stored in the field sko_vty
.user_trs : trigger list;
List of the triggers defined by the user.
The solver doesn't generate multi-triggers if the user has defined some multi-triggers.
*)binders : binders;
The ordered list of quantified term variables of main
.
This list has to be ordered for the skolemization.
*)sko_v : t list;
Set of all the free variables of the quantified formula. In other words, this set is always the complementary of binders
in the set of free variables of main
.
The purpose of this field is to retrieve these variables quickly while performing the lazy skolemization in the SAT solver (see skolemize
).
sko_vty : Ty.t list;
The set of free type variables. In particular this set is always empty if we are the top level.
*)loc : Loc.t;
Location of the "GLOBAL" axiom containing this quantified formula. It forms with name a unique identifier.
*)kind : decl_kind;
Kind of declaration.
*)}
and semantic_trigger =
| Interval of t * Symbols.bound * Symbols.bound
| MapsTo of Var.t * t
| NotTheoryConst of t
| IsTheoryConst of t
| LinearDependency of t * t
and trigger = private {
content : t list;
List of terms that must be present for this trigger to match.
Sorted using matching heuristics; the first term is estimated as the least likely to match.
*)semantic : semantic_trigger list;
hyp : t list;
t_depth : int;
from_user : bool;
}
different views of an expression
constant casts
val int_view : t -> int
Extracts the integer value of the expression, if there is one.
The returned value may be negative or null.
val rounding_mode_view : t -> Fpa_rounding.rounding_mode
Extracts the rounding mode value of the expression, if there is one.
pretty printing
val print : Stdlib.Format.formatter -> t -> unit
val print_list : Stdlib.Format.formatter -> t list -> unit
val print_list_sep : string -> Stdlib.Format.formatter -> t list -> unit
val print_triggers : Stdlib.Format.formatter -> trigger list -> unit
val pp_smtlib : t Fmt.t
pp_smtlib ppf e
prints the expression e
on the formatter ppf
using the SMT-LIB standard.
Comparison and hashing functions
val hash : t -> int
val uid : t -> int
val compare_quant : quantified -> quantified -> int
val free_type_vars : t -> AltErgoLib.Ty.Svty.t
val is_ground : t -> bool
val size : t -> int
val depth : t -> int
val is_positive : t -> bool
val is_int : t -> bool
val is_real : t -> bool
Labeling and models
val name_of_lemma : t -> string
val name_of_lemma_opt : t option -> string
smart constructors for terms
val vrai : t
val faux : t
val void : t
val int : string -> t
val real : string -> t
Special names used for AC(X) abstraction. These corresponds to the K sort in the AC(X) paper.
val is_fresh_ac_name : t -> bool
mk_abstract ty
creates an abstract model term of type ty
. This function is intended to be used only in models.
smart constructors for literals
val mk_builtin : is_pos:bool -> Symbols.builtin -> t list -> t
simple smart constructors for formulas
smart constructor for datatypes.
val mk_constr : Uid.term_cst -> t list -> Ty.t -> t
val mk_tester : Uid.term_cst -> t -> t
Substitutions
Subterms, and related stuff
val sub_terms : Set.t -> t -> Set.t
sub_term acc e
returns the acc augmented with the term and all its sub-terms. Returns the acc if e is not a term. Does not go through literals (except positive uninterpreted predicates application) and formulas
val max_pure_subterms : t -> Set.t
max_pure_subterms e
returns the maximal pure terms of the given expression
val max_terms_of_lit : t -> Set.t
returns the maximal terms of the given literal. Assertion failure if not a literal (should replace the assertion failure with a better error) *
val max_ground_terms_of_lit : t -> Set.t
returns the maximal ground terms of the given literal. Assertion failure if not a literal *
val atoms_rec_of_form : only_ground:bool -> t -> Set.t -> Set.t
traverses a formula recursively and collects its atoms. Only ground atoms are kept if ~only_ground is true
val max_ground_terms_rec_of_form : t -> Set.t
traverses a formula recursively and collects its maximal ground terms
skolemization and other smart constructors for formulas *
val make_triggers :
t ->
binders ->
decl_kind ->
Util.matching_env ->
trigger list
make_triggers f binders decl menv
generate multi-triggers for the formula f
and binders binders
.
An escaped variable of a pattern is a variable that is not in binders
(but the variable is bound by an inner quantified formula). We can replace escaped variables by the underscore variable Var.underscore
.
For instance, if binders
is the set {x, y}
and g(x, y, z)
is a pattern where {(x, y, z)}
are free term variables, we can replace z
by _
.
Our strategy for multi-trigger generations depends on the matching environment menv
as follows:
If menv.greedy
is false
, we try to generate in order:
If menv.greedy
is true
, we try to generate in order:
If menv.triggers_var
is true
, we allow variables as valid triggers.
Note: Mono-trigger with `Sy.Plus` or `Sy.Minus` top symbols are ignored if other mono-triggers have been generated.
The matching environment env
is used to limit the number of multi-triggers generated per axiom.
clean trigger: remove useless terms in multi-triggers after inlining of lets
val resolution_triggers : is_back:bool -> quantified -> trigger list
val mk_match : t -> (Typed.pattern * t) list -> t
val skolemize : quantified -> t
type th_elt = {
th_name : string;
ax_name : string;
ax_form : t;
extends : Util.theories_extensions;
axiom_kind : Util.axiom_kind;
}
val print_th_elt : Stdlib.Format.formatter -> th_elt -> unit
val is_pure : t -> bool
val is_model_term : t -> bool
is_model_term e
checks if the expression e
is a model terms. A model term can be:
module Core : sig ... end
Constructors from the smtlib core theory. https://smtlib.cs.uiowa.edu/theories-Core.shtml
module Ints : sig ... end
Constructors from the smtlib theory of integers. https://smtlib.cs.uiowa.edu/theories-Ints.shtml
module Reals : sig ... end
Constructors from the smtlib theory of reals. https://smtlib.cs.uiowa.edu/theories-Reals.shtml
module BV : sig ... end
Constructors from the smtlib theory of fixed-size bit-vectors and the QF_BV logic.
module ArraysEx : sig ... end
Constructors from the smtlib theory of functional arrays with extensionality logic.