SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Ada-BF and sandwiched LBF use heuristics to find the optimal parameters, so they have shorter construction times than PLBF but have worse accuracy. PLBF has better accuracy but takes more than 3 minutes to find the optimal  $t$  and  $f$ . On the other hand, our fast PLBF and fast PLBF++ take less than 2 seconds. As a result, Fast PLBF constructs 50.8 and 34.3 times faster than PLBF, and fast PLBF++ constructs 63.1 and 39.3 times faster than PLBF for the URLs and EMBER datasets, respectively. This is about the same construction time as sandwiched LBF, which relies heavily on heuristics and, as we will see in the next section, is much less accurate than PLBF.
Figure 11: Trade-off between memory usage and FPR.
Figure 12: Ablation study for hyper-parameter  $N$ .
5.2 Memory Usage and FPR
We compared the trade-off between memory usage and FPR for fast PLBF and fast PLBF++ with Bloom filter, Ada-BF, sandwiched LBF, and PLBF. Following the experiments in the PLBF paper, hyperparameters for PLBF, fast PLBF, and fast PLBF++ were always set to  $N = 1,000$  and  $k = 5$ .
Figure 11 shows each method's trade-off between memory usage and FPR. PLBF, fast PLBF, and fast  $\mathrm{PLBF}++$  have better Pareto curves than the other methods for all datasets. Fast PLBF constructs the same data structure as PLBF in all cases, so it has exactly the same accuracy as PLBF. Fast  $\mathrm{PLBF}++$  achieves almost the same accuracy as PLBF. Fast  $\mathrm{PLBF}++$  has up to 1.0019 and 1.000083 times higher false positive rates than PLBF for the URLs and EMBER datasets, respectively.
5.3 Ablation study for hyper-parameters
The parameters of the PLBFs are memory size,  $N$ , and  $k$ . The memory size is specified by the user, and  $N$  and  $k$  are hyperparameters that are determined by balancing construction time and accuracy. In the previous sections, we set  $N$  to 1,000 and  $k$  to 5, following the original paper on PLBF. In this section, we perform ablation studies for these hyperparameters to confirm that our proposed methods can construct accurate data structures quickly, no matter what hyperparameter settings are used. We also confirm that the accuracy tends to be better and the construction time increases as  $N$  and  $k$  are increased, and that the construction time of the proposed methods increases much slower than PLBF.
Figure 12 shows the construction time and false positive rate with various  $N$  while the memory usage of the backup Bloom filters is fixed at  $500\mathrm{Kb}$  and  $k$  is fixed at 5. For all three PLBFs, the false positive rate tends to decrease as  $N$  increases. (Note that this is the false positive rate on test data, so it does not necessarily decrease monotonically. The appendix shows that the expected value of the false positive rate calculated using training data decreases monotonically as  $N$  increases.) Also, as  $N$  increases, the PLBF construction time increases rapidly, but the fast PLBF construction time increases much more slowly than that, and for fast  $\mathrm{PLBF + + }$ , the construction time changes little. This is because the construction time of PLBF is asymptotically proportional to  $N^3$ , while that of fast PLBF and fast  $\mathrm{PLBF + + }$  is proportional to  $N^2$  and  $N\log N$ , respectively. The experimental results
Figure 13: Ablation study for hyper-parameter  $k$ .
show that the two proposed methods can achieve high accuracy without significantly changing the construction time with large  $N$ .
Figure 13 shows the construction time and false positive rate with various  $k$  while the backup bloom filter memory usage is fixed at  $500\mathrm{Kb}$  and  $N$  is fixed at 1,000. For all three PLBFs, the false positive rate tends to decrease as  $k$  increases. For the EMBER dataset, the false positive rate stops decreasing at about  $k = 20$ , while for the URLs dataset, it continues to decrease even at about  $k = 500$ . (Just as in the case of experiments with varying  $N$ , this decrease is not necessarily monotonic.) In addition, the construction times of all three PLBFs increase proportionally to  $k$ , but fast PLBF has a much shorter construction time than PLBF, and fast PLBF++ has an even shorter construction time than fast PLBF. When  $k = 50$ , fast PLBF constructs 233 and 199 times faster than PLBF, and fast PLBF++ constructs 761 and 500 times faster than PLBF for the URLs and EMBER datasets, respectively. The experimental results indicate that by increasing  $k$ , the two proposed methods can achieve high accuracy without significantly affecting the construction time.
Approximate membership query is a query that asks whether the query  $q$  is contained in the set  $S$  while allowing for false positives with a small probability  $\varepsilon$ . One can prove that at least  $|S| \log_2\left(\frac{1}{\varepsilon}\right)$  bits of memory must be used to answer the approximate membership query if the elements in the set or queries are selected with equal probability from the universal set [20].
A Bloom filter [1] is one of the most basic data structures for approximate membership queries. It compresses the set  $S$  into a bit string using hash functions. This bit string and the hash functions are then used to answer the queries. To achieve an FPR of  $\varepsilon$ , a Bloom filter requires  $|S| \log_2\left(\frac{1}{\varepsilon}\right) \log_2 e$  bits of memory. This is  $\log_2 e$  times the theoretical lower bound.
Various derivatives have been proposed that achieve better memory efficiency than the original Bloom filter. The cuckoo filter [21] is more memory efficient than the original Bloom filter and supports dynamic addition and removal of elements. Pagh et al. [22] proposed a replacement for Bloom filter that achieves a theoretical lower bound. Various other memory-efficient filters exist, including the vacuum filter [23], xor filter [24], and ribbon filter [25]. However, these derivatives do not consider the structure of the distribution and thus cannot take advantage of it.
Kraska et al.[10] proposed using a machine learning model as a prefilter of a backup Bloom filter. Ada-BF [11] extended this design and proposed to exploit the scores output by the machine learning model. PLBF [14] uses a design similar to that of Ada-BF but introduces fewer heuristics for optimization than Ada-BF. Mitzenmacher [12] proposed an LBF that "sandwiches" a machine learning model with two Bloom filters. This achieves better memory efficiency than the original LBF but can actually be interpreted as a special case of PLBF.
7 Limitation and Future Work
As explained in Section 4, it is somewhat intuitive that  $A$  is a monotone matrix or close to it, so it is also intuitive that fast PLBF++ achieves accuracy close to PLBF. Experimental results on the URLs and EMBER datasets also suggest that fast PLBF++ achieves almost the same accuracy as PLBF,
even when the score distribution is not ideal. This experimental rule is further supported by the results of the artificial data experiments described in the appendix. However, there is no theoretical support for the accuracy of fast PLBF++. Theoretical support for how fast PLBF++ accuracy may degrade relative to PLBF is a future issue.
Besides, it is possible to consider faster methods by making stronger assumptions than fast PLBF++. Fast PLBF++ assumes the monotonicity of matrix  $A$ . We adopted this assumption because matrix  $A$  is proved to be monotone under intuitive assumptions about the data distribution. However, by assuming stronger assumptions about matrix  $A$ , the computational complexity of the construction could be further reduced. For example, if matrix  $A$  is totally monotone, the matrix problem for matrix  $A$  can be solved in  $\mathcal{O}(N)$  using algorithms such as [16, 26]. Using such existing DP algorithms is a promising direction toward even faster or more accurate methods, and is a future work.
PLBF is an outstanding LBF that can effectively utilize the distribution of the set and queries captured by a machine learning model. However, PLBF is computationally expensive to construct. We proposed fast PLBF and fast PLBF++ to solve this problem. Fast PLBF is superior to PLBF because fast PLBF constructs exactly the same data structure as PLBF but does so faster. Fast PLBF++ is even faster than fast PLBF and achieves almost the same accuracy as PLBF and fast PLBF. These proposed methods have greatly expanded the range of applications of PLBF.
We thank the anonymous reviewers for their constructive comments. This work was supported by JST AIP Acceleration Research JPMJCR23U2, Japan.
[1] Burton H Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422-426, 1970.
[2] Andrei Broder and Michael Mitzenmacher. Network applications of bloom filters: A survey. _Internet mathematics_, 1(4):485-509, 2004.
[3] Sasu Tarkoma, Christian Esteve Rothenberg, and Eemil Lagerspetz. Theory and practice of bloom filters for distributed systems. IEEE Communications Surveys & Tutorials, 14(1):131-155, 2011.
[4] Shahabeddin Geravand and Mahmood Ahmadi. Bloom filter applications in network security: A state-of-the-art survey. Computer Networks, 57(18):4047-4064, 2013.
[5] Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C Hsieh, Deborah A Wallach, Mike Burrows, Tushar Chandra, Andrew Fikes, and Robert E Gruber. Bigtable: A distributed storage system for structured data. ACM Transactions on Computer Systems (TOCS), 26(2):1-26, 2008.
[6] Michael T Goodrich and Michael Mitzenmacher. Invertible bloom lookup tables. In Allerton Conference on Communication, Control, and Computing (Allerton), 2011.
[7] Guanlin Lu, Young Jin Nam, and David HC Du. Bloomstore: Bloom-filter based memory-efficient key-value store for indexing of data dedduplication on flash. In IEEE Symposium on Mass Storage Systems and Technologies (MSST), 2012.
[8] Mike Hearn and Matt Corallo. Bips: Connection bloom filtering, 2012. URL https://github.com/bitcoin/bips/blob/master/bip-0037 [Online; accessed 22-December-2022], 2012.
[9] Jongbeen Han, Mansub Song, Hyeonsang Eom, and Yongseok Son. An efficient multi-signature wallet in blockchain using bloom filter. In Proceedings of the ACM Symposium on Applied Computing, 2021.
Appendix A details the optimization problem designed in the original PLBF paper [14] and its solution. It includes a comprehensive analysis of the optimization problem and a detailed description of how PLBF's method leads (under certain assumptions) to a solution to the optimization problem, which are not provided in [14]. Appendix B presents details of PLBF and the fast PLBF algorithm along with pseudo-code. Appendix C gives the proof of Theorem 4.3, a theorem about the accuracy of fast  $\mathrm{PLBF}++$ . In Appendix D, we explain the trivial modifications to the PLBF framework that we made for the experiments. Appendix E describes a detailed ablation study of the PLBFs hyperparameters,  $N$  and  $k$ . Appendix F describes the experiments on the simplified solution method presented in the PLBF paper. Appendix G describes experiments with artificial datasets to evaluate the experimental performance of fast  $\mathrm{PLBF}++$  in detail.
Appendix A Solution of the optimization problems
In the original PLBF paper [14], the analysis with mathematical expressions was conducted only for the relaxed problem, while no analysis utilizing mathematical expressions was performed for the general problem. Consequently, it was unclear which calculations were redundant, leading to the repetition of constructing similar DP tables. Hence, this appendix provides a comprehensive analysis of the general problem. It presents the optimal solution and the corresponding value of the objective function using mathematical expressions. This analysis uncovers redundant calculations, enabling the derivation of fast PLBF.
The optimization problem designed by PLBF [14] can be written as follows:
$$
\underset {\boldsymbol {f}, \boldsymbol {t}} {\text {m i n i m i z e}} \quad \sum_ {i = 1} ^ {k} c | \mathcal {S} | G _ {i} \log_ {2} \left(\frac {1}{f _ {i}}\right)
$$
$$
\text {s u b j e c t} \quad \sum_ {i = 1} ^ {k} H _ {i} f _ {i} \leq F \tag {7}
$$
$$
t _ {0} = 0 <   t _ {1} <   t _ {2} <   \dots <   t _ {k} = 1
$$
$$
f _ {i} \leq 1 \quad (i = 1 \dots k).
$$
The objective function represents the total memory usage of the backup Bloom filters. The first constraint equation represents the condition that the expected overall FPR is below  $F$ .  $c \geq 1$  is a constant determined by the type of backup Bloom filters.  $\pmb{G}$  and  $\pmb{H}$  are determined by  $\pmb{t}$ . Once  $\pmb{t}$  is fixed, we can solve this optimization problem to find the optimal  $\pmb{f}$  and the minimum value of the objective function. In the original PLBF paper [14], the condition  $f_{i} \leq 1 (i = 1 \dots k)$  was relaxed; however, here we conduct the analysis without relaxation. We assume  $G_{i} > 0$ ,  $H_{i} > 0$  ( $i = 1 \dots k$ ) and  $|\mathcal{S}| > 0$ .
The Lagrange function is defined using the Lagrange multipliers  $\pmb{\mu} \in \mathbb{R}^k$  and  $\nu \in \mathbb{R}$ , as follows:
$$
L (\boldsymbol {f}, \boldsymbol {\mu}, \nu) = \sum_ {i = 1} ^ {k} c | \mathcal {S} | G _ {i} \log_ {2} \left(\frac {1}{f _ {i}}\right) + \sum_ {i = 1} ^ {k} \mu_ {i} \left(f _ {i} - 1\right) + \nu \left(\sum_ {i = 1} ^ {k} H _ {i} f _ {i} - F\right). \tag {8}
$$
From the KKT condition, there exist  $\bar{\mu}$  and  $\bar{\nu}$  in the local optimal solution  $\bar{f}$  of this optimization problem, and the following holds:
$$
\frac {\partial L}{\partial f _ {i}} (\bar {\boldsymbol {f}}, \bar {\boldsymbol {\mu}}, \bar {\nu}) = 0 \quad (i = 1 \dots k) \tag {9}
$$
$$
\bar {f} _ {i} - 1 \leq 0, \quad \bar {\mu} _ {i} \geq 0, \quad \bar {\mu} _ {i} (\bar {f} _ {i} - 1) = 0 \quad (i = 1 \dots k) \tag {10}
$$
$$
\sum_ {i = 1} ^ {k} H _ {i} \bar {f} _ {i} - F \leq 0, \quad \bar {\nu} \geq 0, \quad \bar {\nu} \left(\sum_ {i = 1} ^ {k} H _ {i} \bar {f} _ {i} - F\right) = 0. \tag {11}
$$
We define  $\mathcal{I}_{f = 1}$  and  $\mathcal{I}_{f < 1}$  as  $\mathcal{I}_{f = 1} = \{i\mid \bar{f}_i = 1\}$  and  $\mathcal{I}_{f < 1} = \{i\mid \bar{f}_i < 1\}$ .  $\mathcal{I}_{f = 1}\cup \mathcal{I}_{f < 1} = \{1\dots k\}$  and  $\mathcal{I}_{f = 1}\cap \mathcal{I}_{f < 1} = \emptyset$  are satisfied. Furthermore, we assume that  $\mathcal{I}_{f < 1}\neq \emptyset$ . This means that there is at least one region that uses a backup Bloom filter with an FPR smaller than 1.
By introducing  $\mathcal{I}_{f = 1}$  and  $\mathcal{I}_{f < 1}$ , Equations (9, 10, 11) can be organized as follows:
$$
c \left| \mathcal {S} \right| G _ {i} = \bar {\mu} _ {i} + \bar {\nu} H _ {i}, \quad \bar {\mu} _ {i} \geq 0, \quad \bar {f} _ {i} = 1 \quad (i \in \mathcal {I} _ {f = 1}) \tag {12}
$$
$$
c \left| \mathcal {S} \right| G _ {i} = \bar {f} _ {i} \bar {\nu} H _ {i}, \quad \bar {\mu} _ {i} = 0, \quad \bar {f} _ {i} <   1 \quad (i \in \mathcal {I} _ {f <   1}) \tag {13}
$$
$$
\sum_ {i \in \mathcal {I} _ {f = 1}} H _ {i} + \sum_ {i \in \mathcal {I} _ {f <   1}} H _ {i} \bar {f} _ {i} - F \leq 0, \quad \bar {\nu} \geq 0, \quad \bar {\nu} \left(\sum_ {i \in \mathcal {I} _ {f = 1}} H _ {i} + \sum_ {i \in \mathcal {I} _ {f <   1}} H _ {i} \bar {f} _ {i} - F\right) = 0. \tag {14}
$$
Here, we get  $\bar{\nu} > 0$ . This is because if we assume  $\bar{\nu} = 0$ , Equation (13) implies that  $G_{i} = 0$  for  $i \in \mathcal{I}_{f < 1} (\neq \emptyset)$ , which contradicts the assumption that  $G_{i} > 0$ . From  $\bar{\nu} > 0$  and Equation (13),
$$
\bar {f} _ {i} = \frac {c | S |}{\bar {\nu}} \frac {G _ {i}}{H _ {i}} \quad (i \in \mathcal {I} _ {f <   1}). \tag {15}
$$
From Equations (14, 15) and  $\bar{\nu} >0$
$$
\sum_ {i \in \mathcal {I} _ {f = 1}} H _ {i} + \sum_ {i \in \mathcal {I} _ {f <   1}} H _ {i} \frac {c | S |}{\bar {\nu}} \frac {G _ {i}}{H _ {i}} - F = 0 \tag {16}
$$
$$
\frac {c \left| S \right|}{\bar {\nu}} = \frac {F - \sum_ {i \in \mathcal {I} _ {f = 1}} H _ {i}}{\sum_ {i \in \mathcal {I} _ {f <   1}} G _ {i}}. \tag {17}
$$
Substituting Equations (15, 17) into the objective function of the optimization problem (7), we obtain
$$
\begin{array}{l} \sum_ {i = 1} ^ {k} c \left| \mathcal {S} \right| G _ {i} \log_ {2} \left(\frac {1}{\bar {f} _ {i}}\right) = \sum_ {i \in \mathcal {I} _ {f <   1}} - c \left| \mathcal {S} \right| G _ {i} \log_ {2} \left(\frac {F - \sum_ {j \in \mathcal {I} _ {f = 1}} H _ {j}}{\sum_ {j \in \mathcal {I} _ {f <   1}} G _ {j}} \frac {G _ {i}}{H _ {i}}\right) (18) \\ = c \left| \mathcal {S} \right| \left(1 - G _ {f = 1}\right) \log_ {2} \left(\frac {1 - G _ {f = 1}}{F - H _ {f = 1}}\right) - c \left| \mathcal {S} \right| \sum_ {i \in \mathcal {I} _ {f <   1}} G _ {i} \log_ {2} \left(\frac {G _ {i}}{H _ {i}}\right). (19) \\ \end{array}
$$
We define  $G_{f = 1}$  and  $H_{f = 1}$  as  $G_{f = 1} = \sum_{i\in \mathcal{I}_{f = 1}}G_{i}$  and  $H_{f = 1} = \sum_{i\in \mathcal{I}_{f = 1}}H_{i}$ , respectively.
PLBF makes the following assumption:
Assumption A.1. For optimal  $t$  and  $\pmb {f},\mathcal{I}_{f = 1} = \varnothing$  or  $\mathcal{I}_{f = 1} = \{k\}$
In other words, PLBF assumes that there is at most one region for which  $f = 1$ , and if there is one, it is the region with the highest score. PLBF then tries all possible thresholds  $t_{k-1}$  (under the division of the score space).
In the following, we discuss the optimal  $\pmb{f}$  and  $\pmb{t}$  under the assumption that the  $j$ -th to  $N$ -th segments are clustered as the  $k$ -th region ( $j \in \{k \dots N\}$ ).
In the case of  $\mathcal{I}_{f = 1} = \varnothing$ , because  $G_{f = 1} = H_{f = 1} = 0$ , Equation (19) becomes
$$
c \left| \mathcal {S} \right| \log_ {2} \left(\frac {1}{F}\right) - c \left| \mathcal {S} \right| G _ {k} \log_ {2} \left(\frac {G _ {k}}{H _ {k}}\right) - c \left| \mathcal {S} \right| \sum_ {i = 1} ^ {k - 1} G _ {i} \log_ {2} \left(\frac {G _ {i}}{H _ {i}}\right). \tag {20}
$$
Meanwhile, in the case of  $\mathcal{I}_{f = 1} = \{k\}$ , Equation (19) becomes
$$
c \left| \mathcal {S} \right| \left(1 - G _ {k}\right) \log_ {2} \left(\frac {1 - G _ {k}}{F - H _ {k}}\right) - c \left| \mathcal {S} \right| \sum_ {i = 1} ^ {k - 1} G _ {i} \log_ {2} \left(\frac {G _ {i}}{H _ {i}}\right). \tag {21}
$$
In both cases, the terms other than the last one are constants under the assumption that the  $j$ -th to  $N$ -th segments are clustered as the  $k$ -th region. Therefore, the value of the objective function is minimized when the 1st to  $(j - 1)$ -th segments are clustered in a way that maximizes  $\sum_{i = 1}^{k - 1}G_i\log_2\left(\frac{G_i}{H_i}\right)$ . Thus, the problem of finding  $\pmb{t}$  that minimizes memory usage can be reduced to the following problem: for each  $j = k\dots N$ , we find a way to cluster the 1st to  $(j - 1)$ -th segments into  $k - 1$  regions that maximizes  $\sum_{i = 1}^{k - 1}G_i\log_2\left(\frac{G_i}{H_i}\right)$ .
Algorithm 1 PLBF [14]
Input:  $\pmb {g}\in \mathbb{R}^{N}$  : probabilities that the keys are contained in each segment  $\pmb {h}\in \mathbb{R}^N$  : probabilities that the non-keys are contained in each segment  $F\in (0,1)$  : target overall FPR  $k\in \mathbb{N}$  : number of regions   
Output:  $\pmb {t}\in \mathbb{R}^{k + 1}$  : threshold boundaries of each region  $\pmb {f}\in \mathbb{R}^{k}$  : FPRs of each region   
Algorithm: THRESMAXDIVDP  $(g,h,j,k)$  constructs  $\mathrm{DP}_{\mathrm{KL}}^j$  and calculates the optimal thresholds by tracing the transitions backward from  $\mathrm{DP}_{\mathrm{KL}}^j [j - 1][k - 1]$  OPTIMALFPR  $(g,h,t,F,k)$  : returns the optimal FPRs for each region under the given thresholds SPACEUSED  $(g,h,t,f)$  : returns the space size used by the backup Bloom filters for the given thresholds and FPRs   
MinSpaceUsed  $\leftarrow \infty$ $t_\mathrm{best}\gets$  None   
 $f_{\mathrm{best}}\gets$  None   
