On Sat, Aug 22, 2009 at 1:50 PM, Simon King <[email protected]> wrote:
> > Hi William, > > On Aug 22, 8:30 pm, William Stein <[email protected]> wrote: > [...] > > > The logic > > > between the equality testing and this question seems like it should be > > > consistent. > > > > That's a good point -- the question is perhaps impossible to answer in > > general in both cases. That said, I know for a fact a lot of people > will > > complain if R.is_field() returns False by default when one can't decide, > > even when R is a field, since I think that used to be the case and people > > *very* frequently completely. This was when is_Field(...) was in the > > top-level namespace (it has since been deprecated). > > Is it deprecated? I get > sage: is_field(RR) > True > without a deprecation warning and without importing anything in Sage > 4.1 I was talking about is_Field, which behaves as I claimed: flat:illustrations wstein$ sage ---------------------------------------------------------------------- | Sage Version 4.1.1, Release Date: 2009-08-14 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: is_Field(RR) /Users/wstein/.sage/temp/flat.local/1363/_Users_wstein__sage_init_sage_0.py:1: DeprecationWarning: Using is_Field from the top level is deprecated since it was designed to be used by developers rather than end users. It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. # -*- coding: utf-8 -*- True The "is_field" is just a shorthand for R.is_field(). > > > I agree that consistent behaviour is good, but I don't see the point > of the "proof=True" option: Catching an error is not more difficult > than putting an extra argument "proof=False". Personally, I am for leaving things the way they are now with exceptions, and adding a way to assert that a ring is a field. See my comment on your excellent suggestion along those lines below. > > What do you think about returning "None" if the answer can't be > determined? I don't like that because None and False are basically the same thing, and I'm sure this won't make users that happy either: sage: R = some construction of my favorite field sage: R.is_field() sage: # No output? It's broken! Anyway, I think all "predicates", i.e., functions in Sage of the form "is_", should return either True or False. > Namely, the typical use case in existing programs should be > if R.is_field(): > run some special algorithm > else: > do the generic blurp > > If R.is_field() returns None, then the generic case would apply (which > is natural if one doesn't know for sure whether R is a field). > > If one really wants to know whether R is provably not a field, then > one asks R.is_field()==False. > > Since it is generally undecidable whether a ring is a field, I think > there should be a generic method for rings that allows the user to > assert that R is a field. Say: > sage: R = some weird definition, the user knows it is a field > sage: R.is_field() > => NotImplementedError > sage: R.assert_field(True) > sage: R.is_field() > True That's definitely a good idea. It would be good to advertise that function in the except that is raised when "R.is_field()" fails. William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
