Re: Semantic Markup: mrow's are needed

Since I will write code that turns semantic LaTeX into
MathML, I am hoping that the natural way for me to approach
the problem will lead to MathML that this group approves!

Let's continue using the product of factorials as an example.
Suppose my code encounters the following author-written source:

$n! m!$

First step is to convert to a verbose semantic LaTeX form,
which in this case might look like:

$\impliedMutiplication{\factorial{n}}{\factorial{m}}$

Now we have the problem of expanding those macros into MathML.
And I just made a key point:  the natural view for me is in
terms of macros that get expanded.  Thus:

1) I need a definition for \factorial{#1} that does not
care what #1 is.

I think the conclusion is that the factorial will be
wrapped in an mrow.  Whether the semantic information is
on the mrow or on the mo, is not particular to me:  I'll
implement whatever is decided and it is the same work either way.

2) I need a definition for \impliedMutiplication{#1}{#2} .

I don't know enough to say whether or not a surrounding mrow is
always optional, or whether the "invisible times" symbol
should be used.  Again, for me the decision is independent of
#1 and #2, and also independent of whether or not the
impliedMultiplication was inside something else.

(If you tell me that the expansion of those macros has to
depend on the nature of their arguments or on the context in
which that appear, then I will deal with it, but that is not
my preference.  Context dependence is needed to obtain some
of Deyan's examples.)

I hope my perspective of "expanding macros" is useful.

Regards,

David


On Tue, 30 Jun 2020, Deyan Ginev wrote:

> Indeed, it is as Bruce suggests -- I was focusing on the argument
> scaffold when you have implicit mrows, to illustrate the point, which
> I see mostly took :> Thanks for adding the missing bits! To belabor
> the point some more, this approach lets you have a number of choices
> when you have "too many" mrows, but it makes sure you have at least
> one choice when the mrows are omitted/implied (choice being to float
> the annotation up).
>
> Maybe a good metaphor here is that Presentation MathML is like cooked
> meat - it has several levels of doneness and every culture has its
> favourite.
>
> Some of the variations that come to mind:
>
> 1. Implied mrows (as in Bruce's email, but I will use "semantic" as
> the attribute name for now, since we haven't formally set it in stone
> yet)
>
> <mrow semantic="times(@f1(@b1),@f2(@b2))">
>   <mi arg="b1">m</mi>
>   <mo arg="f1" semantic="factorial">!</mo>
>   <mi arg="b2">n</mi>
>   <mo arg="f2" semantic="factorial">!</mo>
> </mrow>
>
> 2. Content-tree aligned mrows, coarse-grained annotations
>
> <mrow semantic="times(@f1(@b1),@f2(@b2))">
>   <mrow>
>     <mi arg="b1">m</mi>
>     <mo arg="f1" semantic="factorial">!</mo>
>   </mrow>
>   <mrow>
>     <mi arg="b2">n</mi>
>     <mo arg="f2" semantic="factorial">!</mo>
>   </mrow>
> </mrow>
>
> 3. Overdone mrows, coarse-grained annotations
>
> <mrow notation="times(@f1(@b1),@f2(@b2))">
>   <mrow>
>     <mrow>
>       <mi arg="b1">m</mi>
>     </mrow>
>     <mrow>
>       <mo arg="f1" semantic="factorial">!</mo>
>     </mrow>
>   </mrow>
>   <mrow>
>     <mrow>
>       <mi arg="b2">n</mi>
>     </mrow>
>     <mrow>
>       <mo arg="f2" semantic="factorial">!</mo>
>     </mrow>
>   </mrow>
> </mrow>
>
>
> 4. Content-aligned mrows, fine-grained annotations
>
> <mrow notation="times(@lfactor,@rfactor)">
>   <mrow arg="lfactor" semantic="@op(@m)">
>     <mi arg="m">m</mi>
>     <mo arg="op" semantic="factorial">!</mo>
>   </mrow>
>   <mrow arg="rfactor" semantic="@op(@n)">
>     <mi arg="n">n</mi>
>     <mo arg="op" semantic="factorial">!</mo>
>   </mrow>
> </mrow>
>
> 5. Overdone mrows, fine-grained annotations
>
> <mrow notation="times(@lfactor,@rfactor)">
>   <mrow arg="lfactor" semantic="@op(@m)">
>     <mrow>
>       <mi arg="m">m</mi>
>     </mrow>
>     <mrow>
>       <mo arg="op" semantic="factorial">!</mo>
>     </mrow>
>   </mrow>
>   <mrow arg="rfactor" semantic="@op(@n)">
>     <mrow>
>       <mi arg="n">n</mi>
>     </mrow>
>     <mrow>
>       <mo arg="op" semantic="factorial">!</mo>
>     </mrow>
>   </mrow>
> </mrow>
>
> And one could indeed replace the literal "times" with a pointer to an
> <mo> containing invisible times, if it was available and preferred, or
> still keep this style of annotating even when such invisible times
> <mo> is available.
>
> FWIW, if we took a group vote, I have a feeling we will have at least
> 2 of these 5 choices get a vote for "best practice", depending on
> perspective. So we might as well leave the choice open with some
> illuminating examples how to make it?
>
> Deyan
>
> On Tue, Jun 30, 2020 at 9:11 AM Miller, Bruce R. (Fed) <miller@nist.gov> wrote:
>>
>> On 6/29/20 9:11 PM, Neil Soiffer wrote:
>>> Apologies for the delayed reply -- I put some blinders on for a few days
>>> to grind out some code to linebreak/indent MathML.
>>>
>>> I think David's second reply is the correct one as to my way of
>>> thinking. Using my current (but now old) proposal:
>>> <mrow notation="times(factorial(@1), factorial(#3))">
>>> <mi>m</mi>
>>> <mo>!</mo>
>>> <mi>n</mi>
>>> <mo>!</mo>
>>> </mrow>
>>>
>>> I think Deyan was aiming at something like that using his proposal's
>>> notation, but I don't think it is right. Nowhere is "factorial" present.
>>
>> Right, I think what he was *trying* to say was
>> <mrow notation="times(@f1(@b1),@f2(@b2))">
>>    <mi arg="b1">m</mi>
>>    <mo arg="f1" notation="factorial">!</mo>
>>    <mi arg="b2">n</mi>
>>    <mo arg="f2" notation="factorial">!</mo>
>> </mrow>
>>
>> Which is semantically equivalent to what you wrote, but has the
>> advantage that an agent can more easily track that each "!"
>> corresponds to factorial (for highlighting, navigation, ...
>>   or even linking ? :>
>>
>>
>>>      Neil
>>>
>>> On Fri, Jun 26, 2020 at 7:57 AM Deyan Ginev <deyan.ginev@gmail.com
>>> <mailto:deyan.ginev@gmail.com>> wrote:
>>>
>>>     Hi all,
>>>
>>>     The mini proposal also allows to annotate any presentation tree, but
>>>     you sacrifice the granularity of the annotation - it floats higher. So
>>>     Neil's tree can be annotated as (using the syntax that seemed to be
>>>     the consensus form after yesterday's meeting):
>>>
>>>     <mrow semantic="times(@factorial1(@base1),@factorial2(@base2))">
>>>        <mi arg="base1">m</mi>
>>>        <mo arg="factorial1">!</mo>
>>>        <mi arg="base2">n</mi>
>>>        <mo arg="factorial2">!</mo>
>>>     </mrow>
>>>
>>>     Greetings,
>>>     Deyan
>>>
>>>     On Fri, Jun 26, 2020 at 10:48 AM David Carlisle <davidc@nag.co.uk
>>>     <mailto:davidc@nag.co.uk>> wrote:
>>>     >
>>>     > On 26/06/2020 15:39, Neil Soiffer wrote:
>>>     >
>>>     > We have talked a little about needing proper mrow structure in
>>>     order to mark up prefix/posfix/infix operators. For example, the
>>>     following can not be semantically marked up:
>>>     > <mrow>
>>>     >   <mi>m</mi>
>>>     >   <mo>!</mo>
>>>     >   <mi>n</mi>
>>>     >   <mo>!</mo>
>>>     > </mrow>
>>>     >
>>>     > It needs an extra layer of mrows around the postfix factorials in
>>>     the mrow.
>>>     > <mrow>
>>>     >   <mrow>
>>>     >     <mi>m</mi>
>>>     >     <mo>!</mo>
>>>     >   </mrow>
>>>     >   <mrow>
>>>     >     <mi>n</mi>
>>>     >     <mo>!</mo>
>>>     >   </mrow>
>>>     > </mrow>
>>>     >
>>>     >
>>>     >
>>>     > It seems the main problem (with both forms) is the missing
>>>     invisible times.  Using the notation of one of the current proposals
>>>     (semantics-mini)  you could do
>>>     >
>>>     >
>>>     > <mrow
>>>     >
>>>     > semantic="@3(@2(@1),@5(@4))
>>>     >>
>>>     >
>>>     >   <mi>m</mi>
>>>     >   <mo semantic=factorial>!</mo>
>>>     >   <mo>&invisibletimes;</mo>
>>>     >   <mi>n</mi>
>>>     >   <mo semantic=factorial>!</mo>
>>>     >
>>>     > </mrow>
>>>     >
>>>     >
>>>     > Here's a case we haven't talked about: implicit mrows.
>>>     > <msqrt>
>>>     >   <mi>n</mi>
>>>     >   <mo>!</mo>
>>>     > </msqrt>
>>>     >
>>>     >
>>>     > again can't you do
>>>     >
>>>     >
>>>     > <msqrt semantic="sqrt(@2(@1))">
>>>     >   <mi>n</mi>
>>>     >   <mo semantic=factorial>!</mo>
>>>     > </msqrt>
>>>     >
>>>     >
>>>     >
>>>     > David
>>>     >
>>>     >
>>>     >
>>>     >
>>>     > Disclaimer
>>>     >
>>>     > The Numerical Algorithms Group Ltd is a company registered in
>>>     England and Wales with company number 1249803. The registered office
>>>     is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United
>>>     Kingdom. Please see our Privacy Notice for information on how we
>>>     process personal data and for details of how to stop or limit
>>>     communications from us.
>>>     >
>>>     > This e-mail has been scanned for all viruses and malware, and may
>>>     have been automatically archived by Mimecast Ltd, an innovator in
>>>     Software as a Service (SaaS) for business.
>>>
>>>
>>
>>
>> --
>> bruce.miller@nist.gov
>> http://math.nist.gov/~BMiller/
>>
>>
>
>

Received on Tuesday, 30 June 2020 14:59:56 UTC