Sublinear-Time Computation in the Presence of An Online Adversary

Iden Kalemaj∗ Sofya Raskhodnikova† Nithin Varma‡ June 30, 2021

Abstract We initiate the study of sublinear-time algorithms that access their input via an online adversarial oracle. After answering each query to the input object, such an oracle can erase or corrupt a small number of input values. Our goal is to understand the complexity of basic computational tasks in extremely adversarial situations, where the algorithm’s access to data is blocked—or fraudulent values are introduced—during the execution of the algorithm in response to its actions. Specifically, we focus on property testing in the presence of an online oracle that makes t erasures adversarially after answering each query of the algorithm. We show that two fundamental properties of functions, linearity and quadraticity, can be tested for constant t with asymptotically the same complexity as in the standard property testing model. In contrast, some other properties, including sortedness and the Lipschitz property of sequences, cannot be tested at all, even for t = 1. Our investigation leads to a deeper understanding of the structure of violations to these widely studied properties.

∗Department of Computer Science, Boston University. Email: [email protected]. This work was supported by NSF award CCF-1909612 and Boston University’s Dean’s Fellowship. †Department of Computer Science, Boston University. Email: [email protected]. This work was supported by NSF award CCF-1909612. ‡Department of Computer Science, University of Haifa. Email: [email protected]. This work was supported by the Israel Science Foundation, grant number 497/17 and the PBC Fellowship for Postdoctoral Fellows by the Israeli Council of Higher Education. 1 Introduction

We initiate the study of sublinear-time algorithms that compute in the presence of an online adversary. After the algorithm gets the answer to each query to the input object, such an adversary can hide or corrupt a small number of input values. It might be helpful to think of the algorithm as trying to detect some fraud and of the adversary as trying to obstruct access to data by hiding or corrupting it in order to make it hard to uncover any evidence. Our goal is to understand the complexity of basic computational tasks in extremely adversarial situations, where the algorithm’s access to data is blocked—or fraudulent values are introduced—during the execution of the algorithm in response to its actions. Specifically, we represent the input object as a function f on an arbitrary finite domain1, which the algorithm can access by querying a point x from the domain and receiving the answer O(x) from an oracle. At the beginning of computation, O(x) = f(x) for all points x in the domain of the function. We parameterize our model by a natural number t that controls the number of function values the adversary can modify after the oracle answers each query. Mathematically, we represent the oracle and the adversary as one entity. However, it might be helpful to think of the oracle as the data holder and of the adversary as the obstructionist. A t-online-erasure oracle can replace values O(x) on up to t points x with a special symbol ⊥, thus erasing them, whereas a t-online-corruption oracle can replace them with arbitrary values in the range. The new values will be used by the oracle to answer future queries to the corresponding points. The locations of erasures and corruptions are unknown to the algorithm. The actions of the oracle can depend on the input, the queries made so far, and even on the publicly known code that the algorithm is running, but not on future coin tosses of the algorithm. We focus on investigating property testing in the presence of online erasures. Some of our results also apply to online corruptions and computational tasks related to property testing, as discussed later. In the property testing model, introduced by [RS96, GGR98] with the goal of formally studying sublinear-time algorithms, a property is represented by a set P (of functions satisfying the desired property). A function f is ε-far from P if f differs from each function g ∈ P on at least an ε fraction of domain points. The goal is to distinguish, with constant probability, functions f ∈ P from functions that are ε-far from P. We call an algorithm a t-online-erasure-resilient ε-tester for property P if, given parameters t ∈ N and ε ∈ (0, 1), and access to an input function f via a t-online-erasure oracle, the algorithm accepts with probability at least 2/3 if f ∈ P and rejects with probability at least 2/3 if f is ε-far from P. We study the query complexity of online-erasure-resilient testing of several fundamental properties. We show that for linearity and quadraticity of functions f : {0, 1}d → {0, 1}, the query complexity of t-online- erasure-resilient testing for constant t is asymptotically the same as in the standard model. A function f(x) is linear if it can be represented as a sum of monomials of the form xi, where x = (x1, . . . , xd) is a vector of d bits; the function is quadratic if it can be represented as a sum of monomials, each of the form xi or xixj. To appreciate the difficulty of testing in the presence of online erasures, consider the case of linearity and t = 1. The celebrated tester for linearity in the standard property testing model was proposed by Blum, Luby, and Rubinfeld [BLR93]. It looks for witnesses of non-linearity that consist of three points x, y, and x ⊕ y satisfying f(x) + f(y) 6= f(x ⊕ y), where addition is mod 2, and ⊕ denotes the bitwise XOR operator. Bellare et al. [BCH+96] show that if f is ε-far from linear, then a triple (x, y, x ⊕ y) is a witness with probability at least ε when x, y ∈ {0, 1}d are chosen uniformly and independently at random. In our model, after x and y are queried, the oracle can erase the value of x⊕y. To address this issue, the tester could query three points x, y, and z, and then uniformly select either x ⊕ z or y ⊕ z. If t = 1, the oracle does not have the erasure budget to erase both x ⊕ z and y ⊕ z, and the tester succeeds in catching a triple of the right form with probability 1/2. However, both triples that the tester could have queried—namely, (x, z, x ⊕ z) and (y, z, y ⊕ z)—have to be witnesses of non-linearity for the tester to succeed in catching a witness. So, we need to understand not only the fraction of triples that are witnesses, but also how they interact. Witnesses of non-quadraticity are even more complicated. The tester of Alon et al. [AKK+05] looks for witnesses consisting of points x, y, z, and all four of their linear combinations. We describe a two-player game that models the interaction between the tester and the adversary and give a winning strategy for the tester-

1Input objects such as strings, sequences, images, matrices, and graphs can all be represented as functions.

1 player. We also consider witness structures in which all specified tuples are witnesses of non-quadraticity. We analyze the probability of getting a witness structure under uniform sampling when the input function is ε-far from quadratic. Our investigation leads to a deeper understanding of the structure of witnesses for both properties, linearity and quadraticity. In contrast to linearity and quadraticity, we show that several other properties, specifically, sortedness and the Lipschitz property of sequences, and the Lipschitz property of functions f : {0, 1}d → {0, 1, 2} cannot be tested in the presence of an online-erasure oracle, even with t = 1, no matter how many queries the algorithm makes. Interestingly, witnesses for these properties have a much simpler structure than witnesses for linearity and quadraticity. Consider the case of sortedness of integer sequences, represented by functions f :[n] → N. We say that a sequence is sorted (or the corresponding function is monotone) if f(x) ≤ f(y) for all x < y in [n]. A witness of non-sortedness consists of two points x < y, such that f(x) > f(y). In the standard model, sortedness can be ε-tested with an algorithm that queries an O(pn/ε) + log εn uniform and independent points [FLN 02]. (The fastest testers for this property have O( ε ) query complexity [EKK+00, DGL+99, BGJ+12, CS13, Bel18], but they make correlated queries that follow a more complicated distribution.) Our impossibility result demonstrates that even the simplest testing strategy of querying independent points can be thwarted by an online adversary. To prove this result, we use sequences that are far from being sorted, but where each point is involved in only one witness, allowing the oracle to erase the second point of the witness as soon as the first one is queried. Using a version of Yao’s principle that is suitable for our model, we turn these examples into a general impossibility result for testing sortedness with a 1-online-erasure oracle. Our impossibility result for testing sortedness uses sequences with many (specifically, n) distinct integers. We show that this is not a coincidence by designing a t-online-erasure-resilient sortedness tester that works ε2n for sequences that have O( t ) distinct values. However, the number of distinct values does not have to be large to preclude testing the Lipschitz property in our model. A function f :[n] → N, representing an n-integer sequence, is Lipschitz if |f(x)−f(y)| ≤ |x−y| for all x, y ∈ [n]. Similarly, a function f : {0, 1}d → R d is Lipschitz if |f(x)−f(y)| ≤ kx−yk1 for all x, y ∈ {0, 1} . We show that the Lipschitz property of sequences, as well as d-variate functions, cannot be tested even when the range has size 3, even with t = 1, no matter how many queries the algorithm makes.

Implications for online corruptions. To conclude, we discuss implications of our algorithmic results to computation in the presence of online corruptions. These implications rely on the fact that all three of our testers have 1-sided error, that is, they always accept functions with the property, and that they are nonadaptive, that is, their queries do not depend on answers to previous queries. We consider two types of computational tasks in the presence of online corruptions. The first one is t-online-corruption-resilient testing, defined analogously to t-online-erasure-resilient testing. We show that every nonadaptive, 1-sided error, online-erasure-resilient tester that has a small chance of encountering an erasure (under all adversarial strategies) is also a nonadaptive (2-sided error) online-corruption-resilient tester for the same property, with the same guarantees. This result applies to our testers for linearity and for sortedness with few distinct values. For the second type of computational task, we return to the motivation of the algorithm looking for evidence of fraud. We show that every nonadaptive, 1-sided error, online-erasure-resilient tester for any property P can be modified so that, given access to an input function f that is far from P via an online-corruption oracle, it outputs a witness of f not being in P. This result applies to our testers for sortedness with few distinct values, linearity, and quadraticity.

1.1 Our Results We design t-online-erasure-resilient testers for linearity and quadraticity, two properties widely studied be- cause of their connection to probabilistically checkable proofs (PCPs), applications to hardness of approxi- mating NP-hard problems, and coding theory.

2 Linearity. Starting from the pioneering work of [BLR93], linearity testing has been investigated, e.g., in [BGLR93, BS94, FGL+96, BCH+96, BGS98, Tre98, ST98, ST00, HW03, BSVW03, Sam07, ST09, SW06, KLX10] (see [RR16] for a survey). Linearity can be ε-tested in the standard property testing model with O(1/ε) queries by the BLR tester. We say that a pair (x, y) violates linearity if f(x) + f(y) 6= f(x ⊕ y). The BLR tester repeatedly selects a uniformly random pair of domain points and rejects if it violates linearity. A tight lower bound on the probability that a uniformly random pair violates linearity was proven by Bellare et al. [BCH+96] and Kaufman et al. [KLX10]. We show that linearity can be ε-tested with O(t/ε) queries with a t-online-erasure oracle. When t is constant, the query complexity is O(1/ε), as in the standard property testing model.

Theorem 1.1. There exist a constant c0 ∈ (0, 1) and a 1-sided error, nonadaptive, t-online-erasure-resilient d d/4 t ε-tester for linearity of functions f : {0, 1} → {0, 1} that works for t ≤ c0 · ε · 2 and makes O( ε ) queries. The main ideas behind the linearity tester and its analysis are described in Section 1.3.

Quadraticity. Quadraticity and, more generally, low-degree testing have been studied, e.g., in [BFL91, BFLS91, GLR+91, FGL+96, FS95, RS96, RS97, AKK+05, AS03, MR08, Mos17, KR06, Sam07, ST09, JPRZ09, BKS+10, HSS13, RS13, DG13]. Low-degree testing is closely related to local testing of Reed- Muller codes. The Reed-Muller code C(k, d) consists of evaluations of all functions f : {0, 1}d → {0, 1} that are polynomials of degree at most k. A local tester for a code queries a few locations of a codeword; it accepts if the codeword is in the code, and otherwise it rejects with probability proportional to the distance of the codeword from the code. In the standard property testing model, quadraticity can be ε-tested with O(1/ε) queries by the tester of Alon et al. [AKK+05] that repeatedly selects x, y, z ∼ {0, 1}d and queries f on all of their linear combinations—the points themselves, the double sums x ⊕ y, x ⊕ z, y ⊕ z, and the triple sum x ⊕ y ⊕ z. The tester rejects if the values of the function on all seven queried points sum to 1, since this cannot happen for a quadratic function. A tight lower bound on the probability that the resulting 7-tuple is a witnesses of non-quadraticity was proved by Alon et al. [AKK+05] and Bhattacharyya et al. [BKS+10]. We prove that quadraticity can be ε-tested with O(1/ε) queries with a t-online-erasure-oracle for con- stant t. Our tester can be easily modified to give a local tester for the Reed-Muller code C(2, d) that works with a t-online-erasure oracle. Theorem 1.2. There exists a 1-sided error, nonadaptive, t-online-erasure-resilient ε-tester for quadraticity d 1 of functions f : {0, 1} → {0, 1} that makes O( ε ) queries for constant t. The quadraticity tester and its analysis are the most technical of our contributions. The main ideas behind our quadraticity tester are explained in Section 1.3.

