Open tscrim opened 7 years ago
This is consistent with many other functions that do not treat a ring R as an ideal, for example
sage: ZZ.quotient_ring(ZZ)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
...
TypeError: I must be an ideal of ZZ or an integer
sage: ZZ.quotient_ring(1*ZZ)
Ring of integers modulo 1
So ZZ is not treated as an ideal, but 1*ZZ is. And this is correctly implemented:
sage: (1*ZZ) in Ideals(ZZ)
True
However, that doesn't absolve the problem. I would say it is evidence that it is more systematic. I think I will start digging into this on the code side.
I guess another question is should 1*ZZ == ZZ
and/or be ZZ
?
It is indeed systematic and this sort of thing afflicts other categories, like monoids
sage: ZZ in Monoids()
True
sage: 1*ZZ in Monoids()
False
semigroups,
sage: ZZ in Semigroups()
True
sage: 2*ZZ in Semigroups()
False
and rings:
sage: (1*ZZ) in Rings()
False
sage: (1*ZZ) in Rngs()
False
On the plus side, Sage knows that ideals are additive groups:
ZZ.categories()[24]
Category of additive groups
sage: AG = _
sage: AG.axioms()
frozenset({'AdditiveAssociative', 'AdditiveInverse', 'AdditiveUnital'})
sage: ZZ in AG
True
sage: (2*ZZ) in AG
True
To weigh in on your question, if you make ZZ known as an ideal of itself, then 1*ZZ == ZZ would make sense, and indeed they could be identical.
This was surprising to me:
Should be easy enough to fix as it is just a missed case in the custom
__contains__
method.Component: categories
Issue created by migration from https://trac.sagemath.org/ticket/22722