package smol

  1. Overview
  2. Docs

Parameters

Signature

type t

The type of Monomials. They are mappings from literals to their non-negative exponent. We always ensure that exponents are positive.

exception Monomial_has_non_positive_exponent of Literal.t * int

This exception is raised if a non-positive exponent is found in a monomial.

exception Monomial_set_negative_exponent of Literal.t * int

This exception is raised when trying to set a negative exponent in a monomial.

val one : t

The unit monomial

val is_one : t -> bool

Check if the given monomial is one

val of_literal : Literal.t -> t

of_literal x returns the monomial x

val singleton : Literal.t -> int -> t

singleton x n returns the monomial xⁿ

  • raises [Monomial_set_negative_exponent

    (x,n)] if n < 0

val to_map : t -> int Map.Make(Literal).t

Returns a map from literals to their non-negative exponent

val of_map : int Map.Make(Literal).t -> t

Creates a monomial from a map m.

  • raises [Monomial_set_negative_exponent

    (x,i)] if i < 0 and (x,i) is a binding in m

val to_seq : t -> (Literal.t * int) Seq.t
val add_seq : (Literal.t * int) Seq.t -> t -> t

Adds a sequence of bindings s to the given monomial.

  • raises [Monomial_set_negative_exponent

    (x,i)] if i < 0 and (x,i) is a binding in s

val of_seq : (Literal.t * int) Seq.t -> t

Creates a monomial from a sequence of bindings s.

  • raises [Monomial_set_negative_exponent

    (x,i)] if i < 0 and (x,i) is a binding in s

val get_support : t -> Literal.t list

Returns the list of literals occuring in the object, sorted in lexicographical order

val compare : t -> t -> int

Comparison bewteen monomials. Uses the lexicographical ordering on monomials, with lexicographical ordering on the literals. This order ensures that the unit monomial is the global minimum. This order is used in the implementation of polynomials.

val equal : t -> t -> bool

Equality between monomials

val deg : Literal.t -> t -> int

deg x m returns the largest integer n such that xⁿ divides m. In particular, it returns 0 is x is not present in m.

val mul : t -> t -> t

Commutative multiplication between two monomials.

val set_exponent : Literal.t -> int -> t -> t

set_exponent ensures that, for all n >= 0, deg x (set_exponent x n m) = n.

  • raises [Monomial_set_negative_exponent(x,n)]

    if n < 0

val update : Literal.t -> (int -> int) -> t -> t

update x f m applies f to the exponent of x in m.

  • raises [Monomial_set_negative_exponent(x,f

    (deg x m))] if f returns a negative exponent.

val union : (Literal.t -> int -> int -> int) -> t -> t -> t
  • raises [Monomial_set_negative_exponent(x,f

    x exp_a exp_b)] if f returns a negative exponent.

val remove : Literal.t -> t -> t

Removes a literal from a monomial. Equivalent to set_exponent x 0

val deriv : Literal.t -> t -> (int * t) option

Derivation of m wrt x If x is not in the support of m, returns None (an "empty" monomial). Otherwise, returns Some (i,r) such that ∂m/∂x = i×r, where r is a monomial.

val apply : (module Algebra.Mul_Monoid_S with type t = 'a) -> t -> 'a Map.Make(Literal).t -> 'a * t

Partial application in a monomial. apply (module K) m v returns (c,r) such that the substitution of v in m equals c×r, where r is a monomial.

val to_string : t -> string

Conversion to printable strings.

  • raises [Monomial_has_non_positive_exponent

    (x,i)] if i <= 0 and (x,i) is a binding in the monomial.

module Infix : sig ... end

Infix operators

Mapping functions

val iter : (Literal.t -> int -> unit) -> t -> unit
val fold : (Literal.t -> int -> 'b -> 'b) -> t -> 'b -> 'b
val for_all : (Literal.t -> int -> bool) -> t -> bool
val exists : (Literal.t -> int -> bool) -> t -> bool
val filter : (Literal.t -> int -> bool) -> t -> t
val partition : (Literal.t -> int -> bool) -> t -> t * t
val cardinal : t -> int
val bindings : t -> (Literal.t * int) list
val map : (int -> 'b) -> t -> 'b Map.Make(Literal).t
val mapi : (Literal.t -> int -> 'b) -> t -> 'b Map.Make(Literal).t
OCaml

Innovation. Community. Security.