Context-free grammar for $\{a^x b^y : x \neq y\}$
Let $L = \{a^n b^n : n \in \mathbb N\}$. Your language can be written as $a^+L \cup Lb^+$, and this leads to the following grammar:
$$
\begin{align}
&amp;S \to AT \mid TB \\
&amp;T \to aTb \mid \epsilon \\
&amp;A \to aA \mid a \\
&amp;B \to bB \mid b
\end{align}
$$
We can save a nonterminal by factoring $L$ differently:
$$
L = \{a^na^mb^n : n \geq 0, m \geq 1\} \cup \{a^nb^mb^n : n \geq 0, m \geq 1\}.
$$
This leads to the following grammar:
$$
\begin{align}
&amp;S \to aSb \mid A \mid B \\
&amp;A \to aA \mid a \\
&amp;B \to bB \mid b
\end{align}
$$
There are many other possible variants, for example:
$$
\begin{align}
&amp;S \to A \mid B \\
&amp;A \to aAb \mid aA \mid a \\
&amp;B \to aBb \mid Bb \mid b
\end{align}
$$