[Jprogramming] J functors

Boyko Bantchev boykobb at gmail.com
Fri Mar 30 02:09:43 HKT 2012


>>>>        (f∘g)(x) ≡ f(g(x))
>
> And yet, f and g are not defined here, and neither are x.

Because of course they need not to.  Whatever the domains and codomains
of f and g, they do not change the meaning of composition as defined by
the above identity.

But leave that identity, and consider how the DoJ defines monadic @ :

        u at v y ↔ u v y

Where are the 'definitions' of u, v, and y?

> (And, for
> that matter, the grammar associated with parenthesis are not defined
> here.)

This is a ridiculous nitpicking which does not need to be commented
further.

> Thus, formal definitions depend on the definitions of the symbols used
> in the definition.

False, as exemplified by the definition of @ quoted above.

> More generally, Mathematics deals with numerous
> definitions for the symbols it uses.  There are numerous branches of
> mathematics, each with their own conventions for these definitions.

Irrelevant to the discussion of composition and functors.

>>> One issue, here, is that the definitions of f, g and x are contextual.
>> What do you mean by 'contextual'?
> I mean that, for example, the definition of x depends on the context
> where the phrase that contains x is used.

Again, how does the definition of @ depend on a 'context'?
(Not that that is the only counter-example available, far from that …)

> In one context, x might be 1
> In another context, x might be 2
> ...
> ...

And again, the context of  (f∘g)(x) ≡ f(g(x))  is no different than
that of  u at v y ↔ u v y .  How is the definition of @ 'contextual'?
Are you saying that, in the second identity, the meaning of @ depends
on what y 'might be'?

> And yet none of these statements were part of that "formal definition".

Why should they be, if they are assumed anyway.  Do you consider
u at v y ↔ u v y  'informal' or broken in some way due to not including the
same trivially assumed statements?

>> How can a function have two different domains without being in fact
>> two different functions?  Doesn't make sense to me.
>
> A domain is the set of argument values for which a function is defined.

So far, correct.

> A function can have multiple definitions.

If so, all they are different functions, not one function.

> How else can we talk about extending a function defined on
> integers to be a function defined on real numbers?

By defining a new, different function acting on all reals.
We don't keep and use both at the same time, and no
confusion arises.

> No ranks are changed.
> The rank of the derived verb will sometimes be different, for
> different sentences.  But whether this is a significant issue
> depends on the domain under consideration.

It is significant enough to make @ and @: different adverbs, which
produce (in general) different verbs from the same arguments.
Hence, as I said, if @ is composition in the mathematical sense,
@: isn't.

> Your formal definition did not require that a verb be produced.
> So why is this an issue now?

It did require this in exactly the same sense that  u at v y ↔ u v y
does.

>> If x is an adverb, so that g(x) is a verb, then f(g(x)) is a hook
>> – again, not a composition.
> I do not know what you are talking about here.

What is not clear?  The example was yours.  You took the phrase
f(g(x)) with x an adverb and said that the phrase might represent
composition.  What I am pointing to is that this cannot be true,
even if f and g are verbs: the result is a hook, and a hook is
never a composition (in the same sense that @ or its applications
are compositions).

> If f&g is composition then clearly f(g(x)) is composition.

False.  Not only the two objects are different, they are of different
types.  E.g., if f and g are numeric functions, then f&g is also a
numeric function (a verb), while f(g(x)) is a number.
(Note that all the other examples that you gave in this group,
even though most of them were not compositions, but at least they
designated some verbs.)

>> We have to stick to the mathematical meaning of composition because
>> this is what the definition of functor depends on, and we were
>> discussing functors ...
> Except we seem to have new constraints appearing as new examples
> are introduced?

Examples of what?  If of functors, then according to what definition?
Since you were referring to the notion of functor in Haskell, I am
assuming a functor is something that has a fmap function satisfying
the homomorphic identity I quoted – and that relies on the
mathematical, Haskell, ML, etc. understanding of composiion,
represented in J as @ and &.

>>> You seem to be saying that context is irrelevant.
>> The context of what?  In defining composition, I see no context at all.
> The context under consideration.  This is the context that supplies
> definitions for the functions and which defines their domains.

This has been talked over enough already.  See above.

> Let's consider:
>  f @: g
> ...
> So I am not sure what you are trying to say.

If f and g – and not their modified copies – were subjected to
composition, then the result would be a verb with some rank that
apparently depends on the ranks of f and g.  That rank would not
invariably be infinite, as is the case with @:.  Therefore, what
@: does is not just a composition (although it resembles one).

Moreover, if @: just composed its argument verbs f and g, all of
the following conditions would be kept:
    composition is a true one (equivalent to ∘ in mathematics);
    f takes part in the composition unmodified;
    similar of g;
    the verb resulting from composing f on g is left unmodified.


More information about the Programming mailing list