for  $j = k\dots N$ $\pmb {t}\gets$  THRESMAXDIVDP  $(g,h,j,k)$ $\pmb {f}\gets$  OPTIMALFPR  $(g,h,t,F,k)$  if MinSpaceUsed  $>$  SPACEUSED  $(g,h,t,\pmb {f})$  then MinSpaceUsed  $\leftarrow$  SPACEUSED  $(g,h,t,\pmb {f})$ $t_\mathrm{best}\gets t$ $f_{\mathrm{best}}\gets f$    
return  $t_\mathrm{best},f_\mathrm{best}$
Appendix B Algorithm details
In this appendix, we explain the algorithms for PLBF and the proposed method using pseudo-code in detail. This will help to clarify how each method differs from the others.
First, we show the PLBF algorithm in Algorithm 1. For details of OPTIMALFPR and SPACEUSED, please refer to Appendix B and Equation (2) in the original PLBF paper [14], respectively. The worst case time complexities of OPTIMALFPR and SPACEUSED are  $\mathcal{O}(k^2)$  and  $\mathcal{O}(k)$ , respectively. As the DP table is constructed with a time complexity of  $\mathcal{O}(j^2 k)$  for each  $j = k\ldots N$ , the overall complexity is  $\mathcal{O}(N^3 k)$ .
Next, we show the fast PLBF algorithm in Algorithm 2. The time complexity of building  $\mathrm{DP}_{\mathrm{KL}}^N$  is  $\mathcal{O}(N^2 k)$ , and the worst-case complexity of subsequent computations is  $\mathcal{O}(Nk^2)$ . Because  $N > k$ , the total complexity is  $\mathcal{O}(N^2 k)$ , which is faster than  $\mathcal{O}(N^3 k)$  for PLBF, although fast PLBF constructs the same data structure as PLBF.
Finally, we describe the fast PLBF++ algorithm. The fast PLBF++ algorithm is nearly identical to fast PLBF, but it calculates approximated  $\mathrm{DP}_{\mathrm{KL}}^{N}$  with a computational complexity of  $\mathcal{O}(Nk\log N)$ . Since the remaining calculations are unchanged from fast PLBF, the overall computational complexity is  $\mathcal{O}(Nk\log N + Nk^2)$ .
Appendix C Proof of Theorem 4.3
In this appendix, we present a proof of Theorem 4.3. It demonstrates that fast PLBF++ can attain the same accuracy as PLBF and fast PLBF under certain conditions.
The following lemma holds.
Algorithm 2 Fast PLBF
Algorithm: MAXDIVDP  $(g,h,N,k)$  constructs  $\mathrm{DP}_{\mathrm{KL}}^N$  THRESMAXDIV  $(\mathrm{DP}_{\mathrm{KL}}^{N},j,k)$  calculates the optimal thresholds by tracing the transitions backward from  $\mathrm{DP}_{\mathrm{KL}}^N [j - 1][k - 1]$  MinSpaceUsed  $\leftarrow \infty$ $t_\mathrm{best}\gets \mathrm{None}$ $f_{\mathrm{best}}\gets \mathrm{None}$ $\mathrm{DP}_{\mathrm{KL}}^N\gets \mathrm{MAXDIVD}(\mathbf{g},\mathbf{h},N,k)$    
for  $j = k\dots N$ $t\gets \mathrm{THRESMAXDIV}(\mathrm{DP}_{\mathrm{KL}}^N,j,k)$ $f\gets \mathrm{OPTIMALFPR}(g,h,t,F,k)$    
if MinSpaceUsed  $>$  SPACEUSED  $(g,h,t,f)$  then MinSpaceUsed  $\leftarrow$  SPACEUSED  $(g,h,t,f)$ $t_\mathrm{best}\gets t$ $f_{\mathrm{best}}\gets f$    
return  $t_\mathrm{best},f_\mathrm{best}$
Lemma C.1. Let  $u_{1}, u_{2}, v_{1}$ , and  $v_{2}$  be real numbers satisfying
$$
0 <   u _ {1} <   u _ {2} \tag {22}
$$
$$
0 <   v _ {1} <   v _ {2} \tag {23}
$$
$$
\frac {u _ {1}}{v _ {1}} \geq \frac {u _ {2}}{v _ {2}}. \tag {24}
$$
Furthermore, we define the function  $D(x,y)$  for real numbers  $x > 0$  and  $y > 0$  as follows:
$$
D (x, y) = \left\{\left(u _ {1} + x\right) \log_ {2} \left(\frac {u _ {1} + x}{v _ {1} + y}\right) - u _ {1} \log_ {2} \left(\frac {u _ {1}}{v _ {1}}\right) \right\} - \left\{\left(u _ {2} + x\right) \log_ {2} \left(\frac {u _ {2} + x}{v _ {2} + y}\right) - u _ {2} \log_ {2} \left(\frac {u _ {2}}{v _ {2}}\right) \right\}. \tag {25}
$$
If  $\frac{x}{y} \geq \frac{u_1}{v_1}$  holds, then  $D(x,y) \geq 0$ .
$$
\frac {\partial D}{\partial x} = \log_ {2} \left(\frac {u _ {1} + x}{v _ {1} + y}\right) - \log_ {2} \left(\frac {u _ {2} + x}{v _ {2} + y}\right) \tag {26}
$$
$$
\frac {\partial D}{\partial y} = - \frac {u _ {1} + x}{v _ {1} + y} + \frac {u _ {2} + x}{v _ {2} + y}. \tag {27}
$$
From Equations (22, 23, 24), when  $0 < x, 0 < y$ , and  $\frac{x}{y} \geq \frac{u_1}{v_1}$ , we obtain
$$
\frac {u _ {1} + x}{v _ {1} + y} \geq \frac {u _ {2} + x}{v _ {2} + y}. \tag {28}
$$
$$
\frac {\partial D}{\partial x} \geq 0 \tag {29}
$$
$$
\frac {\partial D}{\partial y} \leq 0. \tag {30}
$$