Re: [sage-devel] "Tri bool"
There is still a semantic problem to solve the following sage: Unknown or False False sage: False or Unknown Unknown Python is using __nonzero__ to deal with these or/and/not operators. This method __nonzero__ implicitly defines the conversion to booleans. And Python sets x or y := x if bool(x) is True and y otherwise It might be changed to x or y := x if trool(x) is True y if trool(x) is False x if trool(x) is Unknown and trool(y) is not True y if trool(x) is Unknown and trool(y) is True I guess it is what you called "shortcut". In this form it is a max operation with True -> 1, Unknown -> 1/2, False -> 0. Vincent -- 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] "Tri bool"
On Tue, Nov 15, 2016 at 09:43:18AM +0100, Vincent Delecroix wrote: > And what do you do with > > my_function1() or my_function2() or my_function3() Shortcut when you meet a True. For "and", shortcut when you meet a Unknown or a False. > shortcut or not shortcut? The current state of Python is that some of > the above functions might not be evaluated (ie shortcut) *before* > knowing the return type. > > > On 15 November 2016 at 09:41, Thierry wrote: > > On Tue, Nov 15, 2016 at 09:27:14AM +0100, Vincent Delecroix wrote: > >> On 15 November 2016 at 09:19, Thierry > >> wrote: > >> > On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: > >> >> Not currently (though we have "Unknown"). The main problem is the > >> >> interaction with Python booleans and the operators "or", "and", "not" > >> >> (which are *not* logical operators). The Sage "Unknown" is badly > >> >> broken for these reasons > >> >> > >> >> sage: not Unknown # waiting for Unknown > >> >> True > >> >> sage: Unknown or False # waiting for Unknown > >> >> False > >> >> > >> >> So be careful if you start using it! > >> >> > >> >> If we would use the correct logical operators ~ (for negation), ^ (for > >> >> xor) and & (for and) then we might be able to come up with something. > >> >> But Sage sort of ignore them. > >> >> > >> >> This problem has been discussed a lot on this mailing list and there > >> >> even exists a (refused) PEP request in this direction. > >> > > >> > For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main > >> > reason for rejecting the proposal was "too much discussions"...). > >> > > >> > Perhaps was the proposal too greedy, so i wonder whether there would be a > >> > possibility to have a trool adding an Unknown to bool that does not > >> > perturb the speed when only True and False are used, and so that the > >> > "short-circuiting semantics" remains preserved. > >> > >> No way! In an expression such as > >> > >> "True or whatever_function(x)" > >> > >> the "whatever_function(x)" is *not* evaluated... > >> > >> sage: def f(): print "hello" > >> sage: True or f() > >> True > > > > I do not see your point. True or Unknown should be True, right ? So we can > > shortcut here as well for trools, no ? > > > > Ciao, > > Thierry > > > > > >> > >> > This could indeed be useful in testing equality of overlaping > >> > real-intervals, undecidable problems in groups, equality of symbolic > >> > expressions, ... > >> > >> But I agree that it could be useful. > >> > >> Vincent > >> > >> -- > >> 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. > > -- > 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.
Re: [sage-devel] "Tri bool"
You are right this was a non-example... -- 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] "Tri bool"
And what do you do with my_function1() or my_function2() or my_function3() shortcut or not shortcut? The current state of Python is that some of the above functions might not be evaluated (ie shortcut) *before* knowing the return type. On 15 November 2016 at 09:41, Thierry wrote: > On Tue, Nov 15, 2016 at 09:27:14AM +0100, Vincent Delecroix wrote: >> On 15 November 2016 at 09:19, Thierry >> wrote: >> > On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: >> >> Not currently (though we have "Unknown"). The main problem is the >> >> interaction with Python booleans and the operators "or", "and", "not" >> >> (which are *not* logical operators). The Sage "Unknown" is badly >> >> broken for these reasons >> >> >> >> sage: not Unknown # waiting for Unknown >> >> True >> >> sage: Unknown or False # waiting for Unknown >> >> False >> >> >> >> So be careful if you start using it! >> >> >> >> If we would use the correct logical operators ~ (for negation), ^ (for >> >> xor) and & (for and) then we might be able to come up with something. >> >> But Sage sort of ignore them. >> >> >> >> This problem has been discussed a lot on this mailing list and there >> >> even exists a (refused) PEP request in this direction. >> > >> > For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main >> > reason for rejecting the proposal was "too much discussions"...). >> > >> > Perhaps was the proposal too greedy, so i wonder whether there would be a >> > possibility to have a trool adding an Unknown to bool that does not >> > perturb the speed when only True and False are used, and so that the >> > "short-circuiting semantics" remains preserved. >> >> No way! In an expression such as >> >> "True or whatever_function(x)" >> >> the "whatever_function(x)" is *not* evaluated... >> >> sage: def f(): print "hello" >> sage: True or f() >> True > > I do not see your point. True or Unknown should be True, right ? So we can > shortcut here as well for trools, no ? > > Ciao, > Thierry > > >> >> > This could indeed be useful in testing equality of overlaping >> > real-intervals, undecidable problems in groups, equality of symbolic >> > expressions, ... >> >> But I agree that it could be useful. >> >> Vincent >> >> -- >> 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. -- 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] "Tri bool"
On Tue, Nov 15, 2016 at 09:27:14AM +0100, Vincent Delecroix wrote: > On 15 November 2016 at 09:19, Thierry wrote: > > On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: > >> Not currently (though we have "Unknown"). The main problem is the > >> interaction with Python booleans and the operators "or", "and", "not" > >> (which are *not* logical operators). The Sage "Unknown" is badly > >> broken for these reasons > >> > >> sage: not Unknown # waiting for Unknown > >> True > >> sage: Unknown or False # waiting for Unknown > >> False > >> > >> So be careful if you start using it! > >> > >> If we would use the correct logical operators ~ (for negation), ^ (for > >> xor) and & (for and) then we might be able to come up with something. > >> But Sage sort of ignore them. > >> > >> This problem has been discussed a lot on this mailing list and there > >> even exists a (refused) PEP request in this direction. > > > > For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main > > reason for rejecting the proposal was "too much discussions"...). > > > > Perhaps was the proposal too greedy, so i wonder whether there would be a > > possibility to have a trool adding an Unknown to bool that does not > > perturb the speed when only True and False are used, and so that the > > "short-circuiting semantics" remains preserved. > > No way! In an expression such as > > "True or whatever_function(x)" > > the "whatever_function(x)" is *not* evaluated... > > sage: def f(): print "hello" > sage: True or f() > True I do not see your point. True or Unknown should be True, right ? So we can shortcut here as well for trools, no ? Ciao, Thierry > > > This could indeed be useful in testing equality of overlaping > > real-intervals, undecidable problems in groups, equality of symbolic > > expressions, ... > > But I agree that it could be useful. > > Vincent > > -- > 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.
Re: [sage-devel] "Tri bool"
On 15 November 2016 at 09:27, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > On 15 November 2016 at 09:19, Thierry wrote: >> On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: >>> Not currently (though we have "Unknown"). The main problem is the >>> interaction with Python booleans and the operators "or", "and", "not" >>> (which are *not* logical operators). The Sage "Unknown" is badly >>> broken for these reasons >>> >>> sage: not Unknown # waiting for Unknown >>> True >>> sage: Unknown or False # waiting for Unknown >>> False >>> >>> So be careful if you start using it! >>> >>> If we would use the correct logical operators ~ (for negation), ^ (for >>> xor) and & (for and) then we might be able to come up with something. >>> But Sage sort of ignore them. >>> >>> This problem has been discussed a lot on this mailing list and there >>> even exists a (refused) PEP request in this direction. >> >> For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main >> reason for rejecting the proposal was "too much discussions"...). >> >> Perhaps was the proposal too greedy, so i wonder whether there would be a >> possibility to have a trool adding an Unknown to bool that does not >> perturb the speed when only True and False are used, and so that the >> "short-circuiting semantics" remains preserved. > > No way! In an expression such as > > "True or whatever_function(x)" > > the "whatever_function(x)" is *not* evaluated... > > sage: def f(): print "hello" > sage: True or f() > True Though it would be doable with signatures of functions. def bool whatever_function() would avoid evaluation but def trool whatever_function() would do it. However, it is a drastic change that needs some kind of signature for functions. -- 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] "Tri bool"
On 15 November 2016 at 09:19, Thierry wrote: > On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: >> Not currently (though we have "Unknown"). The main problem is the >> interaction with Python booleans and the operators "or", "and", "not" >> (which are *not* logical operators). The Sage "Unknown" is badly >> broken for these reasons >> >> sage: not Unknown # waiting for Unknown >> True >> sage: Unknown or False # waiting for Unknown >> False >> >> So be careful if you start using it! >> >> If we would use the correct logical operators ~ (for negation), ^ (for >> xor) and & (for and) then we might be able to come up with something. >> But Sage sort of ignore them. >> >> This problem has been discussed a lot on this mailing list and there >> even exists a (refused) PEP request in this direction. > > For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main > reason for rejecting the proposal was "too much discussions"...). > > Perhaps was the proposal too greedy, so i wonder whether there would be a > possibility to have a trool adding an Unknown to bool that does not > perturb the speed when only True and False are used, and so that the > "short-circuiting semantics" remains preserved. No way! In an expression such as "True or whatever_function(x)" the "whatever_function(x)" is *not* evaluated... sage: def f(): print "hello" sage: True or f() True > This could indeed be useful in testing equality of overlaping > real-intervals, undecidable problems in groups, equality of symbolic > expressions, ... But I agree that it could be useful. Vincent -- 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] "Tri bool"
On 15 November 2016 at 09:12, Bruno Grenet wrote: > Le 15/11/2016 à 08:53, Vincent Delecroix a écrit : >> >> Not currently (though we have "Unknown"). The main problem is the >> interaction with Python booleans and the operators "or", "and", "not" >> (which are *not* logical operators). The Sage "Unknown" is badly >> broken for these reasons >> >> sage: not Unknown # waiting for Unknown >> True >> sage: Unknown or False # waiting for Unknown >> False >> >> So be careful if you start using it! >> >> If we would use the correct logical operators ~ (for negation), ^ (for >> xor) and & (for and) then we might be able to come up with something. >> But Sage sort of ignore them. > > > What do you mean by this? From what I understand, ~, &, ^ are bitwise > operators, while "and", "or", "not" are bit operators. In which sense are > they not logical opeators? For example they are not commutative sage: 0 and False 0 sage: False and 0 False sage: 1 or 3 1 sage: 3 or 1 3 Vincent -- 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] "Tri bool"
On Tue, Nov 15, 2016 at 08:53:43AM +0100, Vincent Delecroix wrote: > Not currently (though we have "Unknown"). The main problem is the > interaction with Python booleans and the operators "or", "and", "not" > (which are *not* logical operators). The Sage "Unknown" is badly > broken for these reasons > > sage: not Unknown # waiting for Unknown > True > sage: Unknown or False # waiting for Unknown > False > > So be careful if you start using it! > > If we would use the correct logical operators ~ (for negation), ^ (for > xor) and & (for and) then we might be able to come up with something. > But Sage sort of ignore them. > > This problem has been discussed a lot on this mailing list and there > even exists a (refused) PEP request in this direction. For reference, it is https://www.python.org/dev/peps/pep-0335/ (the main reason for rejecting the proposal was "too much discussions"...). Perhaps was the proposal too greedy, so i wonder whether there would be a possibility to have a trool adding an Unknown to bool that does not perturb the speed when only True and False are used, and so that the "short-circuiting semantics" remains preserved. This could indeed be useful in testing equality of overlaping real-intervals, undecidable problems in groups, equality of symbolic expressions, ... Ciao, Thierry > Best, > Vincent > > > > On 15 November 2016 at 08:22, Thierry Dumont > wrote: > > When developing a software which aims to prove something, it seems > > necessary to be able to return something in > > {True, False, Indeterminate}. > > > > Of course, there are many possibilities to do this, but is there a > > "canonical" one in Sage ? > > > > In C++, for example, there exists the Boost Tribool library > > (http://www.boost.org/doc/libs/1_62_0/doc/html/tribool.html#tribool.introduction) > > . > > > > t.d. > > > > -- > > 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. -- 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] "Tri bool"
Le 15/11/2016 à 08:53, Vincent Delecroix a écrit : Not currently (though we have "Unknown"). The main problem is the interaction with Python booleans and the operators "or", "and", "not" (which are *not* logical operators). The Sage "Unknown" is badly broken for these reasons sage: not Unknown # waiting for Unknown True sage: Unknown or False # waiting for Unknown False So be careful if you start using it! If we would use the correct logical operators ~ (for negation), ^ (for xor) and & (for and) then we might be able to come up with something. But Sage sort of ignore them. What do you mean by this? From what I understand, ~, &, ^ are bitwise operators, while "and", "or", "not" are bit operators. In which sense are they not logical opeators? Bruno This problem has been discussed a lot on this mailing list and there even exists a (refused) PEP request in this direction. Best, Vincent On 15 November 2016 at 08:22, Thierry Dumont wrote: When developing a software which aims to prove something, it seems necessary to be able to return something in {True, False, Indeterminate}. Of course, there are many possibilities to do this, but is there a "canonical" one in Sage ? In C++, for example, there exists the Boost Tribool library (http://www.boost.org/doc/libs/1_62_0/doc/html/tribool.html#tribool.introduction) . t.d. -- 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.
Re: [sage-devel] "Tri bool"
Not currently (though we have "Unknown"). The main problem is the interaction with Python booleans and the operators "or", "and", "not" (which are *not* logical operators). The Sage "Unknown" is badly broken for these reasons sage: not Unknown # waiting for Unknown True sage: Unknown or False # waiting for Unknown False So be careful if you start using it! If we would use the correct logical operators ~ (for negation), ^ (for xor) and & (for and) then we might be able to come up with something. But Sage sort of ignore them. This problem has been discussed a lot on this mailing list and there even exists a (refused) PEP request in this direction. Best, Vincent On 15 November 2016 at 08:22, Thierry Dumont wrote: > When developing a software which aims to prove something, it seems > necessary to be able to return something in > {True, False, Indeterminate}. > > Of course, there are many possibilities to do this, but is there a > "canonical" one in Sage ? > > In C++, for example, there exists the Boost Tribool library > (http://www.boost.org/doc/libs/1_62_0/doc/html/tribool.html#tribool.introduction) > . > > t.d. > > -- > 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.
[sage-devel] "Tri bool"
When developing a software which aims to prove something, it seems necessary to be able to return something in {True, False, Indeterminate}. Of course, there are many possibilities to do this, but is there a "canonical" one in Sage ? In C++, for example, there exists the Boost Tribool library (http://www.boost.org/doc/libs/1_62_0/doc/html/tribool.html#tribool.introduction) . t.d. -- 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. <>