Yes, I know, that’s the point. Funky is specifically constructed to always return 0. Then we assume “if” and “if, and only if” are equivalent and by following that assumption to its logical conclusion, we deduce that funky returns 1. Therefore, our assumption was incorrect because 0≠1. It follows that “if” isn’t equivalent to “if, and only if”. Also, it’s just a shitpost.
If reading the code as non-programming logic, that conclusion makes sense, yes. However, if, in most syntaxes, is a type of flow control. What it wraps has no meaning to the if statement itself. Reading it through the lens of an interpreter/compiler makes it clear. The statement is approximately:
If and only if a is equal to 1, do the thing {
The thing is: assign the variable b with the value1
}
To one not familiar with how programs are executed, it would make sense that the return value could be 1. But understanding how flow control works in programming, makes this interpretation a challenge.
I don’t think you’re picking up what I’m putting down. I’m not arguing that the return value can be 1, I’m well aware that it can’t — I wrote the function so that it will always return 0. It only returns 1 if we make an incorrect assumption (and mix up semantics with formal logic, but that’s another conversation), the incorrect assumption being “if is equivalent to if, and only if”
Yes, I know, that’s the point. Funky is specifically constructed to always return 0. Then we assume “if” and “if, and only if” are equivalent and by following that assumption to its logical conclusion, we deduce that funky returns 1. Therefore, our assumption was incorrect because 0≠1. It follows that “if” isn’t equivalent to “if, and only if”. Also, it’s just a shitpost.
If reading the code as non-programming logic, that conclusion makes sense, yes. However,
if
, in most syntaxes, is a type of flow control. What it wraps has no meaning to theif
statement itself. Reading it through the lens of an interpreter/compiler makes it clear. The statement is approximately:If and only if a is equal to 1, do the thing { The thing is: assign the variable b with the value 1 }
To one not familiar with how programs are executed, it would make sense that the return value could be 1. But understanding how flow control works in programming, makes this interpretation a challenge.
I don’t think you’re picking up what I’m putting down. I’m not arguing that the return value can be 1, I’m well aware that it can’t — I wrote the function so that it will always return 0. It only returns 1 if we make an incorrect assumption (and mix up semantics with formal logic, but that’s another conversation), the incorrect assumption being “if is equivalent to if, and only if”
Sorry! I sometimes get carried away on correctness.
I mean, making an assumption and arriving to a contradiction is as correct as a proof gets.