Extending a partial order to a total order I came across the question below in Velleman's How to prove it:
Suppose $R$ is a partial order on a set $A$, $B\subseteq A$, and $B$ is ﬁnite. Prove
that there is a partial order $T$ on $A$ such that $R\subseteq T$ and $\forall x \in B\forall y\in A(xTy\vee yTx )$. (Hint: Use induction on the number of elements in $B$. For the induction step, assume the 
conclusion holds for any set $B \subseteq A$ with $n$ elements, and suppose $B$ is a subset of $A$ with $n + 1$ 
elements. Let $b$ be any element of $B$ and let $B' = B \backslash \{ b\}$, a subset of $A$ with $n$ elements. By 
inductive hypothesis, let $T'$ be a partial order on $A$ such that $R \subseteq T'$ and $\forall x\in B'\forall y\in A(xT'y\vee 
yT'x )$. Now let  $A_1 = \{ x\in A \mid xT'b\}$ and $A_2 = A \backslash A_1$ , and let $T = T' \cup ( A_1 \times A_2 )$. Prove that 
$T$  has all the
required properties.)
Proving $T$ has all the properties isn't hard, my problem is: why the sets $A_1$ and $A_2$ are defined like that? How do we know how to define $A_1$ and $A_2$ like this so the partial order $R$ can be extended to a total order. Can anyone please provide a full explanation to this problem? Thanks in advance.
 A: Proof by induction.
Base step
We must start with $B = \{ b_0 \}$.
We define $A_1 = \{ x \in A : xRb_0 \}$ and $A_2 = A \backslash A_1$, and we "extend" the partial order $R$ as follows :

$T = R \cup (A_1 \times A_2)$.

We will check if it works, i.e. if $\forall x \in B$ , $\forall y \in A$ , $x$ and $y$ are "comparable" according to $T$.
But $B = \{ b_0 \}$ and $b_0 \in A_1$, because $b_0Rb_0$, by def of partial order.
So, for all $x \in A_1$, we have that $x$ is "less or equal than" $b_0$, while for all other $x$, because they are in $A_2$, we have that $b_0$ is "less or equal than" $x$.
It is then verified that, with the extension $T$ of $R$, all elements of $B$ (i.e.$b_0$) are "comparable" to all elements of $A$.
We have to prove that $T$ is a partial order on $A$, i.e. reflexivity, anti-simmetry and transitivity.
For reflexivity : $xRx$, so that $xTx$.
For anti-simmetry : assume that $xTy$ and $yTx$; we have four cases:
(i) $xRy$ and $yRx$, then $x=y$, by anti-symm of $R$;
(ii) $xRy$ and $<y,x> \in A_1 \times A_2$; but $y \in A_1 \rightarrow yRb_0$, and $x \in A_2 \rightarrow b_0Rx$, so that $yRx$ by transitivity of $R$. But then we have $xRy$ and $yRx$, so that again $x=y$.
(iii) $<x,y> \in A_1 \times A_2$ and $yRx$; $x \in A_1 \rightarrow xRb_0$ and $y \in A_2 \rightarrow b_0Ry$, so that $xRy$ and again $x=y$.
(iv) $<x,y> \in A_1 \times A_2$ and $<y,x> \in A_1 \times A_2$; but this implies that $x,y \in A_1 \cap A_2 = \emptyset$ : contradiction.
For transitivity, we proceed in the same way.
Induction step
When we prove the induction step, we have the set $B$ with $n+1$ elements, we pick an element $b \in B$ and we consider $B' = B \backslash \{ b \}$, that is a set with $n$ elements.
By induction hypo, B' is ordered by $T'$ extending $R$ such that :

$\forall x \in B' \forall y \in A (xT'y \lor yT'x )$.

But now, where is $b$ ?  Because we have "excluded" $b$ from $B'$, when in the previous step we have obtained the "full comparability" of elements of $B'$ respect to elements of $A$, that by induction hypo we are assuming to exists, $b$ was not in $B'$ but was, of course, an element of $A$; so in the induction hypo we are "assuming" that it is comparable to all elements of $B'$.
When we build the sets :

$A_1 = \{ x \in A : xT'b \}$ and $A_2 = A \backslash A_1$ ,

all elements of $B'$ will be partitioned between $A_1$ and $A_2$ and $b$ is in $A_1$, because by def of partial order : $bT'b$.
We will define :

$T = T' \cup (A_1 \times A_2)$.

Again, we will check the definition; we already know that all $x \in B'$ are comparable to all $y \in A$; we have only to verify it for $b$. Take any $y \in A$ :

if $y \in A_1$, then $yT'b$, so that $yTb$;
if $y \in A_2$, then we have $bTy$, by construction, and it's done.

