Tristate - wanna?

crimaniak via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 27 17:37:11 PDT 2016


On Sunday, 27 March 2016 at 02:36:47 UTC, Alex Parrill wrote:
...
>> a && b == min(a, b)
>> a || b == max(a, b)
>> ~a == N-1-a
>>
>> why to optimize it more?
>
> That's incorrect for the `unknown` value.
>
> Lets say you represented true as 1f, false as 0f, and unknown 
> as NaN...
>
> std.algorithm.max(0, 0f/0f) = 0, but should be NaN
> std.math.fmax(1, 0f/0f) = NaN, but should be 1
>
> N-state logic isn't just about probabilities either. According
  Yes, you right, I mean logic as probability approximation 
(Godel). But in this case you can't assign arbitrary codes to 
values. False == 0, unknown == 1 and true == 2 is here.

> to Wikipedia, Bochvar's three-valued logic has an "internal" 
> state, where any operation with `internal` results in 
> `internal` (similar to NaN). More broadly, the values and 
> operations between them could be whatever the mathematician or 
> developer wants, so a truth table is one of the ways to 
> generally specify an operator.
  Fully arbitrary logic needs tables, yes.



More information about the Digitalmars-d mailing list