Defining q-binomial coefficients \binom{n}{k}_q symbolic in n, k
I would like to verify certain identities involving sums of q-binomial coefficients \binom{n}{k}_q and as such, I would like to treat the q-binomial coefficients as if they were symbolic in n and k. But the version of q-binomial coefficients that are implemented in Sage cannot be used as a symbolic variable in n and k according to this thread. So, to this end I defined my own:
var('q,n,k')
qint = lambda n: sum([q^i for i in range(n)])
qfac = lambda n: 1 if n==0 else prod([qint(i) for i in range(1,n+1)])
qbin = lambda n,k:qfac(n)/(qfac(k)*qfac(n-k))
But if I write
sum(qbin(n,k),k,0,n)
I get the following error:
ValueError: cannot convert n + 1 to int
Is there a way to do these types of summations in Sage? I should note that, for my purposes, it would be enough to limit myself to the case when n and k are non-negative integers.
EDIT: As an example, I would like to prove something like the q-binomial theorem, which says
\sum_{k=0}^n q^{k(k-1)/2} \binom{n}{k}_q x^k = \prod_{k=0}^{n-1} (1+q^k x)
EDIT2: Fixed a typo.