Sortedness. Sortedness testing (see [Ras16] for a survey) was introduced by Ergun et al. [EKK+00]. Its log(εn) + query complexity has been pinned down to Θ( ε ) by [EKK 00, Fis04, CS14, Bel18]. We show that online-erasure-resilient testing of integer-valued sequences is, in general, impossible.

1 Theorem 1.3. For all ε ∈ (0, 12 ], no algorithm can ε-test sortedness of integer sequences when accessed via the 1-online-erasure oracle. In the case without erasures, sortedness can be tested with O(pn/ε) uniform and independent queries [FLN+02]. Theorem 1.3 implies that a uniform tester for a property does not translate into the existence of an online-erasure-resilient tester, counter to the intuition that testers that make only uniform and independent queries should be less prone to adversarial attacks. Our lower bound construction demonstrates that the structure of violations to a property plays an important role in determining whether the property is testable. We prove Theorem 1.3 using Yao’s minimax principle, a common method for showing lower bounds in property testing. A formulation of Yao’s minimax principle suitable for our model is shown in Section A. The hard sequences from the proof of Theorem 1.3 have n distinct values. Pallavoor et al. [PRV18, Pal20] considered the setting when the tester is given an additional parameter r, the number of distinct elements

3 log r in the sequence, and obtained an O( ε )-query tester. Two lower bounds apply to this setting: Ω(log r) for nonadaptive testers [BRY14b] and Ω( log r ) for all testers for the case when r = n1/3 [Bel18]. Pallavoor et log log r √ al. also showed that sortedness can be tested with O( r/ε) uniform and independent queries. We extend the result of Pallavoor et al. to the setting with online erasures for the case when r is small.

Theorem 1.4. Let c0 > 0 be a constant. There exists a 1-sided error, nonadaptive, t-online-erasure-resilient√ r ε-tester for sortedness of n-element sequences with at most r distinct values. The tester makes O( ε ) uniform 2 and independent queries and works when r < ε n . c0t Thus, sortedness is not testable with online erasures when r is large and is testable in the setting when r is small. For example, for Boolean sequences, it is testable with O(1/ε) queries.

The Lipschitz property. Lipschitz testing, introduced by [JR13], was subsequently studied in [CS13, DJRT13, BRY14a, AJMR16, CDJS17]. Lipschitz testing of functions f :[n] → {0, 1, 2} can be performed 1 d d with O( ε ) queries [JR13]. For functions f : {0, 1} → R, it can be done with O( ε ) queries [JR13, CS13]. We show that the Lipschitz property is impossible to test in the online-erasures model even when the range of the function has only 3 distinct values. This applies to both domains, [n] and {0, 1}d.

1 Theorem 1.5. For all ε ∈ (0, 8 ], there is no 1-online-erasure-resilient ε-tester for the Lipschitz property of functions f :[n] → {0, 1, 2}. The same statement holds when the domain is {0, 1}d instead of [n].

Computation in the Presence of Online Corruptions Finally, we state the implications of our algorithmic results to computation in the presence of online corrup- tions. These results are proved in Section 6. Lemma 1.6 states that testers that work in the presence of online erasures and satisfy some additional conditions also work in the presence of online corruptions. Lemma 1.6 uses the notion of an adversarial strategy. We model an adversarial strategy as a distribution on decision trees, where each tree dictates the erasures to be made for a given input and queries of the algorithm. Lemma 1.6. Let P be a property of functions that has a 1-sided error, nonadaptive, t-online-erasure-resilient tester T , such that, for all adversarial strategies, the probability that T queries an erased value of f during its execution is at most 1/3. Then T is a 2-sided error, nonadaptive, t-online-corruption-resilient tester for P. Our online-erasure-resilient testers for linearity and for sortedness with few distinct values have a small probability of encountering an erasure during their computation. As a result, Lemma 1.6 implies online- corruption-resilient testers for these properties. Their performance is summarized in Corollaries 6.1 and 6.2. Our final lemma states the implications of our algorithmic results for the computational task of finding witnesses in the presence of online corruptions. Lemma 1.7. Let P be a property of functions that has a 1-sided error, nonadaptive, t-online-erasure- resilient tester. Then there exists a nonadaptive algorithm with the same query complexity that, given a parameter ε and access via a t-online-corruption-oracle O to a function f that is ε-far from P, outputs with probability at least 2/3 a witness of f∈ / P. The witness consists of queried domain points x1, . . . , xk and values O(x1),..., O(xk) obtained by the algorithm, such that no g ∈ P has g(xi) = O(xi) for all i ∈ [k]. All our online-erasure-resilient testers are nonadaptive and have 1-sided error, so Lemma 1.7 implies algorithms for detecting witnesses for linearity, quadraticity, and for sortedness with few distinct values.

1.2 Comparison to Related Models Our model is closely related to (offline) erasure-resilient testing of Dixit et al. [DRTV18] and tolerant testing of Parnas, Ron, and Rubinfeld [PRR06]. These two models can be thought of as versions of property testing in the presence of offline erasures and corruptions, respectively. In the model of Dixit et al., also investigated in [RV18, RRV19, BFLR20, PRW20, LPRV21, NV21], the adversary performs all erasures to the function

4 x1 x1 x2 x1 x2 y x1 x2 y

Figure 1: The stages in the linearity game for t = 1. Each frame shows a move of Player 1 (as a blue point or a blue solid line) in the winning strategy and a response by Player 2 (as a red dashed line). Each red dashed line between points a and b corresponds to Player 2 erasing a ⊕ b. before the execution of the algorithm. An (offline) erasure-resilient tester is given a parameter α ∈ (0, 1), an upper bound on the fraction of the values that are erased. The adversary we consider is more powerful in the sense that it can perform erasures online, during the execution of the tester. However, in some parameter regimes, our oracle cannot perform as many erasures. Importantly, all three properties that we show are impossible to test in our model, are testable in the model of Dixit et al. with essentially the same query complexity as in the standard model [DRTV18]. The tolerant testing model of [PRR06] has received a lot of attention. An algorithm is an (α, ε)-tolerant tester for a property P if, when given oracle access to a function f, the algorithm accepts with probability at least 2/3 if f is α-close to P and rejects with probability at least 2/3 if f is ε-far from P, where 0 ≤ α < ε ≤ 1. When α  ε, this model can be thought of as (ε − α)-testing with at most an α fraction of the input adversarially corrupted before the execution of the algorithm. As pointed out in [PRR06], the BLR tester is a tolerant tester of linearity for α significantly smaller than ε. Tolerant testing of linearity with distributional assumptions was studied in [KS09] and tolerant testing of Reed-Muller codes over large alphabets was studied in [GR05]. Tolerant testing of sortedness is closely related to approximating the distance to monotonicity and estimating the longest increasing subsequence. These tasks can be performed with polylogorithmic in n number of queries [PRR06, ACCL07, SS17]. As we showed, sortedness is impossible to test in the presence of online erasures. Thus, sortedness is an example of a property easily testable with offline erasures and corruptions, but not testable at all with online erasures. However, it is open if there are properties that have lower query complexity in the online model than in the offline models, since erasures in our model are budgeted differently.

1.3 The Ideas Behind Our Linearity and Quadraticity Testers One challenge in generalizing the testers of [BLR93] and [AKK+05] to work with an online-erasure oracle is that their queries are correlated. First, we want to ensure that the tester can obtain function values on tuples of the right form—(x, y, x ⊕ y) for linearity and (x, y, z, x ⊕ y, x ⊕ z, y ⊕ z, x ⊕ y ⊕ z) for quadraticity. Then we want to ensure that, if the original function is far from the property, the tester is likely to catch such a tuple that is also a witness to not satisfying the property. Next, we formulate a two-player game2 that abstracts the first task. In the game, the tester-player sees what erasures are made by the oracle-player. This assumption is made to abstract out the most basic challenge and is not used in the algorithms’ analyses.

Low-degree testing as a two-player game. Player 1 represents the tester and Player 2 represents the adversary. The players take turns drawing points and edges connecting them, each in their own color. For the case of linearity, Player 1 wins the game if it draws in blue two points and an edge connecting them. (The points represent x, y ∈ {0, 1}d and the edge is their sum x ⊕ y). A move of Player 1 consists of drawing a blue point or a blue edge connecting two existing non-adjacent points. A move of Player 2 consists of drawing at most t red edges between existing points, thus spoiling the picture for Player 1. (This corresponds to the oracle erasing the corresponding sums). A winning strategy for Player 1 is to draw t + 2 points x1, . . . , xt+1, y in its first t + 2 moves. The points xi can be thought of as alternatives—or decoys—for point x. After y is drawn, Player 2 spoils at most t of

2This game has been tested on real children, and they spent hours playing it.

5 Figure 2: Stages in the quadraticity game for t = 1, played according to the winning strategy for Player 1: connecting the y-decoys from the first tree to x-decoys (frames 1-4); drawing z and connecting it to y-decoys and an x-decoy (frames 5-6), and creation of a blue triangle (frames 7–8). Frame 5 contains edges from z to two structures, each replicating frame 4. We depict only points and edges relevant for subsequent frames.

the potential edges connecting y to other points. Now Player 1 draws a remaining valid edge between y and another point, thus winning the game. Fig. 1 shows the strategy playing out for the case of t = 1. In the case of quadraticity, Player 1 wins the game if it draws in blue all the vertices and edges of a triangle and colors the triangle blue. The vertices represent the points x, y, z ∈ {0, 1}d, the edges are the sums x ⊕ y, x ⊕ z, y ⊕ z, and the triangle is the sum x ⊕ y ⊕ z. A move of Player 1 consists of drawing a point or an edge between two existing non-adjacent points or coloring an uncolored triangle between three existing points (in blue). A move of Player 2 consists of at most t steps; in each step, it can draw a red edge between existing points or color a triangle between three existing points (in red). Our online-erasure-resilient quadraticity tester is based on a winning strategy for Player 1 with tO(t) moves. At a high level, Player 1 first draws many decoys for x. The y-decoys are organized in t + 1 full (t + 1)-ary trees of depth t. The root for tree i is yi, its children are yi,j, where j ∈ [t + 1], etc. We jot the rest of the winning strategy for t = 1 and depict it in Fig. 2. In this case, Player 1 does the following (i) (i) (i) (i) for each of two trees: it draws points x1 , . . . , x12 , yi; connects yi to half of x-decoys (w.l.o.g., x1 , . . . , x6 ); (i) (i) draws point yi,1, connects it to two of the x-decoys adjacent to y1 (w.l.o.g., x1 and x2 ); draws point yi,2, (i) (i) (i) (i) connects it to two of x3 , . . . , x6 (w.l.o.g., x3 and x4 ); draws z and connects it to one of the roots (w.l.o.g., (1) (1) (1) y1), connects z to one of y1,1 and y1,2 (w.l.o.g., y1,1), connects z to one of x1 and x2 (w.l.o.g., x1 ), and (1) (1) finally colors one of the triangles x1 y1z and x1 y1,1z, thus winning the game. The decoys are arranged to guarantee that Player 1 always has at least one available move in each step of the strategy. For general t, the winning strategy is described in full detail in Algorithm 2. Recall that the y-decoys are organized in t + 1 full (t + 1)-ary trees of depth t. For every root-to-leaf path in every tree, Player 1 draws edges from all the nodes in that path to a separate set of t + 1 decoys for x. After z is drawn, the tester “walks” along a root-to-leaf path in one of the trees, drawing edges between z and the y-decoys on the path. The goal of this walk is to avoid the parts of the tree spoiled by Player 2. Finally, Player 1 connects z to an x-decoy that is adjacent to all vertices in the path, and then colors a triangle involving this x-decoy, a y-decoy from the chosen path, and z. The structure of decoys guarantees that Player 1 always has t + 1 options for its next move, only t of which can be spoiled by Player 1.

From the game to a tester. There are two important aspects of designing a tester that are abstracted away in the game: First, the tester does not actually know which values are erased until it queries them. Second, the tester needs to catch a witness demonstrating a violation of the property, not merely a tuple of the right form with no erasures. Here, we briefly describe how we overcome these challenges. The simplest tester that can be constructed based on the winning strategy for the linearity game repeats

