From: Massimiliano Mirra Date: 2002-10-27T05:16:43+09:00 Subject: Re: How come true, false don't support <=> (comparison) operator? On Sat, Oct 26, 2002 at 01:06:12PM +0900, Phil Tomson wrote: > >1. Why couldn't one swap 'true' and 'false' in your square-bracket > >comments in the above? That is: why does true have to go with 1 and > >false with 0? > > Well, you're getting deep with this one. I suppose you could say that its > a human imposed convention to associate 1 with true and 0 with false. > But yes, the book I referred to does (I think in order to play with your > mind a bit and to illustrate that different types of boolean algebras can > be concocted [more below]) show an example where the 1 and 0 are switched. > However, I don't think we'd want to do that. I think neither does David. He was suggesting switching just the *associations* between the boolean and the integer (being they arbitrary), not the booleans nor the integers. (If I'm misinterpreting, David, please correct me.) > It would be kind of like > saying that every place in your program where you see a '0' it actually > means '9' and everyplace you see an '8' it actually means '1' and so on > like: > 0 <--> 9 > 1 <--> 8 > 2 <--> 7 > 3 <--> 6 > 4 <--> 5 > > Yes you could do it as a mathematical exercise, but others wouldn't get > the same meaning out of it. Hmmm, then why does everybody insist on seeing `0' where there actually is `false', and `1' where there actually is `true'? ;-) > >2. Does being the greatest and least, in a lattice, have to propagate > >to a direct comparison between the two elements? I'm thinking (by way > >of analogy) of an array: [3,1,5,4], where 5 is the greatest element in > >one sense, and 4 is the greatest in another sense (highest indexed). > > Well, a lattice represents a partially ordered set, so some kind of > comparison relation (which you can define, but usually based on > less-than-or-equal) needs to exist between them. So in order to assert ordinality between `true' and `false' they first should be demonstrated to belong to a lattice, right? Which makes me think... (That usually preludes to one of my pointless digressions. Hit the `next nessage' before it's too late.) Pick any two numbers, say 9 and 16. 9 is less than 16. You can't swap the numbers and keep the relation: `16 is less than 9' doesn't sound quite right, does it? Now pick any two booleans, say day and night. Day comes before night. You can swap them, keep the relation, and it still sounds right: night comes before day. Similarly, true equals negated false, and false equals negated true. Looks like it's no exclusive property of boolean things. Pick any two days of the week, say Sunday and Thursday: Sunday comes before Thursday, Thursday comes before Sunday. Now given those relations, how would you represent numbers, day and night, and days of the week? 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> ... +--> day ----+ | | +-- night <--+ +-> Sunday --+ | | | v Saturday Monday ^ | | v ... ... ^ | | | +- Thursay <-+ All this data can be traversed in one direction but isn't necessarily ordered (in the sense that departing from an element will bring you farther from it), it can also be cyclic (a broken record lattice?). And booleans seem to be inherently so. +--> true ---+ | | +--- false <-+ Good luck on sorting that. :-) Some cyclic data need a convention, not to tell where the series starts, but where we start traversing it. And being a convention... compare some calendars and you'll find that some start weeks on Mondays and some on Sundays. I've never found myself in need of conventions for true and false, though. (See that I brought it back on topic? You gave up hope I could, uh?) Massimiliano -- We shall not cease from exploration And the end of all our exploring Will be to arrive where we started And know the place for the first time. T. S. Eliot, `Four Quartets'