From 6ad2532cd6e2daec265116d533c04c7b9e338fa4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 7 Jan 2021 21:11:10 -0500 Subject: Insert identity can be unique just among arrays with the appropriate cell shape --- docs/spec/inferred.html | 2 +- spec/inferred.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/spec/inferred.html b/docs/spec/inferred.html index c8bf6bc0..d4d22610 100644 --- a/docs/spec/inferred.html +++ b/docs/spec/inferred.html @@ -10,7 +10,7 @@

Identities

When monadic Fold (´) or Insert (˝) is called on an array of length 0, BQN attempts to infer a right identity value for the function in order to determine the result. A right identity value for a dyadic function 𝔽 is a value r such that ee𝔽r for any element e in the domain. For such a value r, the reduction r 𝔽´ l is equivalent to 𝔽´ l for a non-empty list l, because the first application (¯1l) 𝔽 r gives ¯1l, which is the starting point when no initial value is given. It's thus reasonable to define 𝔽´ l to be r 𝔽´ l for an empty list l as well, giving a result r.

For Fold, the result of 𝔽´ on an empty list is defined to be a right identity value for the range of 𝔽, if exactly one such value exists. If an identity can't be proven to uniquely exist, then an error results.

-

For Insert, 𝔽˝ on an array of length 0 is defined similarly, but also depends on the cell shape 1↓≢𝕩. The required domain is the arrays of that shape that also lie in the range of 𝔽 (over arbitrary arguments, not shape-restricted ones).

+

For Insert, 𝔽˝ on an array of length 0 is defined similarly, but also depends on the cell shape 1↓≢𝕩. The required domain is the arrays of that shape that also lie in the range of 𝔽 (over arbitrary arguments, not shape-restricted ones). Furthermore, an identity may be unique among all possible arguments as in the case of Fold, or it may be an array with shape 1↓≢𝕩 and be unique among arrays with that shape. For example, with cell shape 32, all of 0, 20, and 320 are identities for +, but 320 can be used because it is the only indentity with shape 32, while the other identities aren't unique and can't be used.

Identity values for the arithmetic primitives below must be recognized. Under Fold, the result is the given identity value, while under Insert, it is the identity value reshaped to the argument's cell shape.

diff --git a/spec/inferred.md b/spec/inferred.md index a12da31b..5b43c0ef 100644 --- a/spec/inferred.md +++ b/spec/inferred.md @@ -12,7 +12,7 @@ When monadic Fold (`´`) or Insert (`˝`) is called on an array of length 0, BQN For Fold, the result of `𝔽´` on an empty list is defined to be a right identity value for the *range* of `𝔽`, if exactly one such value exists. If an identity can't be proven to uniquely exist, then an error results. -For Insert, `𝔽˝` on an array of length 0 is defined similarly, but also depends on the cell shape `1↓≢𝕩`. The required domain is the arrays of that shape that also lie in the range of `𝔽` (over arbitrary arguments, not shape-restricted ones). +For Insert, `𝔽˝` on an array of length 0 is defined similarly, but also depends on the cell shape `1↓≢𝕩`. The required domain is the arrays of that shape that also lie in the range of `𝔽` (over arbitrary arguments, not shape-restricted ones). Furthermore, an identity may be unique among all possible arguments as in the case of Fold, or it may be an array with shape `1↓≢𝕩` and be unique among arrays with that shape. For example, with cell shape `3‿2`, all of `0`, `2⥊0`, and `3‿2⥊0` are identities for `+`, but `3‿2⥊0` can be used because it is the only indentity with shape `3‿2`, while the other identities aren't unique and can't be used. Identity values for the arithmetic primitives below must be recognized. Under Fold, the result is the given identity value, while under Insert, it is the identity value reshaped to the argument's cell shape. -- cgit v1.2.3