I have a nbyk matrix A and a nbyn matrix B, where B is positive definite. I can form the matrix $M = A^t B A$. Playing around, I always found $rk(M) = rk(A)$ but I can't prove this.

$A^T BAx = 0 \implies (Ax)^TB(Ax)=0 \implies Ax=0$ by positve definiteness of $B$. So $ker(M)=ker(A)$ and hence $rk(M)=rk(A)$. 


This is rather tangential, but I can't help mentioning that this is related to the fact that in a hilbert space, for a (compact) linear operator one has: $Ker A^* \perp Im A$. 

