Linear equations given by $Ax = b$ have a solution if and only if $\operatorname{rank}(A|b) = \operatorname{rank}(A)$ 
Theorem:
Given a system of linear equations $Ax = b$ where $A \in M_{m \times n}\left(\mathbb{R}\right)$, $ x \in \mathbb{R}^{n}_\text{col} $, $ b \in \mathbb{R}^{m}_\text{col}$
Deduce that a solution $x$ exists if and only if $\operatorname{rank}\left(A|b\right) = \operatorname{rank}\left(A\right)$ where $A|b$ is the augmented coefficient matrix of this system

I am having trouble proving the above theorem from my Linear Algebra course, I understand that A|b must reduce under elementary row operations to a form which is consistent but I don't understand exactly why the matrix A|b need have the same rank as A for this to happen.
Please correct me if I am mistaken
 A: To get started,
If the system contains a row such that  [ 0 0 0 0 | b ] with b=/=0 then the system is inconsistent and has no solution. The rank is the number of pivots matrix X has in echelon form, whereby b is the pivot in this row.
Let M=[A ,B], the augmented matrix, where A is the original matrix. 
The system has a solution if and only if rank(A)=rank(M).
If b is a pivot of M then the solution does not exist. Hence rank(m)>rank(a).
A: To see this note that rank of the matrix is dimension of the span of columns of the matrix. Now if $Ax=b$ has solution, then it means that some linear combination of columns of A gives us b, which implies that $b$ lies in $span(A)$ and so $rank(A|b)=rank(A)$. You can argue similarly in the reverse direction.
A: Let $Ax=b$ be the system of equations.Suppose $Ax=b$ has a solution,then $b\in R(A)$ so $\text{Rank}(A)=\text{Rank}(A|b)$.
Conversely,if $a_1,a_2,...,a_n$ be the columns of $A$ and if $\text{Rank}(A)=\text{Rank}(A|b)=r$,then suppose $a_1,a_2,...,a_r$ are $r$ linearly independent vectors among $a_1,...,a_n$ and hence a basis of the column space,but they are $r$ linearly independent columns of $(A|b)$ and hence a basis of the column space of the augmented matrix as rank of augmented matrix is $r$.So,$b$ is a linear combination of $a_1,a_2,...,a_r$.Suppose $c_1a_1+...+c_ra_r=b$ then $x=\begin{pmatrix}c_1\\c_2\\\vdots\\c_r\\0\\\vdots\\0\end{pmatrix}$ is a solution,hence we are done.
