I'm having some trouble converting a second order Markov chain into a first order Markov chain, namely I want to define some new random variables $Y_i$, that have the property $P(Y_i=b|Y_{i-1}=b_1,...Y_0 = b_n) = P(Y_i=b|Y_{i-1}=b_1)$, given random variables $X_i$, that have the property that $P(X_i=a|X_{i-1}=a_1,...X_0 = a_n) = P(X_i=a|X_{i-1}=a_1,X_{i-2}=a_2)$. I also need to find a function such that $f(Y_i) = X_i$. I thought initially that I could simply define $Y_i = X_i + X_{i-1}$, and use something like the Cantor pairing function, but I've been told that the cardinality of the range of the random variables shouldn't matter.
Any suggestions?