HaskellForMaths-0.3.4: Combinatorics, group theory, commutative algebra, non-commutative algebra

Math.CommutativeAlgebra.Polynomial

Description

A module defining the algebra of commutative polynomials over a field k. Polynomials are represented as the free k-vector space with the monomials as basis.

A monomial ordering is required to specify how monomials are to be ordered. The Lex, Glex, and Grevlex monomial orders are defined, with the possibility to add others.

Synopsis

# Documentation

class (Eq m, Show m, Mon m) => Monomial m whereSource

In order to work with monomials, we need to be able to multiply them and divide them. Multiplication is defined by the Mon (monoid) class. Division is defined in this class. The functions here are primarily intended for internal use only.

Methods

mdivides :: m -> m -> BoolSource

mdiv :: m -> m -> mSource

mgcd :: m -> m -> mSource

mlcm :: m -> m -> mSource

mcoprime :: m -> m -> BoolSource

mdeg :: m -> IntSource

Instances

 (Ord v, Show v) => Monomial (Grevlex v) (Ord v, Show v) => Monomial (Glex v) (Ord v, Show v) => Monomial (Lex v) (Ord v, Show v) => Monomial (MonImpl v) (Monomial a, Monomial b) => Monomial (Elim2 a b)

class MonomialConstructor m whereSource

We want to be able to construct monomials over any set of variables that we choose. Although we will often use String as the type of our variables, it is useful to define polymorphic types for monomials.

Methods

mvar :: v -> m vSource

mindices :: m v -> [(v, Int)]Source

var :: (Num k, MonomialConstructor m) => v -> Vect k (m v)Source

`var v` creates a variable in the vector space of polynomials. For example, if we want to work in Q[x,y,z], we might define:

``` [x,y,z] = map var ["x","y","z"] :: [GlexPoly Q String]
```

Notice that, in general, it is necessary to provide a type annotation so that the compiler knows which field and which term order to use.

data MonImpl v Source

The underlying implementation of monomials in variables of type v. Most often, we will be interested in MonImpl String, with the variable "x" represented by M 1 [("x",1)]. However, other types can be used instead.

No Ord instance is defined for MonImpl v, so it cannot be used as the basis for a free vector space of polynomials. Instead, several different newtype wrappers are provided, corresponding to different monomial orderings.

Constructors

 M Int [(v, Int)]

Instances

 MonomialConstructor MonImpl Eq v => Eq (MonImpl v) Show v => Show (MonImpl v) Ord v => Mon (MonImpl v) (Ord v, Show v) => Monomial (MonImpl v)

newtype Lex v Source

A type representing monomials with Lex ordering.

Lex stands for lexicographic ordering. For example, in Lex ordering, monomials up to degree two would be ordered as follows: x^2+xy+xz+x+y^2+yz+y+z^2+z+1.

Constructors

 Lex (MonImpl v)

Instances

 MonomialConstructor Lex (Num k, Ord v, Show v) => Algebra k (Lex v) Eq v => Eq (Lex v) Ord v => Ord (Lex v) Show v => Show (Lex v) Ord v => Mon (Lex v) (Ord v, Show v) => Monomial (Lex v)

type LexPoly k v = Vect k (Lex v)Source

A type representing polynomials with Lex term ordering.

lexvar :: v -> LexPoly Q vSource

`lexvar v` creates a variable in the algebra of commutative polynomials over Q with Lex term ordering. It is provided as a shortcut, to avoid having to provide a type annotation, as with `var`. For example, the following code creates variables called x, y and z:

``` [x,y,z] = map lexvar ["x","y","z"]
```

newtype Glex v Source

A type representing monomials with Glex ordering.

Glex stands for graded lexicographic. Thus monomials are ordered first by degree, then by lexicographic order. For example, in Glex ordering, monomials up to degree two would be ordered as follows: x^2+xy+xz+y^2+yz+z^2+x+y+z+1.

Constructors

 Glex (MonImpl v)

Instances

 MonomialConstructor Glex (Num k, Ord v, Show v) => Algebra k (Glex v) Eq v => Eq (Glex v) Ord v => Ord (Glex v) Show v => Show (Glex v) Ord v => Mon (Glex v) (Ord v, Show v) => Monomial (Glex v)

type GlexPoly k v = Vect k (Glex v)Source

A type representing polynomials with Glex term ordering.

glexvar :: v -> GlexPoly Q vSource

`glexvar v` creates a variable in the algebra of commutative polynomials over Q with Glex term ordering. It is provided as a shortcut, to avoid having to provide a type annotation, as with `var`. For example, the following code creates variables called x, y and z:

``` [x,y,z] = map glexvar ["x","y","z"]
```

newtype Grevlex v Source

A type representing monomials with Grevlex ordering.

Grevlex stands for graded reverse lexicographic. Thus monomials are ordered first by degree, then by reverse lexicographic order. For example, in Grevlex ordering, monomials up to degree two would be ordered as follows: x^2+xy+y^2+xz+yz+z^2+x+y+z+1.

In general, Grevlex leads to the smallest Groebner bases.

Constructors

 Grevlex (MonImpl v)

Instances

 MonomialConstructor Grevlex (Num k, Ord v, Show v) => Algebra k (Grevlex v) Eq v => Eq (Grevlex v) Ord v => Ord (Grevlex v) Show v => Show (Grevlex v) Ord v => Mon (Grevlex v) (Ord v, Show v) => Monomial (Grevlex v)

type GrevlexPoly k v = Vect k (Grevlex v)Source

A type representing polynomials with Grevlex term ordering.

grevlexvar :: v -> GrevlexPoly Q vSource

`grevlexvar v` creates a variable in the algebra of commutative polynomials over Q with Grevlex term ordering. It is provided as a shortcut, to avoid having to provide a type annotation, as with `var`. For example, the following code creates variables called x, y and z:

``` [x,y,z] = map grevlexvar ["x","y","z"]
```

data Elim2 a b Source

Constructors

 Elim2 !a !b

Instances

 (Num k, Ord a, Mon a, Ord b, Mon b) => Algebra k (Elim2 a b) (Eq a, Eq b) => Eq (Elim2 a b) (Ord a, Ord b) => Ord (Elim2 a b) (Show a, Show b) => Show (Elim2 a b) (Mon a, Mon b) => Mon (Elim2 a b) (Monomial a, Monomial b) => Monomial (Elim2 a b)

bind :: (MonomialConstructor m, Num k, Ord a, Show a, Algebra k a) => Vect k (m v) -> (v -> Vect k a) -> Vect k aSource

(%%) :: (Fractional k, Monomial m, Ord m, Algebra k m) => Vect k m -> [Vect k m] -> Vect k mSource

`f %% gs` is the reduction of a polynomial f with respect to a list of polynomials gs. In the case where the gs are a Groebner basis for an ideal I, then `f %% gs` is the equivalence class representative of f in R/I, and is zero if and only if f is in I.