6 d the following procedure. It follows the winning strategy, whereby it queries a random point xi ∼ {0, 1} in lieu of drawing xi, picks a random i ∼ [t + 1], and then queries the sum xi ⊕ y in lieu of drawing an edge 1 (xi, y). The probability that this sum is not erased by the adversary is at least t+1 , since the adversary only has budget for erasing t of the sums. To get a constant probability of successfully obtaining a triple of the form (x, y, x ⊕ y), this procedure has to be repeated Θ(t) times. Since the procedure makes Θ(t) queries, it would result in a tester with query complexity Ω(t2). To get a linear dependence on t, our tester first t queries O( ε ) points to build a reserve, and only then starts querying sums x ⊕ y, where x and y are sampled from the reserve. In some sense, it can be viewed as combining multiple iterations of the winning strategy (without explicitly dividing the points into x’s and y’s). This addresses the first challenge described above. The second challenge is addressed by a structural result (Lemma 2.1) on the concentration of violated pairs among the queried points in the reserve. Our quadraticity tester is based directly on the game. It converts the moves of the winning strategy of Player 1 into a corresponding procedure, making a uniformly random guess at each step about the choices that remain nonerased. There are three core technical lemmas used in the analysis of the algorithm. Lemma 3.4 lower bounds the probability that the tester makes correct guesses at each step about which edges (double sums) and triangles (triple sums) remain nonerased. This probability depends only on the erasure budget t. Lemma 3.3 gives a lower bound on the probability that uniformly random sampled points (the x- and y- decoys together with z) form a large violation structure, where all triangles that Player 1 might eventually complete violate quadraticity. Building on a result of Alon et al., we show that even though the number of triangles involved in the violation structure is large, namely tO(t), the probability of sampling such a structure is α = Ω(min(ε, ct)), where ct ∈ (0, 1) depends only on t. Finally, Lemma 3.2 shows that despite the online adversarial erasures, the tester has a probability of α/2 of sampling the points of such a large violation structure and obtaining their values from the oracle. The three lemmas combined show that quadraticity can be tested with O(1/ε) queries for constant t.

1.4 Conclusions and Open Questions We initiate a study of sublinear-time algorithms in the presence of online adversarial erasures and corruptions. We design efficient online-erasure-resilient testers for several important properties (linearity, quadraticity, and—for the case of small number of distinct values—sortedness). We also show that several basic properties, specifically, sortedness of integer sequences and the Lipschitz properties, cannot be tested in our model. We now list several open problems. • Sortedness is an example of a property that is impossible to test with online erasures, but is easy to test with offline erasures, as well as tolerantly. Is there a property that has smaller query complexity in the online-erasure-resilient model than in the (offline) erasure-resilient model of [DRTV18]? • We design a t-online-erasure-resilient quadraticity tester that makes O(1/ε) queries for constant t. What is the query complexity of t-online-erasure-resilient quadraticity testing in terms of t and ε?

1 k • The query complexity of ε-testing if a function is a polynomial of degree at most k is Θ( ε + 2 ) [AKK+05, BKS+10]. Is there a low-degree test for k ≥ 3 that works in the presence of online erasures?

• Our tester for linearity works in the presence of online corruptions, but our tester for quadraticity does not. Is there an online-corruption-resilient quadraticity tester?

2 An Online-Erasure-Resilient Linearity Tester

In this section, we present our online-erasure-resilient linearity tester (Algorithm 1) and prove Theorem 1.1. In the analysis of Algorithm 1, we let xi, for all i ∈ [q], be random variables denoting the points queried in Step 3. Recall that a pair (x, y) of domain points violates linearity if f(x) + f(y) 6= f(x ⊕ y). The proof of Theorem 1.1 crucially relies on the following lemma about the concentration of pairs violating linearity.

7 Algorithm 1 An Online-Erasure-Resilient Linearity Tester 1 d Input: ε ∈ (0, 2 ), erasure budget t ∈ N, access to function f : {0, 1} → {0, 1} via a t-online-erasure oracle. ct 1: Let c = 88 and q = ε . 2: for all i ∈ [q]: d 3: Sample xi ∼ {0, 1} and query f at xi. 24 4: repeat ε times: 5: Sample a uniform (i, j) such that i, j ∈ [q] and i < j, then query f at xi ⊕ xj. 6: Reject if xi, xj, and xi ⊕ xj are nonerased and f(xi) + f(xj) 6= f(xi ⊕ xj). 7: Accept.

ct 2 Lemma 2.1. Suppose f is ε-far from linear and q = ε . Let Y denote the number of pairs (i, j) ∈ [q] such ε q that i < j and (xi, xj) violates linearity. Then Pr[Y ≤ 4 · 2 ] ≤ 0.25. We prove Lemma 2.1 in Section 2.1. In the rest of this section, we first prove an auxiliary lemma (Lemma 2.2) and then use Lemmas 2.1 and 2.2 to prove Theorem 1.1. We say a query u ∈ {0, 1}d is successfully obtained if it is nonerased right before it is queried, i.e., the tester obtains f(u) as opposed to the symbol ⊥. q Lemma 2.2. Let G1 be the (good)event that all 2 sums xi ⊕ xj of points queried in Step 3 of Algorithm 1 are distinct, and G2 be the (good) event that all q points xi queried in Step 3 are successfully obtained. Then Pr[G1 ∪ G2] ≤ 0.05 for all adversarial strategies. d Proof. First, we analyze event G1. Consider points xi, xj, xk, x` ∼ {0, 1} , where {i, j}= 6 {k, `}. Since these points are distributed uniformly and independently, so are the sums xi ⊕ xj and xk ⊕ x`. The probability d 1 that two uniformly and independently sampled points x, y ∼ {0, 1} are identical is 2d . Therefore, by a q2 1 q4 union bound over all pairs of sums, Pr[G1] ≤ 2 · 2d ≤ 4·2d . To analyze G2, fix an arbitrary adversarial strategy. In Steps 2–3, the algorithm makes at most q queries. d d Hence the oracle erases at most qt points from {0, 1} . Since each point xi is sampled uniformly from {0, 1} , qt Pr [xi is erased when queried] ≤ . d d xi∼{0,1} 2

q2t ct By a union bound over the q points sampled in Step 3, we get Pr[G2] ≤ 2d . We substitute q = ε to get q4 q2t q4 c4t4 Pr[G ∪ G ] ≤ + ≤ = ≤ c4c4 ≤ 0.05, 1 2 4 · 2d 2d 2d ε4 · 2d 0 d/4 since t ≤ c0 · ε · 2 , as stated in Theorem 1.1, and assuming c0 is sufficiently small.  Proof of Theorem 1.1. The query complexity of Algorithm 1 is evident from its description. Clearly, Algo- rithm 1 is nonadaptive and accepts if f is linear. Suppose now that f is ε-far from linear and fix an arbitrary 2 adversarial strategy. We show that Algorithm 1 rejects with probability at least 3 . We call a sum xi ⊕ xj queried in Step 5 violating if the pair (xi, xj) violates linearity. For Algorithm 1 to reject, it must sample i, j ∈ [q] such that xi, xj, and xi ⊕ xj are successfully obtained and xi ⊕ xj is a violating sum. Let Ek, for all k ∈ [24/ε], be the event that in iteration k of Step 4, the algorithm successfully S obtains a violating sum. Let E = k∈[24/ε] Ek. We define the following good event concerning the execution of the for loop: G = G1 ∩ G2 ∩ G3, where G1 and G2 are as defined in Lemma 2.2, and G3 is the event ε q that Y , defined in Lemma 2.1, is at least 4 · 2 . By a union bound and Lemmas 2.1 and 2.2, we know that Pr[G] ≥ 0.7. Therefore, the probability that Algorithm 1 rejects is at least Pr[E ∩ G] = Pr[G] · Pr[E|G] ≥ 0.7 · Pr[E|G].

Suppose that G occurs for the execution of the for loop. Since G2 occurred, all q points queried in Step 3 of Algorithm 1 were successfully obtained. So, the algorithm will reject as soon as it successfully obtains a

8 q violating sum. Since G1 occurred, there are at least 2 distinct sums that can be queried in Step 5. Since ε q G3 occurred, at least 4 · 2 of them are violating. The total number of erasures the adversary makes over the course of the entire execution is at most 2qt, since Algorithm 1 queries at most 2q points. Therefore, the fraction of sums that are nonerased and violating before each iteration of Step 5 is at least ε 2qt ε 5t ε 5ε ε 5ε ε − q ≥ − = − = − > . 4 2 4 q 4 c 4 88 6

That is, Pr[Ek|G] > ε/6 for all k ∈ [24/ε]. Observe that the indicator for the event Ek, for every fixed setting of random coins (of the algorithm and the adversary) used prior to iteration k of Step 5, is a Bernoulli random variable with the probability parameter equal to the fraction of sums that are violating and nonerased right before iteration k. Since independent random coins are used in each iteration of Step 5,

 \  24/ε −4 Pr[E|G] ≤ Pr Ek | G < (1 − ε/6) ≤ e . k∈[24/ε]

−4 This yields that Pr[E ∩ G] > 0.7 · (1 − e ) > 2/3, completing the proof of the theorem. 

2.1 Concentration of Pairs that Violated Linearity In this section, we prove Lemma 2.1 on the concentration of pairs that violate linearity. The proof relies on Claim 2.3 that gives upper bounds on the fraction of pairs (x, y) ∈ ({0, 1}d)2 that violate linearity and on the fraction of triples (x, y, z) ∈ {0, 1}d×3 such that (x, y) and (x, z) violate linearity. The upper bounds are stated as a function of the distance to linearity. The distance of a function f to linearity, denoted εf , is the minimum over all linear functions g over the same domain as f of Prx[f(x) 6= g(x)]. We remark that a tighter upper bound than (1) in Claim 2.3 is shown in [BCH+96, Lemma 3.2]. Since we only need a looser upper bound, we provide a proof for completeness. Claim 2.3. For all f : {0, 1}d → {0, 1}, the following hold:

Pr [(x, y) violates linearity] ≤ 3εf ; (1) x,y∼{0,1}d 2 Pr [(x, y) and (x, z) violate linearity] ≤ εf + 4εf . (2) x,y,z∼{0,1}d

Proof. Let g be the closest linear function to f. Let S ⊆ {0, 1}d be the set of points on which f and g differ, d d i.e., S = {x ∈ {0, 1} | f(x) 6= g(x)}. Then |S| = εf · 2 . For a pair (x, y) to violate linearity, at least one of x, y, and x ⊕ y must be in S. By a union bound,

Pr [(x, y) violates linearity for f] ≤ Pr [x ∈ S ∨ y ∈ S ∨ x ⊕ y ∈ S] ≤ 3 Pr [x ∈ S] = 3εf , x,y∼{0,1}d x,y∼{0,1}d x∼{0,1}d

completing the proof of (1). To prove (2), let Ex,y,z be the event that (x, y) and (x, z) violate linearity. By the Law of Total Probability,

Pr [Ex,y,z] = Pr[Ex,y,z | x ∈ S] Pr[x ∈ S] + Pr[Ex,y,z | x∈ / S] Pr[x∈ / S] x,y,z∼{0,1}d

≤ 1 · εf + Pr[Ex,y,z | x∈ / S]

≤ εf + Pr[(y, z ∈ S) ∨ (x ⊕ y, z ∈ S) ∨ (y, x ⊕ z ∈ S) ∨ (x ⊕ y, x ⊕ z ∈ S) | x∈ / S] 2 ≤ εf + 4 Pr[y, z ∈ S | x∈ / S] = εf + 4εf ,

where, in the last line, we used symmetry and a union bound, and then independence of x, y, and z.  Proof of Lemma 2.1. We prove the lemma by applying Chebyshev’s inequality to Y . For all i, j ∈ [q], where P i < j, let Yi,j be the indicator for the event that (xi, xj) violates linearity. Then Y = i

9 First, we obtain a lower bound on E[Y ]. By linearity of expectation and symmetry, X q q [Y ] = [Yi,j] = · Pr [(xi, xj) violates linearity] ≥ εf , E E d 2 xi,xj ∼{0,1} 2 i

X q Var[Y ] ≤ 3 ε . (3) i,j 2 f i

When {i, j} ∩ {k, `} = ∅, the random variables Yi,j and Yk,` are independent, and thus Cov[Yi,jYk,l] = 0. Consider the case when |{i, j} ∩ {k, `}| = 1. Suppose that i = k. Then

