From 976bd82fb0e830876cca117c302c8a19048033a4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 24 Nov 2022 08:58:41 -0500 Subject: =?UTF-8?q?Specify=20more=20=E2=80=A2math=20functions=20and=20impl?= =?UTF-8?q?ement=20JS=20Fact,=20Comb,=20GCD,=20LCM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/doc/logic.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/doc/logic.html') diff --git a/docs/doc/logic.html b/docs/doc/logic.html index 9b18b817..c1490385 100644 --- a/docs/doc/logic.html +++ b/docs/doc/logic.html @@ -132,6 +132,6 @@

It's not hard to prove that the bilinear extensions have these identity values. Of course 1x is 1×x, or x, and 0x is 0׬x, or ¬1׬x, giving ¬¬x or x again. Both functions are commutative, so these values are identities on the right as well.

Some other logical identities don't always hold. For example, in boolean logic And distributes over Or and vice-versa: abc ←→ (ab)(ac). But substituting × for and +-× for we find that the left hand side is (a×b)+(a×c)+(a×b×c) while the right gives (a×b)+(a×c)+(a×b×a×c). These are equivalent for arbitrary b and c only if a=a×a, that is, a is 0 or 1. In terms of probabilities the difference when a is not boolean is caused by failure of independence. On the left hand side, the two arguments of every logical function are independent. On the right hand side, each pair of arguments to are independent, but the two arguments to , ab and ac, are not. The relationship between these arguments means that logical equivalences no longer apply.

Why not GCD and LCM?

-

APL provides GCD and LCM as extensions of And and Or, while BQN doesn't make these functions primitives. The main reason for omitting them functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there's no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement, which allows the programmer to control the details, and also add functionality such as the extended GCD. Possible implementations for GCD and LCM are shown in bqncrate (GCD, LCM).

+

APL provides GCD and LCM as extensions of And and Or, while BQN doesn't make these functions primitives. The main reason for omitting them functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there's no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement, which allows the programmer to control the details, and also add functionality such as the extended GCD. Possible implementations for GCD and LCM are shown in bqncrate (GCD, LCM), and •math.GCD and •math.LCM are also supported.

A secondary reason is that the GCD falls short as an extension of Or, because its identity value 0 is not total. 0x, for a real number x, is actually equal to |x and not x: for example, 0¯2 is 2 in APL. This means the identity 0x ←→ x isn't reliable in APL.

Unrelatedly, the reason BQN discards APL's ~ for negation is that it looks like ˜, and is less common in mathematics today.

-- cgit v1.2.3