From 59ab5338d4e23eb108a43f876aa979238ae2490e Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 12 Nov 2021 22:15:44 -0500 Subject: Slightly less APL-centric documentation --- docs/doc/logic.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/doc/logic.html') diff --git a/docs/doc/logic.html b/docs/doc/logic.html index 92a03e43..19d4f294 100644 --- a/docs/doc/logic.html +++ b/docs/doc/logic.html @@ -5,7 +5,7 @@

Logic functions: And, Or, Not (also Span)

-

BQN retains the APL symbols and for logical and and or, and changed APL's ~ to ¬ for not, since ~ looks too much like ˜ and ¬ is more common in mathematics today. Like J, BQN extends Not to the linear function 1-. However, it discards GCD and LCM as extensions of And and Or, and instead uses bilinear extensions: And is identical to Times (×), while Or is ׬, following De Morgan's laws (other ways of obtaining a function for Or give an equivalent result—there is only one bilinear extension).

+

BQN uses the mathematical symbols and for logical and and or, and ¬ for not (APL's ~ is discarded since it looks like ˜, and is less common in mathematics today). These functions are arithmetically extended to apply to all numbers. In the case of Not, that means the linear function 1-. The two-argument functions have bilinear extensions: And is identical to Times (×), while Or is ׬, following De Morgan's laws (other ways of obtaining a function for Or give an equivalent result—there is only one bilinear extension).

If the arguments are probabilities of independent events, then an extended function gives the probability of the boolean function on their outcomes (for example, if A occurs with probability a and B with probability b independent of A, then A or B occurs with probability ab). These extensions have also been used in complexity theory, because they allow mathematicians to transfer a logical circuit from the discrete to the continuous domain in order to use calculus on it.

Both valences of ¬ are equivalent to the fork 1+-. The dyadic valence, called "Span", computes the number of integers in the range from 𝕩 to 𝕨, inclusive, when both arguments are integers and 𝕩𝕨 (note the reversed order, which is used for consistency with subtraction). This function has many uses, and in particular is relevant to the Windows function.

These functions are considered arithmetic functions and thus are pervasive.

@@ -39,7 +39,7 @@

As with logical And and Or, any value and 0 is 0, while any value or 1 is 1. The other boolean values give the identity values for the two functions: 1 and any value gives that value, as does 0 or the value.

Why not GCD and LCM?

-

The main reason for omitting these functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there is 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 is 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).

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.

Identity values

It's common to apply a fold ´ or ´ to a list (checking whether all elements are true and whether any are true, respectively), and so it's important for extensions to And and Or to share their identity value. Minimum and Maximum do match And and Or when restricted to booleans, but they have different identity values. It would be dangerous to use Maximum to check whether any element of a list is true because ´⟨⟩ yields ¯∞ instead of 0—a bug waiting to happen. To avoid this the programmer would have to use an initial value 𝕨 of 0, which is easy to forget.

-- cgit v1.2.3