2 2 2 Cov[Yi,jYi,`] = E[Yi,jYi,`] − E[Yi,j]E[Yi,`] ≤ εf + 4εf − εf = εf + 3εf , where the inequality follows from (2) and [BCH+96, Theorem 1.2]. By symmetry,

X X q q Cov[Y Y ] = 6 Cov[Y Y ] ≤ 6 (ε + 3ε2 ) ≤ 15 ε , (4) i,j k,l i,j i,l 3 f f 3 f i

ct since q = ε and c = 88. This completes the proof of Lemma 2.1. 

3 An Online-Erasure-Resilient Quadraticity Tester

This section, we state our online-erasure-resilient quadraticity tester (Algorithm 2) and prove Theorem 1.2. d d The algorithm uses the following notation. For a function f : {0, 1} → {0, 1} and u1, u2, u3 ∈ {0, 1} , let X X  Tf (u1, u2, u3) = f ui , ∅6=S⊆[3] i∈S where the first sum is over F2, and the second sum is the bitwise XOR. We say a triple (u1, u2, u3) violates d quadraticity if Tf (u1, u2, u3) = 1. Recall that a query u ∈ {0, 1} is successfully obtained if it is nonerased right before it is queried, i.e., the tester obtains f(u) as opposed to the symbol ⊥. For a vector j = (`, j1, . . . , jm), where m ∈ [0, t] and `, j1, . . . , jt ∈ [t + 1], we use the convention that (k) j = (`) for m = 0. For k ∈ [0, m], let j = (`, j1, . . . , jk) be the vector containing the first k + 1 entries of j. Finally, let j(−1) be the vector j with its last entry removed. If j = (`), then j(−1) is the empty set ∅. For completeness, we elaborate on the coding-theoretical motivation for the tester of Alon et al. The set of d all linear combinations of 3 linearly independent vectors u1, u2, u3 ∈ {0, 1} forms a 3-dimensional subspace d of the vector space {0, 1} . The set of d-variate quadratic polynomials over F2 (with no free term) form the

10 Algorithm 2 A t-Online-Erasure-Resilient Quadraticity Tester Input: ε ∈ (0, 1), access to function f : {0, 1}d → {0, 1} via a t-online-erasure oracle. (t+1)(t+1)−1 1: 2 t ε 7  Let I = (t + 1) (2t + 1) , J = t , and α = min 2 , (18·IJ(t+1))IJ(t+1) . 2: repeat 4ct/α times: . ct is a constant from Lemma 3.4 that depends only on t. 3: for all ` ∈ [t + 1]: (`) (`) d (`) (`) 4: Query f at independent x1 , . . . , xI ∼ {0, 1} , and let S∅ = {x1 , . . . , xI }. 5: for all integer m ∈ [0, t]: m 6: for all (j1, j2, . . . , jm) ∈ [t + 1] : . When m = 0, the loop is run once. d 7: Let j = (`, j1, . . . , jm) and query f at yj ∼ {0, 1} . t−m 8: Let Sj be a uniformly random subset of Sj(−1) of size (t + 1)(2t + 1) . 9: Query x ⊕ yj for all x ∈ Sj .

