Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearrange Intent section #513

Merged
merged 13 commits into from
Nov 1, 2024
Merged

Rearrange Intent section #513

merged 13 commits into from
Nov 1, 2024

Conversation

brucemiller
Copy link
Contributor

This PR is a first attempt at rearranging the intent section to collect the various parts of definitions, descriptions and behaviors into single places to make the specification easier to use. Mostly, it collects the description of known, unknown, the how properties are used into a new subsection "Using Intent Concepts and Properties".

There is a gh-pages view here: https://brucemiller.github.io/mathml/spec.html#mixing_intent, although the numbering is not correct.

@davidcarlisle
Copy link
Collaborator

You could make respec happier by deleting the <dfn> (as you have done for element in the following item) or referencing it (as done for property on the previous item)

Found definition for "self-property-list", but nothing links to it. This is usually a spec bug!

@brucemiller
Copy link
Contributor Author

brucemiller commented Oct 29, 2024

Since you mention it: I had thought to make two changes to the grammar, but didn't want to go too far mixing changes.

  • fold the self-property-list into the 1st intent line and remove the dt,dd,dfn completely, on the hopes that it is sufficiently described in the later section. It doesn't seem like it needs to called out explicitly (and is a slightly confusing name). Or, of course, simply remove the dfn wrapper if we'll never reference it.
  • Change S to spaces to be infinitesimally more intuitive.

Copy link
Collaborator

@davidcarlisle davidcarlisle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the whole it looks good, there is one respec warning, and I added a suggestion at the point you indicated one was needed. (you can choose to add these or not to your PR using the "commit suggestion" button in the github UI.)

src/intent.html Outdated
@@ -152,7 +143,7 @@ <h3 id="mixing_intent_grammar">The Grammar for <code class="attribue">intent</co
<dt><dfn id="intent_property_list">self-property-list</dfn></dt>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<dt><dfn id="intent_property_list">self-property-list</dfn></dt>
<dt>self-property-list</dt>

src/intent.html Outdated
<p>Note that future updates of the AT and [=Intent Concept Dictionary=] may
include additional concepts, at which time those concepts may also receive special treatment.</p>

<p><em>NEEDS CLARIFICATION: </em>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p><em>NEEDS CLARIFICATION: </em>
<p>

src/intent.html Outdated
the AT may be able to infer the relevant concept. fixity and arguments
from the structure and content of the MathML.
In such cases, it should proceed as above as if the inferred intent had been given explicitly.
</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</p>
For example an AT system might infer in intent of `power` given `<msup><mi>x</mi><mn>2</mn></msup>`,
resulting in a reading such as "x squared". An explicit intent property of `:literal` could be used to over-ride this inferred intent, and lead to a reading such as `x superscript 2`.
</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, could add that. But there's also the case of "short-hand" intent (if that's the right term): I was also concerned with a case like
<mrow><mi>x</mi><mo intent="plus">foo</mo><mi>y</mi></mrow>
which could be inferred to be
<mrow intent="plus:infix($x,$y)">...
Should this be addressed here? (or is it addressed elsewhere already?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruce: perhaps you could say that the two are equivalent (without inference)? But I think a more compelling example would be better -- an example where you would expect some inference. In general, an mrow will read as is unless some inference overrides it E.g., $|x|$ or or maybe $P(A|B)$. In the case of $|x|$, I don't think there is a markup analogous to what you wrote. I think if you wrote <mo intent="xxx">|</mo>, then I'm dubious AT would do a match that comes up with absolute-value -- MathCAT wouldn't.

One thought would be add more examples to the examples section and use them to illustrate some of the edge cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed a very dubious section as a starting point for discussion.

@davidcarlisle
Copy link
Collaborator

@brucemiller

fold the self-property-list into the 1st intent line and remove the dt,dd,dfn completel

I'm not sure. We ended up with that grammar after a rather tortuous iteration and it's managed to stay stable for some time now:-)

The grammar would be simpler if we dropped self-property-list and instead allowed term to be empty so that intent=":literal" was just a property on an empty term rather than a specific self-property, but the consensus was that allowing empty terms (everywhere) was too much so we are where we are.

As you say it's true that we could regard that as a grammar implementation detail and not make the description follow the grammar exactly but (at least in that section) I think it is clearer if it does, as it's describing the grammar rather than describing intent in general (I think....)

@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Oct 29, 2024

On S or spaces I don't mind, I was probably unconciously swayed by

https://www.w3.org/TR/xml/#NT-S

as the xml spec used S here

But if people prefer to change that, then any name is OK

@davidcarlisle
Copy link
Collaborator

ah yes I think we have so far avoided trying to specify how intents on operators are lifted up to have intents with arguments on inferred children (as infering the arguments proved tricky in general) perhaps you are right that just giving some examples as system specific inferred intents would be good.

maybe a new section (before the intent error handling section) on inferring intent?

@brucemiller
Copy link
Contributor Author

Should I go ahead & create such a section, and add the suggestions we've discussed as a starting draft?

@davidcarlisle
Copy link
Collaborator

Should I go ahead & create such a section, and add the suggestions we've discussed as a starting draft?

I think so, this PR is "re-arrage intent section" not for any specific change so I think it makes sense to roll in other changes so people can see the section as a whole

@dginev
Copy link
Contributor

dginev commented Oct 29, 2024

To avoid disrupting discussion here, I have posed my remaining feedback as an add-on PR to this one, visible at brucemiller/mathml#1.

I am grateful for the changes in Bruce's commit 9902004 here, which gave me a foundation to build on.

@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Oct 30, 2024

on f3f9fec it may be worth copying (or perhaps even referencing) some of the examples in the intent-examples collecttion eg

https://w3c.github.io/mathml-docs/intent-examples/#id-1-1eff6f050a4d26222d07f68068e1014a

which shows "n choose k" being inferred from nothing (unless you use the :literal (nee :structure) property to suppress that.

@brucemiller
Copy link
Contributor Author

It may indeed be worth copying some examples, but it would help to have a better sense of where we're trying to go with this section before getting too deep. In writing the "use of" section, the case of <mo intent="plus"> didn't quite fit: there are no explicit arguments. Maybe the containing mrow just gets read literally, and "plus" is spoken at the right time, without any concern of arity or fixity? Alternatively, if it is expected that intent="plus:infix($x,$y)" will somehow be inferred, we probably have to say something about how. Either way, something needs to be said, I think, just different things!

OTOH, for the case where no intent is given, I suspect that we should say as little as possible about inferring intent to avoid limiting implementers from finding the best magic that they can.

@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Oct 30, 2024

It may indeed be worth copying some examples, but it would help to have a better sense of where we're trying to go with this section before getting too deep. In writing the "use of" section, the case of <mo intent="plus"> didn't quite fit: there are no explicit arguments. Maybe the containing mrow just gets read literally, and "plus" is spoken at the right time, without any concern of arity or fixity?

Yes, I think there are two possible models there.

  • one (which is I think what the spec says now) <mo intent="plus"> is a zero-arity plus and that may or may not have a special rule or may just get read as literal plus.

  • the other (which might be useful but we certainly don't want to specify, leaving it up to implementatiions, is that the system decides that plus is infix binary, so infers its arguments from siblings (if there are any) and basically re-writes to intent=plus{$a,$b) on the parent mrow.

Alternatively, if it is expected that intent="plus:infix($x,$y)" will somehow be inferred, we probably have to say something about how. Either way, something needs to be said, I think, just different things!

yes although I suspect we can't say "how" without falling into old rabbit holes around which element siblings are likely arguments and which are just punctuation

OTOH, for the case where no intent is given, I suspect that we should say as little as possible about inferring intent to avoid limiting implementers from finding the best magic that they can.

yes I think though we should say it's allowed. One real problem I had making the intent examples was that mathcat often made a good reading of the original, no-intent version, and then I struggled to add intent in a way not to mess it up. We need to say I think that systems may infer intents either if there are no intents at all or if the intent markup is only partial with not all subterms annotated. The system SHOULD not do that if a :literal property is in scope but otherwise they have free rein to do anything?

@brucemiller
Copy link
Contributor Author

Yes, I think there are two possible models there.
* one (which is I think what the spec says now) <mo intent="plus">is a zero-arityplusand that may or may not have a special rule or may just get read as literalplus`.

Yeah, this is where my thinking was gradually headed, I think. I didn't find it addressed explicitly anywhere, but certainly implied in examples. Probably at the beginning of the Using section we need a bit of clarification along the lines that arity & fixity are only relevant if arguments are given explicitly in the intent form. And the effective speech hint is going to look like the existing ones, except omitting any "of", commas, arguments and such. Perhaps some concepts will want an explicit extra entry? Some won't make sense in any event (as @NSoiffer pointed out).

If we can phrase this right, we probably don't need this new section at all.

* the other ....

The possibility of making the detailed intent completely explicit belongs with the possibility of inferring a intent from scratch: we'd want to allow it, but not get into any details.

@davidcarlisle
Copy link
Collaborator

The possibility of making the detailed intent completely explicit belongs with the possibility of inferring a intent from scratch: we'd want to allow it, but not get into any details.

yes, so I suppose it's a choice of whether we assume anything not forbidden is allowed, and so not mention it or whether we want to give a note that it is allowed and possibly even a an example or two.

@brucemiller
Copy link
Contributor Author

Following the above discussion, I just added some clarification to the beginning of the Using section about matching intents which have no arguments, which (mostly) handles the common case of <mo intent="plus">. It may be that we need to either add arity=0 cases to the dictionaries, or otherwise comment on not saying "integral of"?

Consequently, I've removed the stub section on inference (we can add more later, if needed).

src/intent.html Outdated Show resolved Hide resolved
Copy link
Collaborator

@davidcarlisle davidcarlisle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one trivial typo marked in line (si/is) but otherwise last round of changes look good

src/intent.html Outdated Show resolved Hide resolved
Co-authored-by: David Carlisle <[email protected]>
@NSoiffer
Copy link
Contributor

NSoiffer commented Nov 1, 2024

I think this is a very good rewrite. There is more work to do (e.g., add some text on :literal). But this is a good rearrangement of the material and clarifies that Intent Concept Dictionary is a general idea that can be implemented in a wide variety of ways.

@NSoiffer NSoiffer merged commit 0c8e53b into w3c:main Nov 1, 2024
2 of 3 checks passed
github-actions bot added a commit that referenced this pull request Nov 1, 2024
SHA: 0c8e53b
Reason: push, by NSoiffer

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@davidcarlisle
Copy link
Collaborator

@brucemiller @NSoiffer not sure why the pipeline is failing (the spec seems to have built and pushed to gh-pages)

@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Nov 1, 2024

I'm not quite sure what it was saying, but the failure seems to be an artifact of the fork/PR.
Builds all green again now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants