SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Let  $\widehat{\mathrm{Var}}^h$  be a  $d$ -dimensional vector, where  $d$  is the number of nodes. We introduce a  $d$ -dimensional vector  $\mathrm{rank}^h$ , which represents the index of each element in  $\widehat{\mathrm{Var}}^h$  after a non-decreasing sorting. For example, if  $\widehat{\mathrm{Var}}^h = (5.2, 3.1, 4.5, 1.6)$ , then  $\mathrm{rank}^h = (3, 1, 2, 0)$ . Furthermore, we define a  $d$ -dimensional vector  $\mathrm{rank}$  as the element-wise summation of  $\mathrm{rank}^h$  over all  $h \in [H]$ . In other words,  $\mathrm{rank}$  is calculated as  $\mathrm{rank} = \sum_{h \in [H]} \mathrm{rank}^h$ .
Recall that in Section 3.1 we remarked that we leverage the SCORE approach from Rolland et al. [65] for estimating  $\mathrm{diag}(\nabla^2\log p(x))$  at each data point. Recall also that our identifiability result (Theorem 1) depends on determining whether a leaf node has variance  $\mathrm{Var}_q\left(\frac{\partial s_j(x)}{\partial x_j}\right) = 0$ . In practice, it is unrealistic to simply test for the equality  $\mathrm{Var}_L = 0$  since  $\mathrm{Var}_L$  carries out errors due to finite samples. Instead, we define the following statistic for each estimated leaf node  $L$  (Line 10 in Algorithm 3):
$$
\operatorname {s t a t s} _ {L} = \frac {\operatorname {V a r} _ {L}}{\min  _ {h} \operatorname {V a r} _ {L} ^ {h} + \epsilon}. \tag {8}
$$
Algorithm 3 Practical version of Algorithm 1
Input: Datasets  $X^1, \ldots, X^H$ , threshold  $t$   
Output: Shifted variables set  $\widehat{S}$ , and topological sort  $\hat{\pi}$ .  
1: Initialize  $\widehat{S} = \emptyset$ ,  $\hat{\pi} = (\cdot), \mathcal{N} = \{1, \ldots, d\}$   
2: stats  $\leftarrow (0, \ldots, 0) \in \mathbb{R}^d$   
3: Set  $\mathbf{X} = [(\mathbf{X}^1)^\top | \cdots | (\mathbf{X}^H)^\top]^\top \in \mathbb{R}^{m \times d}$ .  
4: while  $\mathcal{N} \neq \emptyset$  do  
5:  $\forall h \in [H]$ ,  $\widehat{\mathrm{Var}}^h \gets \mathrm{SCORE}(\mathbf{X}^h)$ .  
6:  $\forall h \in [H]$ ,  $\mathrm{rank}^h \gets \mathrm{arg\_sort}(\widehat{\mathrm{Var}}^h)$ .  
7:  $\mathrm{rank} \gets \sum_{h \in [H]} \mathrm{rank}^h$   
8:  $\widehat{L} \gets \mathrm{arg\_min}_j \mathrm{rank}_j$   
9:  $\widehat{\mathrm{Var}} \gets \mathrm{SCORE}(\mathbf{X})$   
10: stats $_L = \frac{\widehat{\mathrm{Var}}_L}{\min_h \widehat{\mathrm{Var}}_L}$   
11:  $\mathcal{N} \gets \mathcal{N} - \{L\}$   
12: Remove the  $\widehat{L}$ -th column of  $\mathbf{X}^h$ ,  $\forall h \in [H]$ , and  $\mathbf{X}$ .  
13:  $\hat{\pi} \gets (\widehat{L}, \hat{\pi})$ .  
14:  $\widehat{S} = \{j | \mathrm{stats}_j > t, \forall j \in [d]\}$
The intuition behind this ratio is that if the leaf node  $L$  is a shifted node then we can expect  $\frac{\mathrm{Var}_L}{\min_h \mathrm{Var}_L^h}$  to be large since  $\mathrm{Var}_L > 0$  (by Theorem 1), and  $\mathrm{Var}_L^h \approx 0$  (by Proposition 1). On the other hand, if the leaf node  $L$  is not a shifted node then we can expect  $\frac{\mathrm{Var}_L}{\min_h \mathrm{Var}_L^h}$  to be small. This is due to the fact that, given a consistent estimator,  $\mathrm{Var}_L$  would converge towards 0 (by Theorem 1) at a faster rate than  $\mathrm{Var}_L^h$  since we utilize a larger amount of data for estimating  $\mathrm{Var}_L$ . Finally,  $\epsilon$  in the denominator is a very small value, e.g.  $10^{-9}$ , and acts as a safeguard against encountering a division by zero<sup>6</sup>.
Then, given the statistic in eq.(8), we can set a threshold  $t$  and define the set of shifted nodes  $S$  by all the nodes  $j$  such that  $\text{stats}_j > t$  (Line 14 in Algorithm 3).
Remark 6 (The elbow strategy). Alternatively, we can employ an adaptive approach to identify the set of shifted nodes by sorting stats in non-increasing order, and look for the "elbow" point. For example, Figure 5 illustrates the variance ratio in (8) for each node sorted in non-increasing order. In this case, node index 5 corresponds to the elbow point, allowing us to estimate nodes 5 and 8 as shifted nodes. Identifying the elbow point has the advantage to detect shifted nodes without relying on a fixed threshold.
A.3 Algorithm details for FOCI
Algorithm 4 Feature ordering by conditional independence (FOCI)
Input: Data  $\widehat{\mathrm{Pre}} (\pmb {X}_j^h),\pmb {X}_j^h$    
Output: Estimated parents of  $X_{j}$ $\widehat{\mathbb{P}\mathbb{A}}_j^h$    
1:  $P\gets \emptyset$    
2: Let  $T_{m}(i,j,P)\equiv T_{m}(\pmb{X}_{j}^{h},\pmb{X}_{i}^{h}\mid \pmb{X}_{P}^{h})\quad \triangleright T_{m}$  is the estimator in Azadkia and Chatterjee [3].   
3: while  $\max_{X_i\notin P,X_i\in \widehat{\mathrm{Pre}} (X_j)}T_m(i,j,P) > 0$  do   
4:  $P\gets P\cup \left\{\arg \max_{X_i\notin P,X_i\in \widehat{\mathrm{Pre}} (X_j)}T_m(i,j,P)\right\}$    
5:  $\widehat{\mathrm{PA}}_j^h\gets P$
In practice, one could omit  $\epsilon$  from the denominator as it is unusual to obtain  $\min_h\mathrm{Var}_L^h = 0$  from finite samples and computational precision.
Figure 5: Statistic in eq.(8) for each node sorted in non-increasing order. In this case, node index 5 corresponds to the elbow point, allowing us to estimate nodes 5 and 8 as shifted nodes.
To prove Theorem 1 we will make use of the following lemmas.
Lemma 1. Let  $\{a_h\}_{h=1}^H$  and  $\{b_h\}_{h=1}^H$  be two sequences of real numbers, where  $a_h > 0, \forall h$ . Then we have:
$$
\left(\sum_ {h = 1} ^ {H} a _ {h} b _ {h} ^ {2}\right) \left(\sum_ {h = 1} ^ {H} a _ {h}\right) - \left(\sum_ {h = 1} ^ {H} a _ {h} b _ {h}\right) ^ {2} \geq 0,
$$
with equality if and only if  $b_{i} = b_{j}, \forall j \neq i \in [H]$ .
Proof. We can invoke the Cauchy-Schwarz inequality with vectors  $\pmb{u} = (\sqrt{a_1},\dots ,\sqrt{a_H})$ , and  $\pmb{v} = (b_{1}\sqrt{a_{1}},\ldots ,b_{H}\sqrt{a_{H}})$ , then we have:
$$
\left(\boldsymbol {u} ^ {\top} \boldsymbol {v}\right) ^ {2} \leq \| \boldsymbol {u} \| _ {2} ^ {2} \| \boldsymbol {v} \| _ {2} ^ {2},
$$
which proves the inequality. The equality holds if and only if  $\pmb{u}$  and  $\pmb{v}$  are linearly dependent, i.e., when  $b_{i} = b_{j}$  for all  $i\neq j\in [H]$ .
Lemma 2. For any  $j$ , if  $\mathbb{P}^h (X_j\mid \mathrm{PA}_j^h) = \mathbb{P}^{h'}(X_j\mid \mathrm{PA}_j^{h'})$ , then  $c_{j}^{h} = c_{j}^{h'}$ .
Proof. Denote the associated density of  $\mathbb{P}^h (X_j\mid \mathrm{PA}_j^h)$  when  $X_{j} = x_{j}$  as  $p_{N_j}^h (x_j - f_j^h (\mathrm{PA}_j^h))$  and let  $u = x_{j} - f_{j}^{h}(\mathrm{PA}_{j}^{h})$
$$
\begin{array}{l} \frac {\partial^ {2}}{\partial (x _ {j}) ^ {2}} \log p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) \\ = \frac {\partial \log p _ {N _ {j}} ^ {h} (u)}{\partial u} \frac {\partial^ {2} u}{\partial (x _ {j}) ^ {2}} + \frac {\partial^ {2} \log p _ {N _ {j}} ^ {h} (u)}{\partial u ^ {2}} \left(\frac {\partial u}{\partial x _ {j}}\right) ^ {2} \\ = 0 + c _ {j} ^ {h} = c _ {j} ^ {h} \\ \end{array}
$$
where we use the fact that  $\frac{\partial u}{\partial x_j} = 1, \frac{\partial^2 u}{\partial (x_j)^2} = 0$ . Then it immediately follows that if  $\mathbb{P}^h(X_j \mid \mathrm{PA}_j^h) = \mathbb{P}^{h'}(X_j \mid \mathrm{PA}_j^{h'})$ , then  $c_j^h = c_j^{h'}$
Lemma 3. For any  $j$ , under Assumption B,  $\frac{\partial}{\partial x_j} \log p_{N_j}^h (x_j - f_j^h (\mathrm{PA}_j^h)) = \frac{\partial}{\partial x_j} \log p_{N_j}^{h'}(x_j - f_j^{h'}(\mathrm{PA}_j^{h'}))$  if and only if  $\mathbb{P}^h (X_j\mid \mathrm{PA}_j^h) = \mathbb{P}^{h'}(X_j\mid \mathrm{PA}_j^{h'})$ , where  $p^h$  and  $p^{h'}$  are the probability density functions corresponding to the probability measures  $\mathbb{P}^h$  and  $\mathbb{P}^{h'}$  when  $X_{j} = x_{j}$ .
Proof. Denote the associated density of  $\mathbb{P}^h (X_j\mid \mathrm{PA}_j^h)$  when  $X_{j} = x_{j}$  as  $p_{N_j}^h (x_j - f_j^h (\mathrm{PA}_j^h))$  , we proceed as follows:
$$
\frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) = \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h ^ {\prime}} (x _ {j} - f _ {j} ^ {h ^ {\prime}} (\mathrm {P A} _ {j} ^ {h ^ {\prime}}))
$$
$$
\begin{array}{l} \Longleftrightarrow \log p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) = \log p _ {N _ {j}} ^ {h ^ {\prime}} (x _ {j} - f _ {j} ^ {h ^ {\prime}} (\mathrm {P A} _ {j} ^ {h ^ {\prime}})) + c o n s t \\ \Longleftrightarrow p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) = p _ {N _ {j}} ^ {h ^ {\prime}} \left(x _ {j} - f _ {j} ^ {h ^ {\prime}} \left(\mathrm {P A} _ {j} ^ {h ^ {\prime}}\right)\right) \cdot e ^ {c o n s t} \\ \Rightarrow \int_ {\mathbb {R}} p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) \mathrm {d} x _ {j} = e ^ {\text {c o n s t}} \cdot \int_ {\mathbb {R}} p _ {N _ {j}} ^ {h ^ {\prime}} \left(x _ {j} - f _ {j} ^ {h ^ {\prime}} \left(\mathrm {P A} _ {j} ^ {h ^ {\prime}}\right)\right) \mathrm {d} x _ {j} \\ \Rightarrow \int_ {\mathbb {R}} p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) \mathrm {d} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) = e ^ {c o n s t} \cdot \int_ {\mathbb {R}} p _ {N _ {j}} ^ {h ^ {\prime}} (x _ {j} - f _ {j} ^ {h ^ {\prime}} (\mathrm {P A} _ {j} ^ {h ^ {\prime}})) \mathrm {d} (x _ {j} - f _ {j} ^ {h ^ {\prime}} (\mathrm {P A} _ {j} ^ {h ^ {\prime}})) \\ \Rightarrow 1 = 1 \cdot e ^ {c o n s t} \\ \Rightarrow c o n s t = 0 \\ \end{array}
$$
Here,  $const$  is a constant that is independent of  $x_{j}$ . Integrating both sides with respect to  $x_{j}$  and using the fact that  $\int p^{h}(x)\mathrm{d}x = 1$ , we conclude that  $const = 0$ . Hence, we can establish the following:
$$
\begin{array}{l} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) = \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h ^ {\prime}} (x _ {j} - f _ {j} ^ {h ^ {\prime}} (\mathrm {P A} _ {j} ^ {h ^ {\prime}})) \\ \Longleftrightarrow p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) = p _ {N _ {j}} ^ {h ^ {\prime}} \left(x _ {j} - f _ {j} ^ {h ^ {\prime}} \left(\mathrm {P A} _ {j} ^ {h ^ {\prime}}\right)\right) \\ \Longleftrightarrow \mathbb {P} ^ {h} \left(X _ {j} \mid \mathrm {P A} _ {j} ^ {h}\right) = \mathbb {P} ^ {h ^ {\prime}} \left(X _ {j} \mid \mathrm {P A} _ {j} ^ {h ^ {\prime}}\right) \\ \end{array}
$$
Proof of Theorem 1. Let us first expand the log density of the mixture distribution:
$$
\log q (x) = \log \left(\sum_ {h = 1} ^ {H} w _ {h} p ^ {h} (x)\right)
$$
Then, recall that  $s(x) = \nabla \log q(x)$ , the  $j$ -entry reads:
$$
\begin{array}{l} s _ {j} (x) = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left[ \frac {\partial}{\partial x _ {j}} \log p ^ {h} \left(x _ {j} \mid \mathrm {P A} _ {j} ^ {h}\right) + \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial}{\partial x _ {j}} \log p ^ {h} \left(x _ {i} \mid \mathrm {P A} _ {i} ^ {h}\right) \right] \\ = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left[ \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) + \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {i}} ^ {h} \left(x _ {i} - f _ {i} ^ {h} \left(\mathrm {P A} _ {i} ^ {h}\right)\right) \right] \tag {9} \\ \end{array}
$$
Condition (i). First we will prove condition (i). That is, given a leaf node  $X_{j}$  in all DAGs  $G^{h}$ ,  $X_{j}$  is not a shifted node (i.e. an invariant node) if and only if  $\mathrm{Var}\left(\frac{\partial s_{j}(x)}{\partial x_{j}}\right) = 0$ .
If  $x_{j}$  is a leaf node in all the DAGs  $G^{h}$ , then  $\mathrm{CH}_j^h = \emptyset, \forall h \in [H]$ , and we can write eq.(9) as:
$$
s _ {j} (x) = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right)
$$
We use  $\mathrm{Den}(\frac{\partial s_j(x)}{\partial x_j})$  and  $\mathrm{Num}(\frac{\partial s_j(x)}{\partial x_j})$  to denote the denominator and numerator of  $\frac{\partial s_j(x)}{\partial x_j}$ , respectively. Then we have:
$$
\mathrm {D e n} \left(\frac {\partial s _ {j} (x)}{x _ {j}}\right) = \left(\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)\right) ^ {2}
$$
$$
\begin{array}{l} \operatorname {N u m} \left(\frac {\partial s _ {j} (x)}{x _ {j}}\right) = \left[ \sum_ {h = 1} ^ {H} w _ {h} p ^ {h} (x) \frac {\partial^ {2}}{\partial x _ {j} ^ {2}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) + w _ {h} p ^ {h} (x) \left(\frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right)\right) ^ {2} \right] \\ \times \left[ \sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x) \right] - \left[ \sum_ {h = 1} ^ {H} w _ {h} p ^ {h} (x) \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) \right] ^ {2} \\ \end{array}
$$
Now, dividing  $\mathrm{Num}(\frac{\partial s_j(x)}{\partial x_j})$  over  $\mathrm{Den}(\frac{\partial s_j(x)}{\partial x_j})$ , we obtain:
$$
\begin{array}{l} \frac {\partial s _ {j} (x)}{\partial x _ {j}} = \frac {\operatorname {N u m} (\frac {\partial s _ {j} (x)}{x _ {j}})}{\operatorname {D e n} (\frac {\partial s _ {j} (x)}{x _ {j}})} = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \frac {\partial^ {2}}{\partial x _ {j} ^ {2}} \log p _ {N _ {j}} ^ {h} (x _ {j} - f _ {j} ^ {h} (\mathrm {P A} _ {j} ^ {h})) \\ + \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left(\frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right)\right) ^ {2} \\ - \left[ \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) \right] ^ {2} \tag {10} \\ \end{array}
$$
Note that since  $x_{j} \notin \mathrm{PA}_{j}^{h}$ , the function  $f_{j}^{h}(\mathrm{PA}_{j}^{h})$  is independent of  $x_{j}$ .
Let  $a_{h} = w_{h}p^{h}(x)$ , and let  $b_{h} = \frac{\partial}{\partial x_{j}}\log p_{N_{j}}^{h}(x_{j} - f_{j}^{h}(\mathrm{PA}_{j}^{h}))$ . Then, the last two summands of the RHS of eq.(10) can be written as:
$$
\frac {1}{\left(\sum_ {h = 1} ^ {H} a _ {h}\right) ^ {2}} \left[ \left(\sum_ {h = 1} ^ {H} a _ {h} b _ {h} ^ {2}\right) \left(\sum_ {h = 1} ^ {H} a _ {h}\right) - \left(\sum_ {h = 1} ^ {H} a _ {h} b _ {h}\right) ^ {2} \right] \geq 0, \tag {11}
$$
where the last inequality holds from Lemma 1. Then, by Lemma 3, we have that  $b_h = b_{h'} \Longleftrightarrow \mathbb{P}^h(X_j \mid \mathrm{PA}_j^h) = \mathbb{P}^{h'}(X_j \mid \mathrm{PA}_j^{h'})$  for all  $h, h' \in [H]$ . Then if  $b_h = b_{h'}$  holds, by Lemma 2, we have  $c_j^h = c_j^{h'} \coloneqq c_j$  and then the first term for eq.(10) boils down to a constant  $c_j$ . Finally, from Lemma 1, we have that equality in eq.(11) holds if and only if  $b_h = b_{h'}$  for all  $h, h' \in [H]$ . Thus, we conclude that:
$$
\text {I f} X _ {j} \text {i s a l e a f n o d e f o r a l l} G ^ {h}, \text {t h e n} X _ {j} \text {i s n o t a s h i f t e d n o d e} \Longleftrightarrow \frac {\partial s _ {j} (x)}{\partial x _ {j}} = c _ {j},
$$
where  $\frac{\partial s_j(x)}{\partial x_j} = c_j$  is equivalent to  $\operatorname{Var}_q\left(\frac{\partial s_j(x)}{\partial x_j}\right) = 0$ .
Condition (ii). We now prove that if  $\operatorname{Var}_q\left(\frac{\partial s_j(x)}{\partial x_j}\right) > 0$ , then only one of the following two cases holds: Case 1)  $X_{j}$  is a leaf node for all  $G^{h}$  and a shifted node. Case 2)  $X_{j}$  is not a leaf node in at least one DAG  $G^{h}$ .
Case 1 follows immediately from the proof of condition (i) above.
For Case 2, we study whether there exists a non-leaf node  $X_{j}$  with  $\operatorname{Var}_{q}\left(\frac{\partial s_{j}(x)}{\partial x_{j}}\right) = 0$ . Taking the partial derivative of  $s_{j}(x)$  in eq.(9) w.r.t.  $x_{j}$ , we have:
$$
\begin{array}{l} \frac {\partial s _ {j} (x)}{\partial x _ {j}} = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left(\frac {\partial^ {2}}{\partial x _ {j} ^ {2}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) + \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial^ {2}}{\partial x _ {j} ^ {2}} \log p _ {N _ {i}} ^ {h} \left(x _ {i} - f _ {i} ^ {h} \left(\mathrm {P A} _ {i} ^ {h}\right)\right)\right) \\ + \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left(\frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) + \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {i}} ^ {h} \left(x _ {i} - f _ {i} ^ {h} \left(\mathrm {P A} _ {i} ^ {h}\right)\right)\right) ^ {2} \\ \end{array}
$$
$$
\left. \right. - \left[ \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \left(\frac {\partial}{\partial x _ {j}} \log p _ {N _ {j}} ^ {h} \left(x _ {j} - f _ {j} ^ {h} \left(\mathrm {P A} _ {j} ^ {h}\right)\right) + \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial}{\partial x _ {j}} \log p _ {N _ {i}} ^ {h} \left(x _ {i} - f _ {i} ^ {h} \left(\mathrm {P A} _ {i} ^ {h}\right)\right)\right)\right] ^ {2}
$$
By Assumptions B, we have  $\frac{\partial^2}{\partial x_j^2}\log p_{N_j}^h (x_j - f_j^h (\mathrm{PA}_j^h)) = c_j^h$ . For simplicity, let  $a_{h} = \frac{\partial}{\partial x_{j}}\log p_{N_{j}}^{h}(x_{j} - f_{j}^{h}(\mathrm{PA}_{j}^{h})) + \sum_{i\in \mathrm{CH}_{j}^{h}}\frac{\partial}{\partial x_{j}}\log p_{N_{i}}^{h}(x_{i} - f_{i}^{h}(\mathrm{PA}_{i}^{h}))$ . Then, we have:
$$
\begin{array}{l} \frac {\partial s _ {j} (x)}{\partial x _ {j}} = \sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} c _ {j} ^ {h} + \underbrace {\sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} \sum_ {i \in \mathrm {C H} _ {j} ^ {h}} \frac {\partial^ {2}}{\partial x _ {j} ^ {2}} \log p _ {N _ {i}} ^ {h} \left(x _ {i} - f _ {i} ^ {h} \left(\mathrm {P A} _ {i} ^ {h}\right)\right)} _ {\text {t e r m 1}} \\ + \underbrace {\sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} a _ {h} ^ {2} - \left(\sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} a _ {h}\right) ^ {2}} _ {\text {t e r m 2}}. \tag {12} \\ \end{array}
$$
We prove that  $\frac{\partial^2}{\partial x_j^2}\log p_{N_i}^h (x_i - f_i^h (\mathrm{PA}_i^h))$ , is not constant under any circumstance, by contradiction. Let  $G^{h}$  be an environment's DAG where  $X_{j}$  is not a leaf, and let  $X_{u}\in \mathrm{CH}_{j}^{h}$  such that  $X_{u}\notin \cup_{i\in \mathrm{CH}_{j}^{h}}\mathrm{PA}_{i}^{h}$ . Note that  $X_{u}$  always exist since  $X_{j}$  is not a leaf, and it suffices to pick a child  $X_{u}$  appearing at the latest position in the topological order of  $G^{h}$ . Now suppose that  $\frac{\partial^2}{\partial x_j^2}\log p_{N_u}^h (x_u - f_u^h (\mathrm{PA}_u^h)) = a$ , where  $a$  is a constant. Then we have:
$$
\frac {\partial}{\partial x _ {j}} \log p _ {N _ {u}} ^ {h} (x _ {u} - f _ {u} ^ {h} (\mathrm {P A} _ {u} ^ {h})) = a x _ {j} + g (x _ {- j}),
$$
$$
\frac {\partial}{\partial x _ {j}} f _ {u} ^ {h} (\mathrm {P A} _ {u} ^ {h}) \cdot \frac {\partial}{\partial n _ {u}} \log p _ {N _ {u}} ^ {h} (n _ {u}) = a x _ {j} + g (x _ {- j}).
$$
By deriving both sides w.r.t.  $x_{u}$  , we obtain:
$$
\frac {\partial}{\partial x _ {j}} f _ {u} ^ {h} \left(\mathrm {P A} _ {u} ^ {h}\right) \cdot \frac {\partial^ {2}}{\partial n _ {u} ^ {2}} \log p _ {N _ {u}} ^ {h} \left(n _ {u}\right) = \frac {\partial g \left(x _ {- j}\right)}{\partial x _ {u}}
$$
$$
\frac {\partial}{\partial x _ {j}} f _ {u} ^ {h} \left(\mathrm {P A} _ {u} ^ {h}\right) \cdot c _ {j} ^ {h} = \frac {\partial g (x _ {- j})}{\partial x _ {u}}.
$$
Since the RHS does not depend on  $x_{j}$ , then  $\frac{\partial f_u^h}{\partial x_j}$  cannot depend on  $x_{j}$  neither, implying that  $f_{u}^{h}$  is linear in  $x_{j}$ , thus contradicting the non-linearity assumption (Assumption A). Consequently, it becomes evident that term 1 cannot be a constant, regardless of whether the node  $X_{j}$  has undergone a shift or not.
Now let us take a look to term 2 in eq.(12). We have:
$$
\sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} a _ {h} ^ {2} - \left(\sum_ {h = 1} ^ {H} \frac {w _ {h} p ^ {h} (x)}{\sum_ {k = 1} ^ {H} w _ {k} p ^ {k} (x)} a _ {h}\right) ^ {2} \geq 0,
$$
where the inequality follows by Jensen's inequality. Thus we conclude that if  $X_{j}$  is a non-leaf node, we have  $\operatorname{Var}_q\left(\frac{\partial s_j(x)}{\partial x_j}\right) > 0$ .
To proof the theorem we will need the following assumptions:
Assumption C. Let  $\mathrm{MB}_j^h$  denote the Markov Blanket of node  $X_{j}$  under environment  $h$ , then assume
- There are non-negative real numbers  $\beta$  and  $C$  such that for any subset  $X_{S} \subseteq \operatorname{Pre}(X_{j}^{h})$  of size  $\leq 1 / \delta + 2$ , any  $x, x' \in \mathbb{R}^{|X_{S}|}$  and any  $t \in \mathbb{R}$ ,
$$
\mid \mathbb {P} (X _ {j} ^ {h} \geq t \mid X _ {\boldsymbol {S}} = x) - \mathbb {P} (X _ {j} ^ {h} \geq t \mid X _ {\boldsymbol {S}} = x ^ {\prime}) \mid \leq C (1 + \| x \| ^ {\beta} + \| x ^ {\prime} \| ^ {\beta}) \| x - x ^ {\prime} \|
$$
where  $|X_{\mathcal{S}}|$  is the size of the set  $X_{\mathcal{S}}$ .
- There are positive numbers  $C_1$  and  $C_2$  such that for any  $X_S$  of size  $\leq 1 / \delta + 2$  and any  $t > 0$ ,  $\mathbb{P}(\|X_S\| \geq t) \geq C_1 e^{-C_2 t}$
- For any subset  $X_{S} \subseteq \operatorname{Pre}(X_{j}^{h})$  such that  $X_{S} \subsetneq \mathrm{MB}_{j}^{h}$ , there exists  $X_{i}$  with  $X_{i} \in \mathrm{MB}_{j}^{h} \backslash X_{S}$ , such that for any  $X_{j}$  with  $X_{j} \notin \mathrm{MB}_{j}^{h}$ ,
$$
Q \left(X _ {S} \cup \left\{X _ {i} \right\}\right) - Q \left(X _ {S} \cup \left\{X _ {j} \right\}\right) \geq \delta / 4 \quad Q \left(X _ {S}\right) = \int \operatorname {V a r} \left(\mathbb {P} \left(X _ {j} ^ {h} \geq t \mid X _ {S}\right)\right) d \mu (t)
$$
where  $\delta$  is the largest number such that for any subset  $X_{S}$  from  $\operatorname{Pre}(X_j^h)$ , there is some  $X_i \notin X_S$  such that  $Q(X_S \cup \{X_i\}) \geq Q(X_S) + \delta$ .
Proof. Under Assumption C, from Theorem 3.1 in [4], we have
$$
\mathbb {P} \left(\widehat {\mathrm {M B}} _ {j} ^ {h} = \mathrm {M B} _ {j} ^ {h}\right) \geq 1 - C _ {3} e ^ {- C _ {4} m}
$$
where  $C_3$  and  $C_4$  are constants that depend only on the data generation process, and  $m$  is the number of samples. Since the estimated topological order  $\hat{\pi}$  is assumed to be valid for all environments, we can conclude that node  $X_j$  is a leaf node in the input data  $\{\mathrm{Pre}(X_j^h), X_j^h\}$  for all  $h$ . As a result, we have  $\mathrm{MB}_j^h = \mathrm{PA}_j^h$  based on the Markov blanket definition. Therefore, the output of Algorithm 4 is equal to the true parent set  $\mathrm{PA}_j^h$  with high probability.
B.3 Proof of Theorem 3 in Appendix D
To prove Theorem 3 we will make use of the following lemmas.
Lemma 4. Suppose  $\mathbf{X}$  is an  $n \times k_x$  dimension matrix,  $\mathbf{Y}$  is an  $n \times k_y$  dimension matrix. Let the columns of the concatenated matrix  $\mathbf{Z} = (\mathbf{X},\mathbf{Y})$  be linearly independent. Consider  $\tilde{\beta}_x$ , a  $k_x$ -dimensional vector, and  $\tilde{\beta}_y$  and  $\beta_y$ , both  $k_y$ -dimensional vectors. If  $\mathbf{X}\tilde{\beta}_x + \mathbf{Y}\tilde{\beta}_y = \mathbf{Y}\beta_y$ , then it follows that  $\tilde{\beta}_y = \beta_y$  and  $\tilde{\beta}_x = 0$ .