10: Remove Sj from Sj(−1) . 11: Sample z ∼ {0, 1}d and query f at z. (t+1) 12: Sample j = (`, j1, . . . , jt) ∼ [t + 1] and query f at yj(m) ⊕ z for all m ∈ [0, t]. (`) (`) (`) (`) 13: Suppose Sj = {x1 , x2 , . . . , xt+1}. Sample i ∼ [t + 1] and query f at xi ⊕ z. (`) 14: Sample m ∼ [0, t] and query f at xi ⊕ yj(m) ⊕ z. (`) 15: Reject if Tf (xi , yj(m) , z) = 1. . All points needed for computing Tf are nonerased. 16: Accept.

punctured Reed-Muller code R(2, d). Its dual, i.e., the set of codewords orthogonal to every codeword in R(2, d), is the code R(d−3, d). The weight of a codeword is the number of bits with value 1. The codewords of minimum weight in R(d − 3, d) are precisely all incidence vectors for 3-dimensional subspaces of {0, 1}d (with the first bit, corresponding to the origin, removed). Therefore, if f ∈ R(2, d), then the dot product of the vector f with the indicator vector for a 3-dimensional subspace is always 0. Proof of Theorem 1.2. We refer to one iteration of the repeat loop in Algorithm 2 as a round. Fix one (t+1) round. We can think of the points yj(m) , where j = (`, j1, . . . , jt) ∈ [t + 1] , m ∈ [0, t], queried in this round as nodes in t + 1 full (t + 1)-ary trees of depth t. For fixed ` ∈ [t + 1], the `-th tree is rooted at the point y(`), which denotes yj(m) for m = 0. The t + 1 edges from a node in the `-th tree to its t + 1 children are labeled with distinct elements from [t + 1]. Specifically, the node yj(m) for m ∈ [t] is the node in the `-th tree whose root-to-leaf path has m edges and has the labels j1, . . . , jm. For each root-to-leaf path in the `-th tree, labelled by j = (`, j1, . . . , jt) ∈ [t + 1], all nodes yj(m) , m ∈ [0, t] are “connected” to (`) (`) (`) (`) t + 1 points x1 , . . . , xt+1 stored in the set Sj . That is, the algorithm queries all points xi ⊕ yj(m) , where i ∈ [t + 1], m ∈ [0, t]. The goal of the algorithm, after it queries z in Step 11, is to query the sum of z with each of the nodes yj(m) for some root-to-leaf path j in some tree, then query the sum of z with one of the (`) (`) points xi , i ∈ [t + 1] connected to this path, and finally, query the sum of z, xi , and one of the nodes in the path. The tree-like structure of queries guarantees that, with non-zero probability, all queries of the tester are successfully obtained. Thus the tester obtains the values of all points of a 3-dimensional subspace of {0, 1}d. If f is quadratic, then Algorithm 2 always accepts. Suppose that f is ε-far from quadratic. Fix an adversarial strategy and a round of Algorithm 2. We show that Algorithm 2 rejects with probability Ω(ε) in this round. (`) Observe that Algorithm 2 makes queries of three types: singletons (of the form xi , yj(m) , and z), (`) (`) (`) doubles (of the form xi ⊕ yj(m) ,xi ⊕ z, and yj(m) ⊕ z), and triples (of the form xi ⊕ yj(m) ⊕ z), where (t+1) (`) (`) i ∈ [I], j = (`, j1, . . . , jt) ∈ [t + 1] , m ∈ [0, t]. We call points of the form xi ⊕ yj(m) , xi ⊕ z, and (`) yj(m) ⊕ z double decoys, and points of the form xi ⊕ yj(m) ⊕ z triple decoys. We refer to double and triple

11 decoys simply as decoys. Only some of the decoys become actual queries. Let G denote the good event that, for the fixed round, all of the following hold: • all singleton queries are successfully obtained;

(`) • all double decoys of the form xi ⊕ yj(m) are nonerased right before yj(m) is queried;

(`) • all double and triple decoys involving z (as well as xi and/or yj(m) ) are nonerased right before z is queried.

To lower bound the rejection probability of the algorithm, we consider the event that all triples of the (`) (t+1) form (xi , yj(m) , z), where i ∈ [I], j = (`, j1, . . . , jt) ∈ [t + 1] , m ∈ [0, t], violate quadraticity, and all queries in the round are successfully obtained. (`) (`) Definition 3.1 (Witness). The singleton queries xi , yj(m) , z form a witness if Tf (xi , yj(m) , z) = 1 for (t+1) all i ∈ [I], j = (`, j1, . . . , jt) ∈ [t + 1] , m ∈ [0, t], and, in addition, all the singletons and all decoys are distinct. Let W denote the event that the singleton queries form a witness and let α be as defined in Step 1. Lemma 3.2 (Probability of Successful Singleton Queries). If f : {0, 1}d → {0, 1} is ε-far from being quadratic, then Pr[W ∩ G] ≥ α/2. α In other words, Lemma 3.2 shows that for every adversarial strategy, with probability at least 2 , the tester successfully obtains singleton queries that form a witness and, in addition, right before each singleton is queried, the decoys involving that singleton are nonerased. The proof of Lemma 3.2 (in Section 3.1) relies on a key structural result about the fraction of large structures where all triples of a certain form violate quadraticity.

Lemma 3.3 (Probability of Singletons Forming a Violation Structure). Let I, J, t ∈ N. Suppose f : {0, 1}d → (`) (`) d {0, 1} is ε-far from being quadratic. For points xi , yj , z ∼ {0, 1} , where (i, j, `) ∈ [I] × [J] × [t + 1],   \ (`) (`) Pr [Tf (xi , yj , z) = 1] ≥ α, (5) i∈[I],j∈[J],`∈[t+1]

ε 7  where α = min 2 , (18·IJ(t+1))IJ(t+1) . We prove Lemma 3.3 in Section 3.2, building on a result of [AKK+05]. To prove Lemma 3.2, we use (t+1) 2 t Pt m (t+1) −1 Lemma 3.3 with I = (t + 1) (2t + 1) and J = m=0(t + 1) = t , which is the number of nodes in each tree. Next, in Lemma 3.4, we show that the probability of successfully obtaining all double and triple queries in the round, given the event W ∩ G, depends only on t. The proof of Lemma 3.4 appears in Section 3.3. Lemma 3.4 (Probability of All Double and Triple Queries Being Nonerased). The probability that all queries made in one round of Algorithm 2 are successfully obtained, conditioned on the event W ∩ G, is at least 1/ct, where ct depends only on t. Let H denote the event that all queries in the round are successfully obtained, and recall that W is the event that the singleton queries form a witness. The probability that Algorithm 2 rejects in the given round is at least Pr[W ∩ H]. Note that

Pr[W ∩ H] ≥ Pr[W ∩ H ∩ G] = Pr[H | W ∩ G] Pr[W ∩ G].

By Lemmas 3.2 and 3.4, we have that Algorithm 2 rejects with probability at least 1 · α for a fixed round. ct 2 4ct 2 Therefore, after α rounds, Algorithm 2 rejects with probability at least 3 . 

12 3.1 Proof of Lemma 3.2 In this section, we prove Lemma 3.2 that bounds from below the probability that the singleton queries are successfully obtained and form a witness, and, in addition, right before each singleton is queried, the decoys involving that singleton are nonerased. We show that if the fraction of large violation structures is at least α (Lemma 3.3), then, despite the adversarial erasures, the probability of successful singleton queries, as described above, is at least α/2. Proof of Lemma 3.2. The key idea of the proof is to keep track of active witnesses during the execution of the round. To simplify notation, let K = (I + J)(t + 1) + 1 and denote by u1, . . . , uK the singleton queries made by Algorithm 2 in the given round.

Definition 3.5 (Active witness). For i ∈ [K], let u1, . . . , ui denote the singleton queries made by Algorithm 2 d K up until a given timepoint of the fixed round. We say a witness (v1, . . . , vK ) ∈ ({0, 1} ) is i-active if

1. The first i entries of the tuple are equal to u1, u2, . . . , ui.

2. All decoys involving uj, where j ≤ i, were nonerased right before uj was queried.

Furthermore, let Ai be a random variable denoting the number of active witnesses right after the i-th singleton query, and let Bi denote the number of active witnesses right before the i-th singleton query. Let B1 denote the number of witnesses at the beginning of the round, such that all singletons and decoys for the witness are nonerased. Note that Pr[W ∩ G] = Pr[AK = 1] = E[AK ]. To lower bound E[AK ], we first show a lower bound on the total fraction of witnesses, used to lower bound B1. We then bound the difference between Ai and Bi+1 and show a relationship between E[Ai] and E[Bi] for general i. All expectations in this d proof are over the choice of singletons u1, . . . , uK ∼ {0, 1} . Claim 3.6. Let α be as defined in Lemma 3.3. If f is ε-far from being quadratic then 7α Pr [(u1, . . . , uK ) is a witness] ≥ . d u1,...,uK ∼{0,1} 8

Proof. The probability that the event of Lemma 3.3 is true for the singleton queries u1, . . . , uK is at least α. Let S denote the set of all singletons and decoys associated with the K-tuple (u1, . . . , uK ). The number of triple decoys associated with the K-tuple is at most IJ(t + 1), whereas the number of double decoys associated with the K-tuple is at most I(J + 1)(t + 1). Therefore, |S| ≤ 3IJ(t + 1). Any two elements in S are uniformly and independently distributed. Therefore, the probability that two elements in S are identical 1 is 2d . By a union bound over all pairs of elements in S, the probability that not all elements in S are distinct |S|2 |S|2 α α 7α is at most 2d . For d large enough, we have 2d ≤ 8 . Therefore, with probability at least α − 8 = 8 , the singleton queries u1, . . . , uK form a witness.  3α Kd Claim 3.7. For all adversarial strategies, B1 ≥ 4 · 2 .

Proof. Recall that B1 counts the number of witnesses at the beginning of the round, such that all singletons and decoys for the witness are nonerased. Algorithm 2 makes at most |S| queries in each round, so it makes 4ct|S| 4t·|S|·ct d at most α queries in total. Therefore, the oracle can erase at most α points from {0, 1} . Each erasure can deactivate at most |S| · 2(K−1)d witnesses, since the point erased could be any one of the |S| 2 7α Kd 4t·|S| ·ct (K−1)d singletons and decoys associated with the witness. By Claim 3.6, we obtain B1 ≥ 8 ·2 − α ·2 . 2 4t·|S| ·ct (K−1)d α Kd 3α Kd Since |S| ≤ 3IJ(t+1), for d large enough, we have α ·2 ≤ 8 ·2 . Therefore, B1 ≥ 4 ·2 . 

2 t (K−1−i)d Claim 3.8. For all i ∈ [K − 1] and all adversarial strategies, Ai − Bi+1 ≤ (t + 1) (2t + 1) · |S| · 2 .

13 Proof. Observe that Algorithm 2 makes at most (t + 1)(2t + 1)t decoy queries between any two singleton queries (this is the number of double queries made in Step 9 for m = 0). Therefore, in the period right after the i-th singleton query and before the (i + 1)-st singleton query, the oracle can perform at most t 2 t ((t + 1)(2t + 1) + 1) · t ≤ (t + 1) (2t + 1) erasures. Let u1, u2, . . . , ui be the first i singleton queries of the algorithm. For each erasure, the oracle can deactivate at most |S| · 2(K−1−i)d witnesses whose first i entries are u1, u2, . . . , ui, by erasing one of the remaining singletons or decoys. Therefore, the number of active witnesses between right after the i-th singleton query and right before the (i + 1)-st singleton query 2 t (K−1−i)d can decrease by at most (t + 1) (2t + 1) · |S| · 2 .  1 Claim 3.9. For all i ∈ [K], it holds that E[Ai] = 2d E[Bi]. d Proof. For v ∈ {0, 1} , let Bi,v denote the number of witnesses that are active right before the i-th singleton P query and whose i-th entry is equal to v. Then, Bi = v∈{0,1}d Bi,v. Let 1(v) be the indicator random variable for the event that the i-th singleton query is equal to v. Then, h X i h X i 1 [A ] = B 1(v) = [1(v)] B = [B ]. E i E i,v E E i,v 2d E i v∈{0,1}d v∈{0,1}d

 We combine the claims above to complete the proof of the lemma. By Claim 3.9, 1 1 1 1 [A ] = [B ] = [A + B − A ] = [A ] − [A − B ] E K 2d E K 2d E K−1 K K−1 2d E K−1 2d E K−1 K K−1 1 1 1 X [Ai − Bi+1] = [B ] − [A − B ] = ··· = [B ] − E . 22d E K−1 2d E K−1 K 2Kd E 1 2(K−i)d i=1 By Claim 3.7, 1 3α [B ] ≥ . 2Kd E 1 4 In addition, Claim 3.8 yields that

K−1 K−1 2 t (K−1−i)d 2 t X [Ai − Bi+1] X (t + 1) (2t + 1) · |S| · 2 K · (t + 1) (2t + 1) · |S| α E ≤ ≤ ≤ , 2(K−i)d 2(K−i)d 2d 4 i=1 i=1

3α α α where the last inequality holds for large enough d. We obtain that Pr[W ∩ G] = E[AK ] ≥ 4 − 4 = 2 . 

3.2 Proof of Lemma 3.3 In this section, we prove Lemma 3.3 on the fraction of large violation structures for which all triples (`) (`) + (xi , yj , z), where (i, j, `) ∈ [I]×[J]×[t+1], violate quadraticity. Our proof builds on a result of [AKK 05]. Proof of Lemma 3.3. Let η denote the fraction of violating triples for f, i.e.,

η := Pr [Tf (u1, u2, u3) = 1]. d u1,u2,u3∼{0,1}

0 (`) (`) d Let η denote the right-hand side of (5), that is, the probability that for xi , yj , z ∼ {0, 1} , all of the (`) (`) triples (xi , yj , z) are violating, where (i, j, `) ∈ [I] × [J] × [t + 1]. Finally, the distance of a function f to quadraticity, denoted by εf , is the minimum over all quadratic functions g over the same domain as f of Prx[f(x) 6= g(x)]. We use the following result from [AKK+05], which we state here for the special case of quadraticity. + 7 1 Claim 3.10 (Theorem 1 of [AKK 05]). For all f, we have η ≥ min( 3 εf , 40 ).

14 0 0 Claim 3.11 lower bounds η in terms of η for all values of εf . Claim 3.13 lower bounds η for small values of εf . We combine these results and use Claim 3.10 to conclude the proof of the lemma.

(`) (`) d Claim 3.11. For all f and points xi , yj , z ∼ {0, 1} , where i ∈ [I], j ∈ [J], ` ∈ [t + 1], it holds that

h \ (`) (`) i IJ(t+1) Pr [Tf (xi , yj , z) = 1] ≥ η . i∈[I],j∈[J],`∈[t+1] Proof. The proof uses the H¨older’sinequality as its key ingredient. 1 1 n Claim 3.12 (H¨older’sinequality). Let p, q ≥ 1 such that p + q = 1. For all (a1, . . . , an), (b1, . . . , bn) ∈ R ,

1/p 1/q X  X p  X q |aibi| ≤ |ai| |bi| . i∈[n] i∈[n] i∈[n]

(`) (`) d (`) (`) (`) For xi , yj , z ∼ {0, 1} , let Tij be the event Tf (xi , yj , z) = 1. Then

h \ (`)i X h \ (`) i Pr Tij = Pr Tij | z = u Pr[z = u] i∈[I],j∈[J],`∈[t+1] u∈{0,1}d i∈[I],j∈[J],`∈[t+1]

1 X h \ (`) i = Pr T | z = u 2d ij u∈{0,1}d i∈[I],j∈[J],`∈[t+1] t+1 1 X h \ (1) i = Pr T | z = u 2d ij u∈{0,1}d i∈[I],j∈[J] t+1  1 X h \ (1) i ≥ Pr T | z = u 2d ij u∈{0,1}d i∈[I],j∈[J]  t+1 \ (1) = Pr Tij , i∈[I],j∈[J] where the first equality holds by the Law of Total Probability; the third equality holds because, conditioned T (`) on z taking a specific value, the events i∈[I],j∈[J] Tij for ` ∈ [t + 1] are independent and have the same probability; the inequality follows from the H¨older’sinequality. We use a similar argument to obtain

I h \ (1)i  h \ (1)i Pr Tij ≥ Pr T1j , i∈[I],j∈[J] j∈[J]

(1) (1) where we condition on the values of y1 , . . . , yJ , and z. Similarly,

h \ (1)i (1) J Pr T1j ≥ (Pr[T11 ]) , j∈[J]

(1) (1) is obtained by conditioning on the values of x1 and z. Since Pr[T11 ] = η, the claim follows.  d Next, we consider the case when εf is small. For u1, u2, u3 ∈ {0, 1} , let span(u1, u2, u3) be the set of P points i∈T ui for ∅= 6 T ⊆ [3] and

[ (`) (`) S = span(xi , yj , z). i∈[I],j∈[J],`∈[t+1] The set S has (I + J)(t + 1) + 1 singletons, at most I(J + 1)(t + 1) double sums, and at most IJ(t + 1) triple sums. Therefore, |S| ≤ 3IJ(t + 1).

15 1 0 εf Claim 3.13. Suppose εf ≤ 2|S| . Then η ≥ 2 . Proof. Let g be a closest quadratic function to f. Any two elements of S are uniformly and independently d (`) (`) d distributed in {0, 1} . Then, for xi , yj , z ∼ {0, 1} , we have

η0 ≥ Pr[f(z) 6= g(z) and f(u) = g(u) ∀ u ∈ S \{z}] X ≥ Pr[f(z) 6= g(z)] − [f(z) 6= g(z) and f(u) 6= g(u)] u∈S\{z} 2 ≥ εf − (|S| − 1)εf = εf (1 − (|S| − 1)εf ).

1 1 1 If εf ≤ 2|S| , then 1 − (|S| − 1)εf ≥ 1 − |S| · 2|S| ≥ 2 , which concludes the proof. 

1 3 Suppose 2|S| ≤ εf ≤ 7·40 . In this case, by Claims 3.10 and 3.11 and using the fact that |S| ≤ 3IJ(t + 1), we have 7 IJ(t+1)  7 IJ(t+1) 7 η0 ≥ ε ≥ ≥ . 3 f 6 · |S| (18 · IJ(t + 1))IJ(t+1) 1 0 1 Finally, if εf ≥ 40 , then again by Claims 3.10 and 3.11, we have η ≥ 40(IJ(t+1)) . We have obtained that 0 ε 7  η ≥ min 2 , (18·IJ(t+1))IJ(t+1) . 

3.3 Proof of Lemma 3.4 In this section, we prove Lemma 3.4, which shows that conditioned on the good event W ∩ G, all queries in one round of Algorithm 2 are successfully obtained. In particular, this probability only depends on the per-query erasure budget t. Proof of Lemma 3.4. We first prove a lower bound on the probability that the queries made in Step 9 are successfully obtained. Claim 3.14. Conditioned on the event W ∩ G, the probability that in one execution of Step 9 at level m ∈ [0, t], all queries in the step are successfully obtained is at least

 1 (t+1)(2t+1)t−m . (t2 + t)(2t + 1)t−m + 1

Proof. Fix the values of `, m, j1, . . . , jm for the given execution of Step 9 and let j = (`, j1, . . . , jm). We can assume, without loss of generality, that Step 6 considers the tuples (j1, . . . , jm) in the lexicographic order. t−m+1 When jm = 1, then right before Step 9 is executed, we have |Sj(−1) | = (t + 1)(2t + 1) . The size of the set Sj(−1) decreases as the value of jm increases, so that for jm = t + 1 we have

t−m+1 t−m |Sj(−1) | = (t + 1)(2t + 1) − t(t + 1)(2t + 1) = (t + 1)(2t + 1)t−m(2t + 1 − t) = (t + 1)2(2t + 1)t−m.

Thus, right before the execution of Step 9, the size of Sj(−1) is always at least (t + 1) times the size of the subset Sj . Let s denote the size of Sj(−1) right before the execution of Step 8. In Step 8 we sample a uniformly 0 t−m random subset Sj of Sj(−1) of size s = (t + 1)(2t + 1) and in Step 9 we query x ⊕ yj for all x ∈ Sj . Conditioned on the event W ∩ G, all sums x ⊕ yj , where x ∈ Sj , are distinct and nonerased right before yj is queried. On the i-th query of Step 9, the tester selects a uniformly random x out of s−(i−1) elements. Right before the i-th query of the tester, the oracle can have erased at most ti of the sums x ⊕ yj , for x ∈ Sj(−1) , since the adversary is not aware of the points belonging to Sj until their sums with yj are queried in Step 9. ti Therefore, the probability that the tester successfully obtains the sum on its i-th query is at least 1 − s−i+1 , 0 where i ∈ [s ]. We argued that, for all values of jm, right before the execution of Step 9, it always holds that

16 s ≥ (t + 1)s0. Therefore, the probability that the tester successfully obtains a sum is always positive. In particular, using the bound s ≥ (t + 1)s0, the probability that all queries in Step 9 are successfully obtained is at least

0 s 0 0 0 Y  ti   ts0 s  1 s  1 s 1 − ≥ 1 − ≥ = . s − i + 1 s − s0 + 1 (t + 1)s0 − s0 + 1 s0t + 1 i=1

