On Tue, Aug 3, 2021 at 4:58 PM Oscar Benjamin
<
oscar.j....@gmail.com> wrote:
>
> On Tue, 3 Aug 2021 at 23:17, Aaron Meurer <
asme...@gmail.com> wrote:
> >
> > > Finally, it must be stressed that Kind instance must be singleton, and we should not implement complicated set theory logic here. This is to facilitate the determination of the kind of associative operation with very large number of arguments.
> >
> > I'm a little confused by this paragraph. I don't see why Kind
> > instances need to be singletons in the Python sense (like SymPy's
> > SingletonMeta), although maybe that isn't what you meant. I agree we
> > shouldn't try to go crazy with Monoids and Rings and so on (at least
> > at this stage), but again, I'm not clear if that is what you are
> > talking about here.
>
> Part of the idea of kind as opposed to type is that there are no
> subkinds in the way that we have subtypes (or subclasses). An object
> has exactly one kind e.g. NumberKind, BooleanKind etc. No object can
> be both a Number and a Boolean because those are two distinct kinds
> and all kinds are mutually exclusive. The kind of a particular object
> therefore can always be an instance of a Python singleton class unless
> the kind needs to be parametrised like MatrixKind(NumberKind).
I see, although I don't in principle see why kinds couldn't be
subclassed or combined, even though I agree it doesn't make sense for
the classes we have now.
I'm mostly just allergic to the word "singleton" in SymPy because I
think putting stuff on SingletonRegistry is almost always unnecessary
and has bad consequences. So as long as we aren't proposing doing
that, I'm fine with this.
>
> Things like Monoid and Ring don't make sense in this context because
> you'd end up having combinations that are super/subsets of each other
> like Monoid and Group or Ring and Field (every group is a monoid and
> every field is a ring). For these it makes more sense to have
> attributes like is_Field, is_Ring etc because then the attributes can
> be set independently. The fact that `.kind` is a single attribute and
> can only have a single value is a deliberate design choice to make it
> clear that an object can only be of one kind.
I'm still not really following this argument. What attributes are you
talking about?
But as I said, I don't think Ring, etc. make sense here.
To me, the idea behind kind is that it is the mathematical "type" of
an object (except we call it "kind" instead of "type" because "type"
already has another meaning in Python). For example, the mathematical
type of 1 is a scalar number. It happens to be an element of the ring
Z, but it's also an element of Q or R or Z[x]. But, critically, it's
*not* an element of, say, the ring of n x n matrices, because the "1"
in that ring is actually a different mathematical type. It's rather I,
the n x n identity matrix, which has many of the same properties as 1,
but is not a scalar number whereas 1 is.
Two objects are of the same kind if they are literally elements of
some ambient algebra, rather than just homomorphic images. The ambient
algebra itself is not that important. We could say matrices, for
instance, are part of some sort of "matrix algebra" that allow adding
and multiplying and so on. But if we could also extend this with other
matrix operations (like e.g., a tensor product), and, critically,
doing so would only be a question of building a class for that
operation. It would not require extending the kind.
There's probably also a nice mathematical type theory (or maybe
category theory) way of looking at this, but I'm not fluent enough in
either to really attempt that.
Aaron Meurer
>
> --
> Oscar
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sympy+un...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAHVvXxRk_6qc4B7bzgpBf3oXmnMtzzzf_FdGzKej8FQHWrofUQ%40mail.gmail.com.