+1 to "Rigerous" testing of equality, but being able to rigorously show if something is not equal is hard (and in many nontrivial cases not possible). bool() should return true "if it can be shown to be equal"
On Wed, Jun 4, 2008 at 6:23 PM, Jason Grout <[EMAIL PROTECTED]> wrote: > > Robert Bradshaw wrote: >> On Jun 4, 2008, at 4:57 PM, Carl Witty wrote: >> >>> On Jun 4, 4:16 pm, Robert Bradshaw <[EMAIL PROTECTED]> >>> wrote: >>>> On Jun 4, 2008, at 2:46 PM, Jason Grout wrote: >>>> >>>>> Of course, bool(some equation) returning False does not necessarily >>>>> mean >>>>> that the two expressions are not equal; it only means that we >>>>> couldn't >>>>> prove them to be equal using some simple simplifications. >>>>> From the docstring for _nonzero_ from equation.py (used to >>>>> implement >>>>> bool()): >>>>> Return True if this (in)equality is definitely true. Return False >>>>> if it >>>>> is false or the algorithm for testing (in)equality is inconclusive. >>>> Should it throw an error in this case? (Is there a way to know if the >>>> result was inconclusive?) >>> In this thread: http://groups.google.com/group/sage-devel/ >>> browse_thread/thread/bcdc671d2791056e/e086a9d59ff4b9ba >>> it seems that the consensus was to throw an error here; but nobody >>> ever implemented it (or even opened a trac ticket, as far as I know). >> >> Thanks for the reference. There's a trac ticket now: >> >> http://trac.sagemath.org/sage_trac/ticket/3369 > > > Rather than throwing an error, we could throw a warning using the > warnings module. Then the user could turn off the warning, just see > text, make it throw an exception, etc. > > As gfurnish notes on the ticket, though, throwing an error was deemed > very bad after discussion. There was only one precedent I found for > throwing an error in _nonzero_, and that was changed a long time ago (I > believe in twisted). My guess is that throwing a warning would be > equally bad. > > I believe the consensus was to have a different function that did > rigorous testing of equality. > > I like Mike Hansen's approach: bool (and the associated if statement > construct) is really: "Return true if you can figure out that it is true". > > Thanks, > > Jason > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
