The Pumping Lemma says, that if $L$ is context-free, there exists $n \in \mathbb{N}$, such that for every word which is longer than $n$ there is a decomposition with
- $|vwx| \leq n$
- $v$ and $x$ are not both empty: $|vx| \geq 1$
- For all natural numbers $i \in \mathbb{N}_0$: $uv^i wx^i y \in L$
So let's see we can find a word from $L = \{a^n b^n\ | n \geq 0\}$ that fulfills these conditions. If we can show that, that would not mean however that $L$ is context-free!
So let $L$ be context-free. Choose $n = 2$. Let $z = a^k b^k \in Z$ with $|z| \geq n$, so $2k \geq n$. Then you can choose the following decomposition (for example):
With $a^k = a^{k-1} a^1$, $b^k = b^1 b^{k-1}$ choose $u= a^{k-1}$, $y = b^{k-1}$ and $v = a$, $x = b$, $w = \varepsilon$. So $|vx| \geq 1$, $|vwx| = 2 \leq n$ Then
$$z = u v^i wx^i y = a^{k-1} a^i b^i b^{k-1} $$
which has exactly as many $a$'s as $b$'s.
To show that $L$ is context free, you can create a nondetermenistic pushdown automaton. Once you've found one you have shown that $L$ is context-free.
Note that you can always find a word in any context-free or regular language and decompose it so that the word does not fulfill the requirements. But that doesn't say anything. $L$ is not context-free if you can show that for every word with length of at least $n$, there is no decomposition whatsoever of this kind - not that you've found one decomposition that doesn't work.
Conclusion:
- To show that a language is context-free, create a nondetermenistic pushdown automaton
- To show that a language is not context free, assume it is context free and show that there for all words of minimum length $n$ there can't be any decomposition with the respective properties.
- To show that a language is regular, create a DFA
- To show that a language is not regular, assume it is regular and use the pumping lemma for regular languages to show that for all world of minimum length there is no decomposition with the respective properties.
- You really need to be careful with the quantifiers ($\forall, \exists, \dots$) in the pumping lemma. It is important to understand that the pumping lemma is not an if is only if condition
The pumping lemma for regular languages states: If $L$ is regular then there exists an $n > 0$, such that for any $x \in L$ with $|x| \geq n$ there exist strings $u, v, w$ such that $x = uvw$, $|uv| \leq n$, $|v| > 0$ and for all $m \geq 0$, $uv^mw \in L$.
The pumping lemma for context free languages states: If $L$ is context free then there exists an $n > 0$ such that for any $x \in L$ with $|x| \geq n$ there exist strings $v, w, x, y, z$ such that $u = vwxyz$, $|wxy| \leq n$, $|wy| > 0$ and for all $m\geq 0$, $uw^mxy^mz \in L$.
Now indeed, if a language $L$ satisfies the conclusion of the pumping lemma for regular languages, then it also satisfies the conclusion of the pumping lemma for context free languages by picking $v = w = \epsilon$ and $x = u$ and $y = v$ and $z = w$, where $u, v, w$ are strings from the conclusion of the pumping lemma for regular languages.
And so what you say is indeed correct. If the conclusion of the pumping lemma for context free languages fails for a particular language $L$ then the language cannot be regular, because the conclusion of the pumping lemma for regular languages must fail for $L$.
However this also follows from the fact that any regular language is context free and in fact can be given by a very simple grammar, called a regular grammar. So if the conclusion of the pumping lemma for context free languages fails, then the language is not context free, which also means that it is not regular.
Best Answer
This is probably not really what you are looking for, but it's the best I know. It's a strengthening of the fairly well-known Parikh's Theorem.
There is a characterisation of the bounded context-free languages. A language $L$ is bounded if $L\subseteq w_1^* w_2^* \ldots w_n^*$ for some fixed words $w_1,\ldots,w_n$, in which case we can define a corresponding subset of $\mathbb{N}_0^n$:
$\Phi(L) = \{(m_1,m_2,\ldots,m_n) \mid w_1^{m_1} w_2^{m_2} \ldots w_n^{m_n}\in L\}.$
By a theorem of Ginsburg and Spanier (Thm 5.4.2 in Ginsburg's book 'The Mathematical Theory of Context-free Languages'), a bounded language $L$ is context-free if and only if $\Phi(L)$ can be expressed as a finite union of linear sets, each with a stratified set of periods. For the definitions of the terms in the last sentence, see my MO question.
This characterisation can be very useful for proving (not necessarily bounded) languages not to be context-free. If we can find words $w_1,\ldots,w_n$ such that $L\cap w_1^*\ldots w_n^*$ is not context-free, then $L$ is not context-free either, since $w_1^*\ldots w_n^*$ is a regular language, and the intersection of a context-free language with a regular language is context-free.