Re: [sage-devel] Reporting bug:the errors about method "is_trivial() in module sage.rings.ideal"

2019-03-10 Thread Simon Brandhorst
Hi Simon,

I can see your reasons. They seem to be from the perspective of someone
who knows about computer algebra. But a mathematician and casual user of 
sage
will think of an ideal as a subset of a ring. He/she will be oblivious of 
the implementation details
and expect x in J to be a containment test. Better innocently type x in J 
and wait a long time (or press ctrl + x)
than misinterpreting a result.
Experts in computer algebra can still use I.gens(). Else we should rename 
the class to 
something like IdealWithGens.

On Sunday, March 10, 2019 at 10:55:17 AM UTC+1, Simon King wrote:

> The problem is that ideal containment and equality tests can be very 
> expensive 
> (involving Gröbner basis computations), and thus it would be hardly 
> feasible 
> to use ideals as, say, keys in dictionaries. 

Maybe we should better use the generators as keys directly? 

> If you really 
> need a mathematically correct containment test and are aware that it may 
> be expensive, you can explicitly request it. But for many cases, a quick 
> and dirty mathematically wrong but computationally sound containment 
> test (or equality test for ideals) suffices.
>
>From a computer algebra system (written largely by mathematicians) 
I would expect to do the mathematically correct thing and otherwise warn
me that a computational perspective is taken.

So +1 for mathematical behavior.

Best
Simon

-- 
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] Reporting bug:the errors about method "is_trivial() in module sage.rings.ideal"

2019-03-10 Thread Simon King
Hi David,

On 2019-03-09, David Roe  wrote:
> I think the right thing to do is to change that definition to the normal
> definition of equality of ideals, which we can implement by just checking
> that each generator is contained in the other ideal.

I see reasons why this is /not/ the right thing to do, at least not for each
instance of an ideal comparison resp. containment test.

The problem is that ideal containment and equality tests can be very expensive
(involving Gröbner basis computations), and thus it would be hardly feasible
to use ideals as, say, keys in dictionaries. Also, the hash of ideals would be
needed to be modified in an expensive way, as it ought to be compatible
with the equality test.

> We'll also need to
> improve ideals in ZZ['x'] a bit, since non-principal ideals don't implement
> containment checking:

It certainly is implemented --- just not by doing "p in I". You don't
want that you innocently ask "p in I", and then Sage is occupied with
the computation of a Gröbner basis for the next few hours. If you really
need a mathematically correct containment test and are aware that it may
be expensive, you can explicitly request it. But for many cases, a quick
and dirty mathematically wrong but computationally sound containment
test (or equality test for ideals) suffices.

Best regards,
Simon

-- 
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] Reporting bug:the errors about method "is_trivial() in module sage.rings.ideal"

2019-03-09 Thread David Roe
I agree that this is a bug; are you able to open a ticket?

The problem is that ideals in Z[x] use the generic ideal code, which
defines equality based on just comparing ordered lists of generators.  I
think the right thing to do is to change that definition to the normal
definition of equality of ideals, which we can implement by just checking
that each generator is contained in the other ideal.  We'll also need to
improve ideals in ZZ['x'] a bit, since non-principal ideals don't implement
containment checking:

sage: R. = ZZ[]
sage: I = R.ideal([x^2+1,x^2+x+1])
sage: J = R.unit_ideal()
sage: I == J
False
sage: type(I)

sage: type(J)

sage: all(g in J for g in I.gens())
True
sage: all(g in I for g in J.gens())
Traceback (most recent call last):
...
NotImplementedError
David

On Sat, Mar 9, 2019 at 3:54 AM Xiaofeng bei  wrote:

> I calculate whether the ideals in ZZ[x]  are coprime. I find a bug in
> function "is_trival()" from 'SageMath version 8.5, Release Date: 2018-12-22'
>
> Following, I will show you a example:
>
> sage: R
> Univariate Polynomial Ring in x over Integer Ring
> sage: m1
> x^2 + 1
> sage: m2
> x^2 + x + 1
> sage: (1+x)*m1+(-x)*m2
> 1
> sage: I=R.ideal([m1,m2])
> sage: I.is_trivial()
> False
> sage: version()
> 'SageMath version 8.5, Release Date: 2018-12-22'
>
>
> In above example, the "I.is_trival()" should return  the "True" instedad
> of "False"
>
> --
> 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.
>

-- 
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.