0 t−m Substituting s = (t + 1)(2t + 1) concludes the proof.  In Steps 4–11, the tester makes only singleton and double queries. Conditioned on W ∩ G, all singleton queries are successfully obtained. All double queries are made in Step 9. By Claim 3.14, the probability that all double queries in Step 9 are successfully obtained depends only on t. Before z is queried in Step 11, conditioned on the event W ∩ G, all double and triple sums of the form (t+1) yj(m) ⊕ z, x ⊕ z, and x ⊕ yj(m) ⊕ z, where m ∈ [0, t], j = (`, j1 . . . , jt) ∈ [t + 1] , and x ∈ Sj , are distinct and nonerased. After z is queried, the oracle can perform at most t erasures. Therefore, there exists

` ∈ [t + 1], say ` = 1, such that all double and triple sums yj(m) ⊕ z, x ⊕ z, and x ⊕ yj(m) ⊕ z, where m ∈ [0, t], (t+1) 1 j = (1, j1 . . . , jt) ∈ [t + 1] , and x ∈ Sj are nonerased after z is queried. With probability t+1 , the 1 tester samples ` = 1 in Step 12. By a similar reasoning, with probability (t+1)t the tester samples values of j1, . . . , jt in Step 12, say j1 = ··· = jt = 1, such that all queries yj(m) ⊕ z, where m ∈ [0, t], are successfully obtained. In addition, right before yj(t) ⊕ z is queried, all sums of the form x ⊕ z and x ⊕ yj(m) ⊕ z, where (t+1) j = (1,..., 1, jt) ∈ [t + 1] , m ∈ [0, t], and x ∈ Sj are nonerased. After yj(t) ⊕z is queried, the oracle performs at most t erasures, so there exists x ∈ Sj such that x⊕z and 1 x ⊕ yj(m) ⊕ z, where j = (1, 1,..., 1) and m ∈ [0, t], are nonerased. With probability t+1 , the tester samples 1 this x in Step 13, and with probability t+1 , it samples m ∈ [0, t] such that the triple sum x ⊕ yj(m) ⊕ z is 1 successfully obtained in Step 14. Thus, with probability (t+1)t+3 , all queries in Steps 12–14 are successfully obtained. Therefore the probability that all queries in one round of Algorithm 2 are successfully obtained, conditioned on W ∩ G, is 1/ct, where ct is a constant depending only on t. 

4 Online-Erasure-Resilient Sortedness Testing

In this section, we prove Theorem 1.3 on the impossibility of general online-erasure-resilient sortedness testing and Theorem 1.4 on online-erasure-resilient testing sortedness of sequences with few distinct values.

4.1 Impossibility of Online-Erasure-Resilient Sortedness Testing In this section, we prove Theorem 1.3 which shows that online-erasure-resilient testing of sortedness of integer sequences is impossible. Proof of Theorem 1.3. By Yao’s principle (see Corollary A.3), it is enough to give a pair of distributions, one over monotone functions over [n] and the other one over functions over [n] that are far from monotone, and an oracle strategy, such that there is no deterministic algorithm that can distinguish the distributions with high probability, when given access to them via a 1-online-erasure oracle that uses the given strategy. Let n ∈ N be even. Consider the following distributions on functions f :[n] → [n]. D+ distribution: Independently for all i ∈ [n/2]: • f(2i − 1) ← 2i − 1 and f(2i) ← 2i − 1, with probability 1/3. • f(2i − 1) ← 2i − 1 and f(2i) ← 2i, with probability 1/3. • f(2i − 1) ← 2i and f(2i) ← 2i, with probability 1/3. D− distribution: Independently for all i ∈ [n/2]:

17 • f(2i − 1) ← 2i and f(2i) ← 2i − 1, with probability 1/3. • f(2i − 1) ← 2i − 1 and f(2i) ← 2i, with probability 2/3. Every function sampled from the distribution D+ is monotone. For a function sampled from the distribution D−, the expected number of index pairs (2i−1, 2i) such that the respective function values are 2i and 2i − 1 is equal to n/6. By a Chernoff bound, the probability that the number of such index-pairs is less than n/12 is at most exp(−n/48). In other words, with probability at least 1 − exp(−n/48), a function sampled from the D− distribution is 1/12-far from being monotone. 1 Consider a deterministic adaptive algorithm T with two-sided error for online erasure-resilient 12 -testing of monotonicity of functions from [n] to [n]. Assume that T is given access to a function sampled from D+ or D− with equal probability, where the access is via a 1-online-erasures oracle. The oracle uses the following strategy. For each i ∈ [n/2], if T queries the point 2i − 1, then the oracle erases the function value at the point 2i; if T queries the point 2i then the oracle erases the function value at the point 2i − 1. The oracle erases exactly one function value between queries. Given this strategy, the tester T never sees a violation to monotonicity. The distribution of function values restricted to any particular index is identical for distributions D+ and − D . Hence, the tester T cannot distinguish the distributions, no matter how many queries it makes. 

4.2 Online-Erasure-Resilient Testing of Sortedness with Few Distinct Values √ r In this section, we prove Theorem 1.4 by showing that O( ε ) uniform queries are sufficient for t-online- erasure-resilient ε-testing of sortedness, when r, the number of distinct values in the sequence, is small. Pallavoor et al. [PRV18] showed a 1-sided error ε-tester for sortedness of real-valued sequences containing at √ r most r distinct values that makes O( ε ) uniform and independent queries. The proof of [PRV18, Theorem 1.5] is the starting point for our analysis. Proof of Theorem 1.4. We call (u, v) ∈ [n]2 a violating pair if u < v and f(u) > f(v). The tester, given input √ 2c r ε ∈ (0, 1) and oracle access to a function f with image size at most r, queries f on ε points selected uniformly and independently at random and rejects if and only if it queries u, v ∈ [n] such that (u, v) is a violating pair. Since the decision made by the tester does not depend on the specific values being queried, but only on the ordering of the queried values, we can assume without loss of generality that the input function is of the form f :[n] → [r]. Clearly, the tester accepts all sorted functions. We show that for c = 32, 2 if f is ε-far from sorted, the tester rejects with probability at least 3 . Suppose f is ε-far from sorted. Define the violation graph G([n],E) to be the graph whose edges are the violating pairs (u, v) ∈ [n]2. Dodis et al. [DGL+99, Lemma 7] show that G has a matching M of size at least εn/2. For each range value i ∈ [r], let Mi be the set of edges (u, v) ∈ M whose lower endpoint u has value i, i.e., f(u) = i. Let Li consist of the |Mi|/2 smallest indices amongst the lower endpoints of the edges in Mi. Let Ui consist of the |Mi|/2 largest indices amongst the upper endpoints of the edges in Mi. It is not hard to see that, for every i ∈ [r], all pairs in Li × Ui are violating. By construction,

X X X |M| εn |L | = |U | = |M |/2 = ≥ . (6) i i i 2 4 i∈[r] i∈[r] i∈[r]

2 We show that with probability at least 3 , for some i ∈ [r], the tester samples a nonerased element both from Li and from Ui, in which case it rejects. Our proof relies on the following claim from [GGL+00], for which we first introduce some notation. Let √ |Li| P L1,...,Lr be disjoint subsets of [n]. Let pi = n and ρ = i∈[r] pi. Suppose we sample c r/ρ uniform points from [n]. Let I be a random variable denoting the set of indices i ∈ [r] such that the sample contains at least one element from the set Li.

18 Claim 4.1 (Claim 1 of [GGL+00]). With probability 1 − e−c over the choice of the sample, X ρ p ≥ √ . i r i∈I √ c r 0 Split the sample into two parts of size ε each. Let Li ⊆ Li be the set of nonerased indices of Li 0 0 0 0 |Li| 0 |Ui | after the tester queries the first part of the sample, and define Ui similarly. Let pi = n , qi = n , and 0 P 0 0 0 0 ρ = min(pi, qi). Assume without loss of generality that pi ≤ qi for all i ∈ [r]. The adversary performs i∈[√r] c rt at most ε erasures after the first part of the sample is queried, therefore

0 √ √ X |L |  X |Li| c rt ε c rt ε ρ0 = i ≥ − ≥ − ≥ , n n εn 4 εn 8 i∈[r] i∈[r]

√ ε2n 0 where we use (6) and the assumption that r ≤ r ≤ 8c2t . Let I be a random variable denoting the set of 0 indices i ∈ [r] such that at least one element of Li is contained in the first part of the sample. By Claim 4.1, − c with probability 1 − e 8 over the first part of the sample, X ε p0 ≥ √ . (7) i 8 r i∈I0

0 The probability that the second part of the sample does not include a nonerased element from ∪i∈[r]Ui is

√ √ √ c r c r  X 0 c rt ε  ε ε  ε − c 1 − q + ≤ 1 − √ + √ ≤ e 16 , i εn 8 r 16 r i∈[r]

P 0 ε2n where we use (7) to lower bound i∈[r] qi, and the assumption that r < ct to upper bound the number of erasures. Therefore, the probability that for some i ∈ [r] the tester samples a nonerased element both from Li and Ui and rejects is at least − c − c 2 (1 − e 8 ) · (1 − e 16 ) ≥ , 3 where the inequality holds for c = 32. 

5 Impossibility of Online-Erasure-Resilient Lipschitz Testing

In this section, we prove Theorem 1.5. We start by showing that 1-online-erasure-resilient Lipschitz testing of functions f :[n] → {0, 1, 2} is impossible. Proof of Theorem 1.5, part 1. We prove the theorem using Yao’s principle. The proof is analogous to that of Theorem 1.3 once the hard distributions are described. In particular, the strategy of the oracle is identical to that used in the proof of Theorem 1.3. Let n ∈ N be a multiple of 4. The following distributions are over functions f :[n] → {0, 1, 2}.

Distribution D+: Independently, for all i ∈ [n] such that i mod 4 ≡ 1: • f(i) ← 0 and f(i + 1) ← 1, with probability 1/2. • f(i) ← 1 and f(i + 1) ← 2, with probability 1/2. Independently, for all i ∈ [n] such that i mod 4 ≡ 3: • f(i) ← 1 and f(i + 1) ← 0, with probability 1/2. • f(i) ← 2 and f(i + 1) ← 1, with probability 1/2.

19 Distribution D−: Independently, for all i such that i mod 4 ≡ 1: • f(i) ← 0 and f(i + 1) ← 2, with probability 1/2. • f(i) ← 1 and f(i + 1) ← 1, with probability 1/2. Independently, for all i such that i mod 4 ≡ 3: • f(i) ← 2 and f(i + 1) ← 0, with probability 1/2. • f(i) ← 1 and f(i + 1) ← 1, with probability 1/2. Every function sampled from the distribution D+ is Lipschitz. For a function sampled from the dis- tribution D−, the expected distance to being Lipschitz is 1/4. The rest of the proof is similar to that of Theorem 1.3.  Next, we prove the second part of Theorem 1.5 showing that 1-online-erasure-resilient Lipschitz testing of functions f : {0, 1}d → {0, 1, 2} is impossible. Proof of Theorem 1.5, part 2. The proof is analogous to the proof of the first part of the theorem once the hard distributions are described. The following distributions are over functions f : {0, 1}d → {0, 1, 2}. Let d e1 ∈ {0, 1} denote the first standard basis vector.

+ d Distribution D : Independently, for all x ∈ {0, 1} such that x1 = 0:

• f(x) ← 0 and f(x ⊕ e1) ← 1, with probability 1/2.

• f(x) ← 1 and f(x ⊕ e1) ← 2, with probability 1/2.

− d Distribution D : Independently, for all x ∈ {0, 1} such that x1 = 0:

• f(x) ← 0 and f(x ⊕ e1) ← 2, with probability 1/2.

• f(x) ← 1 and f(x ⊕ e1) ← 1, with probability 1/2. Every function sampled from the distribution D+ is Lipschitz. For a function sampled from the distribution D−, the expected distance to being Lipschitz is 1/4. The rest of the proof is similar to that of Theorem 1.3. This completes the proof of Theorem 1.5. 

6 Computation in the Presence of Online Corruptions

This section discusses implications of our results to computation in the presence of online corruptions.

6.1 Online-Corruption-Resilience from Online-Erasure-Resilience in Testing In this section, we prove Lemma 1.6 showing that a nonadaptive, 1-sided error, online-erasure-resilient tester that has a small probability of encountering an erasure is also a 2-sided error tester in the presence of online corruptions, with the same guarantees. Proof of Lemma 1.6. Fix a strategy of the t-online-corruption oracle, and let O(c) denote an oracle that uses this strategy. Map the strategy of O(c) to a strategy for a t-online-erasure oracle O(e), so that whenever O(c) modifies the value at a point x to O(c)(x) 6= f(x), the online-erasure oracle erases the value at the same point, i.e., it sets O(e)(x) =⊥. Suppose f ∈ P. If the tester T accesses f via O(e) it always accepts and, with probability at least 2/3, it obtains O(e)(x) = f(x) for all queries x. Fix the random coins of an execution of T for which all queries are successfully obtained. Let T (e) be the execution of T with those coins (where access to f is via O(e)).

20 Similarly, let T (c) be the execution of T with the same coins, when access to f is via O(c). Since T is nonadaptive, T (c) will make the same queries as T (e). By our mapping from O(c) to O(e) and the choice of random coins, T (c) obtains O(c)(x) = f(x) for all queries x. Therefore T (c) accepts. We have obtained that if we run T with access to f via O(c), it accepts with probability at least 2/3. Suppose now that f is ε-far from P and fix the random coins of an execution of T , where access to f is via O(e), such that T rejects. By a similar argument, if we run T with the same coins, where access to f is (c) (c) via O , it will reject. Therefore, T rejects with probability at least 2/3 when access to f is via O . 

6.2 Online-Corruption-Resilient Linearity Tester In this section, we show the existence of a 2-sided error online-corruption-resilient tester for linearity. Corollary 6.1. There exists a constant c0 and a nonadaptive t-online-corruption-resilient ε-tester for lin- earity of functions f : {0, 1}d → {0, 1} that works whenever t ≤ c0 · ε · 2d/4. Proof. Consider Algorithm 1, where we use instead c = 480. Note that the larger the size q of the reserve, the higher is the probability that Algorithm 1 detects a violation to linearity. So for the choice of c = 480, Algorithm 1 is also a 1-sided error online-erasure-resilient tester. By Lemma 1.6, it remains to show that, for all adversarial strategies, Algorithm 1 queries an erased point during its execution with probability at 0 most 1/3. Fix an adversarial strategy, and let G1 and G2 be the events of Lemma 2.2. For c small enough, we have Pr[G1 ∩ G2] ≥ 0.95. q Suppose that G1 ∩ G2 occurs for the execution of the for loop. Since G1 occurred, there are at least 2 distinct sums that can be queried in Step 4. The adversary makes at most 2qt erasures over the course of 2qt 5ε its execution, so the fraction of erased sums before each iteration of Step 4 is at most q ≤ c . Hence, the (2) 24 5ε 24·5 1 probability that Algorithm 1 samples an erased sum in some iteration of Step 4 is at most ε · c ≤ 480 ≤ 4 . We obtain that with probability at least 0.75 · Pr[G1 ∩ G2] ≥ 0.75 · 0.95 ≥ 2/3, all queries of Algorithm 1 are successfully obtained. 

6.3 Online-Corruption-Resilient Tester of Sortedness with Few Distinct Values In this section, we show the existence of a 2-sided error online-corruption-resilient tester for sortedness of sequences with few distinct values.

Corollary 6.2. Let c0 > 0 be a constant. There exists a nonadaptive, t-online-corruption-resilient√ ε-tester r for sortedness of n-element sequences with at most r distinct values. The tester makes O( ε ) uniform and 2 independent queries and works when r < ε n . c0t √ 2c r Proof. Recall that the online-erasure-resilient sortedness tester makes ε uniform and independent queries to f :[n] → [r]. By Lemma 1.6, it suffices to show that, for all adversarial strategies, this tester queries √ 2c rt an erased point with probability at most 1/3. The adversary performs at most ε erasures during the execution of the algorithm. Since the√ tester performs its queries uniformly at random, the probability that 2c rt a given query is erased is at most εn . By a union bound, the probability that some query of the tester 4c2rt ε2n is erased is at most ε2n . By our assumption that r < 12c2t , we obtain that the probability that the tester 1 samples an erased point is at most 3 . 

6.4 Finding Witnesses in the Presence of Online Corruptions In this section, we prove Lemma 1.7. Specifically, we show how to modify a nonadaptive, 1-sided error, online- erasure-resilient tester for a property P to get an algorithm that accesses the input via an online-corruption oracle and outputs a witness demonstrating the violation of P.

21 Proof of Lemma 1.7. Let T be the nonadaptive, 1-sided error, t-online-erasure-resilient tester for P. Let f be ε-far from P. Fix a strategy of the t-online-corruption oracle, and let O(c) denote the oracle running this strategy. Map the strategy of O(c) to a strategy for a t-online-erasure oracle O(e), so that whenever O(c) modifies the value at a point x to O(c)(x) 6= f(x), the online-erasure oracle erases the value at the same point, i.e., it sets O(e)(x) =⊥. If the tester T accesses f via O(e), it detects with probability at least 2/3 a violation to P. Fix the random coins of an execution of T for which it rejects. Let T (e) be the execution of T with those coins (where access to f is via O(e)). Similarly, let T (c) be the execution of T with the same coins, when access to f is via O(c). Since T is nonadaptive, the queries of T (c) will be the same as the queries of T (e). By our mapping from O(c) to O(e), if T (e) obtains O(e)(x) = f(x) for a query x, then T (c) obtains O(c)(x) = f(x) for the same query. Since T (e) is a 1-sided error tester, it can only reject if it successfully obtains values of f on some queried (c) points x1, . . . , xk such that no g ∈ P has g(xi) = f(xi) for all i ∈ [k]. Then, for the same queries, T (c) (c) (c) will obtain O (x1) = f(x1),..., O (xk) = f(xk). Therefore, T finds a witness of f∈ / P. Note that T (c) might output a different set of points violating P as compared to T (e), since T (c) will obtain additional values O(c)(x) ∈ R, for the queries x such that T (e) obtained O(e)(x) =⊥. Therefore, if we run T with access (c) to f via O , it outputs a witness of f∈ / P with probability at least 2/3. 

Acknowledgements We are thankful to for suggesting investigating settings with online adversarial erasures. We thank Noga Ron-Zewi for pointing out relevant references.

References

[ACCL07] Nir Ailon, Bernard Chazelle, Seshadhri Comandur, and Ding Liu. Estimating the distance to a monotone function. Random Structures Algorithms, 31(3):371–383, 2007.

[AJMR16] Pranjal Awasthi, Madhav Jha, Marco Molinaro, and Sofya Raskhodnikova. Testing Lipschitz functions on hypergrid domains. Algorithmica, 74(3):1055–1081, 2016. [AKK+05] , Tali Kaufman, Michael Krivelevich, Simon Litsyn, and Dana Ron. Testing Reed- Muller codes. IEEE Trans. Inf. Theory, 51(11):4032–4039, 2005.

[AS03] and . Improved low-degree testing and its applications. Comb., 23(3):365–426, 2003. [BCH+96] Mihir Bellare, Don Coppersmith, Johan H˚astad,Marcos A. Kiwi, and Madhu Sudan. Linearity testing in characteristic two. IEEE Trans. Information Theory, 42(6):1781–1795, 1996. [Bel18] Aleksandrs Belovs. Adaptive lower bound for testing monotonicity on the line. In Proceedings of Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM), pages 31:1–31:10, 2018. [BFL91] L´aszl´oBabai, , and Carsten Lund. Non-deterministic exponential time has two- prover interactive protocols. Comput. Complex., 1:3–40, 1991.

