Re: [sage-devel] Category question: how to get base ring?

2017-07-10 Thread Jeroen Demeyer

On 2017-06-30 17:01, Nicolas M. Thiery wrote:

On Fri, Jun 30, 2017 at 10:39:50AM +0200, Jeroen Demeyer wrote:

OK, but the question becomes:

Suppose a parent R is in Algebras(something), is it safe to assume that R is
an algebra over R.base_ring()? In other words, what is the semantic of
"base_ring"?


Hmm, good point. The funny thing is that this brings us back to a
brief discussion we had two years ago on #18310


Actually, this seems more related to #22962

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Category question: how to get base ring?

2017-06-30 Thread Nicolas M. Thiery
On Fri, Jun 30, 2017 at 10:39:50AM +0200, Jeroen Demeyer wrote:
> OK, but the question becomes:
> 
> Suppose a parent R is in Algebras(something), is it safe to assume that R is
> an algebra over R.base_ring()? In other words, what is the semantic of
> "base_ring"?

Hmm, good point. The funny thing is that this brings us back to a
brief discussion we had two years ago on #18310, which I started to
rebase one hour ago :-)

I have always made the implicit assumption that, for `R` a module
(e.g. in Modules(something)):

(i)  R is a module over R.base_ring()
(ii) the coefficients of an element or R are in R.base_ring()

I believe most of the category code in Modules and its subcategories
make the same implicit assumption.

(i) I think is just fine: categories would not allow anyway a parent
to be in Modules(R) and Modules(Q) simultaneously, as they would
provide the same code. But of course it ought to be documented and if
at all possible tested.

(ii) is more problematic: as explained in the documentation of
CategoryObject.base_ring the coefficients may live in a larger ring,
the coordinate ring (e.g. for ZZ^2/2)

In #18310, we said that clarifying this would be for #10672, but
apparently this has not been done.

I am not sure what's the best way out. Plausibly to define:

- Specify that base_ring() is what the module is over
- Specify that coordinate_ring() gives the parent of the coefficients
- Warn that some of the code may be broken if the two don't coincide
- Progressively make the code work or raise a warning when they don't
  coincide

What do you think?

Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" 
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Category question: how to get base ring?

2017-06-30 Thread Jeroen Demeyer

On 2017-06-29 19:41, Nicolas M. Thiery wrote:

 Hi Jeroen,

On Tue, Jun 27, 2017 at 11:31:36AM +0200, Jeroen Demeyer wrote:

Suppose that R is some parent which is contained in the category Algebras(B)
for some ring B, how does one determine B from the parent R?



I am asking because I want to implement a new method in the ParentMethods of
Algebras, which needs to refer to the base_ring of the category. I feel like
ParentMethods should have a way to refer back to the category where the
ParentMethods was defined.


You can safely assume that the parent B implements R.base_ring().


OK, but the question becomes:

Suppose a parent R is in Algebras(something), is it safe to assume that 
R is an algebra over R.base_ring()? In other words, what is the semantic 
of "base_ring"?


--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Category question: how to get base ring?

2017-06-29 Thread Nicolas M. Thiery
Hi Jeroen,

On Tue, Jun 27, 2017 at 11:31:36AM +0200, Jeroen Demeyer wrote:
> Suppose that R is some parent which is contained in the category Algebras(B)
> for some ring B, how does one determine B from the parent R?

> I am asking because I want to implement a new method in the ParentMethods of
> Algebras, which needs to refer to the base_ring of the category. I feel like
> ParentMethods should have a way to refer back to the category where the
> ParentMethods was defined.

You can safely assume that the parent B implements R.base_ring().

Alternatively, one could call R.category().base_ring() which will
retrieve the base ring from the its Modules(K) super category. But as
was mentioned earlier, the result may be just "Rings()" or "Fields()".

Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" 
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.