package libabsolute
Module Libabsolute.Expr
This module defines the numerical language and some basic operations over it
numeric expressions (function call, unary negation, binary operations, variables and constants)
and 'a annot_t = 'a annot * 'aErrors
Constructors
Constants
val one : tval zero : tval two : tExpression Constructors
val of_int : int -> tbuilds an expression from an integer
val of_float : float -> tbuilds an expression from an float
val var : string -> tvariables constructor
Predicates
val has_variable : t -> boolchecks if an expression contains a variable
val is_linear : t -> boolchecks if an expression is linear:
- is_linear (2*x + 4*y) = true
- is_linear (2*x*z + y) = false
Operations
convert a binary operator to a rational function. The resulting function may raise Division_by_zero or Non_integer_exposant when the binary operator is respectivelly DIV or POW
bottom-up partial evaluation of expressions when operations involving only constants are involved:
- constant_propagation (x+2) = (x+2)
- constant_propagation (2+2)*x = (4*x)
val collect_vars : t -> int Tools.VarMap.tReturns all the variables appearing in an expression as a map where to each variable is associated the integer number of its occurences
replace expr var value builds a new expression identical to expr where all the occurences of the variable var are replaced by the expression value.
if simplify is true (default behaviour), a round of constant propagation is applied on the resulting expression
fix_var expr var cst builds a new expression identical to expr where all the occurences of the variable var are replaced by the constant cst
if simplify is true (default behaviour), a round of constant propagation is applied on the resulting expression
val eval : t -> Instance.t -> Q.tEvaluates the expression at the given point.
Printing
val pp_var : Format.formatter -> string -> unitvariables printing
val pp_binop : Format.formatter -> binop -> unitbinary operators printing
val print : Format.formatter -> t -> unitexpression printer
val to_string : t -> stringConversion to a string