[BFLR20] Omri Ben-Eliezer, Eldar Fischer, Amit Levi, and Ron D. Rothblum. Hard properties with (very) short PCPPs and their applications. In Proceedings, Innovations in Theoretical Computer Science (ITCS), pages 9:1–9:27, 2020. [BFLS91] L´aszl´oBabai, Lance Fortnow, Leonid A. Levin, and . Checking computations in polylogarithmic time. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 21–31, 1991.

22 [BGJ+12] Arnab Bhattacharyya, Elena Grigorescu, Kyomin Jung, Sofya Raskhodnikova, and David P. Woodruff. Transitive-closure spanners. SIAM J. Comput., 41(6):1380–1425, 2012. [BGLR93] Mihir Bellare, Shafi Goldwasser, Carsten Lund, and A. Russeli. Efficient probabilistically check- able proofs and applications to approximations. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 294–304, 1993. [BGS98] Mihir Bellare, Oded Goldreich, and Madhu Sudan. Free bits, PCPs, and nonapproximability- towards tight results. SIAM J. Comput., 27(3):804–915, 1998. [BKS+10] Arnab Bhattacharyya, Swastik Kopparty, Grant Schoenebeck, Madhu Sudan, and David Zuck- erman. Optimal testing of Reed-Muller codes. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 488–497, 2010. [BLR93] Manuel Blum, Michael Luby, and Ronitt Rubinfeld. Self-testing/correcting with applications to numerical problems. J. Comput. Syst. Sci., 47(3):549–595, 1993.

[BRY14a] Piotr Berman, Sofya Raskhodnikova, and Grigory Yaroslavtsev. Lp-testing. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 164–173, 2014. [BRY14b] Eric Blais, Sofya Raskhodnikova, and Grigory Yaroslavtsev. Lower bounds for testing proper- ties of functions over hypergrid domains. In Proceedings, IEEE Conference on Computational Complexity (CCC), pages 309–320, 2014. [BS94] Mihir Bellare and Madhu Sudan. Improved non-approximability results. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 184–193, 1994. [BSVW03] Eli Ben-Sasson, Madhu Sudan, Salil P. Vadhan, and . Randomness-efficient low degree tests and short PCPs via epsilon-biased sets. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 612–621, 2003. [CDJS17] Deeparnab Chakrabarty, Kashyap Dixit, Madhav Jha, and C. Seshadhri. Property testing on product distributions: Optimal testers for bounded derivative properties. ACM Trans. on Algo- rithms (TALG), 13(2):20:1–20:30, 2017. [CS13] Deeparnab Chakrabarty and C. Seshadhri. Optimal bounds for monotonicity and Lipschitz test- ing over hypercubes and hypergrids. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 419–428, 2013. [CS14] Deeparnab Chakrabarty and C. Seshadhri. An optimal lower bound for monotonicity testing over hypergrids. Theory of Computing, 10:453–464, 2014. [DG13] and Venkatesan Guruswami. PCPs via low-degree long code and hardness for con- strained hypergraph coloring. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 340–349, 2013. [DGL+99] Yevgeniy Dodis, Oded Goldreich, Eric Lehman, Sofya Raskhodnikova, Dana Ron, and Alex Samorodnitsky. Improved testing algorithms for monotonicity. In Proceedings of Approx- imation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (AP- PROX/RANDOM), pages 97–108, 1999. [DJRT13] Kashyap Dixit, Madhav Jha, Sofya Raskhodnikova, and Abhradeep Thakurta. Testing the Lip- schitz property over product distributions with applications to data privacy. In Theory of Cryp- tography Conference (TCC), pages 418–436, 2013. [DRTV18] Kashyap Dixit, Sofya Raskhodnikova, Abhradeep Thakurta, and Nithin Varma. Erasure-resilient property testing. SIAM J. Comput., 47(2):295–329, 2018.

