Zulip Chat Archive

Stream: mathlib4

Topic: Notation for crossProduct


ZhiKai Pong (May 23 2025 at 19:47):

@Eric Wieser I hope you don't mind me pinging, I noticed that for cross products the corresponding symbol
×₃ is typed using \x or \times or \multiplication, but then there is
which is \X or \vectorproduct or \crossproduct which seem a bit odd.

I was typing \crossproduct and it took me while to realize its not what's used in the actual cross product. is there a discrepancy here and should the notation/docstrings be updated?

Notification Bot (Jul 11 2025 at 11:26):

A message was moved here from #new members > Using crossProduct in EuclideanSpace (Fin 3) by Eric Wieser.

Eric Wieser (Jul 11 2025 at 11:27):

I'd be in favor of switching to the notation, as unicode allocates it specifically for this purpose.

ZhiKai Pong (Jul 11 2025 at 14:15):

do we want to keep the 3 in ⨯₃ or just ?

Eric Wieser (Jul 11 2025 at 14:50):

I guess drop it; if we ever get the 7-dimensional version we can add a notation typeclass

ZhiKai Pong (Jul 11 2025 at 16:32):

is there an easier way to find all files that contain crossProduct? I'm currently going through the files manually using Imported by in the docs, which luckily isn't a lot but I'm wondering is there a better way

Eric Wieser (Jul 11 2025 at 16:37):

lake build and see what breaks?

Martin Dvořák (Jul 11 2025 at 17:00):

FYI I find × and really hard to distinguish.

Martin Dvořák (Jul 11 2025 at 17:02):

Also, since dot product, which is used far more often than cross product, does not have a single-symbol operator, I find it weird to give this luxury to cross product.

Martin Dvořák (Jul 11 2025 at 17:02):

That's just my two cents on why I wouldn't make the suggested change.

Martin Dvořák (Jul 11 2025 at 17:06):

BTW copy the following five symbols into your favorite editor with your favorite font in the size you normally use ⨯×xXχ and tell us how easy it is to distinguish them from each other.

ZhiKai Pong (Jul 11 2025 at 17:09):

Martin Dvořák said:

BTW copy the following five symbols into your favorite editor with your favorite font in the size you normally use ⨯×xXχ and tell us how easy it is to distinguish them from each other.

(⨯×xXχΧ theres \Chi as well)

Eric Wieser (Jul 11 2025 at 17:14):

I claim that being able to distinguish them is easy, because all but one will give a lean type error

ZhiKai Pong (Jul 11 2025 at 17:21):

I've made #27006

Martin Dvořák (Jul 11 2025 at 17:36):

Maybe neither ×₃ nor should be the operator; it should be ⨯₃ instead.

Eric Wieser (Jul 11 2025 at 17:37):

I don't think the 3 conveys anything interesting

Kevin Buzzard (Jul 11 2025 at 19:25):

We're trying to mimic what mathematicians write, not what they should write or what it would be convenient if they wrote.

Eric Wieser (Jul 11 2025 at 19:40):

ZhiKai Pong said:

I've made #27006

I've added some meta code to this PR to deprecate the syntax; maybe @Yaël Dillies has opinions since they did something similar for sum notation?

Yaël Dillies (Jul 11 2025 at 19:47):

Have you tried it? I'm slightly worried your suggestion will replace a ×₃ b with rather than a ⨯ b, but if you've tried and it does the right thing, then looks reasonable

Jireh Loreaux (Jul 11 2025 at 19:50):

Personally, I would really prefer the ⨯₃ notation (including the ) because it aids with disambiguation when reading the code (e.g., on GitHub). But perhaps I'm overestimating the possibility for ambiguity.

Eric Wieser (Jul 11 2025 at 20:12):

I claim there is no situation where there is any risk of ambiguity, since thankfully Fin 3 -> R has no coercion to sort!

Eric Wieser (Jul 11 2025 at 20:26):

But maybe this should be put to a vote in a day or so, once any other interested parties have made their argument.

Jireh Loreaux (Jul 11 2025 at 21:11):

You're probably right that it's not necessary, but I think it would still be my preference.

ZhiKai Pong (Jul 13 2025 at 13:51):

do we still want a vote or is the consensus to go with ⨯₃?

Eric Wieser (Jul 13 2025 at 14:00):

/poll What should the syntax be for crossProduct?

  • ×₃ (U+00D7 multiplication sign, status quo)
  • ⨯ (U+2A2F vector or cross product)
  • ⨯₃ (U+2A2F vector or cross product)

ZhiKai Pong (Jul 18 2025 at 09:49):

bump since there's a tie

Edward van de Meent (Jul 18 2025 at 09:53):

Kevin Buzzard said:

We're trying to mimic what mathematicians write, not what they should write or what it would be convenient if they wrote.

Eric Wieser said:

I claim that being able to distinguish them is easy, because all but one will give a lean type error

from this, i gather that what we really want is a custom elaborator for ×, not different notation?

Edward van de Meent (Jul 18 2025 at 09:56):

because i'm in favour of making it easy to type the right thing. i really don't want another "you wrote |, but you really meant "

Edward van de Meent (Jul 18 2025 at 10:08):

it isn't even terribly difficult, i think? we can just do this:

import Mathlib

variable {α β : Type*} {R : Type*} [CommRing R] (a b : Fin 3  R)

@[inherit_doc] scoped[Matrix] infixl:74 " × " => crossProduct

open Matrix

#check α × β -- Prod α β : Type (max u_1 u_2)

#check a × b -- (crossProduct a) b : Fin 3 → R

Edward van de Meent (Jul 18 2025 at 10:09):

so long as there isn't a coersion from Fin 3 -> R to Sort _ i think this should work

Edward van de Meent (Jul 18 2025 at 10:10):

even the hover docstring is disambiguated based on which version parses/typechecks!

Eric Wieser (Jul 18 2025 at 11:35):

i really don't want another "you wrote |, but you really meant "

I think this is fine, as long as the linter tells you this rather than having to ask a human on zulip

Edward van de Meent (Jul 18 2025 at 12:12):

i don't see why there should be a distinct character for this operation

Eric Wieser (Jul 18 2025 at 12:47):

For divides or for vector product?

Eric Wieser (Jul 18 2025 at 12:48):

In either case, that sounds like a gripe to take up with the unicode consortium, and mathlib should just follow their recommendations where possible.

Edward van de Meent (Jul 18 2025 at 13:00):

Eric Wieser said:

mathlib should just follow their recommendations where possible

i suspect that this is a bad idea

Weiyi Wang (Jul 18 2025 at 13:28):

Would a custom elaborator make doc search harder? I hope it won't give me a hard time to find the actual definition if I ctrl-click on the symbol, or putting the symbol in the doc search bar

Edward van de Meent (Jul 18 2025 at 13:38):

i hardly ever use that feature, but guessing from the fact that the hover is correct, i think it'd work?

Edward van de Meent (Jul 18 2025 at 13:39):

putting the symbol in the search bar should find Matrix.«term_×_» in the example i gave above

ZhiKai Pong (Jul 22 2025 at 23:39):

looks like ⨯₃ wins? should we just go ahead and make this change for now or are we still considering the proposed alternatives?

ZhiKai Pong (Jul 29 2025 at 14:29):

@Eric Wieser I've updated #27006 according to poll results (or should I ping you on github instead?)


Last updated: Dec 20 2025 at 21:32 UTC