Hi there, On Nov 8, 9:36 am, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: > There are some design questions which prevented me to do it at first. Let's > start with the simple one: > > - on mathematical sets we have the notion of intersection, union, symmetric > difference. When dealing with EnumeratedSets, does someone have any opinion on > the order of enumeration of the result ? Or should the result be only in the > category Sets ?
I think the design problem comes from the fact the "category of enumerated sets" is not real "category" from the mathematical point of view, although you can embed it inside the category of totally ordered sets with the "enumeration order", that point of view might solve some of your design questions. Concerning the union of sets, in general you have to canonical way of assigning an enumeration, one can decide to enumerate first all the elements of A and then all the elements of B. This works without much trouble for finite sets. If you want a method that works also for infinite ones, you can use the standard Hilbert Hotel tricks: To add a finite set A to an infinite set B you shift all the elements of B the needed places and put the elements of A at the beginning, and to unite two infinite sets you put A[n] inside X[2n] and B[n] inside X[2n-1]. All these methods have the issue that as enumerated sets A.union(B) would be different from B.union(A). Plus the fact that the enumeration choice is arbitrary. Another direction could be to allow to specify an "ambient" enumerated set X that contains both A and B, and endow the union with the enumeration inherited from the ambient set (this would work well with things such as conjugacy classes of groups, where all elements belong to a common set). For this to make any (mathematical) sense, it would be necessary that the enumeration of A and B also come from the enumeration of X, which bring us to the problem of the intersection. If A={a1,a2,a3,a4,a5} and B={a2,a3,a5,a7,a11} (as enumerated sets) it makes sense to consider the intersection as the enumerated set {a2,a3,a5}, but if B={a11,a7,a5,a3,a2} then no enumeration will make sense. So my proposal would be to enumerate only when one has a common parent of A and B that is enumerated. > > Here is a much more complicated one: > > - If a parent is in a sub category of EnumeratedSets or Sets (say e.g.: > FiniteGroup), Currently the forgetful functor is implemented by Set > sage: S = Set(SymmetricGroup(3)) > sage: S > {(2,3), (1,3), (1,2), (1,3,2), (), (1,2,3)} > Compare with: > sage: list(SymmetricGroup(3)) > [(), (2,3), (1,2), (1,2,3), (1,3,2), (1,3)] > sage: FiniteEnumeratedSet(SymmetricGroup(3)) > {(), (2,3), (1,2), (1,2,3), (1,3,2), (1,3)} > But SymmetricGroup(3) is already in the category Sets > sage: SymmetricGroup(3) in Sets() > True > So there should be no need to call explicitely the forgetful functor. > In particular I don't see the point of creating another sage object for those > case. Otherwise said, I only see the reason to create a new sage object for > building a Set, when the object is not a sage Parent in the category Sets, eg: > python list, set, frozenset ... As far as I know "Set" is not (yet) a functor (unless we can apply it to group homomorphisms), but just the "underlying set" of a group. As of why we might need to call it, one can think of the same underlying set {a,b,c,d} having two different group structures (isomorphic to ZZ/ 2ZZ x ZZ/2ZZ or Dihedral(4)) as groups, these would be different (even non-isomorphic), but as sets they are the same (i.e. the forgetful functor is not injective on objects). This, mathematically. As of the implementation within sage, I agree one would think that the quickest way to apply it is just not to use the extra structure that has been previously defined, but I don't know the details on the implementation well enough to say anything intelligent about this. Cheers Javier --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---