I was thinking of an hypothetical programming language with a
kleenean data type which would implement Kleene's three-valued logic. To sum up, it's an extension of the boolean data type with the three constants
unknown means that the value is either
false, but we don't know which.
The truth tables for a kleenean type are well-known and the logic is quite easy to understand. However, I was wondering how one would design a conditional construct to take in account this
if-then-else conditional construct is almost always as follows:
if (boolean condition) then condition is true, do something else condition is false, do some other thing end
However, I have troubles seeing what a kleenean
if construct would look like. How could we interpret the
unknown constant? Technically speaking, it could satisfy the
true condition as well as the
false condition since it is one of these two. However, we can't have it match any of those since it could be the other, it is not really
Is there a well-known way to implement such a construct?
EDIT: To specify a little bit, I would prefere something different than the way
boost::tribool works, or from a simple
switch as if was an enum. Answers about quantum superposition and semantics are welcome.