We are asked to solve this problem:
If $X$ is an irreducible affine variety and $Z \subsetneq X$ a closed sub variety, prove that $$\text{dim}(Z) < \text{dim}(X)$$
During lecture we were given this definition of dimension for an affine variety over $k^n$ (algebraic closed field), and according to the professor we have to use this one for this exercise (I think that in case we would have to prove the equivalence of another definition).
$$ \text{dim} (X) = n \iff n = \min_{p \in X} \text{dim}_k T_p X$$ where we have different equivalent definition of the tangent space of $X$ in a point, (denote $I(X) = \langle f_1,\dots , f_r \rangle$) $$ T_pX := \{ u \in k^n \mid \sum_{i=1}^n u_i \frac{\partial f_j}{\partial x_i}(p) =0 \ \ \ \forall j = 1,\dots r \}$$ or $$ T_pX := (M_p/M_p^2)^*$$ where $M_p := \{ f \in A(X) \mid f(p)=0\}$ and $M_p^2 := \{ fg \mid f,g \in M_p \}$ or the usual one, the vector space of the tangent vectors ($ v \colon A(X) \to k $ satisfying the Leibniz Rule) at $p$.
My attempt I tried to use the first definition of tangent space. We can see $I(Z)=\langle f_1,\dots f_r,f_{r+1},\dots f_s \rangle$. Suppose that $\text{dim}(Z) = \text{dim}(X)$ so there exist a point $p$ s.t. $T_pZ = T_pX$ (it's easy to see that $T_pZ \subset T_pX$), but then I was not able to find a derivation in $T_pX$ but not in $T_pZ$ to find an absurd.
Someone has any hints for this exercise?