23 [EKK+00] Funda Ergun, Sampath Kannan, Ravi Kumar, Ronitt Rubinfeld, and Mahesh Viswanathan. Spot-checkers. J. Comput. System Sci., 60(3):717–751, 2000. [FGL+96] , Shafi Goldwasser, L´aszl´oLov´asz,, and Mario Szegedy. Interactive proofs and the hardness of approximating cliques. Journal of the ACM, 43(2):268–292, 1996. [Fis04] Eldar Fischer. On the strength of comparisons in property testing. Information and Computation, 189(1):107–116, 2004. [FLN+02] Eldar Fischer, Eric Lehman, Ilan Newman, Sofya Raskhodnikova, Ronitt Rubinfeld, and Alex Samorodnitsky. Monotonicity testing over general POset domains. In Proceedings, ACM Sym- posium on Theory of Computing (STOC), pages 474–483, 2002. [FS95] Katalin Friedl and Madhu Sudan. Some improvements to total degree tests. In Third Israel Symposium on Theory of Computing and Systems (ISTCS), pages 190–198, 1995. [GGL+00] Oded Goldreich, Shafi Goldwasser, Eric Lehman, Dana Ron, and Alex Samorodnitsky. Testing monotonicity. Combinatorica, 20(3):301–337, 2000. [GGR98] Oded Goldreich, Shafi Goldwasser, and Dana Ron. Property testing and its connection to learning and approximation. Journal of the ACM, 45(4):653–750, 1998. [GLR+91] Peter Gemmell, Richard J. Lipton, Ronitt Rubinfeld, Madhu Sudan, and Avi Wigderson. Self- testing/correcting for polynomials and for approximate functions. In Proceedings, ACM Sympo- sium on Theory of Computing (STOC), pages 32–42, 1991. [GR05] Venkatesan Guruswami and Atri Rudra. Tolerant locally testable codes. In Proceedings of Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM), pages 306–317, 2005. [HSS13] Elad Haramaty, Amir Shpilka, and Madhu Sudan. Optimal testing of multivariate polynomials over small prime fields. SIAM J. Comput., 42(2):536–562, 2013. [HW03] Johan H˚astadand Avi Wigderson. Simple analysis of graph tests for linearity and PCP. Random Struct. Algorithms, 22(2):139–160, 2003. [JPRZ09] Charanjit S. Jutla, Anindya C. Patthak, Atri Rudra, and David Zuckerman. Testing low-degree polynomials over prime fields. Random Struct. Algorithms, 35(2):163–193, 2009. [JR13] Madhav Jha and Sofya Raskhodnikova. Testing and reconstruction of Lipschitz functions with applications to data privacy. SIAM J. Comput., 42(2):700–731, 2013. [KLX10] Tali Kaufman, Simon Litsyn, and Ning Xie. Breaking the epsilon-soundness bound of the linearity test over GF(2). SIAM J. Comput., 39(5):1988–2003, 2010. [KR06] Tali Kaufman and Dana Ron. Testing polynomials over general fields. SIAM J. Comput., 36(3):779–802, 2006. [KS09] Swastik Kopparty and Shubhangi Saraf. Tolerant linearity testing and locally testable codes. In Proceedings of Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM), pages 601–614, 2009. [LPRV21] Amit Levi, Ramesh Krishnan S. Pallavoor, Sofya Raskhodnikova, and Nithin Varma. Erasure- resilient sublinear-time graph algorithms. In Proceedings, Innovations in Theoretical Computer Science (ITCS), pages 80:1–80:20, 2021. [Mos17] Dana Moshkovitz. Low-degree test with polynomially small error. Comput. Complex., 26(3):531– 582, 2017.

24 [MR08] Dana Moshkovitz and Ran Raz. Sub-constant error low degree test of almost-linear size. SIAM J. Comput., 38(1):140–180, 2008. [NV21] Ilan Newman and Nithin Varma. New algorithms and lower bounds for LIS estimation. Accepted to ICALP 2021, 2021.

[Pal20] Ramesh Krishnan Pallavoor Suresh. Improved Algorithms and New Models in Property Testing. PhD thesis, Boston University, 2020. [PRR06] Michal Parnas, Dana Ron, and Ronitt Rubinfeld. Tolerant property testing and distance approx- imation. Journal of Computer and System Sciences, 6(72):1012–1042, 2006. [PRV18] Ramesh Krishnan S. Pallavoor, Sofya Raskhodnikova, and Nithin Varma. Parameterized property testing of functions. ACM Trans. Comput. Theory, 9(4):17:1–17:19, 2018. [PRW20] Ramesh Krishnan S. Pallavoor, Sofya Raskhodnikova, and Erik Waingarten. Approximating the distance to monotonicity of Boolean functions. Random Structures and Algorithms (to appear), 2020. Preliminary version appeared in SODA 2020.

[Ras16] Sofya Raskhodnikova. Testing if an array is sorted. Encyclopedia of Algorithms, pages 2219–2222, 2016. [RR16] Sofya Raskhodnikova and Ronitt Rubinfeld. Linearity testing/testing hadamard codes. In En- cyclopedia of Algorithms, pages 1107–1110. 2016. [RRV19] Sofya Raskhodnikova, Noga Ron-Zewi, and Nithin Varma. Erasures vs. errors in local decoding and property testing. In Proceedings, Innovations in Theoretical Computer Science (ITCS), pages 63:1–63:21, 2019. [RS96] Ronitt Rubinfeld and Madhu Sudan. Robust characterizations of polynomials with applications to program testing. SIAM J. Comput., 25(2):252–271, 1996.

[RS97] Ran Raz and Shmuel Safra. A sub-constant error-probability low-degree test, and a sub-constant error-probability PCP characterization of NP. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 475–484, 1997. [RS06] Sofya Raskhodnikova and Adam D. Smith. A note on adaptivity in testing properties of bounded degree graphs. Electron. Colloquium Comput. Complex., 13(089), 2006.

[RS13] Noga Ron-Zewi and Madhu Sudan. A new upper bound on the query complexity of testing generalized Reed-Muller codes. Theory Comput., 9:783–807, 2013. [RV18] Sofya Raskhodnikova and Nithin Varma. Brief announcement: Erasure-resilience versus tolerance to errors. In Proceedings, International Colloquium on Automata, Languages and Programming (ICALP), pages 111:1–111:3, 2018.

[Sam07] Alex Samorodnitsky. Low-degree tests at large distances. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 506–515, 2007. [SS17] Michael E. Saks and C. Seshadhri. Estimating the longest increasing sequence in polylogarithmic time. SIAM J. Comput., 46(2):774–823, 2017.

[ST98] Madhu Sudan and Luca Trevisan. Probabilistically checkable proofs with low amortized query complexity. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 18–27, 1998.

25 [ST00] Alex Samorodnitsky and Luca Trevisan. A PCP characterization of NP with optimal amortized query complexity. In Proceedings, ACM Symposium on Theory of Computing (STOC), pages 191–199, 2000. [ST09] Alex Samorodnitsky and Luca Trevisan. Gowers uniformity, influence of variables, and PCPs. SIAM J. Comput., 39(1):323–360, 2009.

[SW06] Amir Shpilka and Avi Wigderson. Derandomizing homomorphism testing in general groups. SIAM J. Comput., 36(4):1215–1230, 2006. [Tre98] Luca Trevisan. Recycling queries in PCPs and in linearity tests (extended abstract). In Proceed- ings, ACM Symposium on Theory of Computing (STOC), pages 299–308, 1998.

[Yao77] Andrew Chi-Chih Yao. Probabilistic computations: Toward a unified measure of complexity (extended abstract). In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 222–227, 1977.

A Yao’s Minimax Principle for Online Erasure Oracles

We extend Yao’s minimax principle [Yao77] to the setting of online erasure oracles, so that it can be used to prove lower bounds on the query complexity of randomized online-erasure-resilient testers. In the standard property testing model, Yao’s principle allows one to prove a lower bound on query complexity by describing a distribution on inputs that is hard to test, in the sense that a deterministic algorithm needs many queries to decide if an input sampled from the distribution has the property or is far from it with high probability. In the setting of online erasures, we show that one can prove a lower bound by describing both a distribution on inputs as well as an oracle erasure strategy so that every deterministic algorithm that accesses the input selected from the distribution via the erasure oracle will need many queries to test a specified property with high probability. Theorem A.1. To prove a lower bound q(n) on the worst-case query complexity of online-erasure-resilient 1 randomized algorithms that perform a specified computational task with error probability strictly less than 3 , it is enough to give a distribution D on inputs of size n and a (randomized) oracle erasure strategy S, such that every deterministic algorithm making at most q(n) queries to an input drawn from D via an online-erasure 1 oracle that uses strategy S, errs with probability at least 3 . We also state a corollary to Theorem A.1 which refers to the more common usage of Yao’s minimax principle for proving lower bounds ,where separate distributions on positive and negative instances are defined. The corollary follows Claim 5 of [RS06] and can be obtained from Theorem A.1 using a similar proof as in [RS06].

Definition A.2. The statistical distance between two discrete distributions D1 and D2 is   CD(D1, D2) = max Pr [x ∈ S] − Pr [x ∈ S] . S⊆support(D1)∪support(D2) x∼D1 x∼D2

Corollary A.3. To prove a lower bound q(n) on the worst-case query complexity of online-erasure-resilient 1 randomized algorithms for a promise decision problem with error probability strictly less than 3 , it is enough to give:

• a distribution D+ on positive instances and a (randomized) oracle erasure strategy S+; • a distribution D− on instances that are negative with high probability and a (randomized) oracle erasure strategy S−;

26 such that it is hard for a q(n)-query deterministic algorithm that accesses the input through an oracle per- + − + − forming erasure strategy S or S to distinguish between D and D . Let a1, . . . , aq(n)(x) be the answers + to the queries of the deterministic algorithm on input x. Let D -view be the distribution on a1, . . . , aq(n)(x) when the input is selected from distribution D+ and accessed via a t-erasure oracle using strategy S+. Define − + − + − 1 D -view similarly. By “hard to distinguish D -view from D -view” we mean CD(D -view, D -view) < 3 . We start with the proof of Theorem A.1. Proof of Theorem A.1. We prove a min-max inequality similar to Yao’s original min-max inequality [Yao77]. The inequality relates the error complexities of the algorithms, rather than their query complexity, which we will fix beforehand. Let q(n) be the query complexity of an algorithm. Consider a randomized algorithm for the specified task, which, on an input of size n, makes at most q(n) queries, and may be incorrect. We can represent the randomized algorithm as a probability distribution τ on the set of all (possibly incorrect) deterministic decision algorithms A with query complexity at most q(n). Let Aq denote the set of such algorithms, and let τ(A) denote the probability of drawing algorithm A from the set Aq. Denote by Xn the set of inputs of size n for the decision problem. Let Sq,n denote the set of deterministic erasure strategies of the oracle for inputs of size n against testers of query complexity at most q(n). An oracle strategy can be represented by a decision tree that, based on the input and the queries of the algorithm, indicates which input entries to erase next. Since we are only considering inputs of fixed size and testers of finite query complexity, the set of oracle strategies is finite. Oracle strategies can be randomized, so we consider a distribution on deterministic strategies. For ease of notation, we consider a joint distribution on inputs and oracle strategies, i.e., we let σ be a distribution on the input-strategy pairs Xn × Sq,n. Given an input x ∈ Xn, an oracle strategy s ∈ Sq,n, and a decision algorithm A, let I(A, x, s) denote the indicator function for A being incorrect on x, i.e., I(A, x, s) = 1 if A is incorrect on x against an oracle that uses strategy s, and I(A, x, s) = 0 otherwise. We show the following min-max inequality X X min max I(A, x, s)τ(A) ≥ max min I(A, x, s)σ(x, s). (8) τ (x,s)∈Xn×Sq,n σ A∈Aq A∈Aq (x,s)∈Xn×Sq,n We comment on how (8) implies Theorem A.1. Suppose there exists some distribution σ on input-strategy pairs, such that the expected error probability of every q(n)-query deterministic algorithm for an input and 1 1 strategy drawn from this distribution is at least 3 . This implies that the right-hand side of (8) is at least 3 . (Note that we can express σ as a distribution D on the inputs and a randomized oracle strategy S). By (8), 1 every q(n)-query randomized algorithm has expected error at least 3 for every input and oracle strategy. 1 Therefore, an algorithm that has error probability strictly less than 3 has to make at least q(n) queries, which implies Theorem A.1. We now show (8). Fix distributions τ and σ on algorithms and input-strategy pairs. Then

X  X  X max I(A, x, s)τ(A) = σ(x, s) max I(A, x, s)τ(A) (x,s)∈Xn×Sq,n (x,s)∈Xn×Sq,n A∈Aq (x,s)∈Xn×Sq,n A∈Aq X X ≥ σ(x, s) I(A, x, s)τ(A)

(x,s)∈Xn×Sq,n A∈Aq X X = τ(A) I(A, x, s)σ(x, s) (9)

A∈Aq (x,s)∈Xn×Sq,n X X ≥ τ(A) min I(A, x, s)σ(x, s) A∈Aq A∈Aq (x,s)∈Xn×Sq,n X = min I(A, x, s)σ(x, s). A∈Aq (x,s)∈Xn×Sq,n

Crucially, the fact that Aq,Xn, and Sq,n are finite allows us to exchange the order of the sums in (9). 

27