Some basic questions about applying operator in quantum mechanics Given a momentum operator
$$
\def\bra #1{\langle#1|}
\def\ket #1{|#1\rangle}
\def\braket #1{\langle#1\rangle}
$$
$$
P \equiv - i \hbar \frac{\partial}{\partial x},
$$
I want to calculate $\bra{a} P \ket{a}$. Here are the steps provided by my professor.
$$\begin{aligned}
\bra{a} P \ket{a}
&= \int dx \int dx' \braket{a | x} \bra{x} P \ket{x'} \braket{x' | a}
  && \left( \text{insert two sets of bases} \int dx \ket{x} \bra{x} = I \right) \\
&= \int dx \int dx' \braket{a | x} 
  \bra{x}
  \left(- i \hbar \frac{\partial}{\partial x'}\right)
  \ket{x'}
  \braket{x' | a}
  && \left( \text{pull in } P = - i \hbar \frac{\partial}{\partial x'} \right) \\
&= \int dx \int dx' - i \hbar \braket{a | x} 
  \braket{x | x'}
  \left(\frac{\partial}{\partial x'}\right)
  \braket{x' | a}
  && \left( \text{move } \ket{x'} \text{ to the left} \right) \\
&= \int dx \int dx' - i \hbar \braket{a | x} 
  \delta(x - x')
  \left(\frac{\partial}{\partial x'}\right)
  \braket{x' | a} \\
&= \int dx - i \hbar \braket{a | x} 
  \left(\frac{\partial}{\partial x}\right)
  \braket{x | a}
  && \left( \int f(x') \delta(x - x')\, dx' = f(x)\right) \\
&= -i \hbar \int dx
  \Psi_a^*(x)
  \left(\frac{\partial}{\partial x}\right)
  \Psi_a(x) 
  && \left( \braket{x | a} = \Psi_a(x) \right) \\
\end{aligned}$$
I have a few questions.

*

*Is $\ket{x'}$ a function? Can I treat it as $f(x')$.

*If $x$ and $x'$ mean "position", why they can become a series of the basis? $\int dx\, \ket{x} \bra{x} = I$

*Is the equation below correct?

$$
\left(- i \hbar \frac{\partial}{\partial x'}\right)
  \ket{x'}
  \braket{x' | a}
= - i \hbar \left(
  \frac{\partial}{\partial x'}
  \ket{x'}
  \braket{x' | a}
\right)
$$


*Why $\ket{x'}$ can be moved to the left at the third step?

 A: Your basic definition is simply wrong/ambiguous. Use @Emilio’s informal rule above, or the correct definition of Sakurai and Napolitano, (1.248), namely,
$$
\def\bra #1{\langle#1|}
\def\ket #1{|#1\rangle}
\def\braket #1{\langle#1\rangle}
$$
$$
P \equiv - i \hbar\int \!\! dx~\ket{x}  \frac{\partial}{\partial x}\bra{x},
$$
sometimes encoded as
$$
P_x \equiv - i \hbar \frac{\partial}{\partial x},
$$
as long as you know what you are doing, which your instructor muffed, to your detriment.
From the correct definition, note
$$
\bra{y} P\ket{z}= \int\! dx \braket {y|x} (-i\hbar \partial_x) \braket{x|z}= -i\hbar \partial_y \delta(y-z),
$$
and the rest will follow correctly.
$$ 
\bra{a} P \ket{a}= \int\! dy  d z ~\braket{a | y} \bra{ y} P \ket{ z} \braket{ z | a}\\
=\int\! dxdy  d z ~\braket{a | y}   \braket {y|x} (-i\hbar \partial_x) \braket{x|z} \braket{ z | a}\\
=\int\! dx  ~  \braket {a|x} (-i\hbar \partial_x) \braket{ x | a}\\
=-i\hbar \int\!\!  dx ~~ \Psi_a^*(x) \partial_x  \Psi_a(x)~.
$$
You can, of course,  go from the first to the penultimate line directly. I left them in to humor your previous wrong derivation.

*

*Yes.

*No.

2&4. are meaningless.
