I know its the first lesson in discrete math, but "there exists a _" makes no sense from an algorithmic perspective. How do you find it?
I know its the first lesson in discrete math, but "there exists a _" makes no sense from an algorithmic perspective. How do you find it?
(if .. do ..)
(macroexpand '(when 1 2 3 4)) (if 1 (do 2 3 4))
but that is not what it seems to do in PM-Lisp take the example of `=` definition:
(def = (and (when A B) (when B A)))
If this were the same functionality clojure it would be testing the truthyness of the evaluation of each when expression
so If I had (and (when 3 5) (when 5 3)) it would evaluate to (and 5 3) which would evaluate to 3 which is truthy.
So that got me stuck in the article. But it seems that when is more like a test/assertion... (when x z) saying for all values of x ... z is implied (i.e. the same way one mathematical rule implies another).
I'm going to reread this article and try to understand better.
It doesn't "do" anything, just sets a constraint which can be matched against later. I took a class on Prolog in school, which works by back-matching against conditionals like that. I remember just sorting a list being mind-bendingly recursive.
I still think there's some funny business going on in the intersection of computable functions, infinite sets and "there exists a _" style conditionals. Can't put my finger on why "there exists a number of the form 2n + 1" feels fine, but "there exists a function in the set of all possible functions" feels wrong.
In fact, it is closely related to the logical and: it is and with short-circuiting, enabling the left expression to control effects in the right.
In Lisp, the two-form if, namely (if x y), can be replaced by (and x y), because and has the right logic and result value, and also the short-circuiting semantics that y is not evaluated if x is false.
If we want the logical if, we can use the equivalent expression (or (not x) y), which has the same truth table:
x y | (if x y) | (or (not x) y)
------------+-----------+----------------
nil nil | nil | t
nil t | nil | t
t nil | nil | nil
t t | t | t
The if/and relationship of course shows up in other languages: if (pointer != NULL) {
if (pointer->foo == 42)
do();
}
--> if (pointer != NULL && pointer->foo)
do();"There exists a number X such that P(X) is true." is nothing more than a short hand for "It is false that for all numbers X, P(X) is false."
In other words, if you accept that it's possible to reason about "for all" then you must accept that it's possible to reason about "there exists" since all "there exists" does is assert that a property is not false for every number.
https://math.stackexchange.com/questions/448527/are-the-g%C3...