I am creating a small Java application to play around with certain concepts in group/semigroup theory. I want to create a set of basic classes to represent these mathematical structures. Below is a very (very) basic interface that could be used to represent a set with a closed operation in Java:
public interface SetWithClosedOperation <T> {
BiFunction<T, T, T> getOperation();
}
Here, the set of possible values is represented by all possible values instances of class T could take. The operation (which is inherently closed on the set) is given by the getOperation function.
My issues are as follows:
- this doesn't allow for you to have finite sets unless you use enums.
- if you use an enum as the generic type then there would be no practical way to represent "subsets" under the same operation, as you cannot have a generic type which represents a restriction of a given enum.
Described attempted code is above. I would like a structure with the following qualities:
- The structure has a set and a closed function on that set.
- You can form substructures of a given example of the structure which has a subset of the original structures set.