Zulip Chat Archive

Stream: Is there code for X?

Topic: Choose on integer


Bin Wu (Nov 08 2024 at 02:44):

I want to find a def of "choose" on integer. When I useNat.choose n k, sometimes I need n or k be negative. I know the definition on math, but haven't find a def on integer in mathlib.
In this case, If a < b , a - b = 0 in natural number. This is not what I wanted.

Kim Morrison (Nov 08 2024 at 03:28):

How do you want to extend it?

Bin Wu (Nov 08 2024 at 03:42):

follow this definition:

(nk)={nkk!,k00,k<0\binom{n}{k} =\left\{\begin{matrix} \frac{n^{\underline{k} }}{k!}, & k \ge 0 \\ 0, & k < 0 \end{matrix}\right.

where n,k : integer, underline{k} means descPochhammer.

Jz Pan (Nov 08 2024 at 06:18):

Do you want docs#Ring.choose over Z?

Bin Wu (Nov 08 2024 at 06:36):

Ring.choose r n still need natural number n

Andrew Yang (Nov 08 2024 at 07:29):

What does n1n^{\underline{-1}} mean? Is it 1n+1\frac{1}{n+1}?

Bin Wu (Nov 08 2024 at 07:31):

When k < 0, we just use the second line.

Andrew Yang (Nov 08 2024 at 07:34):

Ah I missed it.
How is that useful for k < 0? Is there any result that hold over all k?

Bin Wu (Nov 08 2024 at 07:43):

Here is an example

k=0m(mk)(nrk)k=(m+nr)rmm+n\sum\limits_{k=0}^{m} \binom{m}{k} \binom{n}{r-k}k=\binom{m+n}{r} \dfrac{rm}{m+n}

I think it should holds even if r < (m + n)

Jz Pan (Nov 08 2024 at 13:51):

Bin Wu said:

Ring.choose r n still need natural number n

Do you think it's good to extend the definition of Ring.choose to, say, Ring.ichoose, which allows n to be Int? Let's ask the author of Ring.choose.

Johan Commelin (Nov 08 2024 at 14:46):

cc @Scott Carnahan

Scott Carnahan (Nov 08 2024 at 15:10):

If we think of Ring.choose r n as the x ^ n coefficient of a formal expansion of (1 + x)^r in R[[x]], then this expanded definition amounts to saying the expansion has no negative-exponent terms in R((x)). It looks pretty harmless as a generalization, and I would be interested to see what identities extend. Are there references in the literature?

Mauricio Collares (Nov 08 2024 at 15:38):

That's the definition of binomial coefficients in Concrete Mathematics, for example

Mauricio Collares (Nov 08 2024 at 15:49):

In fact, Knuth makes a point of using this convention as much as possible to simplify manipulations, as explained in this excerpt from The Art of Computer Programming

Mauricio Collares (Nov 08 2024 at 15:49):

KnuthBinomial.png

Scott Carnahan (Nov 08 2024 at 15:53):

Thank you for the reference! Ring.ichoose sounds like a good idea. Is there a way to avoid complete duplication of identities?

Sébastien Gouëzel (Nov 08 2024 at 15:54):

I read in the above text that Knuth is a big fan of well-chosen junk values, just like Mathlib :-)

Bin Wu (Nov 09 2024 at 04:26):

Can lean handle this?
n:Zn : \mathbb{Z}, if n0n \ge 0, then we can restrict n to a natural number (n:Nn : \mathbb{N}).

Jz Pan (Nov 09 2024 at 06:05):

Bin Wu said:

Can lean handle this?
n:Zn : \mathbb{Z}, if n0n \ge 0, then we can restrict n to a natural number (n:Nn : \mathbb{N}).

You can see the definition of Z\mathbb{Z} in Lean: docs#Int :

inductive Int : Type where
  | ofNat   : Nat  Int
  | negSucc : Nat  Int

so maybe you can write:

match n with
| ofNat n => Ring.choose r n -- in this case n is non-negative
| _ => 0 -- in this case n is negative

Ruben Van de Velde (Nov 09 2024 at 06:11):

As it happens, this definition exists as docs#Int.toNat

Bin Wu (Nov 09 2024 at 06:20):

Then I think Ring.ichoose is achievable!

Yaël Dillies (Nov 09 2024 at 08:24):

Bin Wu said:

Can lean handle this?
n:Zn : \mathbb{Z}, if n0n \ge 0, then we can restrict n to a natural number (n:Nn : \mathbb{N}).

If you have n : ℤ and hn : 0 ≤ n, then the tactic lift n to ℕ using hn will give you n : ℕ

Julian Berman (Dec 07 2024 at 14:54):

With no illusion that we'll be successful as I don't know the math, (we're learning as we go), last week at the NYC meetup, and probably this afternoon, we were working on generalizing factorials to arbitrary dedekind domains.

Julian Berman (Dec 07 2024 at 14:55):

I see elsewhere in the papers I was flipping through that once that's done there's a general binomial coefficient defined on top of them, though I'm not sure yet if it's the same one as Ring.choose.

Kevin Buzzard (Dec 07 2024 at 14:56):

What is the factorial of ii in Z[i]\mathbb{Z}[i]? What is the factorial of 1Z-1\in\Z? I'm curious about how this works.

Yaël Dillies (Dec 07 2024 at 14:56):

Is this any different to docs#descPochhammer ?

Julian Berman (Dec 07 2024 at 14:57):

https://www.sciencedirect.com/science/article/pii/S0022314X9892220X is one of (the 3) papers

Julian Berman (Dec 07 2024 at 14:58):

Yaël Dillies said:

Is this any different to docs#descPochhammer ?

yes it's different from that

Kevin Buzzard (Dec 07 2024 at 14:58):

And also different to docs#Nat.descFactorial ?

Julian Berman (Dec 07 2024 at 14:59):

(Kevin I don't know how to calculate it yet honestly for specific values.)

Jz Pan (Dec 07 2024 at 15:02):

Kevin Buzzard said:

What is the factorial of ii in Z[i]\mathbb{Z}[i]? What is the factorial of 1Z-1\in\Z? I'm curious about how this works.

Gamma function :rolling_on_the_floor_laughing:

Scott Carnahan (Dec 07 2024 at 15:03):

As far as I can tell from the paper, Bhargava defines generalized factorials as ideals, not elements.

Kevin Buzzard (Dec 07 2024 at 15:06):

yeah it looks like a totally different thing. For example the prime 3 is inert in D=Z[i]D=\mathbb{Z}[i] and the idea is that the 3-adic valuation of this generalized factorial will be 0 up to nu_9(D,(3)) where it's forced to go up to 1 because you've run out of elements of the residue field.

Julian Berman (Dec 07 2024 at 15:07):

Ok, if it's totally unrelated then ignore me clearly!


Last updated: May 02 2025 at 03:31 UTC