I get that they’re equivalent - if something is not p and also not q it is saying it is neither p nor q, like it it’s not both things at once. But is it also the same as saying if p is not true and q is not true then the statement is false? They seem to have the same result when applied to integers - in essence the statement is meaningless if p and q are replaced with two different integers. The statement could have some meaning if p and q were the same integer, although it would be a needlessly bulky way to express negation. If applied to something other than a numeric expression is there any instance or instances where these two booleans things would have a different result when applied to the same variables?
I know this isn’t a rant, but I humbly request this thread remain in the pit. I don’t want to deny anyone the opportunity to call me a stupid piece of shit. I also don’t want to be denied the opportunity to call anyone a stupid piece of shit back. Not like I would, I would probably just ignore them; but I just like knowing that option is available for everyone.
Integers? It’s a boolean expression, it applies to statements. And the expression in your text is not what you have in your heading.
The first expression in the heading is true as long as long as at least one of p and q is false and the second statement is equivalent.
The first expression in your text is true only if both are false, it’s !p && !q. And the equivalent OR statement is, as you write !(p || q).
Now in programming the value of a statement is often represented with integers, usually 0 = FALSE and everything else = TRUE. With that notation 2 && 4 = TRUE while 0 && 2 or 0 && 0 are FALSE, which is obviously not saying anything about the numbers two, four or zero. But that’s fine, because these are not numerical operators.
Given that they’re booleans, both p and q can only have a single value at a time, and so a truth table will demonstrate every possible state of both statements.
From the aesthetics standpoint (as a hobbyist programmer), though, I prefer the first one most of the time. The semantics scream at me, don’t proceed unless I have both p and q! On the other hand, I like the second when, when the semantics indicate, if not p or not q, then react in some way. But this convention certainly lies outside of the domain of logic.
Are you pitting that the operating rules of one mathematical system don’t apply if you expand the domain to incorporate elements of other mathematical systems?
While you’re at it, please enlighten us about complex numbers, because “i” is clearly not a number.
OK, how did this paradox enter your life and does it have some adverse effect in your studies or career?
If you used one of those expressions in a code and it didn’t work, but the other one did, that kind of shit happens in programming languages. Maybe you slaved over many sleepless nights trying to get one expression to work and it didn’t, and you’re massively frustrated that all that work meant NOTHING, absolutely NOTHING! Welcome to coding.
It’s more about the imprecision of English when it comes to logic. I’m trying to explore wherein lies the imprecision more exactly while also allowing people to call me a stupid piece of shit if they so desire.
I’m not sure what you’re on about with the “i”, you may be at a more advanced level than me.
De Morgan’s law entered my life late last month. At first I just kind of skipped over it but then when I got to page 400 of Eric Roberts seminal work on Java I decided to go back to the beginning and reread from chapter 2 onwards.
I started studying programming as a way to not leave the house on my days off. Every time I leave the house, I spend, or should I say, waste money on stupid shit. Around here where I live you could easily drop $7 taking the bus to the coffee shop and buying two cups of coffee. And noone really ever talks to you when you go, they all just sit there glued to their screens - no interest whatsoever in interacting with some retarded looking stranger. So why even bother going out? I can just sit at home and stare at a screen.
But just sitting at home makes one a little stir crazy at times, so I need something to occupy my mind.
My story wouldn’t be complete without stating why I want to save money. Someday I want to live on a farm and raise bluegills. Maybe I’ll raise some catfish too, and I’ll definitely raise some chickens. My wife’s all about the chickens.
From a math perspective, they should be equivalent. However, from a practical perspective inside a program, it’s possible to see different effects. The OR operator will always have to evaluate both inputs, whereas the AND operator can stop if the first input is false. If p and q happen to be functions that have some side effects, you could see a different outcome if both p and q are always evaluated than if sometimes only p is evaluated.
Note, this would be pretty poor programming technique. But, poor programming technique abounds.
Since we’re in the Pit, darn! Heck!
Edit: What I wrote above isn’t exactly right. The OR operator will evaluate both if the first one is false, whereas the AND operator will evaluate both if the first one is true. Anyway, the basic point is the same – you could see situations where only one function is called using one construct but both functions are called using the other construct. I think.
Let’s make sure we understand our parameters here. You ARE a stupid piece of shit, but it has nothing to do with math or logic principals.
Glad to help.
Maybe I should just stick with the bluegills then. I don’t think they’re very logical, I’ve caught several on baitless hooks before. I’ve also caught them when my pole accidentally went in the water while I was doing something else and then I pull the line up and there’s a fish on the end.
The problem with bluegills is that the food conversion rate is too low. People generally like or even love the taste of bluegills (YMMV), but they are a small, bony fish. I was thinking I could cut costs by growing my own feed - maybe get some verniculture going get some crickets hatching. I could probably put some egg in the mix - that’s full of protein right? I would try to market it to chefs or sell in as a specialty item at a farmer’s market. This will probably never end up happening though. If my past track record is any indication of the odds of future success then most likely I will end up with a 20 gallon tank full of guppies and call it a day.
An OR operator doesn’t have to evaluate both arguments. The operation is true if the first argument is true. However, whether or not a particular version of a particular programming language evaluates both arguments is a different matter altogether. IMHO, preferred technique is to make sure it doesn’t matter whether or not both arguments are evaluated.
As I understand it, C for one does short-circuit Boolean evaluations when possible, which leaves the onus on the programmer to make sure that any functions used in a Boolean don’t have side effects (or, if they do have side effects, to make sure that they’re behaving as intended, though that’s much more difficult, and so avoiding side effects altogether is much preferred).
The devil, though, is in that “when possible”. For a mere AND or OR, it’s easy to see when short-circuiting will be possible, but for a more complicated expression, it’s a hard problem to determine at what point you can short-circuit it (in fact, this is basically the first known of the NP-complete problems). So different implementations of C might well have different points at which they short-circuit Boolean evaluations, and a given implementation might short-circuit one but not another, even though the expressions are logically equivalent.
The variations among compilers and languages makes this a pain if you count on the order of evaluation. The general solution is to evaluate all functions before the boolean expression, in the order you want them (which also can be difficult to determine if they interact). Then use only the logical values that result in the boolean expression. Then hope the compiler doesn’t try to optimize away everything you just did.