Background:
I have a function $f(s_i, s_f, x)$ where $s_i \in \{0,1,2,3\}; \quad x,s_f \in \{0,1\}$ which is defined as:
$$ f(s_i, s_f, x) = \begin{cases} 1, & \text{if } (s_i, s_f, x) \in\{(0,0,0),(1,0,1),(2,1,1),(3,1,0)\}\\ 0, & \text{otherwise} \end{cases} $$
also represented by this image:
The function can also be represented as a family of matrices by choosing a particular set of arguments to index the matrix. For example, one representation (let's call this Rep. 1) is to index the rows by $s_f$ and the columns by $x$, giving a set of matrices parametrized by $s_i$:
$$ \begin{equation} f(s_i, s_f, x)= \begin{cases}{\left[\begin{array}{ll} 1 & 0 \\ 0 & 0 \end{array}\right], s_i=0 \quad ;\left[\begin{array}{ll} 0 & 1 \\ 0 & 0 \end{array}\right], s_i=1} \\ {\left[\begin{array}{ll} 0 & 0 \\ 0 & 1 \end{array}\right], s_i=2 \quad ;\left[\begin{array}{ll} 0 & 0 \\ 1 & 0 \end{array}\right], s_i=3}\end{cases} \end{equation} $$
A second matrix representation (Rep. 2) is using $s_f$ for rows, $s_i$ for columns and parametrised by $x$ as follows:
$$ f(s_i, s_f, x)=\left\{\begin{array}{lll} \left(\begin{array}{llll} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right), & x=0 \\ \left(\begin{array}{llll} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{array}\right), & x=1 \end{array}\right. $$
Query:
I want to encode the (non-unitary) matrices in Rep. 1 in such a way that we obtain a block unitary matrix, which can then be represented a gate acting on a quantum circuit.
Any kind of unitary is allowed, (such as encoding in a larger block to obtain some form of a controlled gate) which implements the function $f$, although it would be good if $x$ and $s_f$ are not grouped together in the indexing (since I require $x$ at the 'input' and $s_f$ at the 'output' of the gate)
Illustration: As an example of what I am looking for, the matrices in Rep. 2 can be denoted as a unitary by indexing the rows with the ordered pair $(x,s_f)$ and the columns by $s_i$ to obtain the following matrix:
However, as I said, this form does not let me have $x$ as an input to the gate.
Summary: In general, is there any way of encoding the non-unitary projector matrices into a unitary matrix. If not, is there an explanation of why the matrices in Rep. 1 cannot be grouped to obtain a unitary? Personally, I feel that it is not possible to have a unitary encoding which implements the function AND satisfies the restriction on $x$ and $s_f$, since any matrix obtained is sparse with very few non-zero elements. Any help on this is appreciated.


