Solution (source code)

= Solution

First the entries must be nonnegative: together with the given $a,b\geq0$, validity of the <transition matrix> requires $0\leq a\leq1$ and $0\leq b\leq1/3$. Every row then sums to one.

The only incoming edge to state $2$ is $1\to2$, of <probability> $a$. If $a=0$, no other state can reach $2$, so the chain is not irreducible. If $a>0$, all edges in the directed cycle
$$
1\longrightarrow2\longrightarrow3\longrightarrow4\longrightarrow1
$$
have positive <probability>, since $P_{23}=1/3+b>0$, $P_{34}=1$ and $P_{41}=1/2$. Traversing this cycle connects every state to every other state. Therefore
$$
\boxed{\text{Irreducible exactly when }0<a\leq1,\quad0\leq b\leq\frac13.}
$$