by spyrja · 1y ago · 0 comments
In the case where a and b are not strictly boolean (supposing they are instead probabilities for example) you could even generalize it somewhat in terms of "pure" mathematical operations.
double implies(double a, double b) {
double dif = a - b;
double abx = sqrt(dif * dif);
return 1 + pow(0, abx - dif) - pow(1, abx + dif);
}
Kind of silly, I know, but it does work.I thought about it in terms of cardinalities of types. If A and B are types with |A| and |B| values correspondingly, there are |B|^|A| possible functions A -> B.
Another funny thing is that if you consider
forall a. (a -> a) -> (a -> a)
the type of natural numbers (weird, I know, but basically we encode numbers in unary with number of times we compose (a -> a) to itself), then exponentiation on such numbers will be
a ^ b = b a