Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am posting this as what I'm using in the meanwhile, but ideally it would be a method attribute of the class. The fibers() method is quite helpful here. It gives a dictionary of preimages of each element. Since we have singletons we just pop() and we know it's the inverse element.

Obviously we would want to check for bijectivity here...

> def inverse(func):
>     dic = func.fibers()
>     for i in func.codomain():
>         dic[i] = set(dic[i]).pop()
>     return FiniteSetMaps(func.codomain(),func.domain()).from_dict(dic)