I came across this conditional proability equation (from this paper: https://ccn.berkeley.edu/pdfs/papers/CollinsFrank2013PsychReview.pdf) and I cannot understand how the RHS gives the LHS:
$P(r_t|s_t,a_t,c_t)=\sum_{TS_i}P(r_t|s_t,a_t,TS_i)\times P(TS_i|c_t)$
For more context, $r_t$ is the reward obtained when performing $s_t,a_t$ after observing a context $c_t$, where the context $c_t$ can be used to predict a hidden variable $TS_i$. How does $TS_i$ get replaced by $c_t$ here ?
Also, the paper mentions that the probability of hidden variable $TS_i$ given context $c_t$ can be updated as below using Bayes rule: $P_{t+1}(TS_i|c_t)=\frac{P(r_t|s_t,a_t,TS_i)\times P(TS_i|c_t)}{\sum_{TS_i}P(r_t|s_t,a_t,TS_i)\times P(TS_i|c_t)}$
How is this update of $P(TS_i|c_t)$ possible if $r_t$ occurs as a consequence of selecting $(s_t,a_t)$, which is preceded by observing $c_t$ and predicting $TS_i$?