Zulip Chat Archive

Stream: mathlib4

Topic: Proposal: Triple


Kenny Lau (Jun 18 2025 at 14:30):

I propose the following definition:

universe u

structure Triple (α : Type u) : Type u where
  (fst : α)
  (snd : α)
  (thd : α)

The context is that when @David Ang was working with elliptic curves (which are defined with three coordinates x y z), he found that Fin 3 → R was a bit tricky to work with, and R × R × R while being better also had problems (mainly because of the idiom x.2.1 and x.2.2 instead of x.2 and x.3... so I propose Triple to solve this problem.

(I guess this doesn't have to be low in the hierarchy, I suppose David and I can just have this defined customly in the elliptic curve files.)

What do yall think?

Kevin Buzzard (Jun 18 2025 at 14:31):

Will this be useful for curves in P2\mathbb{P}^2 more generally?

Damiano Testa (Jun 18 2025 at 14:33):

Does α need to be the same for all three factors?

Kenny Lau (Jun 18 2025 at 14:34):

Kevin Buzzard said:

Will this be useful for curves in P2\mathbb{P}^2 more generally?

I'm doing experiments. I'll find out later.

Kenny Lau (Jun 18 2025 at 14:34):

Damiano Testa said:

Does α need to be the same for all three factors?

Maybe HTriple for that?

Jireh Loreaux (Jun 18 2025 at 14:36):

Maybe I'm wrong because it will be isolated enough (to elliptic curves), but this seems like a bad idea to me. All of a sudden you can't easily translate between α × α × α and this triple or Fin 3 → α and this triple (or you have to write dedicated API to do so). Basically anything you end up needing related to Prod you then have to duplicate for Triple. Why not just add some specialized API for Fin 3 → α (or α × α × α, whichever is used in elliptic curves)?

Jireh Loreaux (Jun 18 2025 at 14:38):

I think I saw a proposal to define foo.x, foo.y and foo.z for foo : α × β × γ. That seems reasonable.

Jovan Gerbscheid (Jun 18 2025 at 14:49):

I remember in Haskell, they have a separate tuple type for all the different sizes, which would lead to a lot of duplication. How about the following:

abbrev Tripple (α : Type*) := α × α × α

variable {α : Type*}

def Tripple.snd (t : Tripple α) : α := t.2.1
def Tripple.thd (t : Tripple α) : α := t.2.2

variable (t : Tripple α)

#check t.snd -- t.snd : α

Jireh Loreaux (Jun 18 2025 at 14:57):

Jovan Gerbscheid said:

I remember in Haskell, they have a separate tuple type for all the different sizes

This is because Haskell can't have Fin n (at least not without several language extensions which give you an approximation of dependent types).

Jovan Gerbscheid (Jun 18 2025 at 14:59):

Yes, that's true, but what I meant was that instead of writing α × β × γ as α × (β × γ) (which is also possible in Haskell), they have a separate "Tuple 3" to represent α × β × γ

Jovan Gerbscheid (Jun 18 2025 at 15:03):

My suggestion above keeps the advantages of using R × R × R, but replaces the idiom x.2.1 by x.snd and x.2.2 by x.thd.

Edward van de Meent (Jun 18 2025 at 15:16):

i'd just like to say that imo x.2.1 should basically never occur anyway, since writing x.snd.fst is more explicit about what's going on.

Notification Bot (Jun 19 2025 at 07:19):

53 messages were moved from this topic to #mathlib4 > bikeshed: mp and mpr by Johan Commelin.


Last updated: Dec 20 2025 at 21:32 UTC