Skip to content

Document unicode math operators #3737

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

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

d-torrance
Copy link
Member

@d-torrance d-torrance commented Apr 18, 2025

We document the three unicode math operators that were added back in #3584 (·, ⊠, and ⧢).

We also:

  • Add support for using the augmented versions of these operators.
  • Add a Vector · Vector dot product method.

@d-torrance d-torrance added Documentation Core Issues involving the Core scripts. Interpreter labels Apr 18, 2025
@d-torrance d-torrance requested a review from mahrud April 18, 2025 03:54
@pzinn
Copy link
Contributor

pzinn commented Apr 18, 2025

I'm still opposed to this change, cf my rejected PR #3599

@mahrud
Copy link
Member

mahrud commented Apr 18, 2025

I'm still opposed to this change, cf my rejected PR #3599

It wasn't rejected. We requested changes to balance introducing a new, useful feature while staying clear of undefined behavior when packages define conflicting keywords, at least until the details of that are ironed out. I think with relatively minor changes, it can still make it to this upcoming release.

@@ -74,6 +74,15 @@ assert Equation(x#0, 28)
Foo @ Foo := (x, y) -> Foo(4*x#0 - 5*y#0)
x @= Foo 7
assert Equation(x#0, 77)
Foo · Foo := (x,y) -> Foo(6*x#0 * 7*y#0)
x ·= Foo 8
Copy link
Member

Choose a reason for hiding this comment

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

This looks awkward, and I'm not convinced that it is useful enough to justify supporting it.

Copy link
Member Author

Choose a reason for hiding this comment

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

My original thought was that every flexible binary operator (as long as it didn't introduce ambiguity when appending an extra =, like == -> ===) should support augmented assignment out of the box.

While it's certainly true it would probably be a bad idea to use ·= for an augmented dot product (First v is a vector, but after v ·= w, it's an element of the ring...), we might as well make it available for some other context where it might make sense.

Comment on lines 45 to 53
To insert this character in Emacs, you may press @KBD "C-x 8 RET"@
or @KBD "M-x insert-char"@ and then enter "squared times" in the
minibuffer.

Alternatively, you may press @KBD "C-x RET C-\\"@ or
@KBD "M-x set-input-method"@ and then enter "TeX" in the minibuffer.
Afterwards, typing "\boxtimes" will input the ⊠ character. You may then
toggle the input method using @KBD "C-\\"@ or
@KBD "M-x toggle-input-method"@.
Copy link
Member

Choose a reason for hiding this comment

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

Since these paragraphs are mostly repeated, it may be worthwhile to have an automated section printed at the bottom of unicode operators that explains how to enter them. e.g. something like the "For the programmer" section underneath operators, which explains how to define methods on them.

Also, I still think every unicode operator should be tied to an ascii method name so it can be still used without unicode entry (e.g. ** and tensor for $\otimes$).

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the idea of an automated section -- I'll push a proposal here in a bit.

As for the ascii method name... I'm not sure if we should force a particular name for each operator, or just leave it up to package authors. Maybe one package has ⊠ to be a shortcut for externalTensorProduct and another for strongProduct , etc.

But yeah, we should probably provide an ascii version for each method that's actually defined. I'll go ahead and add dotProduct(Vector, Vector) as a synonym for Vector · Vector.

@d-torrance
Copy link
Member Author

I ended up dropping the Vector · Vector method from this PR, although I'll likely revisit it later. Various complications:

  • What to do with rings over CC? We should probably use the Hermitian transpose, and perhaps that should be implemented in the engine rather than conjugating every entry one at a time?
  • If we add a dotProduct method function to Core to serve as an ascii synonym, then we need to move the definition away from BoijSoiderberg, which currently exports it. But that that opens up a can of worms with the documentation, as its Inputs section defines five different inputs despite the fact that the method takes at most three inputs.

@d-torrance d-torrance force-pushed the unicode-operators branch from 1fe0f56 to f29ad8b Compare May 1, 2025 01:23
@mahrud
Copy link
Member

mahrud commented May 9, 2025

  • But that that opens up a can of worms with the documentation, as its Inputs section defines five different inputs despite the fact that the method takes at most three inputs.

For the record, the solution is to either use Synopsis or group the types together, e.g. M => {matrix,BettiTally} or similar.

@pzinn pzinn mentioned this pull request May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants