# True, False, Uncertain, Impossible

• Booleans with more than two states seem to be a favorite on this board. The new Fortress language under development at Sun has a construct called a BooleanInterval ...

http://research.sun.com/projects/plrg/fortress.pdf

24.2 The Trait Fortress.Standard.BooleanInterval

A boolean interval is a set of boolean values. There are two distinct boolean values, true and false, and therefore there are four distinct boolean intervals, which for convenience are given names:

True         = {true}False        = {false}Uncertain    = {true, false}Impossible   = { }

24.2.2 opr AND (self, other :BooleanInterval):BooleanInterval

The logical AND operator AND returns
Impossible if either argument is
Impossible; otherwise it returns False
if either argument is False; otherwise it
returns Uncertain if either argument
is Uncertain; otherwise it returns True. It
obeys the interval containment rule.
The And bperator may be described by this
table:

AND              Uncertain        True            False        Impossible---------------+----------------+---------------+--------------+----------Uncertain      | Uncertain      | Uncertain     | False        | ImpossibleTrue           | Uncertain      | True          | False        | ImpossibleFalse          | False          | False         | False        | ImpossibleImpossible     | Impossible     | Impossible    | Impossible   | Impossible

Whee!  Of course there is a real two-state Boolean type. This is a special math construct, but pretty cool looking.

• Let me get this straight: So it returns these "boolean values" if an expression cannot be evaluated? Have they heard of exception catching?

• What about !Uncertain and !Impossible ?

Did they add some Certain and Possible states ?

• From reading the PDF, it looks like ¬Uncertain is Uncertain (which makes sense) and ¬Impossible is Impossible (which makes some sense, but less... I'd've used ¬Impossible = Uncertain instead).  Interestingly, their set of operations does seem to be internally consistent, unlike our beloved FileNotFound and Maybe "booleans".

Incidentally, those guys must've been studying an APL manual.  They've used hard-to-type symbols like ∩, →, and ¬ as operators.

• @Baston said:

What about !Uncertain and !Impossible ?

Did they add some Certain and Possible states ?

Without looking into the spec:

!Uncertain = Impossible

!Impossible = Uncertain

• (Hi AmmoQ!  Fix the edit timeout, would you?

Ah, I've got it.  There's some conceptual shear between the concepts of "negation" (what ! normally means) and "complement" (what Fortress uses, represented by the ¬ sign).  The negation of Impossible is Possible, but something Impossible has no possible complement.  It's interesting that they didn't take the set complement (U={true, false}) of each value to be the BooleanInterval complement, which would've lead to AmmoQ's values.

• @Angstrom said:

(Hi AmmoQ!  Fix the edit timeout, would you?

I can't. You have to ask Alex.

• But what about the Unpossible state?

• @Angstrom said:

Incidentally, those guys must've been studying an APL manual.  They've used hard-to-type symbols like ∩, →, and ¬ as operators.

That reminds me, I wish C# allowed me to overload · and × so that I can have decent notation when I'm writing vector dot and cross products... and I wish C# had an easy-to-type name.

It looks like the definitions of the BooleanInterval operations derive from the effects of the corresponding operations of Booleans (Hence the note P AND Q = {x AND y | x←P, y←Q}). So with Uncertain meaning "maybe true, maybe false", Not(Uncertain) becomes "maybe not(true), maybe not(false)". Meanwhile, Impossible doesn't have any elements, so operations on the elements of Impossible leave it unchanged.

I'm intrigued.

True, false, what[i]ever[/i].

• @Watson said:

That reminds me, I wish C# allowed me to overload · and × so that I can have decent notation when I'm writing vector dot and cross products...

I would think C# inherited from C++ the rules on what can and can't be overloaded.  I cannot remember off the top of my head but I think Bjarne Stroustrups' book "The Design and Evolution of C++" has a well thought out reasoning of why overloading of arbitrary symbols and '.' is undesirable.

• Sounds like digital hardware logic to me. But I'm missing a few states. Ofcourse calling it boolean is still WTF.

• @Spacecoyote said:

Have they heard of exception catching?

Nope. The people behind Java haven't heard of exception catching.

• @Spacecoyote said:

Let me get this straight: So it returns these "boolean values" if an expression cannot be evaluated? Have they heard of exception catching?

Of course they did, Guy Steele was one of Fortress' designers for fuck's sake (if you don't know who it is, look up the "Java" programming language, you may have heard of it). The point is that Fortress' goal is to replace Fortran: it's a language crafted towards heavy computations and high performances on supercomputers, you don't want exceptions when you want raw speed.

• I suppose adding Uncertain and Impossible is no worse than adding NaN to the set of numbers, sort of.

Still, I'm somewhat of a purist, and if there are more than two values, it's no longer a Boolean algebra.  It's like a key-of-C diatonic melody with sharps and flats -- it's not diatonic anymore; it's chromatic.  It's like an insect with eight legs, or an IBM Macintosh, or a Westinghouse Frigidaire.  It's a vegetarian beefsteak.  It's outside its category.  It's something else, and the name is wrong.

• @newfweiler said:

I suppose adding Uncertain and Impossible is no worse than adding NaN to the set of numbers, sort of.

<nitpick>Isn't the whole point of NaN that it's not a number?</nitpick>   Of course, I know what you mean.  But it's sort of like NULL in SQL - a marker that says "there is no valid value here", not a value in itself.

@newfweiler said:

Still, I'm somewhat of a purist, and if there are more than two values, it's no longer a Boolean algebra.  It's like a key-of-C diatonic melody with sharps and flats -- it's not diatonic anymore; it's chromatic.  It's like an insect with eight legs, or an IBM Macintosh, or a Westinghouse Frigidaire.  It's a vegetarian beefsteak.  It's outside its category.  It's something else, and the name is wrong.

The mathematicians would disagree with you there....

Although, the BooleanInterval described here doesn't satisfy the axioms for a Boolean algebra, but that's not really a WTF.  Presumably you wouldn't expect something called RealInterval to have the same properties as the real numbers, so why would BooleanInterval be different?

• @Angstrom said:

From reading the PDF, it looks like ¬Uncertain is Uncertain (which makes sense) and ¬Impossible is Impossible (which makes some sense, but less... I'd've used ¬Impossible = Uncertain instead).  Interestingly, their set of operations does seem to be internally consistent, unlike our beloved FileNotFound and Maybe "booleans".

That's because the concept of a 'boolean interval' is lifted directly from mathematics. This is not a new idea, it's just one that is so useless you're unlikely to have ever run across it. It's a mistake to call these 'booleans' - they aren't, they are 'boolean intervals'. They aren't booleans because they don't form a boolean algebra: there is no complement operator (while there do exist valid boolean algebras with more than two elements, including ones which have a meaningful 'maybe' element, they are quite rare, and no system with only three elements can ever form a valid boolean algebra).

They do have an operator SET_COMPLEMENT, where SET_COMPLEMENT(Uncertain) is Impossible and SET_COMPLEMENT(Impossible) is Uncertain. Still not a boolean complement though (a boolean complement operator 'op' is any operator for which the following condition holds: there exist two distinct elements x and y such that for any element a, (a AND op(a) == x) and (a OR op(a) == y); in general, x is 'false' and y is 'true', but you can call them whatever you like).

Incidentally, those guys must've been studying an APL manual.  They've used hard-to-type symbols like ∩, →, and ¬ as operators.

There is nothing hard to type about the ¬ sign. On my keyboard, you hold shift and hit the button below the escape key. While \cap and \rightarrow are not commonly found on keyboards, ¬ has been around for a long time.

• @iwpg said:

@newfweiler said:

Still, I'm somewhat of a purist, and if there are more than two values, it's no longer a Boolean algebra.  It's like a key-of-C diatonic melody with sharps and flats -- it's not diatonic anymore; it's chromatic.  It's like an insect with eight legs, or an IBM Macintosh, or a Westinghouse Frigidaire.  It's a vegetarian beefsteak.  It's outside its category.  It's something else, and the name is wrong.

The mathematicians would disagree with you there....

While there are certainly more boolean algebras than the classical two-valued one, the article you link to is actually wrong (at least, if I remember my math lectures properly): property 4, "universal bounds", is not an axiom for a boolean algebra. It is true for all boolean algebras, but this can be derived from the other axioms, so it shouldn't be on that list.

Wikipedia has an article that is correct (so far as I can see), although I can't be bothered to navigate the awful link creation mechanism right now.

• @asuffield said:

While there are certainly more boolean algebras than the classical two-valued one, the article you link to is actually wrong (at least, if I remember my math lectures properly): property 4, "universal bounds", is not an axiom for a boolean algebra. It is true for all boolean algebras, but this can be derived from the other axioms, so it shouldn't be on that list.

Wikipedia has an article that is correct (so far as I can see), although I can't be bothered to navigate the awful link creation mechanism right now.

Bah.  I was deliberately trying not treat Wikipedia as an authoritative source.   (Not that I expect MathWorld to be Always Right About Everything, but, y'know.)  Just for the record, here's the link. (I agree with you that it's horrible.  I always do links using the "HTML" button, I've never figured out how to do it any other way.)

• @asuffield said:

Incidentally, those guys must've been studying an APL manual.  They've used hard-to-type symbols like ∩, →, and ¬ as operators.

There is nothing hard to type about the ¬ sign. On my keyboard, you hold shift and hit the button below the escape key. While \cap and \rightarrow are not commonly found on keyboards, ¬ has been around for a long time.

Actually, there is EVERYTHING hard to type about that character.  No western keyboard has that symbol on it - actually no keyboard in ANY culture I've ever seen has it.  It's an Extended ASCII character requiring Alt+XXXX to enter.  Any language using those as operators gets a pass in my book.

• @Kyanar said:

Actually, there is EVERYTHING hard to type about that character.  No western keyboard has that symbol on it - actually no keyboard in ANY culture I've ever seen has it.  It's an Extended ASCII character requiring Alt+XXXX to enter.  Any language using those as operators gets a pass in my book.

The ¬ symbol? My keyboard (Brazilian ABNT2) has ¬ bound to AltGr + 6.

• @Kyanar said:

@asuffield said:

Incidentally, those guys must've been studying an APL manual.  They've used hard-to-type symbols like ∩, →, and ¬ as operators.

There is nothing hard to type about the ¬ sign. On my keyboard, you hold shift and hit the button below the escape key. While \cap and \rightarrow are not commonly found on keyboards, ¬ has been around for a long time.

Actually, there is EVERYTHING hard to type about that character.  No western keyboard has that symbol on it - actually no keyboard in ANY culture I've ever seen has it.  It's an Extended ASCII character requiring Alt+XXXX to enter.  Any language using those as operators gets a pass in my book.

Come on!  It's the negation operator in PL/1!  Everybody knows that!  It's the equivalent of "!" or "~" in C.  Yes, it means both arithmetic complement and logical NOT.  It's on an IBM 2741 terminal keyboard.

Old PL/1 joke:     2B | ¬2B ?

• Hmm, I'm actually pretty interested in test-driving fortress now....but I'm surprised no one called this one out:

<FONT face=CMTT10 size=2>

for </FONT><FONT lang=JA face=CMMI10 size=2>i </FONT><FONT lang=KO face=CMSY10 size=2>← </FONT><FONT face=CMR10 size=2>1 : 10 </FONT><FONT face=CMTT10 size=2>do

</FONT><FONT face=CMTI10 size=2>

print</FONT><FONT face=CMR10 size=2>(</FONT><FONT lang=JA face=CMMI10 size=2>i </FONT><FONT face="Times New Roman" size=2>“ ”</FONT><FONT face=CMR10 size=2>)

</FONT><FONT face=CMTT10 size=2>

end

...

</FONT><FONT size=2>

<FONT face="Times New Roman">5 4 6 3 7 2 9 10 1 8</FONT>

</FONT>

I'm reading about a 'sequential generator' that will apparently deliver the numbers in order (just in case I actually want to iterate through a set of values...I'm such a philestine), but I'm not seeing it actually described in the pdf

[Late note:  found it!   It would be   for i <FONT lang=JA face=CMMI10 size=2> </FONT><FONT lang=KO face=CMSY10 size=2>← sequential(</FONT><FONT face=CMR10 size=2>1 : 10) </FONT><FONT face=CMTT10 size=2>do... wacky]

</FONT>

-cw

• @CodeWhisperer said:

Hmm, I'm actually pretty interested in test-driving fortress now....but I'm surprised no one called this one out:

<FONT face="CMTT10" size="2"> </FONT>

<FONT face="CMTT10" size="2">for </FONT><FONT lang="JA" face="CMMI10" size="2">i </FONT><FONT lang="KO" face="CMSY10" size="2">← </FONT><FONT face="CMR10" size="2">1 : 10 </FONT><FONT face="CMTT10" size="2">do</FONT>

<FONT face="CMTT10" size="2"></FONT><FONT face="CMTI10" size="2"> </FONT>

<FONT face="CMTI10" size="2">   print</FONT><FONT face="CMR10" size="2">(</FONT><FONT lang="JA" face="CMMI10" size="2">i </FONT><FONT face="Times New Roman" size="2">“ ”</FONT><FONT face="CMR10" size="2">)</FONT>

<FONT face="CMR10" size="2"></FONT><FONT face="CMTT10" size="2">

end

...

</FONT><FONT size="2">

<FONT face="Times New Roman">5 4 6 3 7 2 9 10 1 8</FONT>

</FONT>

I'm reading about a 'sequential generator' that will apparently deliver the numbers in order (just in case I actually want to iterate through a set of values...I'm such a philestine), but I'm not seeing it actually described in the pdf

[Late note:  found it!   It would be   for i <FONT lang="JA" face="CMMI10" size="2"> </FONT><FONT lang="KO" face="CMSY10" size="2">← sequential(</FONT><FONT face="CMR10" size="2">1 : 10) </FONT><FONT face="CMTT10" size="2">do... wacky]</FONT>

<FONT face="CMTT10" size="2"></FONT>

-cw

I see a way that that could make sense.  If you're using the "for" construct to do ten independant operations (say, solving a system of linear equations), then the out-of-orderness is simply a side effect of using ten threads to execute the operations in parallel.

• @H3SO5 said:

The ¬ symbol? My keyboard (Brazilian ABNT2) has ¬ bound to AltGr + 6.

Funny... the same on a German keyboard, too. (tried with Linux, can't say whether or not it works on Windows)

• @Kyanar said:

@asuffield said:

There is nothing hard to type about the ¬ sign. On my keyboard, you hold shift and hit the button below the escape key. While \cap and \rightarrow are not commonly found on keyboards, ¬ has been around for a long time.

Actually, there is EVERYTHING hard to type about that character.  No western keyboard has that symbol on it

Buu! My keyboard is a UK keyboard. Every UK keyboard has the ¬ sign in that position. The UK is normally considered to be a western country.

The US PC keyboard is the perverse one here. Even older US keyboards (from mainframes and suchlike) often had the ¬ key, because it was used in numerous older programming languages. It's not like you're even reusing the key for something else - the US PC keyboard just has one less key than most others (101 versus 102). There is no discernible good reason for this.

• @asuffield said:

@Kyanar said:
@asuffield said:

There is nothing hard to type about the ¬ sign. On my keyboard, you hold shift and hit the button below the escape key. While \cap and \rightarrow are not commonly found on keyboards, ¬ has been around for a long time.

Actually, there is EVERYTHING hard to type about that character.  No western keyboard has that symbol on it

Buu! My keyboard is a UK keyboard. Every UK keyboard has the ¬ sign in that position. The UK is normally considered to be a western country.

The US PC keyboard is the perverse one here. Even older US keyboards (from mainframes and suchlike) often had the ¬ key, because it was used in numerous older programming languages. It's not like you're even reusing the key for something else - the US PC keyboard just has one less key than most others (101 versus 102). There is no discernible good reason for this.

Right.  Well, I said none that I'd seen (and I'm pretty surprised such an arcane symbol is on the UK keyboard).  Throughout the Asia Pacific region, there is no ¬ (I had to copy/paste that by the way) key.  The key below escape is ~ with shift held down.  So no, that symbol should NOT be used in a programming language.  Unless all its keywords are in Spanish or something.

• @Kyanar said:

Right.  Well, I said none that I'd seen (and I'm pretty surprised such an arcane symbol is on the UK keyboard).  Throughout the Asia Pacific region, there is no ¬ (I had to copy/paste that by the way) key.  The key below escape is ~ with shift held down.  So no, that symbol should NOT be used in a programming language.  Unless all its keywords are in Spanish or something.

Actually this is your quote from above, you did say that *no& western culture has it:

"No western keyboard has that symbol on it - actually no keyboard in ANY culture I've ever seen has it."

But that's beside the point. I actually use it quite often. Because it is so infrequently used, yet easy to access on the standard keyboard, it makes a great delimiter/marker character.

Anyway, if I ever create my own language, I'll certainly use it. I think it looks great. ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.