Usage of AI AI tools assisted with drafting, editing, proofreading, background research, proposing some technical arguments in discussions with the authors (in particular the lower bound of Theorem 5.1), and reviewing the ideas and proofs, including checks for gaps, missing assumptions, edge cases and counterexamples, and suggestions for simpler proofs. The authors retain full responsibility for the final manuscript.
Introduction
We study the standard question of deciding whether an input word w w w belongs to a fixed regular language T T T . The task is well-known to admit a linear-time algorithm, by feeding w w w to an automaton representing T T T . Further, this bound is generally optimal if we must read the entire input w w w . However, in settings where w w w is stored in an array and we can examine any cell in constant time, then there are cases where we can decide membership more efficiently. For instance, with the target language T = Σ ∗ a T = \Sigma^*a T = Σ ∗ a , we can decide membership in constant time, simply by examining the last cell. Likewise, for the language T = a ( Σ Σ ) ∗ b ∣ c ( Σ Σ ) ∗ Σ d T = a(\Sigma\Sigma)^*b \mid c(\Sigma\Sigma)^*\Sigma d T = a ( ΣΣ ) ∗ b ∣ c ( ΣΣ ) ∗ Σ d , we can decide membership simply by examining the first and last letter of the word, if we assume that the length of the word (and hence its parity) is known in advance. Thus, there are regular languages for which we can solve membership with just O ( 1 ) O(1) O ( 1 ) queries. A characterization of such languages is given in [1 ] 1 , together with a proof that all other regular languages require linear query complexity, i.e., Θ ( n ) \Theta(n) Θ ( n ) queries on a word of length n n n .
However, in some cases we may be able to test membership to such languages more efficiently if we can leverage some hypotheses on the word w w w . For instance, we may already know that w w w is a valid Unicode string; or more generally we may have been given the information that w w w belongs to some language and want to test membership to another. This motivates us to study regular membership posed as a promise problem [14 ] , which we dub conditional membership . Specifically, we fix a target language T T T together with a promise language P P P , we are given a word w w w which is promised to lie in P P P , and we wish to determine whether w w w belongs to T T T (the algorithm can return an arbitrary answer if we try to run it on a word outside of P P P ).
To our knowledge, this natural conditional membership problem has not been studied for regular languages, despite its proximity to many similar questions. The one exception is the conclusion of [1 ] which mentions it as an open problem, and already highlights an intriguing phenomenon: with the target language T 0 : = ( Σ Σ ) ∗ ( 01 ) Σ ∗ T_0 := (\Sigma\Sigma)^*(01)\Sigma^* T 0 := ( ΣΣ ) ∗ ( 01 ) Σ ∗ asking for an occurrence of 01 01 01 at an odd position, and the language P 0 : = 0 ∗ 1 ∗ P_0 := 0^*1^* P 0 := 0 ∗ 1 ∗ asserting that the input is sorted, they notice that we can decide membership to T 0 T_0 T 0 conditional to P 0 P_0 P 0 using binary search, i.e., with an intermediate regime of O ( log n ) O(\log n) O ( log n ) queries. This seems not to have been investigated further since 2019, leaving open the question of whether other regimes are possible (beyond constant, logarithmic, and linear), and how to characterize the language pairs that achieve them.
Contributions. In this paper, we give an effective trichotomy on the query complexity of conditional membership for arbitrary pairs of a regular target language T T T and a regular promise language P P P . We assume for simplicity that T ⊆ P T \subseteq P T ⊆ P throughout, we assume that the length n n n of the input word w w w is known in advance, and we consider the model where w w w can be accessed by queries that determine the i i i -th letter w i w_i w i for each 1 ≤ i ≤ n 1 \le i \le n 1 ≤ i ≤ n (i.e., random-access to the cells of an array that stores w w w ). We study the worst-case query complexity , i.e., the complexity for length n n n is the minimum height of a decision tree that correctly classifies membership to T T T on input words of length n n n that belong to P P P . To avoid periodic phenomena, we regularize the complexity by making it monotone, i.e., we study the asymptotic regime as n n n grows of the query complexity obtained by taking the maximum optimal decision tree height across all lengths 0 ≤ n ′ ≤ n 0 \le n' \le n 0 ≤ n ′ ≤ n .
Our trichotomy result is then the following, with the three cases exemplified in Table 1 :
Table 1. Examples of conditional membership problems.
Theorem 1.1. For any fixed regular language pair T ⊆ P T \subseteq P T ⊆ P , the query complexity of conditional membership to T T T assuming P P P follows one of three regimes:
Constant , i.e., O ( 1 ) O(1) O ( 1 ) queries
Logarithmic , i.e., Θ ( log n ) \Theta(\log n) Θ ( log n ) queries
Linear , i.e., Θ ( n ) \Theta(n) Θ ( n ) queries
Further, the trichotomy criterion is effective: given nondeterministic automata A P A_P A P and A T A_T A T that accept P P P and T T T respectively, it is PSPACE-complete to decide which case applies.
To prove this result, we use the framework of algebraic automata theory. Specifically, the characterization is based on a so-called mutual presentation of P P P and T T T , i.e., an arbitrary finite monoid M M M that recognizes them both. Because the regime only depends on the choice of language pair, any choice of mutual presentation will give the same regime. The main challenge that we face is that conditional membership is a promise problem parameterized not by a single language, but by a language pair . For this reason, usual tools such as language varieties are not immediately applicable, and new methods are needed: the present paper can also be seen as first steps towards the development of such algebraic techniques in a new context, which may be relevant beyond the specific problem that we study.
At a high level, our proof proceeds by defining two tolerances on the mutual presentation M M M : tolerances are similar to congruences on monoids but forego the transitivity requirement [25 ] . The tolerances intuitively relate pairs of elements that may be hard to distinguish, i.e., which would require at least some asymptotic number of queries to be told apart. The first tolerance is the guard tolerance which relates pairs of the form ( e x f , e y f ) (exf, eyf) ( e x f , ey f ) , where e e e and f f f are two idempotents with nonempty preimages and where x x x and y y y are two elements with equal-length preimages. The matched-guard tolerance is a refinement of this relation obtained by relating pairs of the form ( e x e , e y e ) (exe, eye) ( e x e , ey e ) with one common surrounding idempotent e e e (still having a nonempty preimage), and with different preimage length requirements. We are interested in whether these tolerances shatter the promise-target pair, i.e., whether they relate two elements whose preimages are in P P P but where one of them has preimages in T T T and the other does not. Intuitively, when a tolerance is not shattered, then it justifies that a conditional membership algorithm can safely avoid querying some parts of the word. And whenever a tolerance is shattered, then the witnessing pair can be used to design a lower bound justifying that some number of queries is necessary to distinguish between the two elements (i.e., to locate the equal-length middle part that can achieve either x x x or y y y depending on its contents, and which may be “hidden” in a long sequence of idempotent factors).
Our specific technical upper bounds are then the following. First, when the guard tolerance is not shattered, we show that the language pair has constant query complexity. This is not too difficult and is simply done by querying a constant-length prefix and suffix of the input word, similarly to the constant query complexity case of regular language membership without a promise. Second, when the matched-guard tolerance is not shattered, we show the language pair has query complexity O ( log n ) O(\log n) O ( log n ) . The idea for this upper bound is a binary search, similar to the example from [1 ] mentioned earlier, but made much more complicated by the fact that we need to perform constantly many binary searches with some elements playing different roles in different parts of the word. In both upper bounds, we rely on the fact that sufficiently long word infixes are guaranteed to contain idempotent factors as a consequence of Ramsey’s theorem (see [19 Section 1.2] ), so we always query word blocks that are long enough to contain idempotents (to be used for pairs in our tolerances).
As for lower bounds, our methodology is the same for both: when one of the tolerances shatters the promise-target pair P , T P,T P , T , we use a shattering pair in the tolerance as a building block to design a reduction. We always reduce from two concrete promise-target pairs, given as the two bottom rows of Table 1 . The first one, with T = a ∗ c b ∗ T = a^*cb^* T = a ∗ c b ∗ and P = a ∗ ( c ∣ d ) b ∗ P = a^*(c|d)b^* P = a ∗ ( c ∣ d ) b ∗ , has a logarithmic query complexity lower bound, intuitively because we must locate the middle part. The second one, with T = a ∗ c ∗ a ∗ T = a^*c^*a^* T = a ∗ c ∗ a ∗ and P = a ∗ ( c ∣ d ) a ∗ P = a^*(c|d)a^* P = a ∗ ( c ∣ d ) a ∗ , has a linear lower bound. To reduce from these languages, we design general-purpose algebraic lemmas showing that intractability is intuitively preserved under some operations: moving to a more specific promise-target specification, taking quotients, taking inverse image by length-multiplying morphisms, and performing a form of concatenation.
We last show that all our algebraic techniques can be applied in polynomial time on the mutual presentation of the languages, so that the trichotomy criterion can be decided in PSPACE given automata representing the promise and target languages, going via an implicit representation of the mutual presentation; and show PSPACE-hardness of telling constant and linear languages apart. We next review some related work, and give the outline of the paper.
Related work. Our result uses algebraic automata theory, which is a common methodology to classify the complexity of problems parameterized by regular languages, provided that the tractable or intractable cases are closed under some algebraic operations (e.g., form a variety). Examples of the methodology include [5 ] (for circuit complexity), [28 ] (for communication complexity ), [3 ] (for dynamic membership ), [20 ] (for trail queries on graph databases ), [12 ] (for sliding window membership ) and [4 ] (for out-of-order membership ). However, in all these works, the studied problem is parameterized by one single language, unlike ours. We also note that our work classifies arbitrary regular language pairs and not monoids, i.e., we do not assume the presence of a neutral letter : this is achieved by some of the works above [3 , 20 , 12 ] but not others [28 , 4 ] .
Other works have investigated the complexity of membership to regular languages in the so-called property testing model. This is somewhat reminiscent of our promise problem: the access model is the same, and the tester must accept for words in the target and reject words that are ϵ \epsilon ϵ -far from the target; otherwise the tester can answer arbitrarily. This problem was introduced in [2 ] , with recent work showing a trichotomy on the query complexity of property testing depending on the target language [6 ] . However, they do not cover our setting where the target and promise language are arbitrary regular languages (rather than being defined in terms of the distance to a single language).
Our problem is also reminiscent of the question of regular language separation [24 ] : given two disjoint languages, the objective is to find a separator (often in a restricted language class) that accepts the first and rejects the second. However, the goal of finding a separator is different from our task of efficient conditional membership testing. Furthermore, conditional membership does not boil down to simply rewriting the promise language P P P and target language T T T to a single separator regular language T ′ T' T ′ on which to test membership (unconditionally). Indeed, if this were the case, then conditional membership would only admit constant and linear complexity regimes, but the example of [1 ] already shows that conditional membership also has a logarithmic regime.
One setting in which conditional membership for regular languages has been significantly studied is through the lens of state complexity , i.e., determining the minimum number of states needed in an automaton that must separate one language from another [13 ] . The best known instance of this setting is perhaps the separating words problem [15 ] , where the two languages to be separated are singleton languages. This relates to works that have investigated three-valued automata variants (which may accept, reject, or return a “don’t know” answer) in the context of verification: these are called separating DFAs in [9 ] and 3DFAs in [10 ] . In all these works, however, the focus is on optimizing the state complexity of separating automata, unlike our work which focuses on query complexity and is independent of the representation of the languages.
Perhaps the most closely related work to ours is the work of Moshkov [21 ] . He fixes a promise language P P P , and studies the following problem: given an unknown word w w w which is promised to belong to P P P , study how many queries are needed to determine w w w exactly in the worst case. His work also shows a trichotomy on P P P with three different regimes (constant, logarithmic, and linear), with a criterion defined in terms of an automaton for P P P . While the problems are different, the upper bounds of [21 ] transfer to our setting in the following sense: whenever a promise language P P P enjoys a sublinear upper bound thanks to [21 ] , then conditional membership for any target language T T T relative to P P P enjoys the same upper bound. This is because determining w w w exactly is sufficient to determine whether w w w belongs to any target language. However, we are not aware of a reduction in the other direction, because the focus of [21 ] is on (non-fixed) single-word target languages. Further, and more importantly, the classification of [21 ] only applies to the promise language, whereas our result characterizes the complexity of conditional membership as a function of both languages.
Paper outline. We give prerequisites, formally define our problem, and state our main result in Section 2. The proof then spans Sections 3 and 4. In Section 3, we define the guard tolerance , show the constant upper bound when the guard tolerance is not shattering, and show the logarithmic lower bound when it is shattering. In Section 4, we define the matched-guard tolerance , show the logarithmic upper bound when the matched-guard tolerance is not shattering, and show the linear lower bound when it is shattering. Last, in Section 5, we show that the trichotomy criterion is effective, by giving our PSPACE-completeness result. We conclude and propose future work directions in Section 6. For lack of space, most detailed proofs are deferred to the appendix.
Preliminaries and Main Result
Write N = { 0 , 1 , 2 , … } \mathbb{N} = \{0,1,2,\ldots\} N = { 0 , 1 , 2 , … } , N + : = N ∖ { 0 } \mathbb{N}_+ := \mathbb{N} \setminus\{0\} N + := N ∖ { 0 } , and [ n ] = { 1 , … , n } [n] = \{1,\ldots,n\} [ n ] = { 1 , … , n } for n ∈ N n \in\mathbb{N} n ∈ N , with [ 0 ] = ∅ [0] = \varnothing [ 0 ] = ∅ . All logarithms are base two unless otherwise specified. We assume the finite alphabet Σ \Sigma Σ has at least two letters, because for ∣ Σ ∣ = 1 |\Sigma| = 1 ∣Σ∣ = 1 knowing the length suffices to determine the word without making queries. Write Σ ∗ \Sigma^* Σ ∗ for all words over Σ \Sigma Σ , ε \varepsilon ε for the empty word, Σ + : = Σ ∗ ∖ { ε } \Sigma^+ := \Sigma^* \setminus\{\varepsilon\} Σ + := Σ ∗ ∖ { ε } , Σ n \Sigma^n Σ n for words of length n ∈ N n \in\mathbb{N} n ∈ N . For w ∈ Σ n w \in\Sigma^n w ∈ Σ n , its length is ∣ w ∣ = n |w| = n ∣ w ∣ = n , and w i ∈ Σ w_i \in\Sigma w i ∈ Σ denotes its letter at position i ∈ [ n ] i \in[n] i ∈ [ n ] .
We use the usual definitions and notation for regular languages , regular expressions , union, concatenation, and Kleene star as in [18 ] . For u ∈ Σ ∗ u \in\Sigma^* u ∈ Σ ∗ , we write u + = u u ∗ u^+ = uu^* u + = u u ∗ . For L ⊆ Σ ∗ L \subseteq\Sigma^* L ⊆ Σ ∗ and u , v ∈ Σ ∗ u,v \in\Sigma^* u , v ∈ Σ ∗ , the quotient u − 1 L v − 1 u^{-1}Lv^{-1} u − 1 L v − 1 is { w ∈ Σ ∗ ∣ u w v ∈ L } \{w \in\Sigma^* \mid uwv \in L\} { w ∈ Σ ∗ ∣ u w v ∈ L } .
Our conditional membership problem will be defined by two regular languages T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , with promise P P P and target T T T . The unknown promised word w w w belongs to P P P , its length n : = ∣ w ∣ n := |w| n := ∣ w ∣ is known, and its target value is 1 if w ∈ T w \in T w ∈ T and 0 otherwise: we will have to determine it by making letter queries , where a query at i ∈ [ n ] i \in[n] i ∈ [ n ] reveals the letter w i w_i w i . We will introduce decision trees to formally define solutions to this problem and thus to measure complexity.
Decision trees and partial words. For n ∈ N n \in\mathbb{N} n ∈ N a word length, a decision tree T \mathcal{T} T is a finite rooted tree whose internal nodes are labeled by positions in [ n ] [n] [ n ] and have one child edge per letter in Σ \Sigma Σ , and whose leaves are labeled 0 or 1. We require that any two distinct internal nodes on the same root-to-leaf path have different position labels. Thus, on every root-to-leaf path (called a branch ), no position is queried twice. The semantics of T \mathcal{T} T is that it maps every input word w ∈ Σ n w \in\Sigma^n w ∈ Σ n to a value in { 0 , 1 } \{0,1\} { 0 , 1 } obtained by following a branch defined as follows: we start at the root, whenever we reach a node labeled i i i then we query w i w_i w i and follow the child edge labeled with the letter w i ∈ Σ w_i \in\Sigma w i ∈ Σ that we receive; and we eventually reach a leaf whose label is in { 0 , 1 } \{0,1\} { 0 , 1 } . We say that T \mathcal{T} T accepts w w w if the label is 1, and that it rejects w w w if the label is 0. We say that T \mathcal{T} T is correct for ( P , T ) (P,T) ( P , T ) at length n n n if the language L L L of the words that it accepts is such that ( L ∩ P ) ∩ Σ n = T ∩ Σ n (L \cap P) \cap\Sigma^n = T \cap\Sigma^n ( L ∩ P ) ∩ Σ n = T ∩ Σ n , i.e., the tree must accept the words of T T T and reject the words of P ∖ T P \setminus T P ∖ T ; the answer for words outside of P P P is unrestricted. We simply call T \mathcal{T} T correct and omit the pair ( P , T ) (P,T) ( P , T ) and the length n n n when clear from context.
The depth of T \mathcal{T} T is the maximum number of queries that can be made on a branch; the depth of a node d d d is the number of queries made before reaching d d d . Note that in particular, for n = 0 n = 0 n = 0 , the tree must always consist of a single leaf at depth zero. The query complexity Q P , T : N → N Q_{P,T} : \mathbb{N} \to\mathbb{N} Q P , T : N → N at n n n is the maximum across all lengths 0 ≤ k ≤ n 0 \leq k \leq n 0 ≤ k ≤ n of the minimum depth of a correct decision tree at length k k k . The reason why we take the maximum over 0 ≤ k ≤ n 0 \leq k \leq n 0 ≤ k ≤ n is to make the function nondecreasing: this regularization avoids periodic phenomena that would complicate the study of asymptotic complexity (e.g., if P P P contains no words of even length, then a correct decision tree of depth 0 exists at every even length). Of course, we always have Q P , T ( n ) ≤ n Q_{P,T}(n) \leq n Q P , T ( n ) ≤ n , as witnessed by the tree that always queries every position (i.e., every branch has length n n n and nodes at depth i i i are labeled by position i + 1 i+1 i + 1 for each $0 \leq i < n). Note that our definitions focus on depth, not tree size (see [7 ] for a broader landscape of complexity measures).
Throughout the paper, we will study the semantics of decision trees in terms of the partial words specified by their branches. Fix a fresh symbol □ ∉ Σ \square\notin\Sigma □ ∈ / Σ . For n ∈ N n \in\mathbb{N} n ∈ N , a partial word of length n n n is a word w ∈ ( Σ ∪ { □ } ) n w \in(\Sigma\cup\{\square\})^n w ∈ ( Σ ∪ { □ } ) n . A completion of w w w is a word of Σ n \Sigma^n Σ n obtained by replacing every □ \square □ of w w w with a letter of Σ \Sigma Σ . The transcript of a node d d d in a decision tree T T T is the partial word containing the answers to queries along the path from the root of T T T to d d d (not including the query that labels d d d ), and □ \square □ elsewhere. Note that T T T reaches node d d d while reading a word w ∈ Σ n w \in\Sigma^n w ∈ Σ n precisely when w w w is a completion of the transcript of d d d . We say that a partial word w w w shatters ( P , T ) (P,T) ( P , T ) if w w w has two completions u , v ∈ Σ n u,v \in\Sigma^n u , v ∈ Σ n forming a shattered pair: one lies in T T T and the other in P ∖ T P \setminus T P ∖ T . The following easy lemma shows that we can in fact define the correctness of trees simply via shattered pairs:
Lemma 2.1. If a decision tree T T T for words of length n ∈ N n \in\mathbb{N} n ∈ N is correct for ( P , T ) (P,T) ( P , T ) at length n n n , then for any leaf ℓ \ell ℓ of T T T the transcript of ℓ \ell ℓ does not shatter ( P , T ) (P,T) ( P , T ) . Conversely, if a decision tree T T T ensures that all its leaves have a transcript that does not shatter ( P , T ) (P,T) ( P , T ) , then we can make T T T correct for ( P , T ) (P,T) ( P , T ) at length n n n by assigning labels to its leaves.
Thus, in subsequent constructions that define decision trees, we can always leave the leaf labels of the tree unspecified: by Lemma 2.1, it suffices to show that no leaf transcript shatters ( P , T ) (P,T) ( P , T ) to show that the leaves can be labeled to make the tree correct.
Algebraic prerequisites. We use semigroups, monoids, monoid morphisms, identity elements, idempotents, subsemigroups, submonoids, direct products, and generated submonoids [27 Section 1.1] . All semigroups and monoids considered in this paper are finite; we omit the qualifier “finite” from now on. For M M M a monoid, we write 1 M 1_M 1 M for its identity, so 1 M x = x 1 M = x 1_Mx = x1_M = x 1 M x = x 1 M = x for x ∈ M x \in M x ∈ M . A zero of M M M is an element 0 M ∈ M 0_M \in M 0 M ∈ M such that 0 M x = x 0 M = 0 M 0_Mx = x0_M = 0_M 0 M x = x 0 M = 0 M for all x ∈ M x \in M x ∈ M . For r ∈ N r \in\mathbb{N} r ∈ N , we write x r x^r x r for the r r r -fold product, with x 0 = 1 M x^0 = 1_M x 0 = 1 M . We define the diagonal relation of M M M to be Δ M : = { ( x , x ) ∣ x ∈ M } \Delta_M := \{(x,x) \mid x \in M\} Δ M := {( x , x ) ∣ x ∈ M } , and its elements are called diagonal pairs . For a semigroup S S S , let Idem ( S ) : = { e ∈ S : e 2 = e } \operatorname{Idem}(S) := \{e \in S : e^2 = e\} Idem ( S ) := { e ∈ S : e 2 = e } be the set of idempotent elements of S S S . For S S S a semigroup, an idempotent power ω \omega ω is an integer in N + \mathbb{N}_+ N + such that x ω x^\omega x ω is idempotent for every x ∈ S x \in S x ∈ S ; for instance ω = ∣ S ∣ ! \omega= |S|! ω = ∣ S ∣ ! [27 Remark 1.3] .
For a morphism η : Σ ∗ → M \eta: \Sigma^* \to M η : Σ ∗ → M , we say that η \eta η recognizes L ⊆ Σ ∗ L \subseteq\Sigma^* L ⊆ Σ ∗ if L = η − 1 ( F ) L = \eta^{-1}(F) L = η − 1 ( F ) for some F ⊆ M F \subseteq M F ⊆ M . A language is regular if and only if it is recognized by a surjective morphism into a monoid [22 Chapter 1, Sections 2.2 and 2.4] .
When considering morphisms to a monoid, we know by Ramsey’s theorem that every sufficiently long word contains a nonempty contiguous factor whose morphic image is idempotent [19 Section 1.2] :
Lemma 2.2 ([19 ] ). Let η : Σ ∗ → M \eta: \Sigma^* \to M η : Σ ∗ → M be a morphism to a monoid of size m m m . There exists q ∈ N + q \in\mathbb{N}_+ q ∈ N + , depending only on m m m , such that every w ∈ Σ ∗ w \in\Sigma^* w ∈ Σ ∗ with ∣ w ∣ ≥ q |w| \ge q ∣ w ∣ ≥ q admits a factorization w = x z u w = xzu w = x z u with u , v ∈ Σ ∗ u,v \in\Sigma^* u , v ∈ Σ ∗ and z ∈ Σ + z \in\Sigma^+ z ∈ Σ + such that η ( z ) \eta(z) η ( z ) is idempotent.
We will also rely on the fact that, for a surjective morphism η : Σ ∗ → M \eta: \Sigma^* \to M η : Σ ∗ → M , every element of M M M has a preimage of length strictly less than ∣ M ∣ |M| ∣ M ∣ :
Lemma 2.3. Let η : Σ ∗ → M \eta: \Sigma^* \to M η : Σ ∗ → M be a surjective morphism to a monoid of size m m m . For every s ∈ M s \in M s ∈ M , there is a preimage w ∈ Σ ∗ w \in\Sigma^* w ∈ Σ ∗ such that η ( w ) = s \eta(w) = s η ( w ) = s and ∣ w ∣ < m |w| < m ∣ w ∣ < m .
Algebraic tools for conditional membership. As we work with a language pair T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , we introduce the following definition that we use throughout the paper:
Definition 2.4 (Mutual presentation). A mutual presentation of T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ consists of a surjective morphism η : Σ ∗ → M \eta: \Sigma^* \to M η : Σ ∗ → M into a monoid M M M , and subsets M T ⊆ M P ⊆ M M_T \subseteq M_P \subseteq M M T ⊆ M P ⊆ M such that P = η − 1 ( M P ) P = \eta^{-1}(M_P) P = η − 1 ( M P ) and T = η − 1 ( M T ) T = \eta^{-1}(M_T) T = η − 1 ( M T ) . We write it as ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) .
Such a presentation always exists: given morphisms η P : Σ ∗ → N P \eta_P : \Sigma^* \to N_P η P : Σ ∗ → N P and η T : Σ ∗ → N T \eta_T : \Sigma^* \to N_T η T : Σ ∗ → N T recognizing P P P and T T T , respectively, where N P , N T N_P,N_T N P , N T are monoids, we combine them into the morphism η : Σ ∗ → N P × N T \eta: \Sigma^* \to N_P \times N_T η : Σ ∗ → N P × N T to the direct product of the monoids N P N_P N P and N T N_T N T by mapping w ∈ Σ ∗ w \in\Sigma^* w ∈ Σ ∗ to ( η P ( w ) , η T ( w ) ) (\eta_P(w),\eta_T(w)) ( η P ( w ) , η T ( w )) , and then restrict the codomain of η \eta η to its image to ensure that η \eta η is surjective.
Our criteria for conditional membership will be phrased using tolerances . This is a standard notion [25 ] which is the analogue of congruences but without requiring transitivity:
Definition 2.5 (Tolerance). A tolerance on a semigroup S S S is a reflexive and symmetric relation R ⊆ S × S R \subseteq S \times S R ⊆ S × S that is compatible with multiplication: ( x , y ) , ( x ′ , y ′ ) ∈ R (x,y),(x',y') \in R ( x , y ) , ( x ′ , y ′ ) ∈ R implies ( x x ′ , y y ′ ) ∈ R (xx',yy') \in R ( x x ′ , y y ′ ) ∈ R . For a monoid M M M , the tolerance closure of V ⊆ M × M V \subseteq M \times M V ⊆ M × M is the least tolerance on M M M containing V V V .
Equivalently, the tolerance closure of V V V is the submonoid V 2 V_2 V 2 of M × M M \times M M × M generated by the pairs of V V V , the converse pairs { ( y , x ) ∣ ( x , y ) ∈ V } \{(y,x) \mid(x,y) \in V\} {( y , x ) ∣ ( x , y ) ∈ V } , and the diagonal pairs. Indeed, V 2 V_2 V 2 is a tolerance that contains V V V and that must be contained in every tolerance that contains V V V . Seeing the generating pairs as letters, the coordinatewise product defines a surjective monoid morphism from the free monoid on these letters onto V 2 V_2 V 2 . By Lemma 2.3, every pair in the tolerance closure is a product of fewer than ∣ M ∣ 2 |M|^2 ∣ M ∣ 2 generators, since V 2 V_2 V 2 has at most ∣ M ∣ 2 |M|^2 ∣ M ∣ 2 elements.
When considering tolerances, we will want to know if they shatter the sets ( M P , M T ) (M_P,M_T) ( M P , M T ) :
Definition 2.6. For M T ⊆ M P ⊆ M M_T \subseteq M_P \subseteq M M T ⊆ M P ⊆ M , a pair ( p , q ) ∈ M × M (p,q) \in M \times M ( p , q ) ∈ M × M is a shattered pair for ( M P , M T ) (M_P,M_T) ( M P , M T ) if one of p , q p,q p , q belongs to M T M_T M T and the other belongs to M P ∖ M T M_P \setminus M_T M P ∖ M T . A relation R ⊆ M × M R \subseteq M \times M R ⊆ M × M shatters ( M P , M T ) (M_P,M_T) ( M P , M T ) if it contains a shattered pair for ( M P , M T ) (M_P,M_T) ( M P , M T ) .
Result statement: Our main result in this paper is then the following trichotomy, which hinges on tolerances τ g \tau_g τ g and τ m g \tau_{mg} τ m g that will be defined in the next sections:
Theorem 2.7. Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ be regular languages, and let ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) be any mutual presentation of T T T and P P P . We can compute tolerances τ g \tau_g τ g and τ m g \tau_{mg} τ m g on M M M such that τ m g ⊆ τ g \tau_{mg} \subseteq\tau_g τ m g ⊆ τ g and such that exactly one of the following three cases occurs:
(1) constant regime. The tolerance τ g \tau_g τ g does not shatter ( M P , M T ) (M_P,M_T) ( M P , M T ) , and Q P , T ( n ) = O ( 1 ) Q_{P,T}(n) = O(1) Q P , T ( n ) = O ( 1 ) .
(2) logarithmic regime. The tolerance τ g \tau_g τ g shatters ( M P , M T ) (M_P,M_T) ( M P , M T ) , but the tolerance τ m g \tau_{mg} τ m g does not shatter ( M P , M T ) (M_P,M_T) ( M P , M T ) , and Q P , T ( n ) = Θ ( log n ) Q_{P,T}(n) = \Theta(\log n) Q P , T ( n ) = Θ ( log n ) .
(3) linear regime. The tolerance τ m g \tau_{mg} τ m g shatters ( M P , M T ) (M_P,M_T) ( M P , M T ) , and Q P , T ( n ) = Θ ( n ) Q_{P,T}(n) = \Theta(n) Q P , T ( n ) = Θ ( n ) .
We prove Theorem 2.7 in Sections 3 and 4, before discussing the effectiveness of the trichotomy in Section 5. Section 3 constructs τ g \tau_g τ g , proves the constant upper bound (Proposition 3.6), and then proves the logarithmic lower bound (Proposition 3.10). Section 4 constructs τ m g \tau_{mg} τ m g , proves the logarithmic upper bound (Proposition 4.4), then the linear lower bound (Proposition 4.18). Note that the classification is an intrinsic property of the language so it is independent of the chosen mutual presentation, even if the tolerances depend on our choice of presentation.
Throughout the proof in Sections 3 and 4, for notational convenience, we fix the alphabet Σ \Sigma Σ and the regular languages T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ with a mutual presentation ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) , and write m : = ∣ M ∣ m := |M| m := ∣ M ∣ . We abuse notation by omitting the pairs ( M P , M T ) (M_P,M_T) ( M P , M T ) and ( P , T ) (P,T) ( P , T ) when there is no ambiguity. Thus, we call a tolerance or a partial word shattering or non-shattering according to whether it shatters the corresponding pair. We write S η : = η ( Σ + ) S_\eta:= \eta(\Sigma^+) S η := η ( Σ + ) for the subsemigroup of images of nonempty words. Note that S η ⊆ M S_\eta\subseteq M S η ⊆ M , with equality if 1 M 1_M 1 M has a nonempty preimage by η \eta η , and S η = M ∖ { 1 M } S_\eta= M \setminus\{1_M\} S η = M ∖ { 1 M } otherwise. We will often consider the idempotents of S η S_\eta S η , and use the following elementary result:
Lemma 2.8. There exists a fixed integer π ∈ N + \pi\in\mathbb{N}_+ π ∈ N + such that Idem ( S η ) = η ( Σ π ) \operatorname{Idem}(S_\eta) = \eta(\Sigma^\pi) Idem ( S η ) = η ( Σ π ) .
The Constant Regime
We start by establishing the constant/logarithmic boundary of Theorem 2.7 : the guard tolerance τ g \tau_g τ g gives a constant upper bound when non-shattering and a logarithmic lower bound when shattering. We first define τ g \tau_g τ g . Next, we prove the constant upper bound when it is non-shattering. We then introduce the contextual guard relation and prove that it equals τ g \tau_g τ g . This gives a representation of the pairs of τ g \tau_g τ g that we use to prove the logarithmic lower bound when τ g \tau_g τ g is shattering.
The Guard Tolerance
To define τ g \tau_g τ g we first need the following auxiliary relation (also used in the next section):
Definition 3.1. For each k ∈ N k \in\mathbb{N} k ∈ N , the k k k -equal-length equivalence τ k , l e n \tau_{k,\mathrm{len}} τ k , len for η \eta η is the relation η ( Σ k ) × η ( Σ k ) \eta(\Sigma^k) \times\eta(\Sigma^k) η ( Σ k ) × η ( Σ k ) . Equivalently, for x , y ∈ M x,y \in M x , y ∈ M , we write x τ k , l e n y x \mathrel{\tau_{k,\mathrm{len}}} y x τ k , len y if there are words u , v ∈ Σ k u,v \in\Sigma^k u , v ∈ Σ k with η ( u ) = x \eta(u)=x η ( u ) = x and η ( v ) = y \eta(v)=y η ( v ) = y . Note that τ k , l e n \tau_{k,\mathrm{len}} τ k , len is an equivalence relation on η ( Σ k ) \eta(\Sigma^k) η ( Σ k ) .
The equal-length relation τ l e n \tau_{\mathrm{len}} τ len for η \eta η is the union of these equivalence relations over all k ∈ N + k \in\mathbb{N}_{+} k ∈ N + . Equivalently, x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y if x x x and y y y have nonempty preimages of the same length.
We show that τ l e n \tau_{\mathrm{len}} τ len is a tolerance on S η S_\eta S η and is generated by the first m 2 m^2 m 2 lengths. It need not be a tolerance on M M M : indeed, if 1 M 1_M 1 M has no nonempty preimage by η \eta η , then the pair ( 1 M , 1 M ) (1_M,1_M) ( 1 M , 1 M ) is missing.
Lemma 3.2. The relation τ l e n \tau_{\mathrm{len}} τ len for η \eta η is a tolerance on S η S_\eta S η . Moreover, τ l e n = ⋃ i = 1 m 2 τ i , l e n \tau_{\mathrm{len}}=\bigcup_{i=1}^{m^2}\tau_{i,\mathrm{len}} τ len = ⋃ i = 1 m 2 τ i , len .
Proof sketch. The first claim is routine, and the union equality follows by Lemma 2.3.
Note that the equal-length relation need not be transitive:
Example 3.3. Consider the monoid M 0 = { 0 , 1 , a , a 2 } M_0=\{0,1,a,a^2\} M 0 = { 0 , 1 , a , a 2 } , where 1 1 1 is the identity, 0 0 0 is a zero, and a 3 = 1 a^3=1 a 3 = 1 . Let Σ = { a , z } \Sigma=\{a,z\} Σ = { a , z } and define η ( a ) : = a \eta(a):=a η ( a ) := a and η ( z ) : = 0 \eta(z):=0 η ( z ) := 0 . Then a τ 1 , l e n 0 a \mathrel{\tau_{1,\mathrm{len}}} 0 a τ 1 , len 0 , witnessed by the words a a a and z z z , and 0 τ 2 , l e n a 2 0 \mathrel{\tau_{2,\mathrm{len}}} a^2 0 τ 2 , len a 2 , witnessed by the words z z zz z z and a a aa aa . However, a a a and a 2 a^2 a 2 are not related by τ l e n \tau_{\mathrm{len}} τ len : every word with nonzero image consists entirely of a a a 's, and its image is determined by its length modulo 3. Thus τ l e n \tau_{\mathrm{len}} τ len is not transitive.
We use τ l e n \tau_{\mathrm{len}} τ len to relate equal-length factors, and define the guard relation by surrounding them by two (possibly different) idempotents with nonempty preimages, finally yielding τ g \tau_g τ g :
Definition 3.4. The guard relation R g ⊆ M × M R_g \subseteq M \times M R g ⊆ M × M consists of the pairs ( e x f , e y f ) (exf,eyf) ( e x f , ey f ) for e , f ∈ Idem ( S η ) e,f \in\operatorname{Idem}(S_\eta) e , f ∈ Idem ( S η ) and x , y ∈ M x,y \in M x , y ∈ M with x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y . We define the guard tolerance τ g \tau_g τ g as the tolerance closure of R g R_g R g .
Example 3.5. Continuing Example 3.3, let us show that the guard tolerance τ g \tau_g τ g of M 0 M_0 M 0 is not transitive, by showing that R g = τ l e n R_g=\tau_{\mathrm{len}} R g = τ len so that τ g = τ l e n \tau_g=\tau_{\mathrm{len}} τ g = τ len . Here S η = M 0 S_\eta=M_0 S η = M 0 , since even the identity has a nonempty preimage, 1 = η ( a 3 ) 1=\eta(a^3) 1 = η ( a 3 ) . In particular, 1 ∈ Idem ( S η ) 1\in\operatorname{Idem}(S_\eta) 1 ∈ Idem ( S η ) . Taking both guards to be 1 1 1 in the definition of R g R_g R g gives τ l e n ⊆ R g \tau_{\mathrm{len}}\subseteq R_g τ len ⊆ R g . Conversely, for e , f ∈ Idem ( S η ) e,f\in\operatorname{Idem}(S_\eta) e , f ∈ Idem ( S η ) and x , y ∈ M 0 x,y\in M_0 x , y ∈ M 0 with x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y , reflexivity gives e τ l e n e e \mathrel{\tau_{\mathrm{len}}} e e τ len e and f τ l e n f f \mathrel{\tau_{\mathrm{len}}} f f τ len f , and compatibility with multiplication gives e x f τ l e n e y f exf \mathrel{\tau_{\mathrm{len}}} eyf e x f τ len ey f . Thus R g ⊆ τ l e n R_g\subseteq\tau_{\mathrm{len}} R g ⊆ τ len . By Lemma 3.2, τ l e n \tau_{\mathrm{len}} τ len is already a tolerance on M 0 M_0 M 0 , so taking the tolerance closure of R g = τ l e n R_g=\tau_{\mathrm{len}} R g = τ len adds no pairs. Hence τ g = τ l e n \tau_g=\tau_{\mathrm{len}} τ g = τ len , and indeed τ g \tau_g τ g is not transitive.
Constant Upper Bound
We now show that if the guard tolerance τ g \tau_g τ g is non-shattering, then the query complexity is constant, because we can solve conditional membership by querying a prefix and a suffix of bounded length.
Proposition 3.6. If the guard tolerance τ g \tau_g τ g is non-shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in O ( 1 ) O(1) O ( 1 ) .
Proof sketch. Let q ∈ N q \in\mathbb{N} q ∈ N be the bound from Lemma 2.2. For each length n ∈ N n \in\mathbb{N} n ∈ N , the decision tree queries all letters if n ≤ 2 q n \leq2q n ≤ 2 q , and the first and last q q q letters otherwise, so it has depth at most 2 q 2q 2 q . A shattering leaf transcript would give a shattered pair of completions sharing the queried prefix s s s and suffix t t t , giving a shattered pair in τ g \tau_g τ g when taking an idempotent factor in s s s and t t t .
Example 3.7. Let Σ = { a , c , d } \Sigma=\{a,c,d\} Σ = { a , c , d } , T c o n s t = c a ∗ T_{\mathrm{const}}=ca^* T const = c a ∗ , and P c o n s t = ( c ∣ d ) a ∗ P_{\mathrm{const}}=(c\mid d)a^* P const = ( c ∣ d ) a ∗ as in Table 1 . Querying the first position decides membership in T T T conditional to P P P . To apply Proposition 3.6, we show directly that τ g \tau_g τ g is non-shattering under any mutual presentation. Each pair in the guard relation R g R_g R g has nonempty preimages sharing their first letter, since the left idempotent has a nonempty preimage. Each diagonal pair has two identical preimages. Swapping such pairs and multiplying them preserves the property that their preimages are either both empty or share their first letter, so every pair in the tolerance closure τ g \tau_g τ g of R g R_g R g has preimages that are either empty or share their first letter. If both preimages belong to P c o n s t P_{\mathrm{const}} P const , they are nonempty and their common first letter determines the same target value; hence τ g \tau_g τ g is non-shattering.
The Contextual Guard Relation
Having proved the constant upper bound when the guard tolerance τ g \tau_g τ g is non-shattering, we now turn to the logarithmic lower bound when τ g \tau_g τ g contains a shattered pair. However, it is not convenient to take the shattered pair directly from τ g \tau_g τ g , because τ g \tau_g τ g is defined only implicitly as a tolerance closure so we have no explicit description of its pairs. We will now show that the guard tolerance can be equivalently expressed in a more explicit way, called the contextual guard relation :
Definition 3.8. The contextual guard relation R c g ⊆ M × M R_{\mathrm{cg}} \subseteq M \times M R cg ⊆ M × M is defined by
R c g : = ⋃ k ∈ N + { ( ℓ e x f ρ , ℓ e y f ρ ) ∣ ℓ , ρ ∈ M , e , f ∈ Idem ( S η ) , e , f , x , y ∈ η ( Σ k ) } ∪ { ( z , z ) ∣ z ∈ M } . R_{\mathrm{cg}} := \bigcup_{k \in\mathbb{N}_{+}} \left\{(\ell e x f \rho,\ell e y f \rho) \mid\ell,\rho\in M,\ e,f \in\operatorname{Idem}(S_{\eta}),\ e,f,x,y \in\eta(\Sigma^{k})\right\} \cup\{(z,z) \mid z \in M\}. R cg := k ∈ N + ⋃ { ( ℓ e x f ρ , ℓ ey f ρ ) ∣ ℓ , ρ ∈ M , e , f ∈ Idem ( S η ) , e , f , x , y ∈ η ( Σ k ) } ∪ {( z , z ) ∣ z ∈ M } .
To understand this definition, note that the non-diagonal pairs in R c g R_{\mathrm{cg}} R cg consist of a pair ( e x f , e y f ) (e x f,e y f) ( e x f , ey f ) defined like in the guard relation R g R_g R g , with e e e , f f f idempotents with a nonempty preimage. However, there are two changes. First, we require that both idempotents and middle elements must admit preimages of the same length k ∈ N + k \in\mathbb{N}_{+} k ∈ N + , which strengthens the requirement x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y from the definition of R g R_g R g . Second, we extend the pair with an arbitrary left and right context ℓ \ell ℓ and ρ \rho ρ .
We now prove that the contextual guard relation R c g R_{\mathrm{cg}} R cg equals the guard tolerance τ g \tau_g τ g used in the constant upper bound, so we can take our shattered pair in the explicit form of the definition of R c g R_{\mathrm{cg}} R cg :
Lemma 3.9. We have τ g = R c g \tau_g = R_{\mathrm{cg}} τ g = R cg .
Proof sketch. We show that R c g ⊆ τ g R_{\mathrm{cg}} \subseteq\tau_g R cg ⊆ τ g because τ g \tau_g τ g is reflexive (so it contains the diagonal pairs) and it contains the non-diagonal pairs because we can extend the pairs of R g R_g R g (which impose weaker length requirements) with contexts ℓ \ell ℓ and ρ \rho ρ (using reflexivity of τ g \tau_g τ g and compatibility with multiplication).
Then, we show that pairs of R g R_g R g are also in R c g R_{\mathrm{cg}} R cg , even when extended with arbitrary contexts ℓ \ell ℓ and ρ \rho ρ . Here we must enforce the stronger length requirements of R c g R_{\mathrm{cg}} R cg , which we do in an auxiliary lemma where we bring the idempotents to a sufficiently high power and use conjugation to synchronize them with the middle parts (possibly up to changing the right context).
Last, we show that R c g R_{\mathrm{cg}} R cg is closed under the tolerance axioms: as we have established R g ⊆ R c g ⊆ τ g R_g \subseteq R_{\mathrm{cg}} \subseteq\tau_g R g ⊆ R cg ⊆ τ g then the minimality of the tolerance closure τ g \tau_g τ g concludes. The challenging part is to check compatibility with multiplication for two non-diagonal pairs: we can simply use the left context and idempotent of the first pair, and the right idempotent and context of the second pair.
Logarithmic Lower Bound
We now turn to the logarithmic lower bound of Theorem 2.7 , showing that a shattering guard tolerance forces at least logarithmic query complexity:
Proposition 3.10 (Logarithmic lower bound). If the guard tolerance τ g \tau_g τ g is shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
We prove this proposition in the rest of the section. We first illustrate the intuition of the proof on the specific pair of languages ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) from Table 1 . We next formally show the lower bound on ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) . Then, we show general-purpose closure properties which will also be used in the next section. This will finally allow us to lift the lower bound from ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) to the general case.
Example 3.11. Let Σ = { a , b , c , d } \Sigma= \{a,b,c,d\} Σ = { a , b , c , d } , T log : = a ∗ c b ∗ T_{\log} := a^{*}cb^{*} T l o g := a ∗ c b ∗ and P log : = a ∗ ( c ∣ d ) b ∗ P_{\log} := a^{*}(c \mid d)b^{*} P l o g := a ∗ ( c ∣ d ) b ∗ . Let ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) be any mutual presentation of this pair. Take the integer ω : = m ! \omega:= m! ω := m ! an idempotent power of M M M ; for a word u ∈ Σ ∗ u \in\Sigma^{*} u ∈ Σ ∗ , we write u ω u^{\omega} u ω to mean ω \omega ω concatenated copies of u u u . Set e : = η ( a ω ) e := \eta(a^{\omega}) e := η ( a ω ) and f : = η ( b ω ) f := \eta(b^{\omega}) f := η ( b ω ) . Then e , f ∈ Idem ( S η ) e,f \in\operatorname{Idem}(S_{\eta}) e , f ∈ Idem ( S η ) , and η ( c ) τ l e n η ( d ) \eta(c) \mathrel{\tau_{\mathrm{len}}} \eta(d) η ( c ) τ len η ( d ) because c c c and d d d have the same length. Hence the images by η \eta η of a ω c b ω a^{\omega}cb^{\omega} a ω c b ω and a ω d b ω a^{\omega}db^{\omega} a ω d b ω are related by R g R_g R g , and therefore by τ g \tau_g τ g . These two images form a shattered pair, because a ω c b ω ∈ T log a^{\omega}cb^{\omega} \in T_{\log} a ω c b ω ∈ T l o g and a ω d b ω ∈ P log ∖ T log a^{\omega}db^{\omega} \in P_{\log} \setminus T_{\log} a ω d b ω ∈ P l o g ∖ T l o g . This witnesses that τ g \tau_g τ g is shattering.
The intuition for why this example does not have constant query complexity is that the position containing c c c or d d d , which decides whether a word of P log P_{\log} P l o g belongs to T log T_{\log} T l o g , can be at an arbitrary
place in a factor of unbounded length. To see how its position can move, recall that the blocks a ω a^\omega a ω and b ω b^\omega b ω on its two sides have idempotent images e e e and f f f . Repeating one block more times and the other fewer times moves this position and keeps the total length unchanged. At the same time, idempotence ensures that the images of the two sides remain e e e and f f f . Thus, a correct decision tree must query this position to distinguish c c c from d d d , which intuitively requires at least logarithmically many bits of information on a word of linear size.
We now formalize the intuition of Example 3.11 by showing the lower bound on ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) :
Lemma 3.12 (Logarithmic lower bound). The conditional membership problem for P log = a ∗ ( c ∣ d ) b ∗ P_{\log}=a^*(c\mid d)b^* P l o g = a ∗ ( c ∣ d ) b ∗ and T log = a ∗ c b ∗ T_{\log}=a^*cb^* T l o g = a ∗ c b ∗ has query complexity at least logarithmic, that is, Q P log , T log ( n ) Q_{P_{\log},T_{\log}}(n) Q P l o g , T l o g ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
In fact the query complexity of ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) is precisely Θ ( log n ) \Theta(\log n) Θ ( log n ) , as will follow from the logarithmic upper bound of the next section. For now, let us sketch the lower bound:
Proof sketch. Fix n ∈ N + n\in\mathbb{N}_+ n ∈ N + and consider the n n n target words u i = a i c b n − i − 1 u_i=a^icb^{n-i-1} u i = a i c b n − i − 1 , for i ∈ { 0 , … , n − 1 } i\in\{0,\ldots,n-1\} i ∈ { 0 , … , n − 1 } . If two such words with different i i i reach the same leaf, its transcript cannot contain c c c . Replacing the c c c in one of these words by d d d therefore gives a completion in P log ∖ T log P_{\log}\setminus T_{\log} P l o g ∖ T l o g of the same transcript, contradicting correctness. Hence the tree has at least n n n leaves and depth at least log ∣ Σ ∣ n \log_{|\Sigma|}n log ∣Σ∣ n .
We transfer the lower bound for ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) to the general case using three reductions: inclusion (Lemma 3.13), quotients (Lemma 3.14), and inverse length-multiplying morphisms (Lemma 3.15). Each reduction constructs a decision tree of no greater depth, using a tree at an input length that is either unchanged, increased by a fixed constant, or multiplied by a fixed positive integer, respectively. We note that these reductions are reminiscent of the closure properties for varieties of regular languages [11 , 22 ] , except that in our context we are working with language pairs:
Lemma 3.13 (Inclusion). Let T 1 ⊆ P 1 ⊆ Σ ∗ T_1\subseteq P_1\subseteq\Sigma^* T 1 ⊆ P 1 ⊆ Σ ∗ and T 2 ⊆ P 2 ⊆ Σ ∗ T_2\subseteq P_2\subseteq\Sigma^* T 2 ⊆ P 2 ⊆ Σ ∗ be such that T 1 ⊆ T 2 T_1\subseteq T_2 T 1 ⊆ T 2 and P 1 ∖ T 1 ⊆ P 2 ∖ T 2 P_1\setminus T_1\subseteq P_2\setminus T_2 P 1 ∖ T 1 ⊆ P 2 ∖ T 2 . Then, for every n ∈ N n\in\mathbb{N} n ∈ N , Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) Q_{P_1,T_1}(n)\leq Q_{P_2,T_2}(n) Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) .
Proof sketch. This is simply because, at each length, a correct tree for ( P 2 , T 2 ) (P_2,T_2) ( P 2 , T 2 ) must also be correct for ( P 1 , T 1 ) (P_1,T_1) ( P 1 , T 1 ) . Indeed, intuitively, the prescribed positive and negative answers for ( P 1 , T 1 ) (P_1,T_1) ( P 1 , T 1 ) are a subset of those of ( P 2 , T 2 ) (P_2,T_2) ( P 2 , T 2 ) .
Lemma 3.14 (Quotient). Let T ⊆ P ⊆ Σ ∗ T\subseteq P\subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ and let u , v ∈ Σ ∗ u,v\in\Sigma^* u , v ∈ Σ ∗ . Then, for every n ∈ N n\in\mathbb{N} n ∈ N , we have Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) Q_{u^{-1}Pv^{-1},u^{-1}Tv^{-1}}(n)\leq Q_{P,T}(n+|u|+|v|) Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) .
Proof sketch. For an input w ∈ u − 1 P v − 1 w\in u^{-1}Pv^{-1} w ∈ u − 1 P v − 1 , simulate a correct tree for ( P , T ) (P,T) ( P , T ) on u w v uwv u w v . Queries in the fixed prefix u u u and suffix v v v are answered for free, and the others query w w w . Since w ∈ u − 1 T v − 1 w\in u^{-1}Tv^{-1} w ∈ u − 1 T v − 1 exactly when u w v ∈ T uwv\in T u w v ∈ T , this decides the quotient problem with no greater depth.
Lemma 3.15 (Inverse Im-morphism). Let T T T and Σ \Sigma Σ be finite alphabets, and let h : T ∗ → Σ ∗ h:T^*\to\Sigma^* h : T ∗ → Σ ∗ be a morphism. Assume that there exists an integer ℓ ∈ N + \ell\in\mathbb{N}_+ ℓ ∈ N + such that ∣ h ( a ) ∣ = ℓ |h(a)|=\ell ∣ h ( a ) ∣ = ℓ for every a ∈ T a\in T a ∈ T . Let T ⊆ Σ ∗ T\subseteq\Sigma^* T ⊆ Σ ∗ , and let P ′ = h − 1 ( P ) P'=h^{-1}(P) P ′ = h − 1 ( P ) and T ′ = h − 1 ( T ) T'=h^{-1}(T) T ′ = h − 1 ( T ) . Then, for every n ∈ N n\in\mathbb{N} n ∈ N , Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) Q_{P',T'}(n)\leq Q_{P,T}(\ell n) Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) .
Proof sketch. For w ∈ P ′ ∩ Γ k w\in P'\cap\Gamma^k w ∈ P ′ ∩ Γ k with k ∈ N k\in\mathbb{N} k ∈ N , simulate a correct tree for ( P , T ) (P,T) ( P , T ) on h ( w ) h(w) h ( w ) . At the first query in block h ( w i ) h(w_i) h ( w i ) for i ∈ [ k ] i\in[k] i ∈ [ k ] , query w i w_i w i and hence learn the whole block; later queries there are free. The inverse images preserve correctness, depth does not increase, and ∣ h ( w ) ∣ = ℓ ∣ w ∣ |h(w)|=\ell|w| ∣ h ( w ) ∣ = ℓ ∣ w ∣ yields the stated length scaling.
With these three reductions we can now show Proposition 3.10 from Lemma 3.12:
Proof sketch. Since τ g \tau_g τ g is shattering, Lemma 3.9 gives a shattered pair in R c g R_{c_g} R c g . Choose equal-length preimages E , F , X , Y ∈ Σ k E,F,X,Y\in\Sigma^k E , F , X , Y ∈ Σ k , for some k ∈ N + k\in\mathbb{N}_+ k ∈ N + , for its guards and middle elements. By idempotence, we can choose fixed words u , v ∈ Σ ∗ u,v\in\Sigma^* u , v ∈ Σ ∗ so that T ′ : = u E ∗ X F ∗ v ⊆ T T':=uE^*XF^*v\subseteq T T ′ := u E ∗ X F ∗ v ⊆ T and P ′ : = u E ∗ ( X ∣ Y ) F ∗ v P':=uE^*(X\mid Y)F^*v P ′ := u E ∗ ( X ∣ Y ) F ∗ v satisfies P ′ ∖ T ′ ⊆ P ∖ T P'\setminus T'\subseteq P\setminus T P ′ ∖ T ′ ⊆ P ∖ T . By inclusion (Lemma 3.13), ( P , T ) (P,T) ( P , T ) is at least as hard as ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) . We use quotients (Lemma 3.14) to remove u u u and v v v . The morphism sending a , b , c , d a,b,c,d a , b , c , d to E , F , X , Y E,F,X,Y E , F , X , Y , respectively, multiplies lengths by k k k , so we use Lemma 3.15 and use again Lemma 3.13 to transfer the logarithmic lower bound for ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) from Lemma 3.12 to ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) , and hence to ( P , T ) (P,T) ( P , T ) .
The Logarithmic Regime
We continue by establishing the logarithmic/linear boundary of Theorem 2.7 . For this, we first introduce the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg . We then prove a logarithmic upper bound when τ m g \tau_{\mathrm{mg}} τ mg is non-shattering. Next, like in the previous section, we introduce the contextual matched-guard relations as a more convenient rephrasing of τ m g \tau_{\mathrm{mg}} τ mg to show a lower bound. We conclude by showing the linear lower bound when τ m g \tau_{\mathrm{mg}} τ mg is shattering.
The Matched-Guard Tolerance
We now define the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg . It is similar to τ g \tau_{\mathrm{g}} τ g , but requires the same idempotent on both sides and imposes different length conditions:
Definition 4.1. The matched-guard relation R m g ⊆ M × M R_{\mathrm{mg}} \subseteq M \times M R mg ⊆ M × M consists of the pairs ( e x e , e y e ) (exe, eye) ( e x e , ey e ) for e ∈ Idem ( S η ) e \in\operatorname{Idem}(S_{\eta}) e ∈ Idem ( S η ) and x , y ∈ M x,y \in M x , y ∈ M with e τ l e n x e\mathrel{\tau_{\mathrm{len}}}x e τ len x and e τ l e n y e\mathrel{\tau_{\mathrm{len}}}y e τ len y . We define the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg as the tolerance closure of R m g R_{\mathrm{mg}} R mg .
As claimed in Theorem 2.7 , the matched-guard tolerance refines the guard tolerance, so the matched-guard tolerance can only be shattering if the guard tolerance is:
Lemma 4.2. The matched-guard relation is contained in the guard relation, and consequently the matched-guard tolerance is contained in the guard tolerance: R m g ⊆ R g R_{\mathrm{mg}} \subseteq R_{\mathrm{g}} R mg ⊆ R g and τ m g ⊆ τ g \tau_{\mathrm{mg}} \subseteq\tau_{\mathrm{g}} τ mg ⊆ τ g .
Proof. Let ( p , q ) ∈ R m g (p,q) \in R_{\mathrm{mg}} ( p , q ) ∈ R mg . By definition, there exist an idempotent e ∈ Idem ( S η ) e \in\operatorname{Idem}(S_{\eta}) e ∈ Idem ( S η ) and elements x , y ∈ M x,y \in M x , y ∈ M such that ( p , q ) = ( e x e , e y e ) (p,q)=(exe,eye) ( p , q ) = ( e x e , ey e ) and we have e τ l e n x e\mathrel{\tau_{\mathrm{len}}}x e τ len x and e τ l e n y e\mathrel{\tau_{\mathrm{len}}}y e τ len y . By symmetry, x τ l e n e x\mathrel{\tau_{\mathrm{len}}}e x τ len e , so compatibility with multiplication gives x e τ l e n e y xe\mathrel{\tau_{\mathrm{len}}}ey x e τ len ey . Since e ( x e ) e = e x e e(xe)e=exe e ( x e ) e = e x e and e ( e y ) e = e y e e(ey)e=eye e ( ey ) e = ey e by idempotence, the definition of the guard relation on ( e ( x e ) e , e ( e y ) e ) (e(xe)e,e(ey)e) ( e ( x e ) e , e ( ey ) e ) witnesses that ( p , q ) ∈ R g (p,q) \in R_{\mathrm{g}} ( p , q ) ∈ R g . Hence R m g ⊆ R g R_{\mathrm{mg}} \subseteq R_{\mathrm{g}} R mg ⊆ R g . The tolerance closure is monotone, which concludes.
Example 4.3. We return to ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) from Example 3.11 , where we showed that τ g \tau_{\mathrm{g}} τ g is shattering. We now show that τ m g \tau_{\mathrm{mg}} τ mg is non-shattering for a mutual presentation of this pair, so our upcoming logarithmic upper bound will apply. Consider the monoid M = { 1 , a , b , c , d , 0 } M=\{1,a,b,c,d,0\} M = { 1 , a , b , c , d , 0 } , with 1 1 1 the identity and 0 0 0 a zero. The only nonzero products of a , b , c , d a,b,c,d a , b , c , d are a 2 = a a^2=a a 2 = a , b 2 = b b^2=b b 2 = b , a c = c ac=c a c = c , a d = d ad=d a d = d , c b = c cb=c c b = c , and d b = d db=d d b = d . Let η : Σ ∗ → M \eta:\Sigma^* \to M η : Σ ∗ → M map each letter to the corresponding element, and set M P = { c , d } M_P=\{c,d\} M P = { c , d } and M T = { c } M_T=\{c\} M T = { c } . This gives a mutual presentation of ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) . As before, ( c , d ) = ( a c b , a d b ) ∈ R g ⊆ τ g (c,d)=(acb,adb) \in R_{\mathrm{g}} \subseteq\tau_{\mathrm{g}} ( c , d ) = ( a c b , a d b ) ∈ R g ⊆ τ g , since a , b ∈ Idem ( S η ) a,b \in\operatorname{Idem}(S_{\eta}) a , b ∈ Idem ( S η ) and c τ l e n d c\mathrel{\tau_{\mathrm{len}}}d c τ len d . For R m g R_{\mathrm{mg}} R mg , however, Idem ( S η ) = { a , b , 0 } \operatorname{Idem}(S_{\eta})=\{a,b,0\} Idem ( S η ) = { a , b , 0 } and a x a ∈ { a , 0 } axa \in\{a,0\} a x a ∈ { a , 0 } , b x b ∈ { b , 0 } bxb \in\{b,0\} b x b ∈ { b , 0 } , and 0 x 0 = 0 0x0=0 0 x 0 = 0 for all x ∈ M x \in M x ∈ M . Thus every pair of R m g R_{\mathrm{mg}} R mg is diagonal or has a zero component. The relation Δ M ∪ ( M × { 0 } ) ∪ ( { 0 } × M ) \Delta_M \cup(M \times\{0\}) \cup(\{0\} \times M) Δ M ∪ ( M × { 0 }) ∪ ({ 0 } × M ) is reflexive and symmetric. It is also compatible with multiplication, because 0 0 0 is a zero. It is therefore a tolerance containing R m g R_{\mathrm{mg}} R mg , so it contains τ m g \tau_{\mathrm{mg}} τ mg . It excludes ( c , d ) (c,d) ( c , d ) , the only shattered pair up to symmetry, so τ m g \tau_{\mathrm{mg}} τ mg is non-shattering and τ m g ⊊ τ g \tau_{\mathrm{mg}} \subsetneq\tau_{\mathrm{g}} τ mg ⊊ τ g .
Logarithmic Upper Bound
We now show that if the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then the query complexity is at most logarithmic. In this case, intuitively, we can solve conditional membership with a bounded number of binary searches over the word to find boundaries between different regions of the word:
Proposition 4.4 (Logarithmic upper bound). If the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then Q P , T ( n ) = O ( log n ) Q_{P,T}(n)=O(\log n) Q P , T ( n ) = O ( log n ) .
Before proving this upper bound, we first examine the following example.
Example 4.5. We return to the languages P log = a ∗ ( c ∣ d ) b ∗ P_{\log}=a^*(c\mid d)b^* P l o g = a ∗ ( c ∣ d ) b ∗ and T log = a ∗ c b ∗ T_{\log}=a^*cb^* T l o g = a ∗ c b ∗ from Example 4.3 . A binary search finds the unique position carrying c c c or d d d : an answer d d d directs the search to the right, while an answer b b b directs it to the left. Thus the query complexity is at most logarithmic. As shown in Example 4.3 , τ m g \tau_{\mathrm{mg}} τ mg is non-shattering for this pair. Hence Proposition 4.4, which we prove below, gives Q P log , T log ( n ) = O ( log n ) Q_{P_{\log},T_{\log}}(n)=O(\log n) Q P l o g , T l o g ( n ) = O ( log n ) ; together with Lemma 3.12, this yields Q P log , T log ( n ) = Θ ( log n ) Q_{P_{\log},T_{\log}}(n)=\Theta(\log n) Q P l o g , T l o g ( n ) = Θ ( log n ) .
We now generalize this binary-search intuition to the general case. The overall challenge is that several binary searches may be needed: further, the same idempotent may occur at different positions, so a single query does not always determine in which direction to search next. Examples E.1 and E.3 in Appendix § 11 illustrate this challenge. One more immediate problem, however, is that a single query does not always yield an idempotent factor of the word. Indeed, as illustrated in Example E.2, idempotent elements that give us directional information need not be images of single letters and may require queries of entire blocks. This is easily addressed by Lemma 2.2: there is a fixed q ∈ N + q \in\mathbb{N}_{+} q ∈ N + such that every factor of at least q q q consecutive letters contains such a subfactor. For this reason, we will always query contiguous blocks of at least q q q letters. In fact, for technical reasons, we also require the block length to be a multiple of the common positive preimage length π \pi π of all idempotents given by Lemma 2.8. Thus, for the rest of this section, we define the block length K : = q π K := q\pi K := q π : this ensures that every block of K K K letters contains a nonempty factor with idempotent image under η \eta η (Lemma 2.2), and every e ∈ Idem ( S η ) e \in\operatorname{Idem}(S_{\eta}) e ∈ Idem ( S η ) has a preimage of length K K K (by Lemma 2.8 and idempotence).
We now explain how to view words and queries over the block alphabet Σ K \Sigma^{K} Σ K which we will use throughout the proof. The decoding of a word W ∈ ( Σ K ) ∗ W \in(\Sigma^{K})^{*} W ∈ ( Σ K ) ∗ concatenates its blocks into a word over Σ \Sigma Σ . For convenience we will abuse notation and see such words W W W as words over Σ \Sigma Σ (i.e., decoding them implicitly), for instance when applying η \eta η or considering membership in P P P and T T T . For W ∈ ( Σ K ) ∗ W \in(\Sigma^{K})^{*} W ∈ ( Σ K ) ∗ , the length ∣ W ∣ \lvert W\rvert ∣ W ∣ counts blocks, and the decoding has length K ∣ W ∣ K\lvert W\rvert K ∣ W ∣ . Similarly, a partial word over Σ K \Sigma^{K} Σ K is a word over Σ K ∪ { □ } \Sigma^{K} \cup\{\Box\} Σ K ∪ { □ } and is (implicitly) decoded to a word over Σ ∪ { □ } \Sigma\cup\{\Box\} Σ ∪ { □ } by replacing each blank block with K K K blanks.
We first introduce τ m g \tau_{\mathrm{mg}} τ mg -coherence, a property of decision trees used throughout the proof:
Definition 4.6. Let Σ \Sigma Σ be an alphabet and let T T T be a decision tree over Σ \Sigma Σ . We say that T T T is τ m g \tau_{\mathrm{mg}} τ mg -coherent if, for every leaf d d d of T T T with transcript t t t and every two completions t x , t y tx,ty t x , t y of t t t , we have η ( t x ) τ m g η ( t y ) \eta(tx)\mathrel{\tau_{\mathrm{mg}}}\eta(ty) η ( t x ) τ mg η ( t y ) . For n ∈ N n \in\mathbb{N} n ∈ N , the τ m g \tau_{\mathrm{mg}} τ mg -coherent query complexity C Σ ( n ) C_{\Sigma}(n) C Σ ( n ) is the maximum, over lengths 0 ≤ k ≤ n 0 \leq k \leq n 0 ≤ k ≤ n , of the minimum depth of a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree over Σ \Sigma Σ at length k k k .
The point of τ m g \tau_{\mathrm{mg}} τ mg -coherence is that it is preserved when decoding decision trees from Σ K \Sigma^{K} Σ K to Σ \Sigma Σ :
Lemma 4.7. Let k , d ∈ N k,d \in\mathbb{N} k , d ∈ N and let T T T be a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree over Σ K \Sigma^{K} Σ K at length k k k and depth at most d d d . We can build a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree T ′ T' T ′ over Σ \Sigma Σ at length K k Kk K k and depth at most K d Kd K d .
Proof sketch. We simply replace each block query by K K K letter queries.
Now, as τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then any τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree over Σ \Sigma Σ can be made correct for ( P , T ) (P,T) ( P , T ) by labeling its leaves, thanks to Lemma 2.1. Indeed, two completions t x , t y t_x,t_y t x , t y of the same leaf transcript have τ m g \tau_{\mathrm{mg}} τ mg -related images, so they cannot form a shattered pair. This allows us to conclude that our goal of building correct decision trees for P P P and T T T over Σ \Sigma Σ reduces to that of building τ m g \tau_{\mathrm{mg}} τ mg -coherent decision trees over Σ K \Sigma^{K} Σ K :
Lemma 4.8. If τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then for all n ∈ N n \in\mathbb{N} n ∈ N , we have Q P , T ( n ) ≤ K ( C Σ K ( ⌊ n / K ⌋ ) + 1 ) Q_{P,T}(n) \leq K(C_{\Sigma^{K}}(\lfloor n/K\rfloor)+1) Q P , T ( n ) ≤ K ( C Σ K (⌊ n / K ⌋) + 1 ) , where C Σ K C_{\Sigma^{K}} C Σ K is the query complexity restricted to τ m g \tau_{\mathrm{mg}} τ mg -coherent decision trees over Σ K \Sigma^{K} Σ K .
Proof sketch. We divide words over Σ \Sigma Σ into blocks of size K K K , with a small suffix of length less than K K K . We query this short suffix, then use a τ m g \tau_{\mathrm{mg}} τ mg -coherent block tree on the prefix (whose length is a multiple of K K K ), which we obtain by Lemma 4.7.
Thus, by Lemma 4.8, to show the logarithmic upper bound it suffices to show C Σ K ( k ) = O ( log ( k + 1 ) ) C_{\Sigma^{K}}(k)=O(\log(k+1)) C Σ K ( k ) = O ( log ( k + 1 )) . Thus, for every k ∈ N k \in\mathbb{N} k ∈ N we must build a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree T T T over blocks (i.e., on Σ K \Sigma^{K} Σ K ) that has logarithmic depth. The point of working on blocks is that any words on Σ K \Sigma^{K} Σ K whose first and last letters are all the same must have images related by τ m g \tau_{\mathrm{mg}} τ mg ; we will use it to show τ m g \tau_{\mathrm{mg}} τ mg -coherence:
Lemma 4.9. For all v ∈ Σ K v \in\Sigma^{K} v ∈ Σ K and X ′ , Y ′ ∈ ( Σ K ) ∗ X',Y' \in(\Sigma^{K})^{*} X ′ , Y ′ ∈ ( Σ K ) ∗ , we have η ( v X ′ v ) τ m g η ( v Y ′ v ) \eta(vX'v)\mathrel{\tau_{\mathrm{mg}}}\eta(vY'v) η ( v X ′ v ) τ mg η ( v Y ′ v ) .
Proof sketch. This relies on the ability to find an idempotent image in the common endpoint (with Lemma 2.2), and using idempotence to pad X ′ X' X ′ and Y ′ Y' Y ′ to a common length which is also compatible with preimages of the idempotents (this relies on Lemma 2.8).
The decision tree T \mathcal{T} T over blocks (i.e., letters of Σ K \Sigma^K Σ K ) will proceed by performing binary search over intervals , corresponding to contiguous ranges of □ \square □ in the transcript of the nodes of T \mathcal{T} T , focusing on so-called active intervals on which Lemma 4.9 is intuitively not yet applicable. We define these notions on an abstract alphabet Γ \Gamma Γ as they are generic, but we will always use Γ : = Σ K \Gamma:= \Sigma^K Γ := Σ K :
Definition 4.10 (Intervals of a partial word). Let Γ \Gamma Γ be an alphabet and t t t a partial word of length k ∈ N k \in\mathbb{N} k ∈ N over Γ \Gamma Γ . Write t = □ k 1 v 1 □ k 2 v 2 ⋯ □ k s v s □ k s + 1 t = \square^{k_1}v_1\square^{k_2}v_2\cdots\square^{k_s}v_s\square^{k_{s+1}} t = □ k 1 v 1 □ k 2 v 2 ⋯ □ k s v s □ k s + 1 , where s ∈ N s \in\mathbb{N} s ∈ N , v i ∈ Γ v_i \in\Gamma v i ∈ Γ for i ∈ [ s ] i \in[s] i ∈ [ s ] , k i ∈ N k_i \in\mathbb{N} k i ∈ N for i ∈ [ s + 1 ] i \in[s+1] i ∈ [ s + 1 ] , and s + ∑ i = 1 s + 1 k i = k s+\sum_{i=1}^{s+1}k_i=k s + ∑ i = 1 s + 1 k i = k . For s = 0 s=0 s = 0 , this means t = □ k t=\square^k t = □ k . For each i ∈ { 0 , … , s } i\in\{0,\ldots,s\} i ∈ { 0 , … , s } , put s i : = i + ∑ j = 1 i k j s_i:=i+\sum_{j=1}^{i}k_j s i := i + ∑ j = 1 i k j and e i : = s i + k i + 1 e_i:=s_i+k_{i+1} e i := s i + k i + 1 . The i i i -th interval of t t t is the (possibly empty) set of blank positions { s i + 1 , … , e i } \{s_i+1,\ldots,e_i\} { s i + 1 , … , e i } , of size k i + 1 k_{i+1} k i + 1 . The interval is active if i = 0 i=0 i = 0 , or if i ∈ [ s ] i\in[s] i ∈ [ s ] and v i v_i v i does not occur among v i + 1 , … , v s v_{i+1},\ldots,v_s v i + 1 , … , v s , i.e., v i ≠ v j v_i\ne v_j v i = v j for every j ∈ { i + 1 , … , s } j\in\{i+1,\ldots,s\} j ∈ { i + 1 , … , s } .
Our binary search strategy will focus on active intervals, of which there are constantly many:
Claim 4.11. For every finite alphabet Γ \Gamma Γ and every partial word t t t over Γ \Gamma Γ , the number of active intervals of t t t is at most ∣ Γ ∣ + 1 |\Gamma|+1 ∣Γ∣ + 1 .
Proof. It is immediate that the preceding letter v i v_i v i of each active interval with i > 0 i>0 i > 0 is unique among active intervals. Thus, there are at most ∣ Γ ∣ |\Gamma| ∣Γ∣ such intervals, plus the first interval.
The point of intervals is that we can use Lemma 4.9 to show that completions agreeing on all active intervals have images related by τ m g \tau_{mg} τ m g , so that intuitively only such intervals must be queried:
Lemma 4.12. Let t t t be a partial word over Σ K \Sigma^K Σ K and let t x , t y t_x,t_y t x , t y be two completions of t t t . If t x t_x t x and t y t_y t y agree on every active interval of t t t , then η ( t x ) τ m g η ( t y ) \eta(t_x)\mathrel{\tau_{mg}}\eta(t_y) η ( t x ) τ m g η ( t y ) .
Proof sketch. We do an induction on the number of non-□ \square □ positions of t t t . Considering the first position that contains a non-□ \square □ letter a ∈ Σ K a\in\Sigma^K a ∈ Σ K , we apply Lemma 4.9 to the factor of the completions of t t t from this position to the last occurrence of a a a in t t t . The remaining suffix is handled using the induction hypothesis, and we conclude by compatibility with multiplication.
We are now ready to define the decision tree T \mathcal{T} T over the block alphabet Σ K \Sigma^K Σ K :
Definition 4.13. Fix k ∈ N k\in\mathbb{N} k ∈ N . Define a decision tree T \mathcal{T} T over Σ K \Sigma^K Σ K for words of length k k k as follows. For every node d d d of T \mathcal{T} T , let t t t be its transcript over Σ K \Sigma^K Σ K . If no active interval of t t t is nonempty, d d d is a leaf. Otherwise, let N ∈ N + N\in\mathbb{N}_+ N ∈ N + be the maximum size of an active interval of t t t . Choose the leftmost active interval of t t t of size N N N , and let i i i be the index of this interval. Label d d d by the middle position m i : = ⌈ ( s i + e i + 1 ) / 2 ⌉ ∈ [ k ] m_i := \lceil(s_i+e_i+1)/2\rceil\in[k] m i := ⌈( s i + e i + 1 ) /2 ⌉ ∈ [ k ] . Because s i < m i ≤ e i s_i<m_i\le e_i s i < m i ≤ e i , we know that position m i m_i m i carries □ \square □ in t t t . Give d d d one child for every block value in Σ K \Sigma^K Σ K . Then repeat the same process on the children, until all nodes are leaves: this terminates as any position queried on a branch is never queried again on that branch.
We now show that T \mathcal{T} T is τ m g \tau_{mg} τ m g -coherent and show the logarithmic bound on its depth:
Claim 4.14. The tree T \mathcal{T} T is τ m g \tau_{mg} τ m g -coherent.
Proof. Let t t t be the transcript of a leaf of T \mathcal{T} T , and let t x , t y t_x,t_y t x , t y be two completions of t t t . Every active interval of t t t is empty, so t x t_x t x and t y t_y t y agree on all of them. By Lemma 4.12, η ( t x ) τ m g η ( t y ) \eta(t_x)\mathrel{\tau_{mg}}\eta(t_y) η ( t x ) τ m g η ( t y ) .
Claim 4.15. The tree T \mathcal{T} T has depth at most B ( ⌈ log 2 ( k + 1 ) ⌉ + 1 ) B(\lceil\log_2(k+1)\rceil+1) B (⌈ log 2 ( k + 1 )⌉ + 1 ) , where B : = ∣ Σ K ∣ + 1 B:=|\Sigma^K|+1 B := ∣ Σ K ∣ + 1 .
Proof sketch. We divide each branch into groups of B B B queries and show that each group halves the largest active-interval size. Fix the first node d d d of a group, let t d t_d t d be its transcript, and let N : = max { ∣ I ∣ : I is an active interval of t d } N:=\max\{|I|:I\text{ is an active interval of }t_d\} N := max { ∣ I ∣ : I is an active interval of t d } be the largest active interval size at d d d . Each query of an interval larger than N / 2 N/2 N /2 splits it into parts of size at most N / 2 N/2 N /2 , and inactive intervals remain inactive. As there are at most B B B active intervals, within B B B queries there will be no interval left with size greater than N / 2 N/2 N /2 . Thus, after O ( log k ) O(\log k) O ( log k ) groups, all active intervals are empty.
As explained after Lemma 4.8, we have now shown Proposition 4.4 with Claims 4.14 and 4.15.
The Contextual Matched-Guard Relations
Having proved the logarithmic upper bound when the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, we now turn to the linear lower bound when it is shattering. Similarly to Definition 3.8 in § 3 , we will need to give an equivalent rephrasing of the matched-guard tolerance which provides a more explicit form for its pairs. Like § 3 we will impose stronger length requirements, but unlike § 3 it will no longer be sufficient to take one single pair and extend it by one common left and right context. Instead, we will need to handle up to s s s pairs at once:
Definition 4.16. For s ∈ N s \in\mathbb{N} s ∈ N , define the s s s -contextual matched-guard relation R c m g , s ⊆ M × M R_{\mathrm{cmg},s} \subseteq M \times M R cmg , s ⊆ M × M as
R_{\mathrm{cmg},s} := \bigcup_{\substack{(k_1,\ldots,k_t)\in\mathbb{N}_+^t\\0\leq t\leq s}}
\{
(
\begin{array}{c}
a_0(e_1x_1e_1)a_1\cdots(e_tx_te_t)a_t,\\
a_0(e_1y_1e_1)a_1\cdots(e_ty_te_t)a_t
\end{array}
\ \middle|\
\begin{array}{l}
a_0,\ldots,a_t\in M,\\
e_i\in\operatorname{Idem}(S_\eta),\quad x_i,y_i\in M,\\
e_i,x_i,y_i\in\eta(\Sigma^{k_i})\text{ for all }i\in[t]
\end{array}
)
Note that R c m g , 0 = Δ M R_{\mathrm{cmg},0}=\Delta_M R cmg , 0 = Δ M , consisting of pairs of the form ( a 0 , a 0 ) (a_0,a_0) ( a 0 , a 0 ) . By definition, R c m g , s ⊆ R c m g , s + 1 R_{\mathrm{cmg},s}\subseteq R_{\mathrm{cmg},s+1} R cmg , s ⊆ R cmg , s + 1 for every s ∈ N s\in\mathbb{N} s ∈ N , i.e., the relations form an increasing hierarchy. See Example E.4 in Appendix § 11 for an illustration of why taking s = 1 s=1 s = 1 does not suffice because R c m g , 1 R_{\mathrm{cmg},1} R cmg , 1 is not closed under multiplication. For the linear lower bound, we need to show that the hierarchy collapses at a height independent of the word length, namely s : = m 2 = ∣ M × M ∣ s:=m^2=|M\times M| s := m 2 = ∣ M × M ∣ , the number of ordered pairs of elements of the monoid M M M :
Lemma 4.17. We have τ m g = R c m g , m 2 \tau_{\mathrm{mg}}=R_{\mathrm{cmg},m^2} τ mg = R cmg , m 2 .
Proof sketch. We prove both inclusions. For R c m g , m 2 ⊆ τ m g R_{\mathrm{cmg},m^2}\subseteq\tau_{\mathrm{mg}} R cmg , m 2 ⊆ τ mg , performing 0 0 0 substitutions gives a diagonal pair, which belongs to τ m g \tau_{\mathrm{mg}} τ mg by reflexivity. Otherwise, the common-length condition gives e i τ l e n x i e_i\mathrel{\tau_{\mathrm{len}}}x_i e i τ len x i and e i τ l e n y i e_i\mathrel{\tau_{\mathrm{len}}}y_i e i τ len y i for each substitution. Thus each guarded pair ( e i x i e i , e i y i e i ) (e_ix_ie_i,e_iy_ie_i) ( e i x i e i , e i y i e i ) belongs to R m g R_{\mathrm{mg}} R mg . We conclude via compatibility with multiplication, using reflexivity for the contexts a i a_i a i .
For τ m g ⊆ R c m g , m 2 \tau_{\mathrm{mg}}\subseteq R_{\mathrm{cmg},m^2} τ mg ⊆ R cmg , m 2 , Lemma 2.3 expresses each pair in τ m g \tau_{\mathrm{mg}} τ mg as a product of fewer than m 2 m^2 m 2 factors from R m g ∪ Δ M R_{\mathrm{mg}}\cup\Delta_M R mg ∪ Δ M . We collect the diagonal factors into common contexts. For each remaining factor ( e x e , e y e ) ∈ R m g (exe,eye)\in R_{\mathrm{mg}} ( e x e , ey e ) ∈ R mg , the witnesses for e τ l e n x e\mathrel{\tau_{\mathrm{len}}}x e τ len x and e τ l e n y e\mathrel{\tau_{\mathrm{len}}}y e τ len y may have different lengths r r r and s s s . Concatenating these witnesses gives preimages of e e e , x e xe x e , and e y ey ey of the same positive length r + s r+s r + s . Since e e e is idempotent, ( e ( x e ) e , e ( e y ) e ) = ( e x e , e y e ) (e(xe)e,e(ey)e)=(exe,eye) ( e ( x e ) e , e ( ey ) e ) = ( e x e , ey e ) . We therefore obtain the required decomposition with fewer than m 2 m^2 m 2 substitutions, so the pair belongs to R c m g , m 2 R_{\mathrm{cmg},m^2} R cmg , m 2 .
Linear Lower Bound {#sec:4.4} We now turn to the linear lower bound of Theorem 2.7 , showing that a shattering matched-guard tolerance forces at least linear query complexity:
Proposition 4.18 (Linear lower bound). If the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( n ) \Omega(n) Ω ( n ) .
We prove this in the rest of the section. We first illustrate our criterion on ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) (Table 1 ):
Example 4.19. Let Σ = { a , c , d } \Sigma=\{a,c,d\} Σ = { a , c , d } , P l i n : = a ∗ ( c ∣ d ) a ∗ P_{\mathrm{lin}}:=a^*(c\mid d)a^* P lin := a ∗ ( c ∣ d ) a ∗ , and T l i n : = a ∗ c a ∗ T_{\mathrm{lin}}:=a^*ca^* T lin := a ∗ c a ∗ (as in Table 1 ). Let ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) be any mutual presentation of this pair. Take the integer ω : = ∣ M ∣ ∈ N + \omega:=|M|\in\mathbb{N}_+ ω := ∣ M ∣ ∈ N + as an idempotent power of M M M . Put e : = η ( a ω ) e:=\eta(a^\omega) e := η ( a ω ) , x : = η ( a ω c ) x:=\eta(a^\omega c) x := η ( a ω c ) , and y : = η ( a ω − 1 d ) y:=\eta(a^{\omega-1}d) y := η ( a ω − 1 d ) , all in M M M . Then e ∈ Idem ( S η ) e\in\operatorname{Idem}(S_\eta) e ∈ Idem ( S η ) , and e τ l e n x e\mathrel{\tau_{\mathrm{len}}}x e τ len x and e τ l e n y e\mathrel{\tau_{\mathrm{len}}}y e τ len y . The witnesses are respectively the word pairs ( a ω , a ω − 1 c ) (a^\omega,a^{\omega-1}c) ( a ω , a ω − 1 c ) and ( a ω , a ω − 1 d ) (a^\omega,a^{\omega-1}d) ( a ω , a ω − 1 d ) , each consisting of words of length ω \omega ω .
Thus ( e x e , e y e ) ∈ R m g (exe,eye)\in R_{\mathrm{mg}} ( e x e , ey e ) ∈ R mg is a shattered pair, as witnessed by a 2 ω − 1 c a ω ∈ T l i n a^{2\omega-1}ca^\omega\in T_{\mathrm{lin}} a 2 ω − 1 c a ω ∈ T lin and a 2 ω − 1 d a ω ∈ P l i n ∖ T l i n a^{2\omega-1}da^\omega\in P_{\mathrm{lin}}\setminus T_{\mathrm{lin}} a 2 ω − 1 d a ω ∈ P lin ∖ T lin . This shows that the matched-guard tolerance is shattering.
Let us now show the linear lower bound for P l i n , T l i n P_{\mathrm{lin}},T_{\mathrm{lin}} P lin , T lin :
Lemma 4.20 (Linear lower bound). The pair ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) of Example 4.19 has Q P l i n , T l i n ( n ) Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(n) Q P lin , T lin ( n ) in Ω ( n ) \Omega(n) Ω ( n ) .
In fact the query complexity of ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) is precisely Θ ( n ) \Theta(n) Θ ( n ) , since querying every position gives a linear upper bound. For now, let us sketch the lower bound:
Proof sketch. Fix n ∈ N + n \in\mathbb{N}_{+} n ∈ N + and answer every query with a a a . Before all n n n positions are queried, some i ∈ [ n ] i \in[n] i ∈ [ n ] remains unknown, so both a i − 1 c a n − i ∈ T l i n a^{i-1}ca^{n-i} \in T_{\mathrm{lin}} a i − 1 c a n − i ∈ T lin and a i − 1 d a n − i ∈ P l i n ∖ T l i n a^{i-1}da^{n-i} \in P_{\mathrm{lin}} \setminus T_{\mathrm{lin}} a i − 1 d a n − i ∈ P lin ∖ T lin complete the transcript. A correct tree therefore cannot decide before depth n n n .
To prove Proposition 4.18, as in the previous section, we will reduce from Lemma 4.20. We will use for this the rephrasing of the matched-guard tolerance as the contextual matched-guard relation, along with the closure lemmas of Section 3 (inclusion, quotient, and inverse length-multiplying morphism). However, because the contextual matched-guard relation may perform multiple substitutions at once (up to m 2 m^2 m 2 ), we will additionally need a form of closure under concatenation :
Lemma 4.21 (Concatenation). Let s ∈ N + s \in\mathbb{N}_{+} s ∈ N + , and for each i ∈ [ s ] i \in[s] i ∈ [ s ] let T i ⊆ P i ⊆ Σ ∗ T_i \subseteq P_i \subseteq\Sigma^* T i ⊆ P i ⊆ Σ ∗ . Define T = T 1 ⋯ T s T = T_1 \cdots T_s T = T 1 ⋯ T s and P = T ∪ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) P = T \cup(P_1 \setminus T_1) \cdots(P_s \setminus T_s) P = T ∪ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) . Assume that T ∩ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) = ∅ T \cap(P_1 \setminus T_1) \cdots(P_s \setminus T_s) = \varnothing T ∩ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) = ∅ . Then, for every n ∈ N n \in\mathbb{N} n ∈ N , we have Q P , T ( s n ) ≥ min i ∈ [ s ] Q P i , T i ( n ) Q_{P,T}(sn) \geq\min_{i \in[s]} Q_{P_i,T_i}(n) Q P , T ( s n ) ≥ min i ∈ [ s ] Q P i , T i ( n ) .
The disjointness assumption in the lemma ensures that concatenating target words cannot also give a concatenation of non-target words. The proof of Lemma 4.21 is more complex than that of the analogous results in Section 3. It uses the notion of the cost of a partial word to keep track of how many queries remain to be done:
Definition 4.22 (Cost of a partial word). Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , let n ∈ N n \in\mathbb{N} n ∈ N , and let w ∈ ( Σ ∪ { □ } ) n w \in(\Sigma\cup\{\square\})^n w ∈ ( Σ ∪ { □ } ) n be a partial word . Write L ( w ) : = { u ∈ Σ n ∣ u is a completion of w } L(w) := \{u \in\Sigma^n \mid u\text{ is a completion of }w\} L ( w ) := { u ∈ Σ n ∣ u is a completion of w } . The cost of w w w relative to ( P , T ) (P,T) ( P , T ) is cost P , T ( w ) : = Q P ∩ L ( w ) , T ∩ L ( w ) ( n ) \operatorname{cost}_{P,T}(w) := Q_{P \cap L(w),T \cap L(w)}(n) cost P , T ( w ) := Q P ∩ L ( w ) , T ∩ L ( w ) ( n ) .
Thus cost P , T ( w ) > 0 \operatorname{cost}_{P,T}(w) > 0 cost P , T ( w ) > 0 exactly when w w w shatters ( P , T ) (P,T) ( P , T ) , by Lemma 2.1. Further, for the all-□ \square □ partial words, we have Q P , T ( n ) = max 0 ≤ ℓ ≤ n cost P , T ( □ ℓ ) Q_{P,T}(n) = \max_{0 \leq\ell\leq n} \operatorname{cost}_{P,T}(\square^\ell) Q P , T ( n ) = max 0 ≤ ℓ ≤ n cost P , T ( □ ℓ ) . The next lemma shows that an answer to a query can always be chosen to decrease the cost by at most one.
Lemma 4.23 (Cost preservation). Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , let w w w be a partial word of length n ∈ N n \in\mathbb{N} n ∈ N , and let j ∈ [ n ] j \in[n] j ∈ [ n ] such that w j = □ w_j = \square w j = □ . There is a letter a ∈ Σ a \in\Sigma a ∈ Σ such that the partial word w a ′ w'_a w a ′ obtained by placing a a a at position j j j satisfies cost P , T ( w a ′ ) ≥ cost P , T ( w ) − 1 \operatorname{cost}_{P,T}(w'_a) \geq\operatorname{cost}_{P,T}(w) - 1 cost P , T ( w a ′ ) ≥ cost P , T ( w ) − 1 .
Proof sketch. If the cost of w a ′ w'_a w a ′ were smaller than the bound across every a ∈ Σ a \in\Sigma a ∈ Σ , as witnessed by decision trees T a T_a T a , then a decision tree for w w w with root labeled j j j and child subtrees T a T_a T a would have height less than the cost of w w w , a contradiction.
In particular, when starting from a partial word of cost k ∈ N k \in\mathbb{N} k ∈ N , we can answer any q ∈ N q \in\mathbb{N} q ∈ N successive queries so that the cost remains at least k − q k-q k − q . When q < k q < k q < k , the resulting partial word is still shattering. This is used to prove Lemma 4.21 in the appendix, intuitively by choosing a branch where we keep track of the cost of the different parts of the concatenation.
We now apply the inclusion, quotient, and inverse-morphism reductions of Section 3 to a shattering guarded pair in the form of Lemma 4.17. Together with the concatenation lemma (Lemma 4.21), this allows us to deduce Proposition 4.18 from the lower bound on P l i n , T l i n P_{\mathrm{lin}},T_{\mathrm{lin}} P lin , T lin (Lemma 4.20):
Proof sketch. Since τ m g \tau_{\mathrm{mg}} τ mg is shattering, the equality τ m g = R c m g , m 2 \tau_{\mathrm{mg}} = R_{\mathrm{cmg},m^2} τ mg = R cmg , m 2 from Lemma 4.17 gives a shattered pair with at most m 2 m^2 m 2 substitutions. Let t ∈ N + t \in\mathbb{N}_{+} t ∈ N + be the number of non-identity substitutions. For each i ∈ [ t ] i \in[t] i ∈ [ t ] , choose equal-length preimages E i , X i , Y i ∈ Σ k i E_i,X_i,Y_i \in\Sigma^{k_i} E i , X i , Y i ∈ Σ k i , for some k i ∈ N + k_i \in\mathbb{N}_{+} k i ∈ N + , for its guard and middle elements. Choose fixed words b 0 , … , b t ∈ Σ ∗ b_0,\ldots,b_t \in\Sigma^* b 0 , … , b t ∈ Σ ∗ for the contexts. By identity, the languages T i : = E i + X i E i + Y i T_i := E_i^+X_iE_i^+Y_i T i := E i + X i E i + Y i and P i : = T i ∪ E i + Y i E i + X i P_i := T_i \cup E_i^+Y_iE_i^+X_i P i := T i ∪ E i + Y i E i + X i for i ∈ [ t ] i \in[t] i ∈ [ t ] , give languages T ′ : = b 0 T 1 ⋯ T t ⊆ T T' := b_0T_1\cdots T_t \subseteq T T ′ := b 0 T 1 ⋯ T t ⊆ T and P ′ : = T ′ ∪ b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) P' := T' \cup b_0(P_1 \setminus T_1)\cdots(P_t \setminus T_t) P ′ := T ′ ∪ b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) with P ′ ∖ T ′ ⊆ P ∖ T P' \setminus T' \subseteq P \setminus T P ′ ∖ T ′ ⊆ P ∖ T .
By the inclusion lemma (Lemma 3.13), ( P , T ) (P,T) ( P , T ) is at least as hard as ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) . By the quotient lemma (Lemma 3.14) we can remove the fixed prefix b 0 b_0 b 0 . We then use the concatenation lemma (Lemma 4.21) and the inverse length-multiplying morphism lemma (Lemma 3.15) to argue that it suffices to show lower bounds on the pairs ( P i , T i ) (P_i,T_i) ( P i , T i ) . Each of them is handled by reducing from the fixed language pair P l i n , T l i n P_{\mathrm{lin}},T_{\mathrm{lin}} P lin , T lin (using Lemma 4.20) via the inclusion and quotient lemmas.
Effective Complexity Classification
We have concluded the proof of Theorem 2.7 which classifies possible query complexity regimes. In this section, we study how we can decide this regime when given finite descriptions of P P P and T T T as nondeterministic finite automata (NFAs), for which we use standard definitions [18 Chapter 2] .
Theorem 5.1 (Effective classification). Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ be regular languages. Given NFAs A P A_P A P and A T A_T A T recognizing P P P and T T T , respectively, it is PSPACE-complete to decide which of the three regimes of Theorem 2.7 applies to Q P , T Q_{P,T} Q P , T .
The PSPACE upper bound therefore also applies when P P P and T T T are described by regular expressions, because they can be translated to NFAs in polynomial time [18 Section 3.2.3] . The proof uses standard techniques for implicit representations of the transition monoid of input automata:
Proof sketch. The challenge to prove the upper bound is that we cannot explicitly build a mutual presentation for P P P and T T T , because its size can be exponential in the NFA. Instead, we recall classical constructions on NFAs to show how we can implicitly represent the transition monoid of an NFA, and thus a mutual presentation for our two NFAs. This relies on the fact that elements of the transition monoid can be represented as polynomial-sized matrices, and that while there may be exponentially many possible products we have bounds on the maximal useful length of a product (via Lemmas 2.3 and 3.2) which ensure that polynomially many bits for the counter suffice. Having an implicit representation of the mutual presentation is then enough to test our criteria through standard techniques, in particular using nondeterminism thanks to Savitch’s theorem [26 ] . The lower bound reduces from NFA universality using standard techniques similar to Greibach’s theorem [16 ] .
Conclusion
In this paper, we have studied the query complexity of the conditional membership problem for regular languages, i.e., determining whether a word w w w belongs to a fixed target T T T under the hypothesis that w w w belongs to a promise P P P . Our main theorem gives the three possible asymptotic regimes: O ( 1 ) O(1) O ( 1 ) (where we can intuitively decide by querying the left and right endpoints of the word), Θ ( log n ) \Theta(\log n) Θ ( log n ) (where we can intuitively decide by performing a generalization of binary search), and Θ ( n ) \Theta(n) Θ ( n ) (where we must examine linearly many positions). We have further shown that the criterion in our trichotomy is PSPACE-complete to decide given automata representations of our two languages P P P and T T T .
Our work opens several directions for further research. One first question would be to translate our algebraic criteria to language-theoretic conditions on P P P and T T T (independent from the mutual presentation). Another question is computational complexity: we do not know if the PSPACE upper bound can be lowered for P P P and T T T given as DFAs. We also do not know the combined complexity of our upper bound algorithms when P P P and T T T are given as input. To improve them, we could in particular avoid the Ramsey-type argument from [19 ] to find idempotent subfactors; we may be able to use traditional pumping arguments instead, at the cost of complicating the proofs. This could ensure block sizes that are linear in the mutual presentation, though this is still superexponential in the size of DFAs representing P P P and T T T (see, e.g., [17 ] ).
Another natural question is to fix a regular promise P P P and determine which of the three complexity regimes can occur across all possible regular targets T ⊆ P T \subseteq P T ⊆ P . This would generalize the constant/linear dichotomy for non-conditional membership [1 ] , which corresponds to P = Σ ∗ P = \Sigma^* P = Σ ∗ , and we suspect that it would relate to [21 ] . We also leave open the question of the nondeterministic or randomized query complexity in our models. For randomized query complexity, we suspect our methodology goes through so the bounds would be unchanged. By contrast, the nondeterministic case is different: for P log , T log P_{\log}, T_{\log} P l o g , T l o g or even P_{\lin}, T_{\lin} from Table 1 the nondeterministic query complexity is constant because a single observed letter suffices to answer positively. We suspect that the constant class matches with Σ 1 [ < , + 1 , Mod ] \Sigma_1[<,+1,\operatorname{Mod}] Σ 1 [ < , + 1 , Mod ] of languages defined by the existential fragment of first order logic with order and modular predicates [8 ] .
Proofs for Section 2 (Preliminaries and Main Result)
Lemma 2.1. If a decision tree T \mathcal{T} T for words of length n ∈ N n \in\mathbb{N} n ∈ N is correct for ( P , T ) (P,T) ( P , T ) at length n n n , then for any leaf ℓ \ell ℓ of T \mathcal{T} T the transcript of ℓ \ell ℓ does not shatter ( P , T ) (P,T) ( P , T ) . Conversely, if a decision tree T \mathcal{T} T ensures that all its leaves have a transcript that does not shatter ( P , T ) (P,T) ( P , T ) , then we can make T \mathcal{T} T correct for ( P , T ) (P,T) ( P , T ) at length n n n by assigning labels to its leaves.
Proof of Lemma 2.1. We first prove the first part of the claim by establishing the contrapositive. Assume that there is a leaf ℓ \ell ℓ of T \mathcal{T} T whose transcript shatters ( P , T ) (P,T) ( P , T ) . This means that there are two completions u u u and v v v of the transcript of ℓ \ell ℓ such that precisely one of them is in T T T and the other is in P ∖ T P \setminus T P ∖ T . As both u u u and v v v have length n n n and both reach ℓ \ell ℓ when read by T \mathcal{T} T , the tree gives the same answer on both so it errs on one of them, i.e., T \mathcal{T} T is not correct.
For the second part of the claim, assume that all leaves of T \mathcal{T} T have a transcript that does not shatter ( P , T ) (P,T) ( P , T ) . Thus, for each leaf ℓ \ell ℓ , when considering the set L ℓ L_\ell L ℓ of words that reach ℓ \ell ℓ (which are precisely the completions of the transcript of ℓ \ell ℓ ), when restricting to the words of P P P , there are two possibilities: either all belong to T T T , or none of them do. We label ℓ \ell ℓ by 0 or 1 accordingly. If the restriction of L ℓ L_\ell L ℓ to P P P is empty, then we arbitrarily label the leaf with 0. Letting T ′ \mathcal{T}' T ′ be the result of labeling all leaves in this way, we obtain that T ′ \mathcal{T}' T ′ correctly accepts or rejects on any word of P P P , so T ′ \mathcal{T}' T ′ is correct. ◀
Lemma 2.2 [19 ] . Let η : Σ ∗ → M \eta:\Sigma^{*}\to M η : Σ ∗ → M be a morphism to a monoid of size m m m . There exists q ∈ N + q\in\mathbb{N}_{+} q ∈ N + , depending only on m m m , such that every w ∈ Σ ∗ w\in\Sigma^{*} w ∈ Σ ∗ with ∣ w ∣ ≥ q |w|\ge q ∣ w ∣ ≥ q admits a factorization w = u z v w=uzv w = u z v with u , v ∈ Σ ∗ u,v\in\Sigma^{*} u , v ∈ Σ ∗ and z ∈ Σ + z\in\Sigma^{+} z ∈ Σ + such that η ( z ) \eta(z) η ( z ) is idempotent.
Proof of Lemma 2.2. By [19 Section 1.2] , there exists q ∈ N + q\in\mathbb{N}_{+} q ∈ N + , depending only on m m m , such that every word of length at least q q q contains a nonempty contiguous factor whose image under η \eta η is idempotent. Writing such a word as w = u z v w=uzv w = u z v , with u , v ∈ Σ ∗ u,v\in\Sigma^{*} u , v ∈ Σ ∗ and z ∈ Σ + z\in\Sigma^{+} z ∈ Σ + , establishes the claim. ◀
Lemma 2.3. Let η : Σ ∗ → M \eta:\Sigma^{*}\to M η : Σ ∗ → M be a surjective morphism to a monoid of size m m m . For every s ∈ M s\in M s ∈ M , there is a preimage w ∈ Σ ∗ w\in\Sigma^{*} w ∈ Σ ∗ such that η ( w ) = s \eta(w)=s η ( w ) = s and ∣ w ∣ < m |w|<m ∣ w ∣ < m .
Proof of Lemma 2.3. Let s ∈ M s\in M s ∈ M . As η \eta η is surjective, there is a preimage w ∈ Σ ∗ w\in\Sigma^{*} w ∈ Σ ∗ such that η ( w ) = s \eta(w)=s η ( w ) = s . Take w w w to have the minimal length among such preimages. If ∣ w ∣ < m |w|<m ∣ w ∣ < m , then we are done, so assume by way of contradiction that ∣ w ∣ ≥ m |w|\ge m ∣ w ∣ ≥ m . Let us focus on the prefix of w w w of length m m m by writing w = a 1 ⋯ a m w ′ w=a_1\cdots a_mw' w = a 1 ⋯ a m w ′ with a 1 , … , a m ∈ Σ a_1,\ldots,a_m\in\Sigma a 1 , … , a m ∈ Σ and w ′ ∈ Σ ∗ w'\in\Sigma^{*} w ′ ∈ Σ ∗ . Now, let us consider the m + 1 m+1 m + 1 prefix images η ( ε ) , η ( a 1 ) , … , η ( a 1 ⋯ a m ) \eta(\varepsilon),\eta(a_1),\ldots,\eta(a_1\cdots a_m) η ( ε ) , η ( a 1 ) , … , η ( a 1 ⋯ a m ) , each of these is an element in the monoid M M M which has size m m m . By the pigeonhole principle, we can choose 0 ≤ i < j ≤ m 0\le i<j\le m 0 ≤ i < j ≤ m such that η ( a 1 ⋯ a i ) = η ( a 1 ⋯ a j ) \eta(a_1\cdots a_i)=\eta(a_1\cdots a_j) η ( a 1 ⋯ a i ) = η ( a 1 ⋯ a j ) . Thus, write u : = a 1 ⋯ a i u:=a_1\cdots a_i u := a 1 ⋯ a i , z : = a i + 1 ⋯ a j z:=a_{i+1}\cdots a_j z := a i + 1 ⋯ a j , and v : = a j + 1 ⋯ a m v:=a_{j+1}\cdots a_m v := a j + 1 ⋯ a m , and let us write w ′ ′ = u z v w ′ w''=uzvw' w ′′ = u z v w ′ . We have η ( w ′ ′ ) = η ( u ) η ( v ) η ( w ′ ) \eta(w'')=\eta(u)\eta(v)\eta(w') η ( w ′′ ) = η ( u ) η ( v ) η ( w ′ ) and η ( u ) = η ( u z ) \eta(u)=\eta(uz) η ( u ) = η ( u z ) so η ( w ′ ′ ) = η ( u ) η ( v ) η ( w ′ ) = η ( u z v ) η ( w ′ ) = η ( w ) \eta(w'')=\eta(u)\eta(v)\eta(w')=\eta(uzv)\eta(w')=\eta(w) η ( w ′′ ) = η ( u ) η ( v ) η ( w ′ ) = η ( u z v ) η ( w ′ ) = η ( w ) . Thus, w ′ ′ w'' w ′′ is also a preimage of s s s and has strictly smaller length, a contradiction. This concludes the proof. ◀
Lemma 2.8. There exists a fixed integer π ∈ N + \pi\in\mathbb{N}_{+} π ∈ N + such that Idem ( S η ) ⊆ η ( Σ π ) \operatorname{Idem}(S_\eta)\subseteq\eta(\Sigma^\pi) Idem ( S η ) ⊆ η ( Σ π ) .
Proof of Lemma 2.8. We first choose a nonempty preimage of each idempotent. The set Idem ( S η ) \operatorname{Idem}(S_\eta) Idem ( S η ) is finite and nonempty, since S η S_\eta S η is a nonempty finite semigroup and every element has an idempotent power. For each e ∈ Idem ( S η ) e\in\operatorname{Idem}(S_\eta) e ∈ Idem ( S η ) , choose a word u e ∈ Σ + u_e\in\Sigma^{+} u e ∈ Σ + with η ( u e ) = e \eta(u_e)=e η ( u e ) = e .
We then take π ∈ N + \pi\in\mathbb{N}_{+} π ∈ N + to be the least common multiple of the lengths ∣ u e ∣ |u_e| ∣ u e ∣ . Then u e π / ∣ u e ∣ u_e^{\pi/|u_e|} u e π /∣ u e ∣ has length π \pi π and image e e e , by idempotence, so indeed every idempotent of Idem ( S η ) \operatorname{Idem}(S_\eta) Idem ( S η ) has a preimage of length π \pi π . ◀
Proofs for Section 3 (The Constant Regime)
The Guard Tolerance
Lemma 3.2. The relation τ η \tau_\eta τ η for η \eta η is a tolerance on S η S_\eta S η . Moreover, τ η = ⋃ i = 1 m 2 τ i , len \tau_\eta=\bigcup_{i=1}^{m^2}\tau_{i,\operatorname{len}} τ η = ⋃ i = 1 m 2 τ i , len .
Proof of Lemma 3.2. We first prove that τ l e n \tau_{\mathrm{len}} τ len is a tolerance on S η S_\eta S η by checking reflexivity, symmetry, and compatibility with multiplication.
By definition, we have τ l e n ⊆ S η × S η \tau_{\mathrm{len}} \subseteq S_\eta\times S_\eta τ len ⊆ S η × S η . For reflexivity, fix x ∈ S η x \in S_\eta x ∈ S η and choose a word u ∈ Σ + u \in\Sigma^{+} u ∈ Σ + with η ( u ) = x \eta(u)=x η ( u ) = x . The pair u , u u,u u , u witnesses that x τ l e n x x\mathrel{\tau_{\mathrm{len}}}x x τ len x .
For symmetry, fix x , y ∈ S η x,y \in S_\eta x , y ∈ S η with x τ l e n y x\mathrel{\tau_{\mathrm{len}}}y x τ len y . Choose nonempty equal-length preimages u , v ∈ Σ + u,v \in\Sigma^{+} u , v ∈ Σ + of x , y x,y x , y . The pair v , u v,u v , u witnesses that y τ l e n x y\mathrel{\tau_{\mathrm{len}}}x y τ len x .
For compatibility with multiplication, fix x , y , x ′ , y ′ ∈ S η x,y,x',y' \in S_\eta x , y , x ′ , y ′ ∈ S η with x τ l e n y x\mathrel{\tau_{\mathrm{len}}}y x τ len y and x ′ τ l e n y ′ x'\mathrel{\tau_{\mathrm{len}}}y' x ′ τ len y ′ . Choose equal-length preimages u , v ∈ Σ + u,v \in\Sigma^{+} u , v ∈ Σ + of x , y x,y x , y , and equal-length preimages u ′ , v ′ ∈ Σ + u',v' \in\Sigma^{+} u ′ , v ′ ∈ Σ + of x ′ , y ′ x',y' x ′ , y ′ . Then u u ′ uu' u u ′ and v v ′ vv' v v ′ are nonempty, have equal length and images x x ′ xx' x x ′ and y y ′ yy' y y ′ , so we have x x ′ τ l e n y y ′ xx'\mathrel{\tau_{\mathrm{len}}}yy' x x ′ τ len y y ′ .
We now prove the length bound described by the union by showing that every pair in τ l e n \tau_{\mathrm{len}} τ len is witnessed by a pair of nonempty preimages having a common length ≤ m 2 \le m^2 ≤ m 2 , where we recall that m m m was defined as m : = ∣ M ∣ m:=|M| m := ∣ M ∣ . Let A : = η ( Σ ) × η ( Σ ) ⊆ M × M A:=\eta(\Sigma)\times\eta(\Sigma)\subseteq M\times M A := η ( Σ ) × η ( Σ ) ⊆ M × M be the alphabet. Let N : = τ l e n ∪ { 1 N } N:=\tau_{\mathrm{len}}\cup\{1_N\} N := τ len ∪ { 1 N } be the monoid obtained by adjoining a fresh identity 1 N ∉ M × M 1_N\notin M\times M 1 N ∈ / M × M to the semigroup τ l e n \tau_{\mathrm{len}} τ len . Define the morphism θ : A ∗ → N \theta:A^*\to N θ : A ∗ → N by θ ( ε ) : = 1 N \theta(\varepsilon):=1_N θ ( ε ) := 1 N and θ ( ( p , q ) ) : = ( p , q ) \theta((p,q)):=(p,q) θ (( p , q )) := ( p , q ) for each letter ( p , q ) ∈ A (p,q)\in A ( p , q ) ∈ A . Thus θ \theta θ does componentwise multiplication on pairs of elements of M M M . It is surjective because τ l e n \tau_{\mathrm{len}} τ len consists precisely of images of pairs of nonempty equal-length words.
Fix ( x , y ) ∈ τ l e n (x,y)\in\tau_{\mathrm{len}} ( x , y ) ∈ τ len . By Lemma 2.3 applied to θ \theta θ , there is a preimage z ∈ A ∗ z\in A^* z ∈ A ∗ with θ ( z ) = ( x , y ) \theta(z)=(x,y) θ ( z ) = ( x , y ) and ∣ z ∣ < ∣ N ∣ ≤ m 2 + 1 |z|<|N|\le m^2+1 ∣ z ∣ < ∣ N ∣ ≤ m 2 + 1 . Since ( x , y ) ≠ 1 N (x,y)\ne1_N ( x , y ) = 1 N , the length k : = ∣ z ∣ k:=|z| k := ∣ z ∣ of the words in this preimage satisfies 1 ≤ k ≤ m 2 1\le k\le m^2 1 ≤ k ≤ m 2 . For each letter of z ∈ A z\in A z ∈ A , choose a pair of letters of Σ \Sigma Σ with suitable image by η \eta η . This gives words u , v ∈ Σ k u,v\in\Sigma^k u , v ∈ Σ k with η ( u ) = x \eta(u)=x η ( u ) = x and η ( v ) = y \eta(v)=y η ( v ) = y . Hence x τ k , l e n y x\mathrel{\tau_{k,\mathrm{len}}}y x τ k , len y , proving τ l e n ⊆ ⋃ i = 1 m 2 τ i , l e n \tau_{\mathrm{len}}\subseteq\bigcup_{i=1}^{m^2}\tau_{i,\mathrm{len}} τ len ⊆ ⋃ i = 1 m 2 τ i , len . The reverse inclusion follows by definition of τ l e n \tau_{\mathrm{len}} τ len , so the claimed equality holds. ◀
Constant Upper Bound
Proposition 3.6. If the guard tolerance τ g \tau_g τ g is non-shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in O ( 1 ) O(1) O ( 1 ) .
Proof of Proposition 3.6. We describe how to construct a correct decision tree for each n ∈ N n\in\mathbb{N} n ∈ N . Let q q q be the bound given by Lemma 2.2 for the morphism η \eta η ; this is a constant independent from n n n . If n ≤ 2 q n\le2q n ≤ 2 q , we simply query all positions. Otherwise, the tree T \mathcal{T} T queries the first and last q q q positions. By Lemma 2.1, it suffices to show that no leaf transcript of T \mathcal{T} T is shattering. By contradiction, assume that T \mathcal{T} T has a leaf ℓ \ell ℓ whose transcript has two completions a , b ∈ Σ n a,b\in\Sigma^n a , b ∈ Σ n , one in T T T and one in P ∖ T P\setminus T P ∖ T . Write a = s α t a=s\alpha t a = s α t and b = s β t b=s\beta t b = s β t , with s , t ∈ Σ q s,t\in\Sigma^q s , t ∈ Σ q the prefix and suffix queried in the transcript, and α , β ∈ Σ n − 2 q \alpha,\beta\in\Sigma^{n-2q} α , β ∈ Σ n − 2 q .
Applying Lemma 2.2 to s s s and t t t , write s = u ℓ u e u s s=u_\ell u_e u_s s = u ℓ u e u s and t = u t u f u p t=u_tu_fu_p t = u t u f u p , where u e , u f ∈ Σ + u_e,u_f\in\Sigma^+ u e , u f ∈ Σ + , the other factors belong to Σ ∗ \Sigma^* Σ ∗ , and η ( u e ) , η ( u f ) \eta(u_e),\eta(u_f) η ( u e ) , η ( u f ) are idempotent.
Since n > 2 q n>2q n > 2 q , the words α \alpha α and β \beta β are nonempty. Thus u s α u t u_s\alpha u_t u s α u t and u s β u t u_s\beta u_t u s β u t are nonempty words of the same length, so η ( u s α u t ) τ l e n η ( u s β u t ) \eta(u_s\alpha u_t)\mathrel{\tau_{\mathrm{len}}}\eta(u_s\beta u_t) η ( u s α u t ) τ len η ( u s β u t ) . As u e , u f u_e,u_f u e , u f are nonempty and their images by η \eta η are idempotent, we have η ( u e ) η ( u s α u t ) η ( u f ) R g η ( u e ) η ( u s β u t ) η ( u f ) \eta(u_e)\eta(u_s\alpha u_t)\eta(u_f)\mathrel{R_g}\eta(u_e)\eta(u_s\beta u_t)\eta(u_f) η ( u e ) η ( u s α u t ) η ( u f ) R g η ( u e ) η ( u s β u t ) η ( u f ) . As τ g \tau_g τ g is the tolerance closure of R g R_g R g , we also have η ( u e ) η ( u s α u t ) η ( u f ) τ g η ( u e ) η ( u s β u t ) η ( u f ) \eta(u_e)\eta(u_s\alpha u_t)\eta(u_f)\mathrel{\tau_g}\eta(u_e)\eta(u_s\beta u_t)\eta(u_f) η ( u e ) η ( u s α u t ) η ( u f ) τ g η ( u e ) η ( u s β u t ) η ( u f ) , and as τ g \tau_g τ g is reflexive we have η ( u e ) τ g η ( u e ) \eta(u_e)\mathrel{\tau_g}\eta(u_e) η ( u e ) τ g η ( u e ) and η ( u p ) τ g η ( u p ) \eta(u_p)\mathrel{\tau_g}\eta(u_p) η ( u p ) τ g η ( u p ) . Now, as τ g \tau_g τ g is a tolerance, it is closed under multiplication, so we deduce η ( a ) τ g η ( b ) \eta(a)\mathrel{\tau_g}\eta(b) η ( a ) τ g η ( b ) . However, one of η ( a ) , η ( b ) \eta(a),\eta(b) η ( a ) , η ( b ) belongs to M T M_T M T and the other belongs to M P ∖ M T M_P\setminus M_T M P ∖ M T , so τ g \tau_g τ g is shattering, contradicting our assumption.
Thus, at every length, there is a correct decision tree of depth at most 2 q 2q 2 q , which establishes that Q P , T ( n ) = O ( 1 ) Q_{P,T}(n)=O(1) Q P , T ( n ) = O ( 1 ) . ◀
The Contextual Guard Relation
Lemma 3.9. We have τ g = R c g \tau_g=R_{c_g} τ g = R c g .
To show Lemma 3.9, we first need a preliminary claim to handle the common length requirement added in the definition of the contextual guard relation relative to the guard relation. This length requirement can always be handled, and we can always freely add a prefix and suffix:
Claim B.1 (Common-length representation). For every ( p , q ) ∈ R g (p,q)\in R_g ( p , q ) ∈ R g and all ℓ , ρ ∈ M \ell,\rho\in M ℓ , ρ ∈ M , we have ( ℓ p ρ , ℓ q ρ ) ∈ R c g (\ell p\rho,\ell q\rho)\in R_{c_g} ( ℓ pρ , ℓ q ρ ) ∈ R c g .
Proof. Fix ( p , q ) ∈ R g (p,q) \in R_g ( p , q ) ∈ R g and ℓ , ρ ∈ M \ell,\rho\in M ℓ , ρ ∈ M . By the definition of R g R_g R g , there are e , f 0 ∈ Idem ( S η ) e,f_0 \in\operatorname{Idem}(S_\eta) e , f 0 ∈ Idem ( S η ) and x 0 , y 0 ∈ M x_0,y_0 \in M x 0 , y 0 ∈ M such that x 0 τ l e n y 0 x_0 \mathrel{\tau_{\mathrm{len}}} y_0 x 0 τ len y 0 , p = e x 0 f 0 p=ex_0f_0 p = e x 0 f 0 , and q = e y 0 f 0 q=ey_0f_0 q = e y 0 f 0 . We construct elements f , x , y , ρ ′ ∈ M f,x,y,\rho' \in M f , x , y , ρ ′ ∈ M such that f ∈ Idem ( S η ) f \in\operatorname{Idem}(S_\eta) f ∈ Idem ( S η ) , e , f , x , y ∈ η ( Σ k ) e,f,x,y \in\eta(\Sigma^k) e , f , x , y ∈ η ( Σ k ) for some length k ∈ N + k \in\mathbb{N}_+ k ∈ N + , and such that ( ℓ e x f ρ ′ , ℓ e y f ρ ′ ) = ( ℓ p ρ , ℓ q ρ ) (\ell exf\rho',\ell eyf\rho')=(\ell p\rho,\ell q\rho) ( ℓ e x f ρ ′ , ℓ ey f ρ ′ ) = ( ℓ pρ , ℓ q ρ ) . Together with e ∈ Idem ( S η ) e \in\operatorname{Idem}(S_\eta) e ∈ Idem ( S η ) , these conditions give a representation of ( ℓ p ρ , ℓ q ρ ) (\ell p\rho,\ell q\rho) ( ℓ pρ , ℓ q ρ ) as required by the definition of R c g R_{\mathrm{cg}} R cg .
Since x 0 τ l e n y 0 x_0 \mathrel{\tau_{\mathrm{len}}} y_0 x 0 τ len y 0 , choose r ∈ N + r \in\mathbb{N}_+ r ∈ N + and X 0 , Y 0 ∈ Σ r X_0,Y_0 \in\Sigma^r X 0 , Y 0 ∈ Σ r with η ( X 0 ) = x 0 \eta(X_0)=x_0 η ( X 0 ) = x 0 and η ( Y 0 ) = y 0 \eta(Y_0)=y_0 η ( Y 0 ) = y 0 . By Lemma 2.8, fix π ∈ N + \pi\in\mathbb{N}_+ π ∈ N + such that Idem ( S η ) ⊆ η ( Σ π ) \operatorname{Idem}(S_\eta) \subseteq\eta(\Sigma^\pi) Idem ( S η ) ⊆ η ( Σ π ) . Since e , f 0 ∈ Idem ( S η ) e,f_0 \in\operatorname{Idem}(S_\eta) e , f 0 ∈ Idem ( S η ) , choose E 0 , F 0 ∈ Σ π E_0,F_0 \in\Sigma^\pi E 0 , F 0 ∈ Σ π with η ( E 0 ) = e \eta(E_0)=e η ( E 0 ) = e and η ( F 0 ) = f 0 \eta(F_0)=f_0 η ( F 0 ) = f 0 .
The word F 0 r F_0^r F 0 r has length r π ≥ r r\pi\ge r r π ≥ r . Factor it as F 0 r = U V F_0^r=UV F 0 r = U V , where V V V is its suffix of length r r r and U U U is its remaining (possibly empty) prefix. In particular, U , V ∈ Σ ∗ U,V \in\Sigma^* U , V ∈ Σ ∗ , ∣ U ∣ = r π − r |U|=r\pi-r ∣ U ∣ = r π − r , and ∣ V ∣ = r |V|=r ∣ V ∣ = r . Set H : = V U H:=VU H := V U ; hence ∣ H ∣ = r π |H|=r\pi ∣ H ∣ = r π . Now set k : = 2 r π ∈ N + k:=2r\pi\in\mathbb{N}_+ k := 2 r π ∈ N + and define E : = E 0 2 r E:=E_0^{2r} E := E 0 2 r , F : = H 2 F:=H^2 F := H 2 , X : = X 0 U H X:=X_0UH X := X 0 U H , and Y : = Y 0 U H Y:=Y_0UH Y := Y 0 U H . We have ∣ E ∣ = 2 r π = k |E|=2r\pi=k ∣ E ∣ = 2 r π = k and ∣ F ∣ = 2 r π = k |F|=2r\pi=k ∣ F ∣ = 2 r π = k . Also, ∣ X ∣ = ∣ Y ∣ = r + ( r π − r ) + r π = k |X|=|Y|=r+(r\pi-r)+r\pi=k ∣ X ∣ = ∣ Y ∣ = r + ( r π − r ) + r π = k . Thus E , F , X , Y ∈ Σ k E,F,X,Y \in\Sigma^k E , F , X , Y ∈ Σ k .
Define f : = η ( F ) f:=\eta(F) f := η ( F ) , x : = η ( X ) x:=\eta(X) x := η ( X ) , y : = η ( Y ) y:=\eta(Y) y := η ( Y ) , and ρ ′ : = η ( V ) ρ \rho':=\eta(V)\rho ρ ′ := η ( V ) ρ . All four elements belong to M M M . Since e e e is idempotent, η ( E ) = η ( E 0 ) 2 r = e \eta(E)=\eta(E_0)^{2r}=e η ( E ) = η ( E 0 ) 2 r = e . Thus e , f , x , y ∈ η ( Σ k ) e,f,x,y \in\eta(\Sigma^k) e , f , x , y ∈ η ( Σ k ) . It remains to prove that f f f is idempotent and that ( ℓ e x f ρ ′ , ℓ e y f ρ ′ ) = ( ℓ p ρ , ℓ q ρ ) (\ell exf\rho',\ell eyf\rho')=(\ell p\rho,\ell q\rho) ( ℓ e x f ρ ′ , ℓ ey f ρ ′ ) = ( ℓ pρ , ℓ q ρ ) .
Set a : = η ( U ) a:=\eta(U) a := η ( U ) and b : = η ( V ) b:=\eta(V) b := η ( V ) . Then a , b ∈ M a,b \in M a , b ∈ M and a b = η ( U V ) = η ( F 0 r ) = f 0 ab=\eta(UV)=\eta(F_0^r)=f_0 ab = η ( U V ) = η ( F 0 r ) = f 0 , since r ≥ 1 r \ge1 r ≥ 1 . By idempotence of a b ab ab , we have ( b a ) 3 = b ( a b ) 2 a = b ( a b ) a = ( b a ) 2 (ba)^3=b(ab)^2a=b(ab)a=(ba)^2 ( ba ) 3 = b ( ab ) 2 a = b ( ab ) a = ( ba ) 2 . Multiplying by b a ba ba gives ( b a ) 4 = ( b a ) 3 = ( b a ) 2 (ba)^4=(ba)^3=(ba)^2 ( ba ) 4 = ( ba ) 3 = ( ba ) 2 . As H = V U H=VU H = V U , it follows that f = η ( H 2 ) = ( b a ) 2 f=\eta(H^2)=(ba)^2 f = η ( H 2 ) = ( ba ) 2 and f 2 = ( b a ) 4 = ( b a ) 2 = f f^2=(ba)^4=(ba)^2=f f 2 = ( ba ) 4 = ( ba ) 2 = f . Further, F ∈ Σ k F \in\Sigma^k F ∈ Σ k and k ≥ 1 k \ge1 k ≥ 1 , so f ∈ S η f \in S_\eta f ∈ S η . Therefore f ∈ Idem ( S η ) f \in\operatorname{Idem}(S_\eta) f ∈ Idem ( S η ) .
The identity H = V U H=VU H = V U and the factorization U V = F 0 r UV=F_0^r U V = F 0 r give U H 3 V = ( U V ) 4 = F 0 4 r UH^3V=(UV)^4=F_0^{4r} U H 3 V = ( U V ) 4 = F 0 4 r . Thus η ( U H 3 V ) = η ( F 0 ) 4 r = f 0 \eta(UH^3V)=\eta(F_0)^{4r}=f_0 η ( U H 3 V ) = η ( F 0 ) 4 r = f 0 , using r ≥ 1 r \ge1 r ≥ 1 and idempotence of f 0 f_0 f 0 . From the definitions of x , y , f , ρ ′ x,y,f,\rho' x , y , f , ρ ′ we obtain ℓ e x f ρ ′ = ℓ e x 0 η ( U H 3 V ) ρ = ℓ e x 0 f 0 ρ = ℓ p ρ \ell exf\rho'=\ell ex_0\eta(UH^3V)\rho=\ell ex_0f_0\rho=\ell p\rho ℓ e x f ρ ′ = ℓ e x 0 η ( U H 3 V ) ρ = ℓ e x 0 f 0 ρ = ℓ pρ and, likewise, ℓ e y f ρ ′ = ℓ e y 0 η ( U H 3 V ) ρ = ℓ e y 0 f 0 ρ = ℓ q ρ \ell eyf\rho'=\ell ey_0\eta(UH^3V)\rho=\ell ey_0f_0\rho=\ell q\rho ℓ ey f ρ ′ = ℓ e y 0 η ( U H 3 V ) ρ = ℓ e y 0 f 0 ρ = ℓ q ρ . The elements ℓ , ρ ′ , e , f , x , y \ell,\rho',e,f,x,y ℓ , ρ ′ , e , f , x , y and the integer k k k satisfy all conditions in the definition of R c g R_{\mathrm{cg}} R cg . Hence ( ℓ p ρ , ℓ q ρ ) ∈ R c g (\ell p\rho,\ell q\rho) \in R_{\mathrm{cg}} ( ℓ pρ , ℓ q ρ ) ∈ R cg . ◀
We are now ready to prove Lemma 3.9:
Proof of Lemma 3.9. We first establish R c g ⊆ τ g R_{\mathrm{cg}} \subseteq\tau_g R cg ⊆ τ g (step 1), then R g ⊆ R c g R_g \subseteq R_{\mathrm{cg}} R g ⊆ R cg (step 2), and finally that R c g R_{\mathrm{cg}} R cg is a tolerance (step 3). The last two facts will yield τ g ⊆ R c g \tau_g \subseteq R_{\mathrm{cg}} τ g ⊆ R cg .
For step 1, we show R c g ⊆ τ g R_{\mathrm{cg}} \subseteq\tau_g R cg ⊆ τ g . Take ( p , q ) ∈ R c g (p,q) \in R_{\mathrm{cg}} ( p , q ) ∈ R cg . If p = q p=q p = q , this is a diagonal pair and it belongs to τ g \tau_g τ g by reflexivity. Otherwise, the definition of R c g R_{\mathrm{cg}} R cg gives ℓ , ρ , x , y ∈ M \ell,\rho,x,y \in M ℓ , ρ , x , y ∈ M , e , f ∈ Idem ( S η ) e,f \in\operatorname{Idem}(S_\eta) e , f ∈ Idem ( S η ) , and k ∈ N + k \in\mathbb{N}_+ k ∈ N + such that p = ℓ e x f ρ p=\ell exf\rho p = ℓ e x f ρ , q = ℓ e y f ρ q=\ell eyf\rho q = ℓ ey f ρ , and e , f , x , y ∈ η ( Σ k ) e,f,x,y \in\eta(\Sigma^k) e , f , x , y ∈ η ( Σ k ) . In particular, x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y , so ( e x f , e y f ) ∈ R g ⊆ τ g (exf,eyf) \in R_g \subseteq\tau_g ( e x f , ey f ) ∈ R g ⊆ τ g . The reflexivity of τ g \tau_g τ g gives ( ℓ , ℓ ) , ( ρ , ρ ) ∈ τ g (\ell,\ell),(\rho,\rho) \in\tau_g ( ℓ , ℓ ) , ( ρ , ρ ) ∈ τ g . Since τ g \tau_g τ g is compatible with multiplication, ( p , q ) = ( ℓ e x f ρ , ℓ e y f ρ ) ∈ τ g (p,q)=(\ell exf\rho,\ell eyf\rho) \in\tau_g ( p , q ) = ( ℓ e x f ρ , ℓ ey f ρ ) ∈ τ g .
For step 2, we show R g ⊆ R c g R_g \subseteq R_{\mathrm{cg}} R g ⊆ R cg . This follows immediately from Theorem B.1 by taking ℓ : = 1 M \ell:=1_M ℓ := 1 M and ρ : = 1 M \rho:=1_M ρ := 1 M .
For step 3, we prove that R c g R_{\mathrm{cg}} R cg is a tolerance on M M M . It is reflexive because it contains all diagonal pairs. It is symmetric: this is immediate for diagonal pairs, and for non-diagonal pairs exchanging x x x and y y y in the definition preserves every condition and exchanges the two coordinates.
We check compatibility with multiplication. There are three cases depending on the kind of elements we are multiplying. First, the product of two diagonal pairs is again a diagonal pair. Second, if exactly one factor is a diagonal pair ( d , d ) (d,d) ( d , d ) with d ∈ M d \in M d ∈ M , then multiplying a pair of the form ( ℓ e x f ρ , ℓ e y f ρ ) (\ell exf\rho,\ell eyf\rho) ( ℓ e x f ρ , ℓ ey f ρ ) on the left replaces ℓ \ell ℓ by d ℓ d\ell d ℓ , and multiplying it on the right replaces ρ \rho ρ by ρ d \rho d ρ d . In either case the defining conditions remain satisfied. Hence these products belong to R c g R_{\mathrm{cg}} R cg .
Now consider the third case of multiplying two non-diagonal pairs (i.e., pairs ( p , q ) (p,q) ( p , q ) with p ≠ q p \ne q p = q ) of R c g R_{\mathrm{cg}} R cg . For each i ∈ { 1 , 2 } i \in\{1,2\} i ∈ { 1 , 2 } , write the i i i -th pair as ( ℓ i e i x i f i ρ i , ℓ i e i y i f i ρ i ) (\ell_i e_i x_i f_i\rho_i,\ell_i e_i y_i f_i\rho_i) ( ℓ i e i x i f i ρ i , ℓ i e i y i f i ρ i ) , where ℓ i , ρ i , x i , y i ∈ M \ell_i,\rho_i,x_i,y_i \in M ℓ i , ρ i , x i , y i ∈ M and e i , f i ∈ Idem ( S η ) e_i,f_i \in\operatorname{Idem}(S_\eta) e i , f i ∈ Idem ( S η ) . The definition of R c g R_{\mathrm{cg}} R cg provides k i ∈ N + k_i \in\mathbb{N}_+ k i ∈ N + such that e i , f i , x i , y i ∈ η ( Σ k i ) e_i,f_i,x_i,y_i \in\eta(\Sigma^{k_i}) e i , f i , x i , y i ∈ η ( Σ k i ) . Consequently, x i τ l e n y i x_i \mathrel{\tau_{\mathrm{len}}} y_i x i τ len y i for i ∈ { 1 , 2 } i \in\{1,2\} i ∈ { 1 , 2 } ; in particular, x i , y i ∈ S η x_i,y_i \in S_\eta x i , y i ∈ S η .
Set z : = f 1 ρ 1 ℓ 2 e 2 ∈ M z:=f_1\rho_1\ell_2e_2 \in M z := f 1 ρ 1 ℓ 2 e 2 ∈ M . Since f 1 ∈ S η f_1 \in S_\eta f 1 ∈ S η , it has a nonempty preimage. Surjectivity of η \eta η gives preimages in Σ ∗ \Sigma^* Σ ∗ for ρ 1 , ℓ 2 , e 2 \rho_1,\ell_2,e_2 ρ 1 , ℓ 2 , e 2 . Concatenating them after a nonempty preimage of f 1 f_1 f 1 gives a nonempty preimage of z z z . Thus z ∈ S η z \in S_\eta z ∈ S η , and reflexivity of τ l e n \tau_{\mathrm{len}} τ len on S η S_\eta S η gives z τ l e n z z \mathrel{\tau_{\mathrm{len}}} z z τ len z . Compatibility of τ l e n \tau_{\mathrm{len}} τ len with multiplication on S η S_\eta S η now gives x 1 z x 2 τ l e n y 1 z y 2 x_1zx_2 \mathrel{\tau_{\mathrm{len}}} y_1zy_2 x 1 z x 2 τ len y 1 z y 2 . The coordinatewise product of the two given pairs is ( ℓ 1 e 1 ( x 1 z x 2 ) f 2 ρ 2 , ℓ 1 e 1 ( y 1 z y 2 ) f 2 ρ 2 ) (\ell_1e_1(x_1zx_2)f_2\rho_2,\ell_1e_1(y_1zy_2)f_2\rho_2) ( ℓ 1 e 1 ( x 1 z x 2 ) f 2 ρ 2 , ℓ 1 e 1 ( y 1 z y 2 ) f 2 ρ 2 ) . Apply Claim B.1 to the pair ( e 1 ( x 1 z x 2 ) f 2 , e 1 ( y 1 z y 2 ) f 2 ) ∈ R g (e_1(x_1zx_2)f_2,e_1(y_1zy_2)f_2)\in R_g ( e 1 ( x 1 z x 2 ) f 2 , e 1 ( y 1 z y 2 ) f 2 ) ∈ R g , with contexts ℓ 1 , ρ 2 ∈ M \ell_1,\rho_2\in M ℓ 1 , ρ 2 ∈ M . The claim applies because e 1 , f 2 ∈ Idem ( S η ) e_1,f_2\in\operatorname{Idem}(S_\eta) e 1 , f 2 ∈ Idem ( S η ) and x 1 z x 2 τ l e n y 1 z y 2 x_1zx_2\mathrel{\tau_{\mathrm{len}}}y_1zy_2 x 1 z x 2 τ len y 1 z y 2 . The product therefore belongs to R c g R_{c_g} R c g . This proves compatibility with multiplication, and hence R c g R_{c_g} R c g is a tolerance on M M M .
Since R c g R_{c_g} R c g is a tolerance (by step 3) and since R c g R_{c_g} R c g contains R g R_g R g (by step 2), the minimality of τ g \tau_g τ g gives τ g ⊆ R c g \tau_g\subseteq R_{c_g} τ g ⊆ R c g . Combined with step 1, this establishes τ g = R c g \tau_g=R_{c_g} τ g = R c g .
Logarithmic Lower Bound
Proposition 3.10 (Logarithmic lower bound). If the guard tolerance τ g \tau_g τ g is shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
To show Proposition 3.10, we will first show the following lemma:
Lemma 3.12 (Logarithmic lower bound). The conditional membership problem for P log = a ∗ ( c ∣ d ) b ∗ P_{\log}=a^*(c\mid d)b^* P l o g = a ∗ ( c ∣ d ) b ∗ and T log = a ∗ c b ∗ T_{\log}=a^*cb^* T l o g = a ∗ c b ∗ has query complexity at least logarithmic, that is, Q P log , T log ( n ) Q_{P_{\log},T_{\log}}(n) Q P l o g , T l o g ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
Proof of Lemma 3.12. Fix a word length n ∈ N + n\in\mathbb{N}_+ n ∈ N + , and let T \mathcal{T} T be a correct decision tree for ( P log , T log ) (P_{\log},T_{\log}) ( P l o g , T l o g ) at length n n n . We show that the depth of T \mathcal{T} T is at least logarithmic in n n n .
We will use words of P log ∩ Σ n P_{\log}\cap\Sigma^n P l o g ∩ Σ n of a specific form. For every i ∈ { 0 , … , n − 1 } i\in\{0,\ldots,n-1\} i ∈ { 0 , … , n − 1 } , let u i : = a i c b n − i − 1 u_i:=a^icb^{n-i-1} u i := a i c b n − i − 1 and v i : = a i d b n − i − 1 v_i:=a^idb^{n-i-1} v i := a i d b n − i − 1 . The word u i u_i u i belongs to T log T_{\log} T l o g , whereas the word v i v_i v i belongs to P log ∖ T log P_{\log}\setminus T_{\log} P l o g ∖ T l o g . Thus, for every i i i , the pair ( u i , v i ) (u_i,v_i) ( u i , v i ) is a shattered pair.
We make the following claim (*): two words u i u_i u i and u i ′ u_{i'} u i ′ for two different indices i ≠ i ′ i\ne i' i = i ′ cannot reach the same leaf ℓ \ell ℓ of T \mathcal{T} T . Suppose towards a contradiction that there exist i ≠ i ′ i\ne i' i = i ′ for which this happens. Equivalently, the transcript τ \tau τ of ℓ \ell ℓ admits both u i u_i u i and u i ′ u_{i'} u i ′ as completions.
The transcript τ \tau τ cannot contain the letter c c c . Indeed, the word u i u_i u i contains c c c only at position i + 1 i+1 i + 1 , while the word u i ′ u_{i'} u i ′ contains c c c only at position i ′ + 1 i'+1 i ′ + 1 . Since i ≠ i ′ i\ne i' i = i ′ , there is no position at which both words contain c c c . Hence, as τ \tau τ admits both words as completions, we know that τ \tau τ cannot contain c c c .
In particular, position i + 1 i+1 i + 1 , which contains c c c in u i u_i u i , is not queried on the path to ℓ \ell ℓ . The words u i u_i u i and v i v_i v i differ only at this position: u i u_i u i contains c c c there and v i v_i v i contains d d d there. They agree at every other position. Thus, v i v_i v i is also a completion of τ \tau τ .
Consequently, τ \tau τ has a completion u i ∈ T log u_i\in T_{\log} u i ∈ T l o g and a completion v i ∈ P log ∖ T log v_i\in P_{\log}\setminus T_{\log} v i ∈ P l o g ∖ T l o g , so it is shattering. As τ \tau τ is the transcript of ℓ \ell ℓ which is a leaf of T \mathcal{T} T , by Lemma 2.1 this contradicts our assumption that T \mathcal{T} T was correct. We conclude that, whenever i ≠ i ′ i\ne i' i = i ′ , the words u i u_i u i and u i ′ u_{i'} u i ′ must reach different leaves, i.e., we have established (*).
Now, there are n n n words u 0 , … , u n − 1 u_0,\ldots,u_{n-1} u 0 , … , u n − 1 , so T \mathcal{T} T must have at least n n n different leaves. Let d d d be the depth of T \mathcal{T} T . Since every internal node of a decision tree has at most ∣ Σ ∣ |\Sigma| ∣Σ∣ outgoing edges, a decision tree of depth d d d has at most ∣ Σ ∣ d |\Sigma|^d ∣Σ ∣ d leaves. We therefore have n ≤ ∣ Σ ∣ d n\le|\Sigma|^d n ≤ ∣Σ ∣ d , and hence d ≥ log ∣ Σ ∣ n d\ge\log_{|\Sigma|}n d ≥ log ∣Σ∣ n .
As Σ \Sigma Σ is fixed together with P log P_{\log} P l o g and T log T_{\log} T l o g , this shows that d d d is in Ω ( log n ) \Omega(\log n) Ω ( log n ) . The decision tree T \mathcal{T} T was an arbitrary correct decision tree at length n n n , so the minimum depth of a correct decision tree at length n n n is in Ω ( log n ) \Omega(\log n) Ω ( log n ) . By the definition of query complexity, we conclude that Q P log , T log ( n ) Q_{P_{\log},T_{\log}}(n) Q P l o g , T l o g ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
We now state and prove the three reductions used to transfer the logarithmic lower bound: inclusion, quotients, and inverse length-multiplying morphisms.
Lemma 3.13 (Inclusion). Let T 1 ⊆ P 1 ⊆ Σ ∗ T_1\subseteq P_1\subseteq\Sigma^* T 1 ⊆ P 1 ⊆ Σ ∗ and T 2 ⊆ P 2 ⊆ Σ ∗ T_2\subseteq P_2\subseteq\Sigma^* T 2 ⊆ P 2 ⊆ Σ ∗ be such that T 1 ⊆ T 2 T_1\subseteq T_2 T 1 ⊆ T 2 and P 1 ∖ T 1 ⊆ P 2 ∖ T 2 P_1\setminus T_1\subseteq P_2\setminus T_2 P 1 ∖ T 1 ⊆ P 2 ∖ T 2 . Then, for every n ∈ N n\in\mathbb{N} n ∈ N , Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) Q_{P_1,T_1}(n)\le Q_{P_2,T_2}(n) Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) .
Proof of Lemma 3.13. Fix a length k ∈ N k\in\mathbb{N} k ∈ N , and let T \mathcal{T} T be a decision tree that is correct for ( P 2 , T 2 ) (P_2,T_2) ( P 2 , T 2 ) at length k k k . We claim that the same decision tree is correct for ( P 1 , T 1 ) (P_1,T_1) ( P 1 , T 1 ) at length k k k .
Indeed, every word of T 1 ∩ Σ k T_1\cap\Sigma^k T 1 ∩ Σ k belongs to T 2 ∩ Σ k T_2\cap\Sigma^k T 2 ∩ Σ k , so it is accepted by T \mathcal{T} T . Likewise, every word of ( P 1 ∖ T 1 ) ∩ Σ k (P_1\setminus T_1)\cap\Sigma^k ( P 1 ∖ T 1 ) ∩ Σ k belongs to ( P 2 ∖ T 2 ) ∩ Σ k (P_2\setminus T_2)\cap\Sigma^k ( P 2 ∖ T 2 ) ∩ Σ k , so it is rejected by T \mathcal{T} T . Hence T \mathcal{T} T is correct for ( P 1 , T 1 ) (P_1,T_1) ( P 1 , T 1 ) . Thus, at every length k k k , the minimum depth of a correct decision tree for ( P 1 , T 1 ) (P_1,T_1) ( P 1 , T 1 ) is at most the corresponding minimum depth for ( P 2 , T 2 ) (P_2,T_2) ( P 2 , T 2 ) . Taking the maximum over 0 ≤ k ≤ n 0\le k\le n 0 ≤ k ≤ n yields Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) Q_{P_1,T_1}(n)\le Q_{P_2,T_2}(n) Q P 1 , T 1 ( n ) ≤ Q P 2 , T 2 ( n ) , as required.
Lemma 3.14 (Quotient). Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ and let u , v ∈ Σ ∗ u,v \in\Sigma^* u , v ∈ Σ ∗ . Then, for every n ∈ N n \in\mathbb{N} n ∈ N , we have
Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) . Q_{u^{-1}Pv^{-1},u^{-1}Tv^{-1}}(n) \le Q_{P,T}(n+|u|+|v|). Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) .
Proof of Lemma 3.14. Fix k ∈ N k \in\mathbb{N} k ∈ N , and let T \mathcal{T} T be a decision tree that is correct for ( P , T ) (P,T) ( P , T ) at length ∣ u ∣ + k + ∣ v ∣ |u|+k+|v| ∣ u ∣ + k + ∣ v ∣ . We construct a decision tree T ′ \mathcal{T}' T ′ for ( u − 1 P v − 1 , u − 1 T v − 1 ) (u^{-1}Pv^{-1},u^{-1}Tv^{-1}) ( u − 1 P v − 1 , u − 1 T v − 1 ) at length k k k by simulating T \mathcal{T} T on u w v uwv u w v , where w ∈ Σ k w \in\Sigma^k w ∈ Σ k is the input.
Whenever T \mathcal{T} T queries a position belonging to w w w , we query the corresponding position of w w w in T ′ \mathcal{T}' T ′ . Whenever it queries a position belonging to u u u or v v v , the answer is already known, so we follow the corresponding edge without making a query in T ′ \mathcal{T}' T ′ .
If w ∈ u − 1 T v − 1 w \in u^{-1}Tv^{-1} w ∈ u − 1 T v − 1 , then u w v ∈ T uwv \in T u w v ∈ T , so T ′ \mathcal{T}' T ′ accepts. If w ∈ u − 1 P v − 1 ∖ u − 1 T v − 1 w \in u^{-1}Pv^{-1} \setminus u^{-1}Tv^{-1} w ∈ u − 1 P v − 1 ∖ u − 1 T v − 1 , then u w v ∈ P ∖ T uwv \in P \setminus T u w v ∈ P ∖ T , so T ′ \mathcal{T}' T ′ rejects. Hence T ′ \mathcal{T}' T ′ is correct for ( u − 1 P v − 1 , u − 1 T v − 1 ) (u^{-1}Pv^{-1},u^{-1}Tv^{-1}) ( u − 1 P v − 1 , u − 1 T v − 1 ) and has depth at most that of T \mathcal{T} T .
Thus, for every k ∈ N k \in\mathbb{N} k ∈ N , the minimum depth at length k k k for ( u − 1 P v − 1 , u − 1 T v − 1 ) (u^{-1}Pv^{-1},u^{-1}Tv^{-1}) ( u − 1 P v − 1 , u − 1 T v − 1 ) is at most the minimum depth at length ∣ u ∣ + k + ∣ v ∣ |u|+k+|v| ∣ u ∣ + k + ∣ v ∣ for ( P , T ) (P,T) ( P , T ) . Taking the maximum over 0 ≤ k ≤ n 0 \le k \le n 0 ≤ k ≤ n yields
Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) . Q_{u^{-1}Pv^{-1},u^{-1}Tv^{-1}}(n) \le Q_{P,T}(n+|u|+|v|). Q u − 1 P v − 1 , u − 1 T v − 1 ( n ) ≤ Q P , T ( n + ∣ u ∣ + ∣ v ∣ ) .
Lemma 3.15 (Inverse lm-morphism). Let Γ \Gamma Γ and Σ \Sigma Σ be finite alphabets, and let h : Γ ∗ → Σ ∗ h:\Gamma^* \to\Sigma^* h : Γ ∗ → Σ ∗ be a morphism. Assume that there exists an integer ℓ ∈ N + \ell\in\mathbb{N}_+ ℓ ∈ N + such that ∣ h ( a ) ∣ = ℓ |h(a)|=\ell ∣ h ( a ) ∣ = ℓ for every a ∈ Γ a \in\Gamma a ∈ Γ . Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , and let P ′ = h − 1 ( P ) P'=h^{-1}(P) P ′ = h − 1 ( P ) and T ′ = h − 1 ( T ) T'=h^{-1}(T) T ′ = h − 1 ( T ) . Then, for every n ∈ N n \in\mathbb{N} n ∈ N , Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) Q_{P',T'}(n) \le Q_{P,T}(\ell n) Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) .
Proof of Lemma 3.15. Fix k ∈ N k \in\mathbb{N} k ∈ N , and let T \mathcal{T} T be a correct decision tree for ( P , T ) (P,T) ( P , T ) at length ℓ k \ell k ℓ k . We construct a correct decision tree T ′ \mathcal{T}' T ′ for ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) at length k k k whose depth is at most that of T \mathcal{T} T .
On an input u = a 1 ⋯ a k ∈ Γ k u=a_1\cdots a_k \in\Gamma^k u = a 1 ⋯ a k ∈ Γ k , the tree T ′ \mathcal{T}' T ′ simulates T \mathcal{T} T on h ( u ) = h ( a 1 ) ⋯ h ( a k ) h(u)=h(a_1)\cdots h(a_k) h ( u ) = h ( a 1 ) ⋯ h ( a k ) in the following way. Whenever T \mathcal{T} T queries position j ∈ [ ℓ k ] j \in[\ell k] j ∈ [ ℓ k ] , then there are unique i ∈ [ k ] i \in[k] i ∈ [ k ] and r ∈ [ ℓ ] r \in[\ell] r ∈ [ ℓ ] such that j = ℓ ( i − 1 ) + r j=\ell(i-1)+r j = ℓ ( i − 1 ) + r , i.e., position j j j of h ( u ) h(u) h ( u ) is the r r r -th position in the block h ( a i ) h(a_i) h ( a i ) .
If position i i i of u u u has not yet been queried, then T ′ \mathcal{T}' T ′ queries it. The answer determines a i a_i a i , and therefore determines the whole block h ( a i ) h(a_i) h ( a i ) and, in particular, the letter at position j j j of h ( u ) h(u) h ( u ) . If position i i i has already been queried in an ancestor node in T ′ \mathcal{T}' T ′ (i.e., a position in the same block has already been queried in an ancestor node in T ′ \mathcal{T}' T ′ ), then this is already known. Thus T ′ \mathcal{T}' T ′ can in either case follow the same edge as T \mathcal{T} T .
Therefore T ′ \mathcal{T}' T ′ follows the same path that T \mathcal{T} T follows on h ( u ) h(u) h ( u ) . Moreover, our construction ensures that each position of u u u is queried at most once, and a query is made only when T \mathcal{T} T queries a position in the corresponding block. Hence the depth of T ′ \mathcal{T}' T ′ is at most the depth of T \mathcal{T} T .
It remains to verify that T ′ \mathcal{T}' T ′ is correct. If u ∈ P ′ u \in P' u ∈ P ′ , then h ( u ) ∈ P h(u) \in P h ( u ) ∈ P , and by definition u ∈ T ′ u \in T' u ∈ T ′ if and only if h ( u ) ∈ T h(u) \in T h ( u ) ∈ T . Since T \mathcal{T} T is correct for ( P , T ) (P,T) ( P , T ) , the tree T ′ \mathcal{T}' T ′ is therefore correct for ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) .
We have thus shown that, for every k ∈ N k \in\mathbb{N} k ∈ N , the minimum depth of a correct decision tree for ( P ′ , T ′ ) (P',T') ( P ′ , T ′ ) at length k k k is at most the minimum depth of a correct decision tree for ( P , T ) (P,T) ( P , T ) at length ℓ k \ell k ℓ k . Taking the maximum over 0 ≤ k ≤ n 0 \le k \le n 0 ≤ k ≤ n yields Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) Q_{P',T'}(n) \le Q_{P,T}(\ell n) Q P ′ , T ′ ( n ) ≤ Q P , T ( ℓ n ) , as required.
We now have what is needed to prove Proposition 3.10:
Proof of Proposition 3.10. By Lemma 3.9, τ g = R c g \tau_g=R_{\mathrm{cg}} τ g = R cg . Since τ g \tau_g τ g is shattering, we may choose a shattered pair ( p , q ) ∈ R c g (p,q) \in R_{\mathrm{cg}} ( p , q ) ∈ R cg with p ∈ M P p \in M_P p ∈ M P and q ∈ M T q \in M_T q ∈ M T . In particular, p ≠ q p \ne q p = q .
By the definition of R c g R_{\mathrm{cg}} R cg , there exist ℓ , ρ , x , y ∈ M \ell,\rho,x,y \in M ℓ , ρ , x , y ∈ M , idempotents e , f ∈ Idem ( S n ) e,f \in\operatorname{Idem}(S_n) e , f ∈ Idem ( S n ) , and an integer k ∈ N + k \in\mathbb{N}_+ k ∈ N + such that p = ℓ e x f p p=\ell exfp p = ℓ e x f p , q = ℓ e y f p q=\ell eyfp q = ℓ ey f p , and e , f , x , y ∈ η ( Σ k ) e,f,x,y \in\eta(\Sigma^k) e , f , x , y ∈ η ( Σ k ) . Choose E , F , X , Y ∈ Σ k E,F,X,Y \in\Sigma^k E , F , X , Y ∈ Σ k representing e , f , x , y e,f,x,y e , f , x , y , respectively, so η ( E ) = e \eta(E)=e η ( E ) = e , η ( F ) = f \eta(F)=f η ( F ) = f , η ( X ) = x \eta(X)=x η ( X ) = x , and η ( Y ) = y \eta(Y)=y η ( Y ) = y , and L , R ∈ Σ ∗ L,R \in\Sigma^* L , R ∈ Σ ∗ with η ( L ) = ℓ \eta(L)=\ell η ( L ) = ℓ and η ( R ) = ρ \eta(R)=\rho η ( R ) = ρ . Set u=\ell E^iX^F^jv and v = ℓ E i Y F j v v=\ell E^iYF^jv v = ℓ E i Y F j v . Since e , f e,f e , f are idempotent, for all i , j ∈ N i,j \in\mathbb{N} i , j ∈ N we have \eta(uE^iX^F^jv)=\ell e^{i+1}xf^{j+1}\rho=p and η ( u E i Y F j v ) = ℓ e i + 1 y f j + 1 ρ = q \eta(uE^iYF^jv)=\ell e^{i+1}yf^{j+1}\rho=q η ( u E i Y F j v ) = ℓ e i + 1 y f j + 1 ρ = q .
We now proceed through three consecutive reductions to show that the lower bound for ( P l o g , T l o g ) (P_{\mathrm{log}},T_{\mathrm{log}}) ( P log , T log ) holds for this problem.
First, we use the inclusion lemma, Lemma 3.13, to show that it suffices to show our lower bound for T ′ = u E ∗ X F ∗ v T'=uE^*XF^*v T ′ = u E ∗ X F ∗ v and P ′ = u E ∗ Y F ∗ v ∪ u E ∗ X F ∗ v P'=uE^*YF^*v \cup uE^*XF^*v P ′ = u E ∗ Y F ∗ v ∪ u E ∗ X F ∗ v . Indeed, p ∈ M T p \in M_T p ∈ M T and q ∈ M P ∖ M T q \in M_P \setminus M_T q ∈ M P ∖ M T , so T ′ ⊆ T T' \subseteq T T ′ ⊆ T and P ′ ⊆ P P' \subseteq P P ′ ⊆ P . The two languages u E ∗ X F ∗ v uE^*XF^*v u E ∗ X F ∗ v and u E ∗ Y F ∗ v uE^*YF^*v u E ∗ Y F ∗ v are disjoint because their words have distinct images p p p and q q q under η \eta η . Thus P ′ ∖ T ′ = u E ∗ Y F ∗ v ⊆ P ∖ T P'\setminus T'=uE^*YF^*v \subseteq P\setminus T P ′ ∖ T ′ = u E ∗ Y F ∗ v ⊆ P ∖ T , so the inclusion lemma applies. We now remove the fixed prefix u u u and suffix v v v using the quotient lemma, Lemma 3.14. This establishes that it suffices to show the lower bound for T ′ ′ : = u − 1 T ′ v − 1 = E ∗ X F ∗ T^{\prime\prime} := u^{-1}T'v^{-1} = E^*XF^* T ′′ := u − 1 T ′ v − 1 = E ∗ X F ∗ and P ′ ′ : = u − 1 P ′ v − 1 = E ∗ Y F ∗ ∪ E ∗ X F ∗ P^{\prime\prime} := u^{-1}P'v^{-1} = E^*YF^* \cup E^*XF^* P ′′ := u − 1 P ′ v − 1 = E ∗ Y F ∗ ∪ E ∗ X F ∗ .
Finally, using the inverse length-multiplying morphism lemma, Lemma 3.15, we reduce this problem to the example languages T log T_{\log} T l o g and P log P_{\log} P l o g from Example 3.11. The words E E E , F F F , X X X , Y Y Y all have length k k k , so define a length-multiplying morphism h : Γ ∗ → Σ ∗ h:\Gamma^* \to\Sigma^* h : Γ ∗ → Σ ∗ , where Γ = { a , b , c , d } \Gamma= \{a,b,c,d\} Γ = { a , b , c , d } , by h ( a ) = E h(a) = E h ( a ) = E , h ( b ) = F h(b) = F h ( b ) = F , h ( c ) = X h(c) = X h ( c ) = X , and h ( d ) = Y h(d) = Y h ( d ) = Y . This allows us to apply the inverse length-multiplying morphism lemma. Every word of T log T_{\log} T l o g maps into T ′ ′ T^{\prime\prime} T ′′ , and every word of P log ∖ T log P_{\log} \setminus T_{\log} P l o g ∖ T l o g maps into E ∗ Y F ∗ E^*YF^* E ∗ Y F ∗ . The languages E ∗ X F ∗ E^*XF^* E ∗ X F ∗ and E ∗ Y F ∗ E^*YF^* E ∗ Y F ∗ are disjoint: otherwise, adding the prefix u u u and suffix v v v to a word in the intersection would give a word whose image under η \eta η would have to be both p p p and q q q , which is impossible because p ≠ q p \ne q p = q . Hence T log ⊆ h − 1 ( T ′ ′ ) T_{\log} \subseteq h^{-1}(T^{\prime\prime}) T l o g ⊆ h − 1 ( T ′′ ) and P log ∖ T log ⊆ h − 1 ( P ′ ′ ) ∖ h − 1 ( T ′ ′ ) P_{\log} \setminus T_{\log} \subseteq h^{-1}(P^{\prime\prime}) \setminus h^{-1}(T^{\prime\prime}) P l o g ∖ T l o g ⊆ h − 1 ( P ′′ ) ∖ h − 1 ( T ′′ ) , so the inclusion lemma applies to the inverse-image problem. This inclusion step is needed because in general we do not have T log = h − 1 ( T ′ ′ ) T_{\log} = h^{-1}(T^{\prime\prime}) T l o g = h − 1 ( T ′′ ) and P log ∖ T log = h − 1 ( P ′ ′ ) ∖ h − 1 ( T ′ ′ ) P_{\log} \setminus T_{\log} = h^{-1}(P^{\prime\prime}) \setminus h^{-1}(T^{\prime\prime}) P l o g ∖ T l o g = h − 1 ( P ′′ ) ∖ h − 1 ( T ′′ ) , because the inverse images may contain additional words: for instance, if E = F = X E = F = X E = F = X , then h ( a ) = X ∈ T ′ ′ h(a) = X \in T^{\prime\prime} h ( a ) = X ∈ T ′′ although a ∉ T log a \notin T_{\log} a ∈ / T l o g .
Chaining the inequalities given by the reductions, this gives Q P , T ( k n + ∣ u ∣ + ∣ v ∣ ) ≥ Q P log , T log ( n ) Q_{P,T}(kn + |u| + |v|) \ge Q_{P_{\log},T_{\log}}(n) Q P , T ( k n + ∣ u ∣ + ∣ v ∣ ) ≥ Q P l o g , T l o g ( n ) for every n ∈ N n \in\mathbb{N} n ∈ N . By Lemma 3.12, the right-hand side is Ω ( log n ) \Omega(\log n) Ω ( log n ) . Since k > 0 k > 0 k > 0 , u u u , and v v v are fixed, monotonicity of Q P , T Q_{P,T} Q P , T yields that Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( log n ) \Omega(\log n) Ω ( log n ) .
Proofs for Section 4 (The Logarithmic Regime)
Logarithmic Upper Bound
Proposition 4.4 (Logarithmic upper bound). If the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then Q P , T ( n ) = O ( log n ) Q_{P,T}(n) = O(\log n) Q P , T ( n ) = O ( log n ) .
We first show the auxiliary results given in the main text:
Lemma 4.7. Let k , d ∈ N k,d \in\mathbb{N} k , d ∈ N and let T T T be a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree over Σ K \Sigma^K Σ K at length k k k and depth at most d d d . We can build a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree T ′ T' T ′ over Σ \Sigma Σ at length K k Kk K k and depth at most K d Kd K d .
Proof of Lemma 4.7. We replace each block query by K K K letter queries. We first construct T ′ T' T ′ , then verify that τ m g \tau_{\mathrm{mg}} τ mg -coherence is preserved, before finally bounding the depth of T ′ T' T ′ .
We first construct T ′ T' T ′ . At each internal node of T T T that queries block i ∈ [ k ] i \in[k] i ∈ [ k ] , where i i i is the queried block position, replace the node by a complete tree that queries the positions K ( i − 1 ) + 1 , … , K i K(i-1)+1,\ldots,Ki K ( i − 1 ) + 1 , … , K i in order. The answers form a block A ∈ Σ K A \in\Sigma^K A ∈ Σ K , the block read at position i i i . Attach the corresponding child of the original node at the leaf reached by A A A . Keep all original leaf labels. Since no block is queried twice along a branch of T T T , and distinct blocks occupy disjoint letter positions, it is also true that no letter is queried twice along a branch of T ′ T' T ′ .
We now prove that coherence is preserved. Let d ′ d' d ′ be a leaf of T ′ T' T ′ with transcript t ′ t' t ′ , and let d d d be the original leaf of T T T from which it arose, with transcript t t t . For any two completions t x , t y t_x,t_y t x , t y of t ′ t' t ′ , grouping their letters into blocks gives completions of t t t . Since T T T is τ m g \tau_{\mathrm{mg}} τ mg -coherent, we have η ( t x ) τ m g η ( t y ) \eta(t_x) \mathrel{\tau_{\mathrm{mg}}} \eta(t_y) η ( t x ) τ mg η ( t y ) . Hence T ′ T' T ′ is τ m g \tau_{\mathrm{mg}} τ mg -coherent.
Finally, we bound the depth. Each block query is replaced by exactly K K K letter queries. Thus each branch of length at most d d d becomes a branch of length at most K d Kd K d , as claimed.
Lemma 4.8. If τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, then for all n ∈ N n \in\mathbb{N} n ∈ N , we have Q P , T ( n ) ≤ K ( C Σ K ( ⌊ n / K ⌋ + 1 ) Q_{P,T}(n) \le K(C_{\Sigma^K}(\lfloor n/K\rfloor+ 1) Q P , T ( n ) ≤ K ( C Σ K (⌊ n / K ⌋ + 1 ) , where C Σ K C_{\Sigma^K} C Σ K is the query complexity restricted to τ m g \tau_{\mathrm{mg}} τ mg -coherent decision trees over Σ K \Sigma^K Σ K .
Proof of Lemma 4.8. Fix n ∈ N n \in\mathbb{N} n ∈ N : we construct a correct tree T T T over Σ \Sigma Σ for every length m ≤ n m \le n m ≤ n . Fix a word length m ∈ N m \in\mathbb{N} m ∈ N with m ≤ n m \le n m ≤ n , and write m = K k + r m = Kk + r m = K k + r , where k = ⌊ m / K ⌋ ∈ N k = \lfloor m/K \rfloor\in\mathbb{N} k = ⌊ m / K ⌋ ∈ N counts full blocks and $0 \le r < K$ is the number of remaining letters. If k = 0 k = 0 k = 0 , query all m m m letters and label each leaf according to membership in T T T for inputs in P P P (arbitrarily otherwise). Otherwise, for k > 0 k > 0 k > 0 , let D : = C Σ K ( k ) D := C_{\Sigma^K}(k) D := C Σ K ( k ) , the query complexity restricted to coherent block trees up to length k k k . By the definition of D D D , there exists a τ m g \tau_{\mathrm{mg}} τ mg -coherent tree T k T_k T k over Σ K \Sigma^K Σ K at length k k k of depth at most $D. Use Lemma 4.7 to translate it to a τ m g \tau_{\mathrm{mg}} τ mg -coherent decision tree T k ′ T'_k T k ′ over Σ \Sigma Σ at length K k Kk K k of depth at most K D KD K D . Then, to build T T T , first query the final r r r letters using a complete decision tree, and then attach a copy of T k ′ T'_k T k ′ at each leaf.
We next establish correctness of the leaves of T T T . The claim is immediate for k = 0 k=0 k = 0 , so assume that k > 0 k>0 k > 0 . Fix a leaf of T T T , and let u ∈ Σ r u\in\Sigma^r u ∈ Σ r be the suffix revealed by the first r r r queries. Let d d d be the corresponding leaf of T k ′ T'_k T k ′ , let t t t be its transcript, and take any two completions t x , t y t_x,t_y t x , t y of t t t . By τ m g \tau_{\mathrm{mg}} τ mg -coherence, we have η ( t x ) τ m g η ( t y ) \eta(t_x)\mathrel{\tau_{\mathrm{mg}}}\eta(t_y) η ( t x ) τ mg η ( t y ) , interpreting the block words through decoding. Since η ( u ) τ m g η ( u ) \eta(u)\mathrel{\tau_{\mathrm{mg}}}\eta(u) η ( u ) τ mg η ( u ) by reflexivity, compatibility with multiplication shows that the words t x u t_xu t x u and t y u t_yu t y u also have images related by τ m g \tau_{\mathrm{mg}} τ mg . As τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, these two words cannot lie on opposite sides of T T T while both belonging to P P P . This holds for every two completions of the resulting leaf transcript, so Lemma 2.1 gives a correct leaf labeling.
Finally, we bound the depth. If k = 0 k=0 k = 0 , the tree has depth m < K m<K m < K . Otherwise, it has depth at most r + K D r+KD r + K D , where r < K r<K r < K . Hence in both cases the depth is at most K ( D + 1 ) K(D+1) K ( D + 1 ) . Taking the maximum over all m ≤ n m\le n m ≤ n gives Q P , T ( n ) ≤ K ( C Σ K ( ⌊ n / K ⌋ ) + 1 ) Q_{P,T}(n)\le K\left(C_{\Sigma^K}\left(\lfloor n/K\rfloor\right)+1\right) Q P , T ( n ) ≤ K ( C Σ K ( ⌊ n / K ⌋ ) + 1 ) . ◀
Lemma 4.9. For all v ∈ Σ K v\in\Sigma^K v ∈ Σ K and X ′ , Y ′ ∈ ( Σ K ) ∗ X',Y'\in(\Sigma^K)^* X ′ , Y ′ ∈ ( Σ K ) ∗ , we have η ( v X ′ v ) τ m g η ( v Y ′ v ) \eta(vX'v)\mathrel{\tau_{\mathrm{mg}}}\eta(vY'v) η ( v X ′ v ) τ mg η ( v Y ′ v ) .
Proof of Lemma 4.9. We first fix the two middle words and their lengths. Fix v ∈ Σ K v\in\Sigma^K v ∈ Σ K and X ′ , Y ′ ∈ ( Σ K ) ∗ X',Y'\in(\Sigma^K)^* X ′ , Y ′ ∈ ( Σ K ) ∗ . By symmetry of τ m g \tau_{\mathrm{mg}} τ mg , up to exchanging X ′ X' X ′ and Y ′ Y' Y ′ , assume ∣ X ′ ∣ ≤ ∣ Y ′ ∣ |X'|\le|Y'| ∣ X ′ ∣ ≤ ∣ Y ′ ∣ (when counting blocks, i.e., as words on Σ K \Sigma^K Σ K ). Set d : = ∣ Y ′ ∣ − ∣ X ′ ∣ ∈ N d:=|Y'|-|X'|\in\mathbb{N} d := ∣ Y ′ ∣ − ∣ X ′ ∣ ∈ N , the difference in the number of blocks. We first find an idempotent factor of v v v . Since K = q π ≥ q K=q\pi\ge q K = q π ≥ q , Lemma 2.2 gives a factorization v = h e g v=heg v = h e g , where h , g ∈ Σ ∗ h,g\in\Sigma^* h , g ∈ Σ ∗ , e ∈ Σ + e\in\Sigma^+ e ∈ Σ + , and η ( e ) \eta(e) η ( e ) is idempotent. In particular, η ( e ) ∈ Idem ( S η ) \eta(e)\in\operatorname{Idem}(S_\eta) η ( e ) ∈ Idem ( S η ) .
Now, we pick a suitable preimage for e e e . By Lemma 2.8, choose E ∈ Σ π E\in\Sigma^\pi E ∈ Σ π with η ( E ) = η ( e ) \eta(E)=\eta(e) η ( E ) = η ( e ) . Since K = q π K=q\pi K = q π and q > 0 q>0 q > 0 , the word E q ∈ Σ K E^q\in\Sigma^K E q ∈ Σ K has image η ( E q ) = η ( e ) \eta(E^q)=\eta(e) η ( E q ) = η ( e ) by idempotence. Put X : = g X ′ h e ( E q ) d X:=gX'he(E^q)^d X := g X ′ h e ( E q ) d and Y : = g Y ′ h e Y:=gY'he Y := g Y ′ h e in Σ ∗ \Sigma^* Σ ∗ . Counting letters of Σ \Sigma Σ , we have ∣ X ∣ = K ∣ X ′ ∣ + K + d K = K ∣ Y ′ ∣ + K = ∣ Y ∣ |X|=K|X'|+K+dK=K|Y'|+K=|Y| ∣ X ∣ = K ∣ X ′ ∣ + K + d K = K ∣ Y ′ ∣ + K = ∣ Y ∣ , a positive multiple of K K K and hence of π \pi π .
We next apply the matched-guard relation to equal-length words. Set ℓ : = ∣ X ∣ / π ∈ N + \ell:=|X|/\pi\in\mathbb{N}_+ ℓ := ∣ X ∣/ π ∈ N + , the number of blocks of length π \pi π in X X X . The word E ℓ E^\ell E ℓ has length ∣ X ∣ = ∣ Y ∣ |X|=|Y| ∣ X ∣ = ∣ Y ∣ and image η ( E ℓ ) = η ( e ) \eta(E^\ell)=\eta(e) η ( E ℓ ) = η ( e ) by idempotence. Thus η ( e ) τ l e n η ( X ) \eta(e)\mathrel{\tau_{\mathrm{len}}}\eta(X) η ( e ) τ len η ( X ) and η ( e ) τ l e n η ( Y ) \eta(e)\mathrel{\tau_{\mathrm{len}}}\eta(Y) η ( e ) τ len η ( Y ) , so Definition 4.1 gives η ( e X e ) R m g η ( e Y e ) \eta(eXe)\mathrel{R_{\mathrm{mg}}}\eta(eYe) η ( e X e ) R mg η ( e Y e ) . By idempotence of η ( e ) \eta(e) η ( e ) , we have η ( e ( E q ) d e ) = η ( e ) \eta(e(E^q)^de)=\eta(e) η ( e ( E q ) d e ) = η ( e ) ; this also holds when d = 0 d=0 d = 0 . Hence η ( v X ′ v ) = η ( h e g X ′ h e g ) = η ( h e g X ′ h e ( E q ) d e g ) = η ( h ) η ( e X e ) η ( g ) \eta(vX'v)=\eta(hegX'heg)=\eta(hegX'he(E^q)^deg)=\eta(h)\eta(eXe)\eta(g) η ( v X ′ v ) = η ( h e g X ′ h e g ) = η ( h e g X ′ h e ( E q ) d e g ) = η ( h ) η ( e X e ) η ( g ) and η ( v Y ′ v ) = η ( h e g Y ′ h e g ) = η ( h e g Y ′ h e e g ) = η ( h ) η ( e Y e ) η ( g ) \eta(vY'v)=\eta(he gY'heg)=\eta(he gY'heeg)=\eta(h)\eta(eYe)\eta(g) η ( v Y ′ v ) = η ( h e g Y ′ h e g ) = η ( h e g Y ′ h ee g ) = η ( h ) η ( e Y e ) η ( g ) . Since τ m g \tau_{\mathrm{mg}} τ mg contains R m g R_{\mathrm{mg}} R mg , reflexivity and compatibility with multiplication give η ( v X ′ v ) τ m g η ( v Y ′ v ) \eta(vX'v)\mathrel{\tau_{\mathrm{mg}}}\eta(vY'v) η ( v X ′ v ) τ mg η ( v Y ′ v ) . ◀
Lemma 4.12. Let t t t be a partial word over Σ K \Sigma^K Σ K and let t x , t y t_x,t_y t x , t y be two completions of t t t . If t x t_x t x and t y t_y t y agree on every active interval of t t t , then η ( t x ) τ m g η ( t y ) \eta(t_x)\mathrel{\tau_{\mathrm{mg}}}\eta(t_y) η ( t x ) τ mg η ( t y ) .
Proof of Lemma 4.12. We prove the invariant by induction on the number s ∈ N s\in\mathbb{N} s ∈ N of non-□ \square □ positions of an arbitrary partial word t t t over Σ K \Sigma^K Σ K . At each step, we compare the factor from the first non-□ \square □ letter to its last occurrence and then apply induction to the remaining suffix. Write k : = ∣ t ∣ k:=|t| k := ∣ t ∣ for the length of t t t .
We establish the base case s = 0 s=0 s = 0 . Then t = □ k t=\square^k t = □ k . Its only interval is active, so any two completions t x t_x t x and t y t_y t y of t t t must be identical, and the conclusion follows by reflexivity of τ m g \tau_{\mathrm{mg}} τ mg .
We next set up the inductive step. Let s ∈ N + s\in\mathbb{N}_+ s ∈ N + , and assume the assertion holds for all partial words with fewer than s s s non-□ \square □ positions. Recall the factorization t = □ k 1 v 1 □ k 2 ⋯ v s □ k s + 1 t=\square^{k_1}v_1\square^{k_2}\cdots v_s\square^{k_{s+1}} t = □ k 1 v 1 □ k 2 ⋯ v s □ k s + 1 . For each i ∈ { 0 , … , s } i\in\{0,\ldots,s\} i ∈ { 0 , … , s } , let x i , y i ∈ ( Σ K ) ∗ x_i,y_i\in(\Sigma^K)^* x i , y i ∈ ( Σ K ) ∗ be the respective words filling the i i i -th interval of t t t in t x , t y t_x,t_y t x , t y ; each of these words has length k i + 1 k_{i+1} k i + 1 in blocks, and is empty exactly when the i i i -th interval is empty. Thus t x = x 0 v 1 x 1 ⋯ v s x s t_x=x_0v_1x_1\cdots v_sx_s t x = x 0 v 1 x 1 ⋯ v s x s and t y = y 0 v 1 y 1 ⋯ v s y s t_y=y_0v_1y_1\cdots v_sy_s t y = y 0 v 1 y 1 ⋯ v s y s . Since the first interval is active, x 0 = y 0 x_0=y_0 x 0 = y 0 .
We compare the factors with matching endpoints next. We now focus on the first non-□ \square □ letter v 1 v_1 v 1 of t t t . Let j : = max { i ∈ [ s ] ∣ v i = v 1 } j:=\max\{i\in[s]\mid v_i=v_1\} j := max { i ∈ [ s ] ∣ v i = v 1 } be the index of the last occurrence of v 1 v_1 v 1 in t t t . Let p x , p y ∈ ( Σ K ) ∗ p_x,p_y\in(\Sigma^K)^* p x , p y ∈ ( Σ K ) ∗ be the respective factors of t x , t y t_x,t_y t x , t y from v 1 v_1 v 1 through v j v_j v j , inclusive, and let u x , u y ∈ ( Σ K ) ∗ u_x,u_y\in(\Sigma^K)^* u x , u y ∈ ( Σ K ) ∗ be their respective suffixes strictly after v j v_j v j . Then t x = x 0 p x u x t_x=x_0p_xu_x t x = x 0 p x u x and t y = x 0 p y u y t_y=x_0p_yu_y t y = x 0 p y u y . If j = 1 j=1 j = 1 , then we have p x = p y = v 1 p_x=p_y=v_1 p x = p y = v 1 , so η ( p x ) τ m g η ( p y ) \eta(p_x)\mathrel{\tau_{\mathrm{mg}}}\eta(p_y) η ( p x ) τ mg η ( p y ) by reflexivity. Otherwise, let X ′ , Y ′ ∈ ( Σ K ) ∗ X',Y'\in(\Sigma^K)^* X ′ , Y ′ ∈ ( Σ K ) ∗ be the respective... factors strictly between v 1 v_1 v 1 and v j v_j v j in p x , p y p_x,p_y p x , p y . Since p x = v 1 X ′ v j p_x=v_1X'v_j p x = v 1 X ′ v j , p y = v 1 Y ′ v j p_y=v_1Y'v_j p y = v 1 Y ′ v j , and v j = v 1 v_j=v_1 v j = v 1 , applying Lemma 4.9 gives η ( p x ) τ m g η ( p y ) \eta(p_x)\ \tau_{\mathrm{mg}}\ \eta(p_y) η ( p x ) τ mg η ( p y ) .
We will now apply the induction hypothesis to the remaining suffix. Let t ′ t' t ′ be the suffix partial word of t t t strictly after v j v_j v j ; when j = s j=s j = s , this is t ′ = □ k s + 1 t'=\square^{k_{s+1}} t ′ = □ k s + 1 . The words u x , u y u_x,u_y u x , u y are completions of t ′ t' t ′ , which has s − j < s s-j<s s − j < s non-□ \square □ positions. The first interval of t ′ t' t ′ corresponds to the j j j -th interval of t t t , which is active because v j v_j v j has no later occurrence. Every other active interval of t ′ t' t ′ corresponds to an active interval of t t t , since the occurrences later than its preceding block are unchanged. Hence u x , u y u_x,u_y u x , u y agree on every active interval of t ′ t' t ′ . By the induction hypothesis, η ( u x ) τ m g η ( u y ) \eta(u_x)\ \tau_{\mathrm{mg}}\ \eta(u_y) η ( u x ) τ mg η ( u y ) . Finally, note that x 0 = y 0 x_0=y_0 x 0 = y 0 , so reflexivity and compatibility with multiplication give η ( t x ) τ m g η ( t y ) \eta(t_x)\ \tau_{\mathrm{mg}}\ \eta(t_y) η ( t x ) τ mg η ( t y ) .
Claim 4.15. The tree T \mathcal{T} T has depth at most B ( ⌊ log 2 ( k + 1 ) ⌋ + 1 ) B(\lfloor\log_2(k+1)\rfloor+1) B (⌊ log 2 ( k + 1 )⌋ + 1 ) , where B : = ∣ Σ K ∣ + 1 B:=|\Sigma^K|+1 B := ∣ Σ K ∣ + 1 .
Proof of Claim 4.15. We partition each branch into groups of at most B B B queries. We first show that a query cannot make an unchanged interval active. We then prove that each group halves the largest active-interval size (measured at the first node of the group), and iterate this bound.
We first describe how each query changes the intervals. Let t t t be the transcript before a query, let s ∈ N s\in\mathbb{N} s ∈ N be its number of non-□ \square □ positions, and let i ∈ { 0 , … , s } i\in\{0,\ldots,s\} i ∈ { 0 , … , s } be the index of the interval containing the queried position. Let v ∈ Σ K v\in\Sigma^K v ∈ Σ K be the block returned by the query, and let t ′ t' t ′ be the resulting transcript. The intervals of t ′ t' t ′ with indices less than i i i are the corresponding intervals of t t t . Its i i i -th and ( i + 1 ) (i+1) ( i + 1 ) -th intervals are the two parts of the old i i i -th interval, minus the queried position. For j > i + 1 j>i+1 j > i + 1 , the j j j -th interval of t ′ t' t ′ is the ( j − 1 ) (j-1) ( j − 1 ) -th interval of t t t . For each unchanged interval that was inactive in t t t , let v j v_j v j be its preceding block and choose ℓ ∈ { j + 1 , … , s } \ell\in\{j+1,\ldots,s\} ℓ ∈ { j + 1 , … , s } with v ℓ = v j v_\ell=v_j v ℓ = v j . The original non-□ \square □ blocks occur in the same order in t ′ t' t ′ , so v ℓ v_\ell v ℓ is still later than v j v_j v j . Thus this interval remains inactive. This means that the active intervals in t ′ t' t ′ correspond to active intervals in t t t , plus up to two newly active intervals which must be one of the two parts of the queried interval.
We next prove that the largest active-interval size is halved on a group of B B B consecutive queries along any branch of the decision tree T \mathcal{T} T . Fix its first node d d d of the group, let t d t_d t d be the transcript of d d d , and let N : = max { ∣ I ∣ : I is an active interval of t d } N:=\max\{|I|:I\text{ is an active interval of }t_d\} N := max { ∣ I ∣ : I is an active interval of t d } be the maximum active-interval size at d d d . This value is fixed throughout the group. If N = 0 N=0 N = 0 , then d d d is a leaf and there is nothing to show. Otherwise, we say that an active interval is big if its size is greater than N / 2 N/2 N /2 . Initially, at most B B B active intervals of t d t_d t d are big, because t d t_d t d has at most B B B active intervals by Claim 4.11. Now, as we are selecting intervals of maximal size, at any node whose transcript has at least one big active interval, then we will select a big interval to query. Now, it suffices to observe that newly active intervals cannot be big: this is because d d d had no active intervals of size greater than N N N , and when querying an interval of size at most N N N then the newly active intervals are obtained by splitting the queried interval (by the previous paragraph) so no big active interval can be created (and in particular no active interval of size greater than N N N is ever created). We have shown that, at each node, at least one big interval is queried and removed, and no new big intervals are created. Thus, after at most B B B queries, either the branch ends or every active interval has size at most N / 2 N/2 N /2 .
We now iterate along an arbitrary branch. For each group index a ∈ N a\in\mathbb{N} a ∈ N for which the branch reaches depth a B aB a B , let d a d_a d a be the node at that depth, and let us define its maximum active-interval size: N a : = max { ∣ I ∣ : I is an active interval of the transcript of d a } N_a:=\max\{|I|:I\text{ is an active interval of the transcript of }d_a\} N a := max { ∣ I ∣ : I is an active interval of the transcript of d a } . At the root, we have N 0 = k N_0=k N 0 = k . By the preceding paragraph, if both d a d_a d a and d a + 1 d_{a+1} d a + 1 exist, then N a + 1 ≤ N a / 2 N_{a+1}\leq N_a/2 N a + 1 ≤ N a /2 . Induction gives N a ≤ k / 2 a N_a\leq k/2^a N a ≤ k / 2 a whenever d a d_a d a exists. If k = 0 k=0 k = 0 , the root is a leaf. Otherwise choose a : = ⌊ log 2 ( k + 1 ) ⌋ + 1 a:=\lfloor\log_2(k+1)\rfloor+1 a := ⌊ log 2 ( k + 1 )⌋ + 1 . Then k / 2 a < 1 k/2^a<1 k / 2 a < 1 , so any node d a d_a d a would have all active intervals empty and would be a leaf. Thus no branch contains more than a B aB a B queries, and so the claimed depth bound holds.
We can now conclude the proof of Proposition 4.4:
Proof of Proposition 4.4. Fix n ∈ N n\in\mathbb{N} n ∈ N and let k : = ⌊ n / K ⌋ k:=\lfloor n/K\rfloor k := ⌊ n / K ⌋ . For every 1 ≤ j ≤ k 1\leq j\leq k 1 ≤ j ≤ k , construct the tree T j \mathcal{T}_j T j on j j j blocks as explained in the main text. By Claim 4.15, its depth is at most B ( ⌊ log 2 ( j + 1 ) ⌋ + 1 ) B(\lfloor\log_2(j+1)\rfloor+1) B (⌊ log 2 ( j + 1 )⌋ + 1 ) , where B : = ∣ Σ K ∣ + 1 B:=|\Sigma^K|+1 B := ∣ Σ K ∣ + 1 does not depend on j j j . By Claim 4.14, every T j \mathcal{T}_j T j is τ m g \tau_{\mathrm{mg}} τ mg -coherent (and the single-leaf tree is coherent at length zero). Let d : = B ( ⌊ log 2 ( k + 1 ) ⌋ + 1 ) d:=B(\lfloor\log_2(k+1)\rfloor+1) d := B (⌊ log 2 ( k + 1 )⌋ + 1 ) : this bounds the depth of all these trees. Since j ≤ k j \le k j ≤ k , we have shown that τ m g \tau_{\mathrm{mg}} τ mg -coherent query complexity on alphabet Σ K \Sigma^K Σ K satisfies C Σ K ( k ) ≤ d C_{\Sigma^K}(k) \le d C Σ K ( k ) ≤ d .
We now transfer the bound to ordinary query complexity. Since τ m g \tau_{\mathrm{mg}} τ mg is non-shattering, Lemma 4.8 gives Q P , T ( n ) ≤ K ( C Σ K ( k ) + 1 ) ≤ K ( d + 1 ) Q_{P,T}(n) \le K(C_{\Sigma^K}(k)+1) \le K(d+1) Q P , T ( n ) ≤ K ( C Σ K ( k ) + 1 ) ≤ K ( d + 1 ) . Since K K K and B B B are fixed, this is O ( 1 + log ( n + 1 ) ) O(1+\log(n+1)) O ( 1 + log ( n + 1 )) , and hence O ( log n ) O(\log n) O ( log n ) as n n n grows.
The Contextual Matched-Guard Relations
Lemma 4.17. We have τ m g = R c m g , m 2 \tau_{\mathrm{mg}} = R_{\mathrm{cmg},m^2} τ mg = R cmg , m 2 .
Proof of Lemma 4.17. We prove τ m g = R c m g , m 2 \tau_{\mathrm{mg}} = R_{\mathrm{cmg},m^2} τ mg = R cmg , m 2 by showing the two inclusions, where we recall that m m m was defined as m : = ∣ M ∣ m := |M| m := ∣ M ∣ , i.e., the size of the monoid M M M . First, we prove R c m g , m 2 ⊆ τ m g R_{\mathrm{cmg},m^2} \subseteq\tau_{\mathrm{mg}} R cmg , m 2 ⊆ τ mg , which is the easy direction, simply by establishing that each pair in the definition of R c m g , m 2 R_{\mathrm{cmg},m^2} R cmg , m 2 is a product of pairs in τ m g \tau_{\mathrm{mg}} τ mg . Second, we prove τ m g ⊆ R c m g , m 2 \tau_{\mathrm{mg}} \subseteq R_{\mathrm{cmg},m^2} τ mg ⊆ R cmg , m 2 , using the fact that pairs of τ m g \tau_{\mathrm{mg}} τ mg can be expressed as a product of at most m 2 m^2 m 2 pairs from R m g R_{\mathrm{mg}} R mg and Δ M \Delta_M Δ M .
We first prove R c m g , m 2 ⊆ τ m g R_{\mathrm{cmg},m^2} \subseteq\tau_{\mathrm{mg}} R cmg , m 2 ⊆ τ mg . Let ( p , q ) ∈ R c m g , m 2 (p,q) \in R_{\mathrm{cmg},m^2} ( p , q ) ∈ R cmg , m 2 , where p , q ∈ M p,q \in M p , q ∈ M . By Definition 4.16, there exist an integer t ∈ N t \in\mathbb{N} t ∈ N with 0 ≤ t ≤ m 2 0 \le t \le m^2 0 ≤ t ≤ m 2 and elements a 0 , … , a t ∈ M a_0,\ldots,a_t \in M a 0 , … , a t ∈ M which are the contexts. For each i ∈ [ t ] i \in[t] i ∈ [ t ] , that is, for each integer 1 ≤ i ≤ t 1 \le i \le t 1 ≤ i ≤ t , the definition gives a positive integer k i ∈ N + k_i \in\mathbb{N}_+ k i ∈ N + , an idempotent e i ∈ Idem ( S η ) e_i \in\operatorname{Idem}(S_\eta) e i ∈ Idem ( S η ) , and two elements x i , y i ∈ M x_i,y_i \in M x i , y i ∈ M . These elements satisfy e i , x i , y i ∈ η ( Σ k i ) e_i,x_i,y_i \in\eta(\Sigma^{k_i}) e i , x i , y i ∈ η ( Σ k i ) . The element e i e_i e i is the idempotent (the “guard”), and x i , y i x_i,y_i x i , y i are the middle elements of the i i i -th pair. The definition also gives p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t p = a_0(e_1x_1e_1)a_1\cdots(e_tx_te_t)a_t p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t and q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t q = a_0(e_1y_1e_1)a_1\cdots(e_ty_te_t)a_t q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t .
If t = 0 t = 0 t = 0 , these equalities give p = q = a 0 p = q = a_0 p = q = a 0 , so ( p , q ) ∈ τ m g (p,q) \in\tau_{\mathrm{mg}} ( p , q ) ∈ τ mg by reflexivity. Suppose now that t ≥ 1 t \ge1 t ≥ 1 . For each i ∈ [ t ] i \in[t] i ∈ [ t ] , membership of e i , x i , y i e_i,x_i,y_i e i , x i , y i in η ( Σ k i ) \eta(\Sigma^{k_i}) η ( Σ k i ) means that each is the image of a word of length k i k_i k i . Since k i > 0 k_i > 0 k i > 0 , Definition 3.1 gives e i τ l e n x i e_i \mathrel{\tau_{\mathrm{len}}} x_i e i τ len x i and e i τ l e n y i e_i \mathrel{\tau_{\mathrm{len}}} y_i e i τ len y i . Since e i ∈ Idem ( S η ) e_i \in\operatorname{Idem}(S_\eta) e i ∈ Idem ( S η ) and x i , y i ∈ M x_i,y_i \in M x i , y i ∈ M , Definition 4.1 gives ( e i x i e i , e i y i e i ) ∈ R m g ⊆ τ m g (e_ix_ie_i,e_iy_ie_i) \in R_{\mathrm{mg}} \subseteq\tau_{\mathrm{mg}} ( e i x i e i , e i y i e i ) ∈ R mg ⊆ τ mg . Also, ( a i , a i ) ∈ τ m g (a_i,a_i) \in\tau_{\mathrm{mg}} ( a i , a i ) ∈ τ mg for every 0 ≤ i ≤ t 0 \le i \le t 0 ≤ i ≤ t , by reflexivity of τ m g \tau_{\mathrm{mg}} τ mg . By compatibility with multiplication, the product of these pairs belongs to τ m g \tau_{\mathrm{mg}} τ mg . Take the product in this order: ( a 0 , a 0 ) (a_0,a_0) ( a 0 , a 0 ) , then ( e 1 x 1 e 1 , e 1 y 1 e 1 ) (e_1x_1e_1,e_1y_1e_1) ( e 1 x 1 e 1 , e 1 y 1 e 1 ) , then ( a 1 , a 1 ) (a_1,a_1) ( a 1 , a 1 ) , and so on, ending with ( a t , a t ) (a_t,a_t) ( a t , a t ) . The formulas for p p p and q q q show that this product is ( p , q ) (p,q) ( p , q ) . Thus R c m g , m 2 ⊆ τ m g R_{\mathrm{cmg},m^2} \subseteq\tau_{\mathrm{mg}} R cmg , m 2 ⊆ τ mg .
We now prove τ m g ⊆ R c m g , m 2 \tau_{\mathrm{mg}} \subseteq R_{\mathrm{cmg},m^2} τ mg ⊆ R cmg , m 2 , starting with a bound on the number of factors needed to obtain a pair in τ m g \tau_{\mathrm{mg}} τ mg . First note that the relation R m g R_{\mathrm{mg}} R mg is symmetric by definition: whenever ( e x e , e y e ) ∈ R m g (exe,eye) \in R_{\mathrm{mg}} ( e x e , ey e ) ∈ R mg for e ∈ Idem ( S η ) e \in\operatorname{Idem}(S_\eta) e ∈ Idem ( S η ) and x , y ∈ M x,y \in M x , y ∈ M with e τ l e n x e \mathrel{\tau_{\mathrm{len}}} x e τ len x and e τ l e n y e \mathrel{\tau_{\mathrm{len}}} y e τ len y , exchanging x x x and y y y gives ( e y e , e x e ) ∈ R m g (eye,exe) \in R_{\mathrm{mg}} ( ey e , e x e ) ∈ R mg . However, R m g R_{\mathrm{mg}} R mg need not be reflexive, so let Γ : = Δ M ∪ R m g ⊆ M × M \Gamma:= \Delta_M \cup R_{\mathrm{mg}} \subseteq M \times M Γ := Δ M ∪ R mg ⊆ M × M . We regard Γ \Gamma Γ as an alphabet whose letters are pairs of elements of M M M . By Definition 2.5 (more specifically the equivalent rephrasing given immediately below Definition 2.5), τ m g \tau_{\mathrm{mg}} τ mg is in fact the submonoid of M × M M \times M M × M generated by Γ \Gamma Γ : this uses the fact that Γ \Gamma Γ is already symmetric because R m g R_{\mathrm{mg}} R mg was.
Thus, let us define the morphism μ : Γ ∗ → τ m g \mu\colon\Gamma^* \to\tau_{\mathrm{mg}} μ : Γ ∗ → τ mg by μ ( ( u , v ) ) : = ( u , v ) \mu((u,v)) := (u,v) μ (( u , v )) := ( u , v ) for every letter ( u , v ) ∈ Γ (u,v) \in\Gamma ( u , v ) ∈ Γ . For a word over Γ \Gamma Γ , the morphism μ \mu μ takes the product of its letters in M × M M \times M M × M ; it maps the empty word to ( 1 M , 1 M ) (1_M,1_M) ( 1 M , 1 M ) . Since Γ \Gamma Γ generates τ m g \tau_{\mathrm{mg}} τ mg , this morphism is surjective. Let ( p , q ) ∈ τ m g (p,q) \in\tau_{\mathrm{mg}} ( p , q ) ∈ τ mg , where p , q ∈ M p,q \in M p , q ∈ M . Applying Lemma 2.3 to this surjective morphism μ \mu μ gives an integer r ∈ N r \in\mathbb{N} r ∈ N with r < ∣ τ m g ∣ ≤ ∣ M × M ∣ = m 2 r < |\tau_{\mathrm{mg}}| \le|M \times M| = m^2 r < ∣ τ mg ∣ ≤ ∣ M × M ∣ = m 2 . It also gives letters g 1 , … , g r ∈ Γ g_1,\ldots,g_r \in\Gamma g 1 , … , g r ∈ Γ such that ( p , q ) = g 1 ⋯ g r (p,q) = g_1 \cdots g_r ( p , q ) = g 1 ⋯ g r in M × M M \times M M × M . When r = 0 r = 0 r = 0 , this is the empty product ( p , q ) = ( 1 M , 1 M ) (p,q) = (1_M,1_M) ( p , q ) = ( 1 M , 1 M ) .
We next show how to replace the diagonal factors in g 1 ⋯ g r g_1\cdots g_r g 1 ⋯ g r by contexts, without changing ( p , q ) (p,q) ( p , q ) . Let t ∈ N t \in\mathbb{N} t ∈ N be the number of factors g j g_j g j that do not belong to the diagonal relation Δ M \Delta_M Δ M . Every such factor belongs to R m g R_{\mathrm{mg}} R mg because g j ∈ Γ = Δ M ∪ R m g g_j \in\Gamma= \Delta_M \cup R_{\mathrm{mg}} g j ∈ Γ = Δ M ∪ R mg . We have 0 ≤ t ≤ r < m 2 0 \le t \le r < m^2 0 ≤ t ≤ r < m 2 .
If t = 0 t = 0 t = 0 , all the factors belong to Δ M \Delta_M Δ M , and their product also belongs to Δ M \Delta_M Δ M . Thus p = q p = q p = q ; the case r = 0 r = 0 r = 0 is included here. Taking a 0 : = p ∈ M a_0 := p \in M a 0 := p ∈ M and t = 0 t = 0 t = 0 in Definition 4.16 gives ( p , q ) = ( a 0 , a 0 ) ∈ R c m g , m 2 (p,q) = (a_0,a_0) \in R_{\mathrm{cmg},m^2} ( p , q ) = ( a 0 , a 0 ) ∈ R cmg , m 2 .
Suppose now that t ≥ 1 t \ge1 t ≥ 1 . Write the factors that are not diagonal, in the order in which they occur, as ( p 1 , q 1 ) , … , ( p t , q t ) ∈ R m g (p_1,q_1),\ldots,(p_t,q_t) \in R_{\mathrm{mg}} ( p 1 , q 1 ) , … , ( p t , q t ) ∈ R mg , with p i , q i ∈ M p_i,q_i \in M p i , q i ∈ M for i ∈ [ t ] i \in[t] i ∈ [ t ] . We define elements $a_0,\ldots,a_t \in M from the diagonal factors. The element a 0 a_0 a 0 is the product in M M M of the entries of the diagonal factors before ( p 1 , q 1 ) (p_1,q_1) ( p 1 , q 1 ) . For $1 \le i < t$, the element a i a_i a i is the product of the entries of the diagonal factors between ( p i , q i ) (p_i,q_i) ( p i , q i ) and ( p i + 1 , q i + 1 ) (p_{i+1},q_{i+1}) ( p i + 1 , q i + 1 ) . The element a t a_t a t is the product of the entries of the diagonal factors after ( p t , q t ) (p_t,q_t) ( p t , q t ) . These products are taken in M M M , in the original order, so an empty product is 1 M 1_M 1 M ; the corresponding empty diagonal product in M × M M \times M M × M is ( 1 M , 1 M ) (1_M,1_M) ( 1 M , 1 M ) . A diagonal factor has the form ( a , a ) (a,a) ( a , a ) with a ∈ M a \in M a ∈ M and contributes the same element to both coordinates. Therefore, multiplication in M × M M \times M M × M gives p = a 0 p 1 a 1 ⋯ p t a t p = a_0p_1a_1 \cdots p_ta_t p = a 0 p 1 a 1 ⋯ p t a t and q = a 0 q 1 a 1 ⋯ q t a t q = a_0q_1a_1 \cdots q_ta_t q = a 0 q 1 a 1 ⋯ q t a t . We keep the elements a 0 , … , a t a_0,\ldots,a_t a 0 , … , a t as the contexts in Definition 4.16 .
We now show how to choose preimages of the guard and middle elements for each pair ( p i , q i ) (p_i,q_i) ( p i , q i ) . Fix i ∈ [ t ] i \in[t] i ∈ [ t ] . Since ( p i , q i ) ∈ R m g (p_i,q_i) \in R_{\mathrm{mg}} ( p i , q i ) ∈ R mg , Definition 4.1 gives an idempotent e i ∈ Idem ( S η ) e_i \in\operatorname{Idem}(S_\eta) e i ∈ Idem ( S η ) and elements x i ′ , y i ′ ∈ M x'_i,y'_i \in M x i ′ , y i ′ ∈ M such that p i = e i x i ′ e i p_i = e_ix'_ie_i p i = e i x i ′ e i , q i = e i y i ′ e i q_i = e_iy'_ie_i q i = e i y i ′ e i , e i τ l e n x i ′ e_i \mathrel{\tau_{\mathrm{len}}} x'_i e i τ len x i ′ , and e i τ l e n y i ′ e_i \mathrel{\tau_{\mathrm{len}}} y'_i e i τ len y i ′ . Here e i e_i e i is the idempotent guard, and x i ′ , y i ′ x'_i,y'_i x i ′ , y i ′ are the original middle elements. By Definition 3.1 , the relation e i τ l e n x i ′ e_i \mathrel{\tau_{\mathrm{len}}} x'_i e i τ len x i ′ gives a positive integer r i ∈ N + r_i \in\mathbb{N}_+ r i ∈ N + and words U i , V i ∈ Σ r i U_i,V_i \in\Sigma^{r_i} U i , V i ∈ Σ r i . These words satisfy η ( U i ) = e i \eta(U_i) = e_i η ( U i ) = e i and η ( V i ) = x i ′ \eta(V_i) = x'_i η ( V i ) = x i ′ . Similarly, e i τ l e n y i ′ e_i \mathrel{\tau_{\mathrm{len}}} y'_i e i τ len y i ′ gives a positive integer s i ∈ N + s_i \in\mathbb{N}_+ s i ∈ N + and words U i ′ , W i ∈ Σ s i U'_i,W_i \in\Sigma^{s_i} U i ′ , W i ∈ Σ s i . These words satisfy η ( U i ′ ) = e i \eta(U'_i) = e_i η ( U i ′ ) = e i and η ( W i ) = y i ′ \eta(W_i) = y'_i η ( W i ) = y i ′ . Thus U i U_i U i and U i ′ U'_i U i ′ are preimages of the same guard e i e_i e i , while V i V_i V i and W i W_i W i are preimages of the two original middle elements. The problem is that the lengths r i r_i r i and s i s_i s i are generally not equal, so we must now explain how to build preimages of one common positive length to satisfy the common-length requirements of R c m g , m 2 R_{\mathrm{cmg},m^2} R cmg , m 2 .
Thus, let us build words of one common positive length that are preimages of the guard and of two new middle elements. Set k i : = r i + s i ∈ N + k_i := r_i+s_i \in\mathbb{N}_+ k i := r i + s i ∈ N + , the required common length. Define E i : = U i U i ′ E_i := U_iU'_i E i := U i U i ′ , a preimage for the guard; X i : = V i U i ′ X_i := V_iU'_i X i := V i U i ′ , a preimage for the first new middle element; and Y i : = U i W i Y_i := U_iW_i Y i := U i W i , a preimage for the second new middle element. Since U i , V i U_i,V_i U i , V i have length r i r_i r i and U i ′ , W i U'_i,W_i U i ′ , W i have length s i s_i s i , the words E i , X i , Y i E_i,X_i,Y_i E i , X i , Y i all belong to Σ k i \Sigma^{k_i} Σ k i . By the morphism property of η \eta η and e i 2 = e i e_i^2=e_i e i 2 = e i , we have η ( E i ) = η ( U i ) η ( U i ′ ) = e i 2 = e i \eta(E_i)=\eta(U_i)\eta(U'_i)=e_i^2=e_i η ( E i ) = η ( U i ) η ( U i ′ ) = e i 2 = e i , η ( X i ) = x i ′ e i \eta(X_i)=x'_ie_i η ( X i ) = x i ′ e i , and η ( Y i ) = e i y i ′ \eta(Y_i)=e_iy'_i η ( Y i ) = e i y i ′ . Define the new middle elements x i : = η ( X i ) ∈ M x_i := \eta(X_i) \in M x i := η ( X i ) ∈ M and y i : = η ( Y i ) ∈ M y_i := \eta(Y_i) \in M y i := η ( Y i ) ∈ M . It follows from these three words that e i , x i , y i ∈ η ( Σ k i ) e_i,x_i,y_i \in\eta(\Sigma^{k_i}) e i , x i , y i ∈ η ( Σ k i ) . This is the common-length condition in Definition 4.16 for the i i i -th pair, so the common-length condition holds for every i ∈ [ t ] i \in[t] i ∈ [ t ] .
We now check that the new middle elements x i , y i x_i,y_i x i , y i give the original pair ( p i , q i ) (p_i,q_i) ( p i , q i ) . Since x i = x i ′ e i x_i=x'_ie_i x i = x i ′ e i , y i = e i y i ′ y_i=e_iy'_i y i = e i y i ′ , and e i 2 = e i e_i^2=e_i e i 2 = e i , we have e i x i e i = e i ( x i ′ e i ) e i = e i x i ′ e i = p i e_ix_ie_i=e_i(x'_ie_i)e_i=e_ix'_ie_i=p_i e i x i e i = e i ( x i ′ e i ) e i = e i x i ′ e i = p i and e i y i e i = e i ( e i y i ′ ) e i = e i y i ′ e i = q i e_iy_ie_i=e_i(e_iy'_i)e_i=e_iy'_ie_i=q_i e i y i e i = e i ( e i y i ′ ) e i = e i y i ′ e i = q i . Thus ( e i x i e i , e i y i e i ) = ( p i , q i ) (e_ix_ie_i,e_iy_ie_i)=(p_i,q_i) ( e i x i e i , e i y i e i ) = ( p i , q i ) . This equality holds for every i ∈ [ t ] i \in[t] i ∈ [ t ] .
We finally prove that ( p , q ) ∈ R c m g , m 2 (p,q) \in R_{\mathrm{cmg},m^2} ( p , q ) ∈ R cmg , m 2 , completing the second inclusion. For t = 0 t=0 t = 0 , this was proved above with a 0 = p a_0=p a 0 = p . For t ≥ 1 t \geq1 t ≥ 1 , we have 0 ≤ t < r 2 0 \leq t < r^2 0 ≤ t < r 2 and contexts a 0 , … , a t ∈ M a_0,\ldots,a_t \in M a 0 , … , a t ∈ M . For every i ∈ [ t ] i \in[t] i ∈ [ t ] , we also have a positive integer k i ∈ N + k_i \in\mathbb{N}_+ k i ∈ N + , an idempotent e i ∈ Idem ( S η ) e_i \in\operatorname{Idem}(S_\eta) e i ∈ Idem ( S η ) , and middle elements x i , y i ∈ M x_i,y_i \in M x i , y i ∈ M . They satisfy e i , x i , y i ∈ η ( Σ k i ) e_i,x_i,y_i \in\eta(\Sigma^{k_i}) e i , x i , y i ∈ η ( Σ k i ) . The equalities for ( p i , q i ) (p_i,q_i) ( p i , q i ) and the products with the contexts give p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t p=a_0(e_1x_1e_1)a_1\cdots(e_tx_te_t)a_t p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t and q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t q=a_0(e_1y_1e_1)a_1\cdots(e_ty_te_t)a_t q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t . These are exactly the conditions of Definition 4.16 with s = m 2 s=m^2 s = m 2 . Consequently, ( p , q ) ∈ R c m g , m 2 (p,q) \in R_{\mathrm{cmg},m^2} ( p , q ) ∈ R cmg , m 2 . Since ( p , q ) ∈ τ m g (p,q) \in\tau_{\mathrm{mg}} ( p , q ) ∈ τ mg was arbitrary, τ m g ⊆ R c m g , m 2 \tau_{\mathrm{mg}} \subseteq R_{\mathrm{cmg},m^2} τ mg ⊆ R cmg , m 2 . Together with the first inclusion, this proves τ m g = R c m g , m 2 \tau_{\mathrm{mg}} = R_{\mathrm{cmg},m^2} τ mg = R cmg , m 2 .
Linear Lower Bound
Proposition 4.18 (Linear lower bound). If the matched-guard tolerance τ m g \tau_{\mathrm{mg}} τ mg is shattering, then Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( n ) \Omega(n) Ω ( n ) .
We first show the auxiliary results given in the main text:
Lemma 4.20 (Linear lower bound). The pair ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) of Example 4.19 has Q P l i n , T l i n ( n ) Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(n) Q P lin , T lin ( n ) in Ω ( n ) \Omega(n) Ω ( n ) .
Proof of Lemma 4.20. Fix a word length n ∈ N + n \in\mathbb{N}_+ n ∈ N + , and let T \mathcal{T} T be a correct decision tree for ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) from Example 4.19 at length n n n . We show that T \mathcal{T} T has depth at least n n n .
For every position i ∈ [ n ] i \in[n] i ∈ [ n ] , consider the word of T l i n T_{\mathrm{lin}} T lin having c c c at position i i i and a a a everywhere else, and the word of P l i n ∖ T l i n P_{\mathrm{lin}} \setminus T_{\mathrm{lin}} P lin ∖ T lin having d d d at position i i i and a a a everywhere else. More precisely, define u i : = a i − 1 c a n − i u_i := a^{i-1}ca^{n-i} u i := a i − 1 c a n − i and v i : = a i − 1 d a n − i v_i := a^{i-1}da^{n-i} v i := a i − 1 d a n − i . Then u i ∈ T l i n u_i \in T_{\mathrm{lin}} u i ∈ T lin and v i ∈ P l i n ∖ T l i n v_i \in P_{\mathrm{lin}} \setminus T_{\mathrm{lin}} v i ∈ P lin ∖ T lin .
We follow a path in T \mathcal{T} T by answering every query with the letter a a a . Suppose that after fewer than n n n queries the tree reaches a leaf. Since fewer than n n n positions have been queried, there is some position i ∈ [ n ] i \in[n] i ∈ [ n ] which has not been queried.
Both u i u_i u i and v i v_i v i are then completions of the transcript of this leaf. Indeed, every queried position is different from i i i , and both words contain the letter a a a at every such position. However, u i ∈ T l i n u_i \in T_{\mathrm{lin}} u i ∈ T lin whereas v i ∈ P l i n ∖ T l i n v_i \in P_{\mathrm{lin}} \setminus T_{\mathrm{lin}} v i ∈ P lin ∖ T lin . Hence the transcript of this leaf is shattering.
:::
By Lemma 2.1, the transcript of a leaf of a correct decision tree cannot be shattering. Therefore the path obtained by answering every query with a a a cannot reach a leaf before all n n n positions have been queried.
Consequently, T \mathcal{T} T has depth at least n n n . Since T \mathcal{T} T was an arbitrary correct decision tree at length n n n , every correct decision tree for ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) at length n n n has depth at least n n n . Therefore Q P l i n , T l i n ( n ) ≥ n Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(n) \ge n Q P lin , T lin ( n ) ≥ n , and in particular Q P l i n , T l i n ( n ) Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(n) Q P lin , T lin ( n ) is in Ω ( n ) \Omega(n) Ω ( n ) .
Lemma 4.21 (Concatenation). Let s ∈ N + s \in\mathbb{N}_{+} s ∈ N + , and for each i ∈ [ s ] i \in[s] i ∈ [ s ] let T i ⊆ P i ⊆ Σ ∗ T_i \subseteq P_i \subseteq\Sigma^* T i ⊆ P i ⊆ Σ ∗ . Define T = T 1 ⋯ T s T = T_1 \cdots T_s T = T 1 ⋯ T s and P = T ∪ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) P = T \cup(P_1 \setminus T_1) \cdots(P_s \setminus T_s) P = T ∪ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) . Assume that T ∩ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) = ∅ T \cap(P_1 \setminus T_1) \cdots(P_s \setminus T_s) = \varnothing T ∩ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) = ∅ . Then, for every n ∈ N n \in\mathbb{N} n ∈ N , we have Q P , T ( s n ) ≥ min i ∈ [ s ] Q P i , T i ( n ) Q_{P,T}(sn) \ge\min_{i \in[s]} Q_{P_i,T_i}(n) Q P , T ( s n ) ≥ min i ∈ [ s ] Q P i , T i ( n ) .
For this, we first show the auxiliary result:
Lemma 4.23 (Cost preservation). Let T ⊆ P ⊆ Σ ∗ T \subseteq P \subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ , let w w w be a partial word of length n ∈ N n \in\mathbb{N} n ∈ N , and let j ∈ [ n ] j \in[n] j ∈ [ n ] such that w j = □ w_j = \square w j = □ . There is a letter a ∈ Σ a \in\Sigma a ∈ Σ such that the partial word w a ′ w'_a w a ′ obtained by placing a a a at position j j j satisfies cost P , T ( w a ′ ) ≥ cost P , T ( w ) − 1 \operatorname{cost}_{P,T}(w'_a) \ge\operatorname{cost}_{P,T}(w) - 1 cost P , T ( w a ′ ) ≥ cost P , T ( w ) − 1 .
Proof of Lemma 4.23. Let k : = cost P , T ( w ) ∈ N k := \operatorname{cost}_{P,T}(w) \in\mathbb{N} k := cost P , T ( w ) ∈ N . For every a ∈ Σ a \in\Sigma a ∈ Σ , let w a ′ w'_a w a ′ be the partial word obtained by placing a a a at position j j j , and let d a : = cost P , T ( w a ′ ) ∈ N d_a := \operatorname{cost}_{P,T}(w'_a) \in\mathbb{N} d a := cost P , T ( w a ′ ) ∈ N . Choose a correct decision tree T a \mathcal{T}_a T a of minimum depth d a d_a d a for the promised completions of w a ′ w'_a w a ′ , i.e., for the language pair P ∩ L ( w a ′ ) P \cap L(w'_a) P ∩ L ( w a ′ ) and T ∩ L ( w a ′ ) T \cap L(w'_a) T ∩ L ( w a ′ ) . If T a \mathcal{T}_a T a queries a position whose letter is specified by w a ′ w'_a w a ′ , we can replace this query by the subtree reached after that letter. Doing so for every such query preserves correctness on the promised completions and does not increase the depth. In particular, the resulting tree never queries position j j j .
We construct a decision tree which first queries j j j and, for every possible answer a ∈ Σ a \in\Sigma a ∈ Σ , follows the corresponding resulting tree. No position is queried twice on a branch, and every promised completion of w w w for the answer a ∈ Σ a \in\Sigma a ∈ Σ follows the tree T a \mathcal{T}_a T a . Thus the constructed tree is correct for ( P ∩ L ( w ) , T ∩ L ( w ) ) (P \cap L(w), T \cap L(w)) ( P ∩ L ( w ) , T ∩ L ( w )) at length n n n , and has depth at most 1 + max a ∈ Σ d a 1 + \max_{a \in\Sigma} d_a 1 + max a ∈ Σ d a . By the definition of cost, k ≤ 1 + max a ∈ Σ d a k \le1 + \max_{a \in\Sigma} d_a k ≤ 1 + max a ∈ Σ d a . Hence there is some a ∈ Σ a \in\Sigma a ∈ Σ with d a ≥ k − 1 d_a \ge k - 1 d a ≥ k − 1 , and choosing w ′ = w a ′ w' = w'_a w ′ = w a ′ proves the claim. ◀
We can now conclude the proof of Lemma 4.21:
Proof of Lemma 4.21. We will in fact rephrase the desired result to the following stronger claim using the notion of cost (*): for any partial words w 1 , … , w s w_1,\ldots,w_s w 1 , … , w s letting d : = min i ∈ [ s ] cost P i , T i ( w i ) d := \min_{i \in[s]} \operatorname{cost}_{P_i,T_i}(w_i) d := min i ∈ [ s ] cost P i , T i ( w i ) , we have d ≤ cost P , T ( w 1 ⋯ w s ) d \le\operatorname{cost}_{P,T}(w_1 \cdots w_s) d ≤ cost P , T ( w 1 ⋯ w s ) . If d = 0 d = 0 d = 0 , the cost inequality is immediate. Otherwise let T \mathcal{T} T be a correct decision tree for ( P ∩ L ( w 1 ⋯ w s ) , T ∩ L ( w 1 ⋯ w s ) ) (P \cap L(w_1 \cdots w_s), T \cap L(w_1 \cdots w_s)) ( P ∩ L ( w 1 ⋯ w s ) , T ∩ L ( w 1 ⋯ w s )) at length ∣ w 1 ⋯ w s ∣ |w_1 \cdots w_s| ∣ w 1 ⋯ w s ∣ , and we show that T \mathcal{T} T has depth at least d d d to establish the desired lower bound on the depth of T \mathcal{T} T .
We will now inductively define a specific branch β = d ( 0 ) , … \beta= d^{(0)}, \ldots β = d ( 0 ) , … of the tree T \mathcal{T} T from its root to a leaf. In this paragraph, we describe exactly how to choose this branch. In the next paragraph, we show that it has length at least d d d , witnessing the desired lower bound on the depth of T \mathcal{T} T . For this, we will examine the transcripts of nodes along this branch, towards the goal of applying Lemma 4.23 on them. We initialise β \beta β with d ( 0 ) d^{(0)} d ( 0 ) being the root of the tree, and will now use the transcripts to explain how we choose the node d ( q + 1 ) d^{(q+1)} d ( q + 1 ) from the preceding node d ( q ) d^{(q)} d ( q ) for each q ≥ 0 q \ge0 q ≥ 0 until the branch has reached a leaf. If d ( q ) d^{(q)} d ( q ) is a leaf, the definition of β \beta β is finished. Otherwise, considering the internal node d ( q ) d^{(q)} d ( q ) , let w i ( q ) w_i^{(q)} w i ( q ) for each i ∈ [ s ] i \in[s] i ∈ [ s ] be the partial word obtained as the restriction of the transcript of d ( q ) d^{(q)} d ( q ) to the part corresponding to w i w_i w i , together with the letters already specified in w i w_i w i ; we initially have w i ( 0 ) = w i w_i^{(0)} = w_i w i ( 0 ) = w i . Now, there are two cases. First, if d ( q ) d^{(q)} d ( q ) queries a position which is already known in the initial partial word w = w 1 ⋯ w s w = w_1 \cdots w_s w = w 1 ⋯ w s , then the only possible answer is the one corresponding to w w w and we extend the definition of β \beta β by setting d ( q + 1 ) d^{(q+1)} d ( q + 1 ) to be the child of d ( q ) d^{(q)} d ( q ) that corresponds to the only possible answer: we then have w i ( q + 1 ) = w i ( q ) w_i^{(q+1)} = w_i^{(q)} w i ( q + 1 ) = w i ( q ) . Second, if d ( q ) d^{(q)} d ( q ) queries a position which carries a □ \square □ in the initial partial word w = w 1 ⋯ w s w = w_1 \cdots w_s w = w 1 ⋯ w s , it falls into a range corresponding to one factor, say w i w_i w i for i ∈ [ s ] i \in[s] i ∈ [ s ] . We will then have w j ( q + 1 ) = w j ( q ) w_j^{(q+1)} = w_j^{(q)} w j ( q + 1 ) = w j ( q ) for each j ∈ [ s ] j \in[s] j ∈ [ s ] with j ≠ i j \ne i j = i , and w i ( q + 1 ) w_i^{(q+1)} w i ( q + 1 ) will be obtained from w i ( q ) w_i^{(q)} w i ( q ) by revealing one additional letter (i.e., replacing one □ \square □ ) at the position that d ( q ) d^{(q)} d ( q ) laryna queries. We are now in a position to apply Lemma 4.23 for the pair ( P i , T i ) (P_i,T_i) ( P i , T i ) , the partial word w i ( q ) w_i^{(q)} w i ( q ) , and the queried position within the part of the unknown word corresponding to i i i . This gives us a letter a ∈ Σ a\in\Sigma a ∈ Σ , and we choose the child of d ( q ) d^{(q)} d ( q ) labeled a a a to be d ( q + 1 ) d^{(q+1)} d ( q + 1 ) , extending the definition of the branch β \beta β .
We now show that the branch β \beta β thus defined cannot finish before depth d d d , establishing the lower bound on the depth of T \mathcal{T} T . Suppose by way of contradiction that β \beta β reaches a leaf d ( q ) d^{(q)} d ( q ) after q < d q<d q < d queries. The inequality of Lemma 4.23 shows that each w i ( q ) w_i^{(q)} w i ( q ) has positive cost, because we had cost P i , T i ( w i ( 0 ) ) ≥ d \operatorname{cost}_{P_i,T_i}(w_i^{(0)})\ge d cost P i , T i ( w i ( 0 ) ) ≥ d by our choice of d d d and because w i ( 0 ) = w i w_i^{(0)}=w_i w i ( 0 ) = w i , and for each of the q q q queries along β \beta β we either had w i ( q + 1 ) = w i ( q ) w_i^{(q+1)}=w_i^{(q)} w i ( q + 1 ) = w i ( q ) or w i ( q + 1 ) w_i^{(q+1)} w i ( q + 1 ) obtained from w i ( q ) w_i^{(q)} w i ( q ) by choosing a letter achieving the inequality of Lemma 4.23, i.e., decrementing the cost by at most 1, so we conclude by q < d q<d q < d . As each w i ( q ) w_i^{(q)} w i ( q ) has positive cost, we know that it shatters ( P i , T i ) (P_i,T_i) ( P i , T i ) . Thus, choose completions u i ∈ T i u_i\in T_i u i ∈ T i and v i ∈ P i ∖ T i v_i\in P_i\setminus T_i v i ∈ P i ∖ T i of w i ( q ) w_i^{(q)} w i ( q ) for every i ∈ [ s ] i\in[s] i ∈ [ s ] . Then u 1 ⋯ u s ∈ T u_1\cdots u_s\in T u 1 ⋯ u s ∈ T and v 1 ⋯ v s ∈ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) v_1\cdots v_s\in(P_1\setminus T_1)\cdots(P_s\setminus T_s) v 1 ⋯ v s ∈ ( P 1 ∖ T 1 ) ⋯ ( P s ∖ T s ) . We assumed that these two sets are disjoint, so v 1 ⋯ v s v_1\cdots v_s v 1 ⋯ v s is in P ∖ T P\setminus T P ∖ T . Both words complete w 1 ⋯ w s w_1\cdots w_s w 1 ⋯ w s and reach leaf d ( q ) d^{(q)} d ( q ) , so this witnesses that the transcript of d ( q ) d^{(q)} d ( q ) is shattering, contradicting the correctness of the tree by Lemma 2.1. Thus the depth of T \mathcal{T} T is at least d d d , proving cost P , T ( w 1 ⋯ w s ) ≥ d \operatorname{cost}_{P,T}(w_1\cdots w_s)\ge d cost P , T ( w 1 ⋯ w s ) ≥ d .
Having shown (), we explain why this implies the result claimed in the statement. Fix n ∈ N n\in\mathbb{N} n ∈ N . We have Q P i , T i ( n ) = max 0 ≤ r ≤ n cost P i , T i ( □ r ) Q_{P_i,T_i}(n)=\max_{0\le r\le n}\operatorname{cost}_{P_i,T_i}(\Box^r) Q P i , T i ( n ) = max 0 ≤ r ≤ n cost P i , T i ( □ r ) , so choose n i ≤ n n_i\le n n i ≤ n for each i ∈ [ s ] i\in[s] i ∈ [ s ] as a value of r r r that attains the maximum. Set ℓ : = ∑ i = 1 s n i ≤ s n \ell:=\sum_{i=1}^s n_i\le sn ℓ := ∑ i = 1 s n i ≤ s n . We have Q P , T ( s n ) = max 0 ≤ r ≤ s n cost P , T ( □ r ) Q_{P,T}(sn)=\max_{0\le r\le sn}\operatorname{cost}_{P,T}(\Box^r) Q P , T ( s n ) = max 0 ≤ r ≤ s n cost P , T ( □ r ) , so in particular Q P , T ( s n ) ≥ cost P , T ( □ ℓ ) Q_{P,T}(sn)\ge\operatorname{cost}_{P,T}(\Box^\ell) Q P , T ( s n ) ≥ cost P , T ( □ ℓ ) , we have cost P , T ( □ ℓ ) ≥ min i ∈ [ s ] cost P i , T i ( □ n i ) \operatorname{cost}_{P,T}(\Box^\ell)\ge\min_{i\in[s]}\operatorname{cost}_{P_i,T_i}(\Box^{n_i}) cost P , T ( □ ℓ ) ≥ min i ∈ [ s ] cost P i , T i ( □ n i ) by our stronger claim ( ), and we have Q P i , T i ( n i ) = cost P i , T i ( □ n i ) Q_{P_i,T_i}(n_i)=\operatorname{cost}_{P_i,T_i}(\Box^{n_i}) Q P i , T i ( n i ) = cost P i , T i ( □ n i ) for each i ∈ [ s ] i\in[s] i ∈ [ s ] by our choice of n i n_i n i . Combining the three inequalities proves the claim. ◀
Proof of Proposition 4.18. Since τ m g \tau_{\mathrm{mg}} τ mg is shattering, choose a shattered pair ( p , q ) ∈ τ m g (p,q)\in\tau_{\mathrm{mg}} ( p , q ) ∈ τ mg with p ∈ M T p\in M_T p ∈ M T and q ∈ M P ∖ M T q\in M_P\setminus M_T q ∈ M P ∖ M T . In particular, p ≠ q p\ne q p = q . By Lemma 4.17, we have ( p , q ) ∈ R c m g , m 2 (p,q)\in R_{\mathrm{cmg},m^2} ( p , q ) ∈ R cmg , m 2 . Thus, by Definition 4.16, there exist t ∈ N t\in\mathbb{N} t ∈ N with t ≤ m 2 t\le m^2 t ≤ m 2 , elements a 0 , … , a t ∈ M a_0,\ldots,a_t\in M a 0 , … , a t ∈ M , and, for every i ∈ [ t ] i\in[t] i ∈ [ t ] , an idempotent e i ∈ Idem ( S η ) e_i\in\operatorname{Idem}(S_\eta) e i ∈ Idem ( S η ) , elements x i , y i ∈ M x_i,y_i\in M x i , y i ∈ M , and k i ∈ N + k_i\in\mathbb{N}_+ k i ∈ N + such that p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t p=a_0(e_1x_1e_1)a_1\cdots(e_tx_te_t)a_t p = a 0 ( e 1 x 1 e 1 ) a 1 ⋯ ( e t x t e t ) a t and q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t q=a_0(e_1y_1e_1)a_1\cdots(e_ty_te_t)a_t q = a 0 ( e 1 y 1 e 1 ) a 1 ⋯ ( e t y t e t ) a t , with e i , x i , y i ∈ η ( Σ k i ) e_i,x_i,y_i\in\eta(\Sigma^{k_i}) e i , x i , y i ∈ η ( Σ k i ) for every i ∈ [ t ] i\in[t] i ∈ [ t ] .
We may assume ( ∗ ) (*) ( ∗ ) : e i x i e i ≠ e i y i e i e_ix_ie_i\ne e_iy_ie_i e i x i e i = e i y i e i for all i ∈ [ t ] i\in[t] i ∈ [ t ] . Indeed, if e i x i e i = e i y i e i e_ix_ie_i=e_iy_ie_i e i x i e i = e i y i e i , replace the consecutive factors a i − 1 ( e i x i e i ) a i a_{i-1}(e_ix_ie_i)a_i a i − 1 ( e i x i e i ) a i and a i − 1 ( e i y i e i ) a i a_{i-1}(e_iy_ie_i)a_i a i − 1 ( e i y i e i ) a i by their common product in both coordinates and omit the i i i -th substitution. After reindexing, the expressions for p , q p,q p , q , the bound t ≤ m 2 t\le m^2 t ≤ m 2 , and the common-length conditions of the remaining substitutions are preserved. This proves (*). Further, at least one substitution remains, because if t = 0 t=0 t = 0 then the defining expressions give p = q = a 0 p=q=a_0 p = q = a 0 but we have p ≠ q p\ne q p = q . Thus, we must have t ≥ 1 t\ge1 t ≥ 1 .
For every i ∈ [ t ] i\in[t] i ∈ [ t ] , choose E i , X i , Y i ∈ Σ k i E_i,X_i,Y_i\in\Sigma^{k_i} E i , X i , Y i ∈ Σ k i with η ( E i ) = e i \eta(E_i)=e_i η ( E i ) = e i , η ( X i ) = x i \eta(X_i)=x_i η ( X i ) = x i , and η ( Y i ) = y i \eta(Y_i)=y_i η ( Y i ) = y i . For every i ∈ { 0 , … , t } i\in\{0,\ldots,t\} i ∈ { 0 , … , t } , choose b i ∈ Σ ∗ b_i\in\Sigma^* b i ∈ Σ ∗ with η ( b i ) = a i \eta(b_i)=a_i η ( b i ) = a i ; these words exist by surjectivity of η \eta η .
For i ∈ [ t ] i\in[t] i ∈ [ t ] , define T i : = E i + X i E i + b i T_i:=E_i^+X_iE_i^+b_i T i := E i + X i E i + b i and P i : = T i ∪ E i + Y i E i + b i P_i:=T_i\cup E_i^+Y_iE_i^+b_i P i := T i ∪ E i + Y i E i + b i . For all r , s ∈ N + r,s\in\mathbb{N}_+ r , s ∈ N + , and the idempotence of e i e_i e i gives η ( E i r X i E i s ) = e i x i e i \eta(E_i^rX_iE_i^s)=e_ix_ie_i η ( E i r X i E i s ) = e i x i e i and η ( E i r Y i E i s ) = e i y i e i \eta(E_i^rY_iE_i^s)=e_iy_ie_i η ( E i r Y i E i s ) = e i y i e i . These two elements of M M M are different, so E i + X i E i + E_i^+X_iE_i^+ E i + X i E i + and E i + Y i E i + E_i^+Y_iE_i^+ E i + Y i E i + are disjoint. Appending the same fixed word b i b_i b i preserves disjointness. Consequently P i ∖ T i = E i + Y i E i + b i P_i\setminus T_i=E_i^+Y_iE_i^+b_i P i ∖ T i = E i + Y i E i + b i .
Define T ′ : = b 0 T 1 ⋯ T t T':=b_0T_1\cdots T_t T ′ := b 0 T 1 ⋯ T t and P ′ : = T ′ ∪ b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) P':=T'\cup b_0(P_1\setminus T_1)\cdots(P_t\setminus T_t) P ′ := T ′ ∪ b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) . By η ( E i r X i E i s ) = e i x i e i \eta(E_i^rX_iE_i^s)=e_ix_ie_i η ( E i r X i E i s ) = e i x i e i and η ( E i r Y i E i s ) = e i y i e i \eta(E_i^rY_iE_i^s)=e_iy_ie_i η ( E i r Y i E i s ) = e i y i e i for all r , s ∈ N + r,s\in\mathbb{N}_+ r , s ∈ N + , and η ( b i ) = a i \eta(b_i)=a_i η ( b i ) = a i , every word in T ′ T' T ′ has image p p p , whereas every word in b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) b_0(P_1\setminus T_1)\cdots(P_t\setminus T_t) b 0 ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) has image q q q . Since p ∈ M T p\in M_T p ∈ M T and q ∈ M P ∖ M T q\in M_P\setminus M_T q ∈ M P ∖ M T , these two languages are disjoint, further we have T ′ ⊆ T T'\subseteq T T ′ ⊆ T and P ′ ∖ T ′ ⊆ P ∖ T P'\setminus T'\subseteq P\setminus T P ′ ∖ T ′ ⊆ P ∖ T . By the inclusion lemma (Lemma 3.13), we deduce that Q P , T ( N ) ≥ Q P ′ , T ′ ( N ) Q_{P,T}(N)\ge Q_{P',T'}(N) Q P , T ( N ) ≥ Q P ′ , T ′ ( N ) for every N ∈ N N\in\mathbb{N} N ∈ N , so it suffices to show the lower bound for P ′ , T ′ P',T' P ′ , T ′ .
Now, removing the fixed prefix b 0 b_0 b 0 , define T ′ ′ : = b 0 − 1 T ′ = T 1 ⋯ T t T'':=b_0^{-1}T'=T_1\cdots T_t T ′′ := b 0 − 1 T ′ = T 1 ⋯ T t and P ′ ′ : = b 0 − 1 P ′ = T ′ ′ ∪ ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) P'':=b_0^{-1}P'=T''\cup(P_1\setminus T_1)\cdots(P_t\setminus T_t) P ′′ := b 0 − 1 P ′ = T ′′ ∪ ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) . Since T ′ = b 0 T ′ ′ T'=b_0T'' T ′ = b 0 T ′′ and P ′ = b 0 P ′ ′ P'=b_0P'' P ′ = b 0 P ′′ , the quotient lemma (Lemma 3.14) gives Q P ′ , T ′ ( N + ∣ b 0 ∣ ) ≥ Q P ′ ′ , T ′ ′ ( N ) Q_{P',T'}(N+|b_0|)\ge Q_{P'',T''}(N) Q P ′ , T ′ ( N + ∣ b 0 ∣ ) ≥ Q P ′′ , T ′′ ( N ) for every N ∈ N N\in\mathbb{N} N ∈ N . So it suffices to show the lower bound for P ′ ′ , T ′ ′ P'',T'' P ′′ , T ′′ .
Fix an integer k ≥ 3 k\ge3 k ≥ 3 and, for each i ∈ [ t ] i\in[t] i ∈ [ t ] , set n i : = k i k + ∣ b i ∣ ∈ N n_i:=k_i k+|b_i|\in\mathbb{N} n i := k i k + ∣ b i ∣ ∈ N . We show that the query complexity for ( P i , T i ) (P_i,T_i) ( P i , T i ) at length n i n_i n i is at least k − 2 k-2 k − 2 . Fix i ∈ [ t ] i\in[t] i ∈ [ t ] . Since E i , X i , Y i E_i,X_i,Y_i E i , X i , Y i all have length k i k_i k i , removing the fixed first block E i E_i E i and the fixed suffix E i b i E_ib_i E i b i gives T i ′ : = E i − 1 T i ( E i b i ) − 1 = E i ∗ X i E i ∗ T_i':=E_i^{-1}T_i(E_ib_i)^{-1}=E_i^*X_iE_i^* T i ′ := E i − 1 T i ( E i b i ) − 1 = E i ∗ X i E i ∗ and P i ′ : = E i − 1 P i ( E i b i ) − 1 = T i ′ ∪ E i ∗ Y i E i ∗ P_i':=E_i^{-1}P_i(E_ib_i)^{-1}=T_i'\cup E_i^*Y_iE_i^* P i ′ := E i − 1 P i ( E i b i ) − 1 = T i ′ ∪ E i ∗ Y i E i ∗ . Indeed, after removing b i b_i b i , every word in P i P_i P i is a concatenation of blocks of length k i k_i k i beginning and ending with E i E_i E i . Deleting these two blocks leaves precisely a word of E i ∗ X i E i ∗ E_i^*X_iE_i^* E i ∗ X i E i ∗ or of E i ∗ Y i E i ∗ E_i^*Y_iE_i^* E i ∗ Y i E i ∗ , respectively, and every word in either language arises in this way. In particular, T i = E i T i ′ E i b i T_i = E_iT_i'E_ib_i T i = E i T i ′ E i b i and P i = E i P i ′ E i b i P_i = E_iP_i'E_ib_i P i = E i P i ′ E i b i . The two languages E i ∗ X i E i ∗ E_i^*X_iE_i^* E i ∗ X i E i ∗ and E i ∗ Y i E i ∗ E_i^*Y_iE_i^* E i ∗ Y i E i ∗ are also disjoint. Otherwise, for a common word z z z , the word E i z E i E_izE_i E i z E i would belong to both E i + X i E i + E_i^+X_iE_i^+ E i + X i E i + and E i + Y i E i + E_i^+Y_iE_i^+ E i + Y i E i + , contradicting their disjointness.
Define the morphism h i : { a , c , d } ∗ → Σ ∗ h_i : \{a,c,d\}^* \to\Sigma^* h i : { a , c , d } ∗ → Σ ∗ by h i ( a ) : = E i h_i(a) := E_i h i ( a ) := E i , h i ( c ) : = X i h_i(c) := X_i h i ( c ) := X i , and h i ( d ) : = Y i h_i(d) := Y_i h i ( d ) := Y i . All three images have length k i ∈ N + k_i \in\mathbb{N}_+ k i ∈ N + . By the definitions of ( P l i n , T l i n ) (P_{\mathrm{lin}},T_{\mathrm{lin}}) ( P lin , T lin ) in Lemma 4.20, we have the following inclusions (**): h i ( T l i n ) ⊆ T i ′ h_i(T_{\mathrm{lin}}) \subseteq T_i' h i ( T lin ) ⊆ T i ′ and h i ( P l i n ∖ T l i n ) ⊆ E i ∗ Y i E i ∗ ⊆ P i ′ ∖ T i ′ h_i(P_{\mathrm{lin}}\setminus T_{\mathrm{lin}}) \subseteq E_i^*Y_iE_i^* \subseteq P_i'\setminus T_i' h i ( P lin ∖ T lin ) ⊆ E i ∗ Y i E i ∗ ⊆ P i ′ ∖ T i ′ . Thus the map w ↦ E i h i ( w ) E i b i w \mapsto E_ih_i(w)E_ib_i w ↦ E i h i ( w ) E i b i sends T l i n T_{\mathrm{lin}} T lin into T i T_i T i and P l i n ∖ T l i n P_{\mathrm{lin}}\setminus T_{\mathrm{lin}} P lin ∖ T lin into P i ∖ T i P_i\setminus T_i P i ∖ T i .
We now transfer the lower bound of Lemma 4.20 through the three reduction lemmas on each factor of the concatenation. We know by Lemma 4.20 that k − 2 ≤ Q P l i n , T l i n ( k − 2 ) k-2 \le Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(k-2) k − 2 ≤ Q P lin , T lin ( k − 2 ) . The two inclusions for h i h_i h i given in (**) imply, by the inclusion lemma (Lemma 3.13), that Q P l i n , T l i n ( k − 2 ) ≤ Q h i − 1 ( P i ′ ) , h i − 1 ( T i ′ ) ( k − 2 ) Q_{P_{\mathrm{lin}},T_{\mathrm{lin}}}(k-2) \le Q_{h_i^{-1}(P_i'),h_i^{-1}(T_i')}(k-2) Q P lin , T lin ( k − 2 ) ≤ Q h i − 1 ( P i ′ ) , h i − 1 ( T i ′ ) ( k − 2 ) . By the inverse lm-morphism lemma (Lemma 3.15), this last quantity is at most Q P i ′ , T i ′ ( k i ( k − 2 ) ) Q_{P_i',T_i'}(k_i(k-2)) Q P i ′ , T i ′ ( k i ( k − 2 )) . We can now apply the quotient lemma (Lemma 3.14) with prefix E i E_i E i and suffix E i b i E_ib_i E i b i to show an upper bound on the last quantity given by Q P i , T i ( k i ( k − 2 ) + 2 k i + ∣ b i ∣ ) = Q P i , T i ( n i ) Q_{P_i,T_i}(k_i(k-2)+2k_i+|b_i|)=Q_{P_i,T_i}(n_i) Q P i , T i ( k i ( k − 2 ) + 2 k i + ∣ b i ∣ ) = Q P i , T i ( n i ) . Chaining all inequalities together, we get Q P i , T i ( n i ) ≥ k − 2 Q_{P_i,T_i}(n_i)\ge k-2 Q P i , T i ( n i ) ≥ k − 2 for every i ∈ [ t ] i\in[t] i ∈ [ t ] .
We now combine these bounds using the concatenation lemma (Lemma 4.21). Put n ∗ : = max i ∈ [ t ] n i n_*:=\max_{i\in[t]}n_i n ∗ := max i ∈ [ t ] n i . We verify the disjointness hypothesis of Lemma 4.21. If a word z z z belonged to both T ′ ′ T'' T ′′ and ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) (P_1\setminus T_1)\cdots(P_t\setminus T_t) ( P 1 ∖ T 1 ) ⋯ ( P t ∖ T t ) , then b 0 z b_0z b 0 z would have both images p p p and q q q under η \eta η , contradicting p ≠ q p\ne q p = q . Hence Q P ′ ′ , T ′ ′ ( t n ∗ ) ≥ min i ∈ [ t ] Q P i , T i ( n ∗ ) ≥ k − 2 Q_{P'',T''}(tn_*)\ge\min_{i\in[t]}Q_{P_i,T_i}(n_*)\ge k-2 Q P ′′ , T ′′ ( t n ∗ ) ≥ min i ∈ [ t ] Q P i , T i ( n ∗ ) ≥ k − 2 , where the second inequality uses n ∗ ≥ n i n_*\ge n_i n ∗ ≥ n i and monotonicity.
Finally, we transfer the bound to ( P , T ) (P,T) ( P , T ) . The quotient lemma (Lemma 3.14) and inclusion lemma (Lemma 3.13) give Q P , T ( ∣ b 0 ∣ + t n ∗ ) ≥ k − 2 Q_{P,T}(|b_0|+tn_*)\ge k-2 Q P , T ( ∣ b 0 ∣ + t n ∗ ) ≥ k − 2 . Put C : = max i ∈ [ t ] k i ∈ N + C:=\max_{i\in[t]}k_i\in\mathbb{N}_+ C := max i ∈ [ t ] k i ∈ N + and D : = max i ∈ [ t ] ∣ b i ∣ ∈ N D:=\max_{i\in[t]}|b_i|\in\mathbb{N} D := max i ∈ [ t ] ∣ b i ∣ ∈ N . Since n i = k i k + ∣ b i ∣ ≤ C k + D n_i=k_ik+|b_i|\le Ck+D n i = k i k + ∣ b i ∣ ≤ C k + D for each i i i , we have Q P , T ( ∣ b 0 ∣ + t ( C k + D ) ) ≥ k − 2 Q_{P,T}(|b_0|+t(Ck+D))\ge k-2 Q P , T ( ∣ b 0 ∣ + t ( C k + D )) ≥ k − 2 for every integer k ≥ 3 k\ge3 k ≥ 3 . As the lower bound holds for infinitely many values, by monotonicity of Q P , T Q_{P,T} Q P , T , we finally have that Q P , T ( n ) Q_{P,T}(n) Q P , T ( n ) is in Ω ( n ) \Omega(n) Ω ( n ) . ◀
Proofs for Section 5 (Effective Complexity Classification)
Theorem 5.1 (Effective classification). Let T ⊆ P ⊆ Σ ∗ T\subseteq P\subseteq\Sigma^* T ⊆ P ⊆ Σ ∗ be regular languages. Given NFAs A P A_P A P and A T A_T A T recognizing P P P and T T T , respectively, it is PSPACE-complete to decide which of the three regimes of Theorem 2.7 applies to Q P , T Q_{P,T} Q P , T .
Proof of Theorem 5.1. We first show the PSPACE upper bound, before showing PSPACE-hardness at the end of the section.
Let A P A_P A P and A T A_T A T be the input NFAs which accept P P P and T T T respectively. Write Q P , Q T Q_P,Q_T Q P , Q T for their respective state sets, of respective cardinalities n P , n T ∈ N n_P,n_T\in\mathbb{N} n P , n T ∈ N . We use the standard notion of Boolean matrices [23 Chapter IV, Section 3.2] to represent elements of the transition monoid of A P A_P A P and A T A_T A T . For an NFA with state set Q Q Q , the Boolean matrix A w ∈ { 0 , 1 } Q × Q A_w\in\{0,1\}^{Q\times Q} A w ∈ { 0 , 1 } Q × Q of w ∈ Σ ∗ w\in\Sigma^* w ∈ Σ ∗ has ( A w ) p , q = 1 (A_w)_{p,q}=1 ( A w ) p , q = 1 exactly when a path from p ∈ Q p\in Q p ∈ Q to q ∈ Q q\in Q q ∈ Q is labeled w w w . For two such matrices A , B A,B A , B , define their product by ( A B ) p , q = ⋁ r ∈ Q ( A p , r ∧ B r , q ) (AB)_{p,q}=\bigvee_{r\in Q}(A_{p,r}\wedge B_{r,q}) ( A B ) p , q = ⋁ r ∈ Q ( A p , r ∧ B r , q ) . Thus A u v = A u A v A_{uv}=A_uA_v A uv = A u A v and A ε A_\varepsilon A ε is the identity matrix. The map w ↦ A w w\mapsto A_w w ↦ A w is the transition-relation morphism.
For each word w ∈ Σ ∗ w\in\Sigma^* w ∈ Σ ∗ , we write A w P A_w^P A w P and A w T A_w^T A w T for the Boolean matrices corresponding to w w w via the transition-relation morphism, and we define η ( w ) : = ( A w P , A w T ) \eta(w):=(A_w^P,A_w^T) η ( w ) := ( A w P , A w T ) and M : = η ( Σ ∗ ) M:=\eta(\Sigma^*) M := η ( Σ ∗ ) , with componentwise multiplication. Define M P ⊆ M M_P\subseteq M M P ⊆ M as the set of matrix pairs whose first matrix has an entry 1 1 1 from an initial state to a final state of the automaton for P P P . Define M T ⊆ M M_T\subseteq M M T ⊆ M analogously using the second matrix and the automaton for T T T . It is then easy to notice that we have P = η − 1 ( M P ) P=\eta^{-1}(M_P) P = η − 1 ( M P ) and T = η − 1 ( M T ) T=\eta^{-1}(M_T) T = η − 1 ( M T ) . As T ⊆ P T\subseteq P T ⊆ P and η \eta η is surjective onto M M M , we have M T ⊆ M P M_T\subseteq M_P M T ⊆ M P . Hence ( M , η , M P , M T ) (M,\eta,M_P,M_T) ( M , η , M P , M T ) is a mutual presentation. Put s : = n P 2 + n T 2 ∈ N s:=n_P^2+n_T^2\in\mathbb{N} s := n P 2 + n T 2 ∈ N and B : = 2 s ∈ N + B:=2^s\in\mathbb{N}_+ B := 2 s ∈ N + . Each element of M M M is represented by s s s bits, and we have ∣ M ∣ ≤ B |M|\le B ∣ M ∣ ≤ B . Note that we do not construct the mutual presentation explicitly. Each individual element of M M M can be represented in polynomial space (as a pair of transition matrices), the transition matrix pairs for the letters of the alphabet are given in the input, and given two pairs we can test them for equality, test them for membership in M T M_T M T and M P M_P M P , and multiply them in polynomial space by multiplying their two constituent matrices. Idempotence can also be tested in polynomial space.
By Savitch’s theorem [26 ] , NPSPACE equals PSPACE. It therefore suffices to give nondeterministic polynomial-space algorithms. We first explain how to test membership in M M M , in S η S_{\eta} S η , and in τ l e n \tau_{\mathrm{len}} τ len .
Given a pair of matrices z z z , we can test whether it represents an element of M M M and whether it belongs to S η S_{\eta} S η in the following way. We start with the identity pair η ( ε ) \eta(\varepsilon) η ( ε ) , and we guess a word letter by letter, updating its image by multiplying by η ( a ) \eta(a) η ( a ) for each guessed letter a ∈ Σ a \in\Sigma a ∈ Σ . We accept if the final image equals z z z , and maintain a polynomially-sized counter and reject if the sequence of guesses exceeds B B B . (Note that we do not store the guessed sequence explicitly, because it may have exponential length.) This correctly decides membership in M M M by Lemma 2.3, since every element of M M M has a preimage of length less than ∣ M ∣ ≤ B \lvert M\rvert\le B ∣ M ∣ ≤ B . For membership in S η S_{\eta} S η , use the same procedure, but require at least one letter. The process is also correct because non-empty preimages witnessing membership to S η S_{\eta} S η must also have length at most B B B . Indeed, take a shortest nonempty preimage. If its length exceeds ∣ M ∣ \lvert M\rvert ∣ M ∣ , two of its first ∣ M ∣ + 1 \lvert M\rvert+1 ∣ M ∣ + 1 nonempty prefix images coincide, and removing the factor between these prefixes gives a shorter nonempty preimage with the same image, a contradiction.
To test x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y for two candidate matrix pairs x , y x,y x , y , start with two identity pairs. At each step, guess two letters a , b ∈ Σ a,b \in\Sigma a , b ∈ Σ and multiply the respective running images by η ( a ) \eta(a) η ( a ) and η ( b ) \eta(b) η ( b ) . Guessing the two words in parallel ensures that they have equal length. Accept when the two images are equal to x x x and y y y and at least one step has been performed, and reject if the process has not succeeded in ∣ M ∣ 2 ≤ B 2 \lvert M\rvert^{2} \le B^{2} ∣ M ∣ 2 ≤ B 2 steps; this suffices by Lemma 3.2.
The membership tests for R g R_g R g and R m g R_{mg} R m g are similar, so we present both of them at once for a generic R ∈ { R g , R m g } R \in\{R_g,R_{mg}\} R ∈ { R g , R m g } . To test whether two given matrix pairs are related by R = R g R=R_g R = R g , guess any choice of candidate matrix pairs e , f , x , y e,f,x,y e , f , x , y and check e , f ∈ S η e,f \in S_{\eta} e , f ∈ S η , e 2 = e e^{2}=e e 2 = e , f 2 = f f^{2}=f f 2 = f , x τ l e n y x \mathrel{\tau_{\mathrm{len}}} y x τ len y , and the two equalities defining ( e x f , e y f ) (exf,eyf) ( e x f , ey f ) . For R = R m g R=R_{mg} R = R m g , guess matrix pairs e , x , y e,x,y e , x , y and check e ∈ S η e \in S_{\eta} e ∈ S η , e 2 = e e^{2}=e e 2 = e , e τ l e n x e \mathrel{\tau_{\mathrm{len}}} x e τ len x , e τ l e n y e \mathrel{\tau_{\mathrm{len}}} y e τ len y , and the equalities defining ( e x e , e y e ) (exe,eye) ( e x e , ey e ) . The preceding tests verify in particular that the guessed elements actually belong to M M M . Thus membership in R R R , in its converse R − 1 : = { ( y , x ) ∣ ( x , y ) ∈ R } R^{-1}:=\{(y,x)\mid(x,y)\in R\} R − 1 := {( y , x ) ∣ ( x , y ) ∈ R } , or in the diagonal Δ M : = { ( z , z ) ∣ z ∈ M } \Delta_M:=\{(z,z)\mid z\in M\} Δ M := {( z , z ) ∣ z ∈ M } can be tested in nondeterministic polynomial space.
Lastly for the upper bound, we explain how to test membership of a pair of candidate matrix pairs in the tolerance closure C C C of R ∈ { R g , R m g } R\in\{R_g,R_{mg}\} R ∈ { R g , R m g } . Put G : = R ∪ R − 1 ∪ Δ M G:=R\cup R^{-1}\cup\Delta_M G := R ∪ R − 1 ∪ Δ M . By the bound established after Definition 2.5 , every pair in C C C is a product of fewer than ∣ M ∣ 2 ≤ B 2 \lvert M\rvert^{2}\le B^{2} ∣ M ∣ 2 ≤ B 2 elements of G G G . Guess such a product by starting at ( 1 M , 1 M ) (1_M,1_M) ( 1 M , 1 M ) and then guessing each factor, verifying its membership to G G G by the preceding tests, accumulating the product of the guessed elements, and stopping if we exceed B 2 B^{2} B 2 steps, which again only requires a polynomially sized counter. This decides membership in C C C .
Thus, we can test membership in τ g \tau_g τ g and τ m g \tau_{mg} τ m g in nondeterministic polynomial space. Last, to test whether C C C shatters ( M P , M T ) (M_P,M_T) ( M P , M T ) , guess two matrix pairs, we simply test that one belongs to M T M_T M T and the other to M P ∖ M T M_P\setminus M_T M P ∖ M T , and apply the membership test to check if the pair of the two matrix pairs belongs to C C C . Thus, both tolerance membership and shattering are decidable in PSPACE, which establishes that we can determine the regime of Theorem 2.7 in PSPACE.
We last show the PSPACE lower bound, which adapts techniques from Greibach’s theorem [16 ] . The reduction is from the problem of NFA universality, which is well-known to be PSPACE-hard. Let A A A be an input NFA on which we want to decide universality, and let Σ \Sigma Σ be its alphabet. Let # , a , c , d \#,a,c,d # , a , c , d be four fresh letters. We build in polynomial time from A A A two NFAs A P A_P A P and A T A_T A T recognizing the promise language P : = ( Σ ∗ ) # a ∗ ( c ∣ d ) a ∗ P:=(\Sigma^*)\#a^*(c\mid d)a^* P := ( Σ ∗ ) # a ∗ ( c ∣ d ) a ∗ and the target language T : = ( L ( A ) # a ∗ ( c ∣ d ) a ∗ ) ∪ ( Σ ∗ # a ∗ c a ∗ ) T:=(L(A)\#a^*(c\mid d)a^*)\cup(\Sigma^*\#a^*ca^*) T := ( L ( A ) # a ∗ ( c ∣ d ) a ∗ ) ∪ ( Σ ∗ # a ∗ c a ∗ ) , where L ( A ) L(A) L ( A ) denotes the language accepted by A A A . Note that T ⊆ P T\subseteq P T ⊆ P . We now claim the following, which suffices to conclude:
If A A A is universal, then conditional membership to P , T P,T P , T can be done in O ( 1 ) O(1) O ( 1 ) (in fact without making any queries at all);
If A A A is not universal, then conditional membership to P , T P,T P , T requires Θ ( n ) \Theta(n) Θ ( n ) queries.
Indeed, if A A A is universal, then we have L ( A ) = Σ ∗ L(A)=\Sigma^* L ( A ) = Σ ∗ , so that the first term of the union in the definition of T T T is a superset of the second, so we can rewrite equivalently T = Σ ∗ # a ∗ ( c ∣ d ) a ∗ T=\Sigma^*\#a^*(c\mid d)a^* T = Σ ∗ # a ∗ ( c ∣ d ) a ∗ and we have in fact P = T P = T P = T . Thus, conditional membership for P , T P,T P , T is trivial and can be solved with no queries at all.
By contrast, if A A A is not universal, there is a word w ∈ Σ ∗ ∖ L ( A ) w \in\Sigma^* \setminus L(A) w ∈ Σ ∗ ∖ L ( A ) . We now consider the languages P ′ : = ( w # ) − 1 P P' := (w\#)^{-1}P P ′ := ( w # ) − 1 P and T ′ : = ( w # ) − 1 T T' := (w\#)^{-1}T T ′ := ( w # ) − 1 T . We have P ′ = a ∗ ( c ∣ d ) a ∗ P' = a^*(c|d)a^* P ′ = a ∗ ( c ∣ d ) a ∗ and T ′ = a ∗ c a ∗ T' = a^*ca^* T ′ = a ∗ c a ∗ , noting in particular that the first term of the union in the definition of T T T contributes no terms to the quotient. We recognize that P ′ , T ′ P',T' P ′ , T ′ is in fact precisely P l i n , T l i n P_{\mathrm{lin}},T_{\mathrm{lin}} P lin , T lin which has a linear query complexity lower bound by Lemma 4.20, and we know that taking quotients preserve lower bounds by Lemma 3.14. Thus, conditional membership for P , T P,T P , T requires Ω ( n ) \Omega(n) Ω ( n ) queries. This establishes correctness and concludes the proof.
Additional Examples
This section collects examples illustrating successive binary searches in Proposition 4.4 and the need for multiple substitutions in Definition 4.16 .
Example E.1. Let Σ = { a , b , c , d , e } \Sigma= \{a,b,c,d,e\} Σ = { a , b , c , d , e } , T log 2 : = a ∗ c b ∗ c e ∗ T_{\log2} := a^*cb^*ce^* T l o g 2 := a ∗ c b ∗ c e ∗ , and P log 2 : = a ∗ ( c ∣ d ) b ∗ ( c ∣ d ) e ∗ P_{\log2} := a^*(c \mid d)b^*(c \mid d)e^* P l o g 2 := a ∗ ( c ∣ d ) b ∗ ( c ∣ d ) e ∗ . Here, finding only the boundary between the a a a and b b b regions is not enough: we also need to find the boundary between the b b b and e e e regions. This corresponds to performing two binary searches, with each letter indicating in which region we fall.
Example E.2. Let Σ = { a , b , c , d } \Sigma= \{a,b,c,d\} Σ = { a , b , c , d } be the alphabet, T log 3 : = ( a a b ) ∗ c ( a a b ) ∗ c ( a a b ) ∗ T_{\log3} := (aab)^*c(aab)^*c(aab)^* T l o g 3 := ( aab ) ∗ c ( aab ) ∗ c ( aab ) ∗ , and P log 3 : = ( a a b ) ∗ ( c ∣ d ) ( a a b ) ∗ ( c ∣ d ) ( a a b ) ∗ P_{\log3} := (aab)^*(c \mid d)(aab)^*(c \mid d)(aab)^* P l o g 3 := ( aab ) ∗ ( c ∣ d ) ( aab ) ∗ ( c ∣ d ) ( aab ) ∗ . This is a variant of the previous example, where querying blocks of size 3 indicates in which ( a a b ) ∗ (aab)^* ( aab ) ∗ factor we are, depending on the remainder of the position of the b b b modulo 3.
Example E.3. Let Σ = { a , b , c , d , e , f } \Sigma= \{a,b,c,d,e,f\} Σ = { a , b , c , d , e , f } , T log 4 : = e ∗ ( a ∗ c b ∗ ∣ b ∗ c a ∗ ) f ∗ T_{\log4} := e^*(a^*cb^* \mid b^*ca^*)f^* T l o g 4 := e ∗ ( a ∗ c b ∗ ∣ b ∗ c a ∗ ) f ∗ , and P log 4 : = e ∗ ( a ∗ ( c ∣ d ) b ∗ ∣ b ∗ ( c ∣ d ) a ∗ ) f ∗ P_{\log4} := e^*(a^*(c \mid d)b^* \mid b^*(c \mid d)a^*)f^* P l o g 4 := e ∗ ( a ∗ ( c ∣ d ) b ∗ ∣ b ∗ ( c ∣ d ) a ∗ ) f ∗ . Here we illustrate a nested binary search. All a a a ’s precede all b b b ’s or vice versa, so until both an a a a and a b b b have been queried, an answer a a a alone does not tell us which direction to search. Alternatively, a first binary search can locate the end of the initial e e e region: querying the next position either reveals c c c or d d d and settles membership, or reveals a a a or b b b and determines the order. Thus, the direction indicated by an answer in the inner binary search may only become clear once we have completed the outer binary search.
Example E.4. Let Σ = { a , b , c , d } \Sigma= \{a,b,c,d\} Σ = { a , b , c , d } , T l i n 2 : = a ∗ c a ∗ b ∗ c b ∗ T_{\mathrm{lin2}} := a^*ca^*b^*cb^* T lin2 := a ∗ c a ∗ b ∗ c b ∗ and P l i n 2 : = T l i n 2 ∪ a ∗ d a ∗ b ∗ d b ∗ P_{\mathrm{lin2}} := T_{\mathrm{lin2}} \cup a^*da^*b^*db^* P lin2 := T lin2 ∪ a ∗ d a ∗ b ∗ d b ∗ . The promise requires the two occurrences from { c , d } \{c,d\} { c , d } to agree: both are c c c , or both are d d d . Changing only one occurrence of c c c to d d d violates the promise, so the two replacements must be coordinated.
Take the mutual presentation that identifies two words when they have the same membership in both languages within every left and right context. Identify each word with its image in the monoid M M M . Then a 2 = a a^2 = a a 2 = a and b 2 = b b^2 = b b 2 = b , since repeating an a a a or b b b does not change membership in either language. The pairs ( a c a , a d a ) (aca,ada) ( a c a , a d a ) and ( b c b , b d b ) (bcb,bdb) ( b c b , b d b ) belong to R c m g , 1 R_{\mathrm{cmg},1} R cmg , 1 : the guards are respectively a a a and b b b , and all guards and middle words have length 1. Their product is ( a c a b c b , a d a b d b ) (acabcb,adabdb) ( a c ab c b , a d ab d b ) .
This product does not belong to R c m g , 1 R_{\mathrm{cmg},1} R cmg , 1 . Indeed, one replacement must change both c c c ’s to d d d ’s, so its two copies of the same nonempty guard must surround both positions. The left copy would consist only of a a a ’s and the right copy only of b b b ’s, which is impossible for the same nonempty word. Thus R c m g , 1 R_{\mathrm{cmg},1} R cmg , 1 is not compatible with multiplication.