Module Micromega_plugin.Vect
type tThe type of vectors or equivalently linear expressions. The current implementation is using association lists. A list
(0,c),(x1,ai),...,(xn,an)represents the linear expression c + a1.xn + ... an.xn where ai are rational constants and xi are variables.Note that the variable 0 has a special meaning and represent a constant. Moreover, the representation is spare and variables with a zero coefficient are not represented.
type vector= t
Generic functions
Basic accessors and utility functions
val pp_gen : (Stdlib.out_channel -> var -> unit) -> Stdlib.out_channel -> t -> unitpp_gen pp_var o vprints the representation of the vectorvover the channelo
val pp : Stdlib.out_channel -> t -> unitpp o vprints the representation of the vectorvover the channelo
val pp_smt : Stdlib.out_channel -> t -> unitpp_smt o vprints the representation of the vectorvover the channelousing SMTLIB conventions
val variables : t -> Micromega_plugin.Mutils.ISet.tvariables vreturns the set of variables with non-zero coefficients
val get_cst : t -> NumCompat.Q.tget_cst vreturns c i.e. the coefficient of the variable zero
val decomp_cst : t -> NumCompat.Q.t * tdecomp_cst vreturns the pair (c,a1.x1+...+an.xn)
val decomp_fst : t -> (var * NumCompat.Q.t) * tval cst : NumCompat.Q.t -> tcst creturns the vector v=c+0.x1+...+0.xn
val is_constant : t -> boolis_constant vholds ifvis a constant vector i.e. v=c+0.x1+...+0.xn
val null : tnullis the empty vector i.e. 0+0.x1+...+0.xn
val is_null : t -> boolis_null vreturns whethervis thenullvector i.eequal v null
val get : var -> t -> NumCompat.Q.tget xi vreturns the coefficient ai of the variablexi.getis also defined for the variable 0
val set : var -> NumCompat.Q.t -> t -> tset xi ai' vreturns the vector c+a1.x1+...ai'.xi+...+an.xn i.e. the coefficient of the variable xi is set to ai'
val update : var -> (NumCompat.Q.t -> NumCompat.Q.t) -> t -> tupdate xi f vreturns c+a1.x1+...+f(ai).xi+...+an.xn
val fresh : t -> intfresh vreturn the fresh variable with index 1+ max (variables v)
val choose : t -> (var * NumCompat.Q.t * t) optionchoose vdecomposes a vectorvdepending on whether it isnullor not.- returns
None if v is
null
- returns
Some(x,n,r) where v = r + n.x x is the smallest variable with non-zero coefficient n <> 0.
val from_list : NumCompat.Q.t list -> tfrom_list lreturns the vector c+a1.x1...an.xn from the list of coefficientl=c;a1;...;an
val decr_var : int -> t -> tdecr_var i vdecrements the variables of the vectorvby the amounti. Beware, it is only defined if all the variables of v are greater than i
val gcd : t -> NumCompat.Z.tgcd vreturns gcd(num(c),num(a1),...,num(an)) where num extracts the numerator of a rational value.
Linear arithmetics
val add : t -> t -> tadd v1 v2is vector addition.- parameter v1
is of the form c +a1.x1 +...+an.xn
- parameter v2
is of the form c'+a1'.x1 +...+an'.xn
- returns
c1+c1'+ (a1+a1').x1 + ... + (an+an').xn
val mul : NumCompat.Q.t -> t -> tmul a vis vector multiplication of vectorvby a scalara.- returns
a.v = a.c+a.a1.x1+...+a.an.xn
val mul_add : NumCompat.Q.t -> t -> NumCompat.Q.t -> t -> tmul_add c1 v1 c2 v2returns the linear combination c1.v1+c2.v2
val div : NumCompat.Q.t -> t -> tdiv c1 v1returns the mutiplication by the inverse of c1 i.e (1/c1).v1
Iterators
val fold : ('acc -> var -> NumCompat.Q.t -> 'acc) -> 'acc -> t -> 'accfold f acc vreturns f (f (f acc 0 c ) x1 a1 ) ... xn an
val find : (var -> NumCompat.Q.t -> 'c option) -> t -> 'c optionfind f vreturns the firstf xi aisuch thatf xi ai <> None. If no such xi ai exists, it returns None
val for_all : (var -> NumCompat.Q.t -> bool) -> t -> boolfor_all p vreturns /\_>=0 (f xi ai)
val exists2 : (NumCompat.Q.t -> NumCompat.Q.t -> bool) -> t -> t -> (var * NumCompat.Q.t * NumCompat.Q.t) optionexists2 p v v'returns Some(xi,ai,ai') if p(xi,ai,ai') holds and ai,ai' <> 0. It returns None if no such pair of coefficient exists.
val dotproduct : t -> t -> NumCompat.Q.tdotproduct v1 v2is the dot product of v1 and v2.
module Bound : sig ... end