## 2 Principle of Operation  
The schematic diagram of the proposed all-optical pattern recognition system is shown in Figure 2. Initially, the input BPSK data with a length of \(n\) bits is repeated \(m\) times via the storage loop with a duration of \(nT\). Here, \(m\) represents the number of bits in the BPSK target, and \(T\) represents the bit period of the input data. The phase information is mapped into a power-modulated signal, which is characterized by an alternative mark inversion (AMI) pattern through the 1-bit DI. Assuming the two optional phases of the BPSK signal are 0 and \(\pi\), the former is encoded as 0, and the latter is encoded as 1. Then, the output power of the AMI pattern, \(P_{AMI}=0\), corresponds to the consecutive bit sequence (10, 01), and \(P_{AMI}\
eq 0\) corresponds to the consecutive bit sequence (00, 11). If the electrical field of the input BPSK signal is denoted as \(E_{in}\), the electrical fields of the upper arm \(E_{upper1-R}\) and lower arm \(E_{lower1-R}\) after entering the first Y branch in the right DI can be expressed as  
\[ \begin{bmatrix}E_{upper1-R}\\ E_{lower1-R}\end{bmatrix} = \begin{bmatrix}\sqrt{2}/2&j\sqrt{2}/2\\ j\sqrt{2}/2&\sqrt{2}/2\end{bmatrix}\begin{bmatrix}E_{in}\\ 0\end{bmatrix} = \begin{bmatrix}\sqrt{2}/2E_{in}\\ j\sqrt{2}/2E_{in}\end{bmatrix} . \tag{1}\]  
Equation (1) describes the electric field distribution of the input BPSK signal \(E_{in}\) after passing through the first Y branch of the right DI. The lower arm signal acquires an additional \(j\) phase factor due to the DI, while the upper arm signal remains unchanged. The electrical fields of the upper arm \(E_{upper2-R}\) and lower arm \(E_{lower2-R}\) after entering the second Y branch in the right DI can be expressed as Equation (2), where \(\Delta\varphi_{in}\) is the adjacent bit phase difference of the input BPSK signal. \[ \begin{bmatrix}E_{upper2-R}\\ E_{lower2-R}\end{bmatrix} = \begin{bmatrix}\sqrt{2}/2&j\sqrt{2}/2\\ j\sqrt{2}/2&\sqrt{2}/2\end{bmatrix}\begin{bmatrix}\sqrt{2}/2E_{in}\\ j\sqrt{2}/2E_{in}\cdot e^{i\Delta\varphi_{in}}\end{bmatrix} = \begin{bmatrix}1/ 2E_{in}\big{(}1-e^{i\Delta\varphi_{in}}\big{)}\\ j1/2E_{in}\big{(}1+e^{i\Delta\varphi_{in}}\big{)}\end{bmatrix}  \tag{2}\]  
Equation (2) further illustrates the electric field distribution after passing through the second Y branch. Notably, signals in both the upper and lower arms are influenced by the phase difference \(\Delta\varphi_{in}\) between adjacent bits, causing rotation in the IQ plane. Equations (1) and (2) demonstrate how the phase information of the input BPSK signal is converted into amplitude information via the DI, which is the first step in achieving phase-modulated signal to amplitude signal conversion. Here, we select the lower arm as the output; the output power of the right DI \(P_{AMI-R}\) can be obtained as Equation (3), where \(P_{in}=\ \left|E_{in}\right|^{2}\) denotes the power of the input signal. \[ \begin{array}{rl}P_{AMI-R}=\left|E_{lower2-R}\right|^{2}&=\left|j1/2E_{in} \big{(}1+e^{i\Delta\varphi_{in}}\big{)}\right|^{2}\\ &=\left|j1/2E_{in}\big{(}e^{i0}+e^{i\Delta\varphi_{in}}\big{)}\right|^{2}\\ &=\left|j1/2E_{in}e^{i\Delta\varphi_{in}/2}\Big{(}e^{-i\Delta\varphi_{in}/2}+e ^{i\Delta\varphi_{in}/2}\Big{)}\right|^{2}\\ &=\left|jE_{in}e^{i\Delta\varphi_{in}/2}\cos(\Delta\varphi_{in}/2)\right|^{2} \\ &=P_{in}\cos^{2}(\Delta\varphi_{in}/2)\end{array}  \tag{3}\]  
Equation (3) calculates the output power \(P_{AMI-R}\) at the right DI, which depends on the input signal power \(P_{in}\) and the phase difference \(\Delta\varphi_{in}\). For BPSK signals with phase states 0 or \(\pi\), \(\cos(2\Delta\varphi_{in})\) can only be 1 or \(-1\), resulting in two distinct power levels. This corresponds to the generation of alternate mark inversion (AMI) or duobinary signals. Equation (3) explains how the DI maps the phase information of BPSK signals into two power levels, enabling subsequent signal processing. Next, the following optical switch is initially open and then closed at the beginning of the second loop.