# Equivalence of the $Q(s,a)$ and $V(s)$ under optimality conditions?

Are the state-action values and the state value function equivalent for a given policy? I would assume so as the value function is defined as $$V(s)=\sum_a \pi(a|s)Q_{\pi}(s,a)$$. If we are operating a greedy policy and hence acting optimally, doesn't this mean that in fact the policy is deterministic and then $$\pi(a|s)$$ is $$1$$ for the optimal action and $$0$$ for all others? Would this then lead to an equivalence between the two?

Here is my work to formulate some form of proof where I start with the idea that a policy is defined to be better than a current policy if for all states then $$Q_{\pi}(S,\pi^∗(s))\geq Vπ_{\pi}(s)$$ :

I iteratively apply the optimal policy to each time step until I eventually get to a fully optimal time step of rewards

$$Vπ_{\pi}(s)≤Q_{\pi}(S,\pi^∗(s))$$ $$=Eπ[R_{t+1}+\gamma V_{\pi}(St+1)|St=s]$$ $$\leq E[Rt+1+\gamma Q_{\pi}(S_{t+1},\pi^∗(S_{t+1})|S_t=s]$$ $$\leq E[Rt+1+\gamma Rt+2+\gamma 2Q \pi^*(S_{t+2},\pi^∗(S_{t+2})|S_t=s]$$ $$\leq E[R_{t+1}+\gamma R_{t+2}+....|S_t=s]$$ $$=V\pi^∗(s)$$

I would say that our final two lines are in fact inequalities, and for me this makes intuitive sense in that if we are always taking a deterministic greedy action our value function and Q function are the same. As detailed here, for a given policy and state we have that $$V(s)=\sum_a \pi(a|s)Q_{\pi}(s,a)$$ and if the policy is optimal and hence greedy then $$\pi(a|s)$$ is deterministic.

In general they are not the same and that should be clear as to why -- mathematically you are conditioning on an extra random variable being known in the state-action value function. You have the correct relationship between them, but I think your understanding of the two may be slightly off. The state-action value function is a function of both $$s$$ and $$a$$ whereas the value function is a function of just $$s$$. As you have noted, the value function is equal to the expected value of the state-action value function, with the expectation taken over the action distribution induced by the policy.
However, if you have a deterministic policy, then two are equivalent only if you evaluate the state-action value function at the action that the deterministic policy gives. That is, $$v_\pi(s) = Q(s, \pi(s))$$. This is because, as you say, for a given state the policy will assign probability one to a certain action and 0 to all other actions in the action space and so the equation I just wrote is what the expectation in your question reduces to.
Now, you might think 'well the policy is deterministic so we are always going to choose this action, so my theory was correct'. This is not true. The definition of the state-action value function is the value of the expected future (possibly discounted) returns given that we are in state $$s$$ and given that we have taken action $$a$$. This means that we have already chosen our action and we are not choosing it according to the policy -- the policy will only choose all future actions.