package smol

  1. Overview
  2. Docs

Module Monomial.MakeSource

Parameters

Signature

Sourcetype t

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

Sourceexception Monomial_has_non_positive_exponent of Literal.t * int

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

Sourceexception Monomial_set_negative_exponent of Literal.t * int

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

Sourceval one : t

The unit monomial

Sourceval is_one : t -> bool

Check if the given monomial is one

Sourceval of_literal : Literal.t -> t

of_literal x returns the monomial x

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

singleton x n returns the monomial xⁿ

  • raises [Monomial_set_negative_exponent

    (x,n)] if n < 0

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

Returns a map from literals to their non-negative exponent

Sourceval 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

Sourceval to_seq : t -> (Literal.t * int) Seq.t
Sourceval 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

Sourceval 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

Sourceval get_support : t -> Literal.t list

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

Sourceval 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.

Sourceval equal : t -> t -> bool

Equality between monomials

Sourceval 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.

Sourceval mul : t -> t -> t

Commutative multiplication between two monomials.

Sourceval 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

Sourceval 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.

Sourceval 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.

Sourceval remove : Literal.t -> t -> t

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

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourcemodule Infix : sig ... end

Infix operators

Mapping functions

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

Innovation. Community. Security.