News for hackers. Stuff that matters.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by dietrichepp on Saturday January 06, 2024 @02:04AM (#38889173)
My problem here is that I distinguish between multiplication and addition by seeing which one distributes over the other.

  a * (x + y) = (a * x) + (a * y)
However, the reverse doesn’t work…

  a + (x * y) =? (a + x) * (a + y)
Why is this a problem?

  a ∧ (x ∨ y) = (a ∧ x) ∨ (a ∧ y)
  a ∨ (x ∧ y) = (a ∨ x) ∧ (a ∨ y)
Both are true. So, who are we to say that one corresponds to multiplication, and the other corresponds to addition? The two operations are too similar to each other.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by throwaway421967 on Saturday January 06, 2024 @02:50AM (#38889412)
because 1 \and 0 = 0 same as 1 * 0 = 0 and 1 \or 0 = 1 same as 1 + 0 = 1
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by dietrichepp on Saturday January 06, 2024 @02:55AM (#38889438)
Choosing false = 0 and true = 1 is putting the cart before the horse.

It is equally true that 1*0=0 is the same as false|true=true, and 0+1=1 is the same as true&false=false.

But it is also not true that 1+1=1, so it is probably wrong to equate 'or' with '+'. The operation has the wrong properties.

As someone who sometimes dabbles in electronics, 0 = true makes a lot of intuitive sense to me. You have your pin with an open collector, your pull-up resistor, and “true” (as in, it is true that the transistor is conducting) pulls the voltage to ground, which is 0.

As someone who uses a Unix shell, 0 = true makes a lot of intuitive sense to me.

  $ true; echo $?
  0
  $ false; echo $?
  1
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by ninthcat on Saturday January 06, 2024 @03:42AM (#38889710)
You can interpret 0 and 1 as probabilities. 1 + 1 = 1 in this case makes sense because P(A or B) = P(A) + P(B) - P(A and B). You can interpret "A or B" as a set union and "A and B" as a set intersection. Of course it's easy to draw a three-way correspondence between Boolean arithmetic, the events represented by the empty set and the whole space, and sets within some universe because all the objects are so simple, but these correspondences also generalize well to systems with more than two possible values. The ease of generalizing makes me think it's not just a matter of coincidence or convention that we have 0 <=> false.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by nyssos on Saturday January 06, 2024 @09:20AM (#38891631)
You've just moved the point where we make the arbitrary choice to here:

> You can interpret "A or B" as a set union and "A and B" as a set intersection.

{True, False, Or, And} and {False, True, And, Or} are two different naming conventions for the exact same structure: the unique boolean algebra on two elements.

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by ninthcat on Saturday January 06, 2024 @01:30PM (#38893846)
A union B is defined as the set of things that are in A or in B; A intersect B is defined as the set of things that are in A and in B. So I don't really see it as an arbitrary choice.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by carlob on Saturday January 06, 2024 @05:23AM (#38890203)
Actually if you think about Boolean logic as mod 2 arithmetics xor is addition, rather than or.