Riez representation theorem: Let V be a finite-dimensional inner product space over $F$, and let $g:V \rightarrow F$ be a linear mapping. There exists a unique vector y in V such that $g(x)= \langle x,y\rangle$ for all $x \in V$.
Proof: Let $\beta={v_1,v_2,...,v_m}$ be an orthonormal basis for V, and let $y=\sum_{i=1}^n \overline{g(v_i)} v_i$. Define $h:v \rightarrow F$ by $h(x)=\langle x,y \rangle$. Furthermore, for $1 \leq j \leq n$ we have \begin{align} &h(v_j) = \langle v_j,y \rangle \\ &= \left\langle v_j, \sum_{i=1}^n \overline{g(v_i)} v_i\right\rangle \\&= \sum_{i=1}^n g(v_i)\langle v_j,v_i \rangle \\&= \sum_{i=1}^n \overline{g(v_i)} \end{align}
since $g$ and $h$ both agree on $\beta$, we have that $g=h$.
to show y is unique, suppose $g(x)=\langle x,y' \rangle$ for all $x$. Then $\langle x,y \rangle = \langle x,y'\rangle$ for all $x$. Hence we have $y=y'$
My question: why do we let $y=\sum_{i=1}^n \overline{g(v_i)} v_i$, especially there is a bar over $g(v_i)$. Also can someone explain the general idea of the proof here, especially why we define another linear map $h$?
Let me refresh you with some results.
Recall that, as a simple consequence of the definition of inner product, the brackets $\langle \cdot,\cdot \rangle$ take out the scalars from the first entry, but they bring out the complex conjugates from the second, that is, $$\langle u,cv \rangle = \overline{c} \langle u,v \rangle. \tag{1}$$
Also, following the analogy that in $\mathbb{R}^3$ (to be illustrative, it doesn't really matter) every vector $\mathbf{x} = (x,y,z)$ can be written as \begin{align} \mathbf{x} &= xe_1 + ye_2 + ze_3 \\ &= \langle \mathbf{x},e_1 \rangle e_1 + \langle \mathbf{x},e_2 \rangle e_2 + \langle \mathbf{x},e_3 \rangle e_3 \end{align} where $e_1$, $e_2$ and $e_3$ are the standard basis vectors, then, any vector $v$ in an abstract inner product space can be written as $$v = \langle v,w_1 \rangle w_1 + \langle v,w_2 \rangle w_2 + \cdots + \langle v,w_n \rangle w_n \tag{2}$$ where $w_1,w_2,\dots,w_n$ must be form an orthonormal basis for the whole space (which is the case for our example in $\mathbb{R}^3$).
Now, we start with the given problem. We want to find some vector $y \in \textsf{V}$ such that $g(x) = \langle x,y \rangle$ for all $x \in \textsf{V}$, that is, the rule of correspondence of $g$ is completely determined by $y$.
First, choose an orthonormal basis for $\textsf{V}$, let's say, $v_1,v_2,\dots,v_n$ (this can be done since the space is finite-dimensional). Then, for any $x \in \textsf{V}$ we have \begin{align} g(x) &= g(\langle x,v_1 \rangle v_1 + \langle x,v_2 \rangle v_2 + \cdots + \langle x,v_n \rangle v_n) \tag{3} \\ &= \langle x,v_1 \rangle g(v_1) + \langle x,v_2 \rangle g(v_2) + \cdots + \langle x,v_n \rangle g(v_n) \tag{4} \\ &= \langle x,\overline{g(v_1)}v_1 \rangle + \langle x,\overline{g(v_2)}v_2 \rangle + \cdots + \langle x,\overline{g(v_n)}v_n \rangle \tag{5} \\ &= \langle x, \overline{g(v_1)}v_1 + \overline{g(v_2)}v_2 + \cdots + \overline{g(v_n)}v_n \rangle \tag{6} \end{align} where $(3)$ happens by our observation $(2)$, $(4)$ by the linearity of $g$, $(5)$ by $(1)$ since $g(v_1),\dots,g(v_n)$ are scalars, and $(6)$ follows from the linearity in the second entry of the inner product.
So, letting $y := \overline{g(v_1)}v_1 + \overline{g(v_2)}v_2 + \cdots + \overline{g(v_n)}v_n$ in the last step we have that $g(x) = \langle x,y \rangle$, as desired. To show the uniqueness, suppose there are $y'$ such that $g(x) = \langle x,y' \rangle$ for any $x$. Then, for any $x \in \textsf{V}$, $$\langle x,y-y' \rangle = \langle x,y \rangle - \langle x,y' \rangle = 0.$$ In particular, for $x=y-y'$ we see that $\langle y-y',y-y' \rangle = 0$, which only happens when $y-y'=0$, that is, $y'$ must be the same as $y$.