Matrix(f::DiscreteFunction) returns an n-by-n zero-one matrix in which there is a 1 in position i,j exactly when f(i)==j.


DiscreteFunction is a function from {1,2,...,n} to itself. It can be created by DiscreteFunction(list) where list is a one-dimensional array of positive integers. Alternatively, it can be created using positive integer arguments.

The following are equivalent:


DiscreteFunction(A) creates a new discrete function based on the square matrix A. It is required that each row of A have exactly one nonzero element. Note that if A=Matrix(f) then DiscreteFunction(A)==f.


If f and g are of type DiscreteFunction, then f+g is their disjoint sum.


sqrt(g::DiscreteFunction) returns a function f such that f*f==g or throws an error if no such function exists. This method uses integer linear programming.


has_sqrt(f::DiscreteFunction) checks if there is a function g such that g*g==f. Returns true if so and false otherwise.


image("f::DiscreteFunction") returns a Set containing all the output values of f.


quick_sqrt_test(f::DiscreteFunction) is a quick check of a necessary condition for f to have a square root. If this returns false then f does not have a square root. If it returns true, it might.


sources(f::DiscreteFunction) returns a list of all inputs to f that are not the output of f. That is, this is a list of the vertices with out-degree 0 in the graph of f.


fixed_points(f::DiscreteFunction) returns a list of fixed points of the function, i.e., those values x such that f(x)==x.