Thanks Simon.

> The default behaviour of "x in P" for any parent P in Sage is:
>  x in P
>  <=>
>  P(x)==x is True (and does not raise an error)

This default behavior is very badly suited. In parallel to my second
mail, I found the more striking example
{{{
sage: R = Zmod(5)
sage: i = ZZ(3)
sage: j = R(3)
sage: i in R and j in ZZ
True
sage: i == j
True
sage: 1/i in R
False
sage: 1/i == 1/j
False
}}}

I definitely think that "Zmod(5)(3) in ZZ" should return False.
Remarks that it is true as a subset as Zmod(5)(3) is the set of
integers equal to 3 mod 5. In other words "3 in Zmod(5)(3)" should
returns True but it returns an error.

> I think that's a mess. P should at least know that it is a subset of ZZ.
> Hence, its embedding into ZZ should be registered as a coercion. And it
> should be able to convert a positive python int.

It is easy to create an embedding into ZZ and modify the __contains__
method. Then many things work well.

Note that P is a facade and hence it is normal that its elements have
a parent different from P. But is there a canonical way to tell that a
Parent is a subset of another Parent?

Best,
Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to