Crate discrete [] [src]

Combinatorial phantom types for discrete mathematics.

All discrete spaces has the following functions:

    fn count(dim) -> uint;
    fn to_index(dim, pos) -> uint;
    fn to_pos(dim, index, &mut pos);

This makes it possible to allocate to solve tasks as:

  • Allocate enough memory for the space
  • Read and write data
  • Convert from and to natural numbers
  • Iterate through the space
  • Pick a random object of the space

Iterating through the space can be done simply by counting from zero up to the size of the space.

Phantom types are used because they represents the general spaces. For example, we can represent a general two-dimensional space, instead of binding the type to the size.

For any constructed space, there is a dimension and position type. The dimension and position types are compositions, given by the type of the constructed space.

Structs

Context

A discrete space that can model spatial operations over arbitrary states, therefore useful for context analysis.

Data

Used by the final subspace.

Dimension

Dimension is natural number, position is the same as index.

DimensionN

Dimension is a list of numbers, position is a list of numbers.

DirectedContext

Same as Context, but for directed edges.

EqPair

Dimension is natural number, position is (min, max).

NeqPair

Dimension is natural number, position is (min, max).

Of

Used to combine the dimensional and position types.

Pair

Dimension is natural number, position is (min, max).

Permutation

Dimension is natural number, position is a list of numbers.

PowerSet

Dimension is natural number, position is a list of numbers.

Subspace

Used to nest a subspace.

Traits

Construct

Constructs a new space.

Count

Implemented by spaces that can count the number of objects.

ToIndex

Implemented by spaces that can convert position to index.

ToPos

Implemented for spaces which can convert an index to position type.