Yes, not all structural functions can be recognized (I use "well
defined" in the mathematical sense meaning that the definition never
allows two conflicting results for the same arguments; it's actually
sort of a complement to "defined").

In practice recognizing structural functions isn't difficult, and the
natural tacit way to write a given structural function will be
recognized. This works by a kind of symbolic evaluation described in the
section "A structural Under algorithm". Explicit functions can be
recognized in the same way, but the need to control side effects makes
it harder to implement.

Marshall

On Mon, Jul 26, 2021 at 05:41:51PM -0400, Raul Miller wrote:
> Your concept of a structural function might be well defined
> mathematically, but it's not clear to me that recognizing structural
> functions could be efficiently implemented for the general case of
> user defined structural functions.
> 
> I think this means that you wind up requiring the user to declare
> whether some function is structural or not, and this requires that all
> user function definition retain that information in some fashion.
> 
> Does this match your understanding of your writeup?
> 
> Thanks,
> 
> -- 
> Raul
> 
> On Mon, Jul 26, 2021 at 5:23 PM Marshall Lochbaum <[email protected]> 
> wrote:
> >
> > I'm the inventor(?) of structural Under. I won't comment on whether it
> > makes sense for J but can offer a little more context.
> >
> > The operation is well defined: here's a specification with proof. It's
> > pretty difficult because it needs to support arbitrary paths into a
> > nested array, but would be much simpler if defined only on flat arrays,
> > and chances are there's an easier proof that I just couldn't find.
> > https://mlochbaum.github.io/BQN/spec/inferred.html#under
> >
> > In this definition the structural inverse x u&.:v y depends only on
> > ((v x) u v y) and y, not x, so vu in (v .: vu) would only ever need
> > those two arguments.
> >
> > There's also a tutorial section about structural Under in BQN here.
> > https://mlochbaum.github.io/BQN/tutorial/variable.html#modifying-part-of-an-array
> >
> > Structural Under isn't always compatible with the existing Under. J
> > seems to avoid inverting structural operations when the shape could
> > vary, but it uses fills when the shape is fixed but elements are
> > unknown. The following result starts with three fills when structural
> > Under would return a result beginning with 0 1 2. Copy (#) is another
> > example.
> >
> >    |.&.(3&}.) i.10
> > 0 0 0 9 8 7 6 5 4 3
> >
> >    |.&.(1 0 0 1 0&#) 'abcde'
> > d  a
> >
> > Marshall
> >
> > On Mon, Jul 26, 2021 at 12:57:10PM -0700, Elijah Stone wrote:
> > > 'Structural under' is an extension to under (&. &.:) that allows it to
> > > operate on otherwise uninvertible structure-changing verbs.  It is
> > > implemented in dzaima/apl (https://github.com/dzaima/APL/).
> > >
> > > For example:
> > >
> > >    -&.{. 1 2 3 4  NB. take the head, negate it, reaffix it to the rest of
> > > the body
> > > _1 2 3 4
> > >    }:&.}. 1 2 3 4 NB. remove the head, remove the tail, and then sew the
> > > head back on
> > > 1 2 3
> > >    |:&.}. i.4 3   NB. remove the head, transpose the body, and then 
> > > reattach
> > > the head
> > > 1 2  3
> > > 3 6  9
> > > 4 7 10
> > > 5 8 11
> > >   |.&., i.2 3     NB. ravel, reverse, and then unravel
> > > 5 4 3
> > > 2 1 0
> > >
> > > To make this functionality available to users, I suggest using .: for
> > > 'assign under', by analogy to :. and ::.  Then:
> > >
> > >   u&.:(v .: vu) y  ←→  vu y;u v y.
> > > x u&.:(v .: vu) y  ←→  vu x;y;(v x) u v y
> > >
> > > The reason that vu is only applied monadically is to allow for the 
> > > expected
> > > identity:
> > >
> > > u&.:(m&(v .: vu)) y ←→ m vu y;u v y
> > >
> > > Thoughts?
> > >
> > >  -E
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to