4 ms·
If the question is, what was the first programming language that introduced "If-then-else" then the read makes sense, but I'm not sure if was really an inventiv
by chriskanan 6y ago
If the question is, what was the first programming language that introduced "If-then-else" then the read makes sense, but I'm not sure if was really an inventive step.
In propositional logic, which was developed well before the first computers by Leibniz, Frege, Boole, De Morgan, etc.:
"If A then B else C" can be stated as:
(A --> B) ^ (¬A --> C)
So, in patent/invention language, I'm not sure if it would really constitute an invention since it is just putting a known mathematical formalism into a programming language.
It would be possible to implement this in Leibniz' calculus ratiocinator ~300 years ago: https://link.springer.com/chapter/10.1007/978-3-319-93779-3_4 https://link.springer.com/chapter/10.1007/978-3-319-93779-3_...
- kopakabana 6y agoYou should add that to Wikipedia: https://en.m.wikipedia.org/wiki/Conditional_(computer_programming) https://en.m.wikipedia.org/wiki/Conditional_(computer_progra...
- abecedarius 6y agoMcCarthy published a paper in 1961 about if-then-else as a form of propositional logic replacing and/or/not, with its own identities playing a role like associativity, de Morgan's laws, etc. This had to be invented. It's interesting to me that these identities and the canonical form McCarthy introduced there were exactly how BDDs work (when you just add memoizing, which was also invented about the same time) -- but BDDs weren't invented until the 1980s. (Explanation at https://codewords.recurse.com/issues/four/the-language-of-choice https://codewords.recurse.com/issues/four/the-language-of-ch...) It's easy to think things are obvious in hindsight.
- deleted 6y ago[deleted]
- tempodox 6y agoYour formula `(A --> B) ^ (¬A --> C)` expands to `¬(A & B) & (A | ¬C)`. I would propose that `(A & B) ^ (¬A & C)`, which expands to `(¬A | B) & (A | C)`, comes closer to actual `if` semantics.
- hollerith 6y agoThey are equivalent (assuming ^ is the same as &). In particular, A --> B is equivalent to ¬A | B.
- tempodox 6y agoI see. I interpreted `^` as XOR. The implication (`-->`) was clear enough to not be misunderstood.
- chriskanan 6y agoThe "ʌ" symbol (^ due to laziness) is commonly used to mean AND in propositional/formal logic in mathematics: https://en.wikipedia.org/wiki/Propositional_calculus https://en.wikipedia.org/wiki/Propositional_calculus
- tempodox 6y agoI know, but due to the use of “¬” for the negation I would have expected “∧” (‘LOGICAL AND’, U+2227), or at least something less ambiguous, like “&”. C conditioned me into thinking of ASCII caret as XOR.