Manuscript Offprint
arXiv:2611.01346Metric Testing: A Characterization of One-Sided Testability
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We give a unified framework for one-sided testability (constant-query testing) of metric families. For a broad class of families defined by fixed local predicates, we prove that testability is equivalent to two structural properties: packing amplification, which turns many edge-disjoint local violations into a positive density of violations, and completion stability, which allows locally consistent partial matrices with few missing entries to be cheaply completed. This characterization yields a common proof strategy and simpler proofs of classical testability results for ultrametrics, tree pseudometrics, Euclidean pseudometrics in fixed dimension, and several others.
Our framework also gives new quantitative bounds for metric testing: a nonadaptive one-sided upper bound for matrices with entries in the bounded range , and two-sided nonadaptive and adaptive lower bounds for general metrics.
*University of Minnesota Twin Cities, MN, USA. Email: ztan@umn.edu †University of Minnesota Twin Cities, MN, USA. Email: teske096@umn.edu
Contents
1 Introduction 2 1.1 Our results 3 1.2 Related work, and comparison with our results 4 1.3 Organization of the paper 5
2 Preliminaries 5
3 Characterization of one-sided testing: Proof of Theorem 1.1 9 3.1 Canonical testers and removability 9 3.2 Structural decomposition of removability 10
4 Packing amplification 12 4.1 Ultrametrics and tree pseudometrics 12 4.2 Euclidean pseudometrics and edgewise restrictions 14 4.3 Robust metric faces and the packing obstruction for general metrics 16
5 Completion stability 17 5.1 Ultrametrics and tree pseudometrics via recursive separation 18 5.2 Euclidean pseudometrics via affine anchor rigidity 20 5.3 Metrics with bounded aspect ratio via cyclic entropy 21 5.4 Twin rigidity, completion obstructions, and logical independence 24
6 Quantitative testing bounds 26 6.1 Quantitative testing of removable geometric families 26 6.2 Signed noise on robust metric faces 27 6.3 Density-sensitive sampling and asymmetric faces 28 6.4 The full nonadaptive complexity on a bounded range 29 6.5 Contextual blow-up and adaptive metric testing lower bounds 30
A one-sided -tester is a randomized algorithm that accepts every member in with probability 1 and rejects every -far input with probability at least 2/3. We call the family one-sided testable if, for every , there is such a tester whose query complexity is bounded by independently of .
Parnas and Ron [PR03] initiated the study of metric property testing and proved one-sided testability for several families, including ultrametrics and non-injective tree and Euclidean metrics. Krauthgamer and Sasson [KS03] improved the testing bounds for finite dimensional Euclidean realizability. More recently, Bao, Kannan, and Waingarten [BKW25] obtained improved bounds for ultrametric testing, studied tree metric testing, and gave a sublinear-query tester for general metrics. They also proved lower bounds for general metric testing, ruling out nonadaptive one-sided testers whose query complexity is polynomial in and independent of . Together, these results raise a structural question:
What structural properties make a metric family one-sided testable?
In fact, one-sided testability already forces locality: -far inputs must reveal small certificates of non-membership under random sampling. Indeed, for families invariant under relabelling, an adaptation of the canonicalization argument of Goldreich and Trevisan [GT03] simulates a -query tester using the induced matrix on a uniformly sampled set of at most points. Perfect completeness forces the simulation to accept every sampled configuration that occurs in a valid input. Thus, on an -far input, the sample must contain, with probability at least 2/3, a configuration incompatible with every valid completion on points. Small, detectable obstructions are therefore a necessary consequence of one-sided testability. This perspective also underlies Alon and Shapira's characterization of oblivious one-sided graph testing through semi-hereditary properties [AS08].
It is therefore natural to focus on metric families characterizable by a local predicate: a matrix belongs to the family exactly when every -point restriction satisfies the predicate, where depends only on the family. This structure is shared by many families: general metrics and ultrametrics are determined by 3-point conditions, tree realizability by conditions on at most 4 points, and Euclidean realizability in fixed dimension by conditions on a bounded number of points. For these families, the challenge is to understand when being far from membership makes local violations detectable by sampling.
Our main contribution is a unified structural characterization of one-sided testability. Our approach connects two tasks, repairing an input and detecting its violations, through two complementary properties:
-
Packing amplification: many independent violations force abundant violations.
-
Completion stability: few holes in locally consistent data require few edits.
To see how these properties work together, delete the pairs covered by a maximal collection of edge-disjoint local violations. Maximality ensures that the remaining partial matrix is locally consistent. If the collection is small, only a few holes are created, and completion stability yields a valid matrix close to the original input. Thus, an input far from the family must contain many edge-disjoint violations, which packing amplification turns into sufficiently many violations for random sampling to detect. We show that these two properties together characterize one-sided testability. Separating these tasks gives a common proof strategy across metric families, yields simplified proofs of several classical testability results, and identifies distinct mechanisms behind the failure of testability.
1.1 Our results
Fix a local predicate on points characterizing a metric family . A -point restriction that fails is called a local violation. We introduce two properties, with all bounds uniform in .
Packing amplification. For every , there exists such that any -point matrix containing at least edge-disjoint local violations contains at least local violations in total. Here, edge-disjointness means that no two violations share an unordered pair of indices.
Completion stability. A partial matrix contains unspecified pairs, called holes, and is locally consistent if every fully specified -point restriction satisfies . For every , there exists such that any locally consistent partial matrix containing at most holes can be completed to a member of after changing at most specified pairs (filling the holes incurs no cost).
Theorem 1.1 (Informal). For metric families characterized by a local predicate, one-sided testability is equivalent to packing amplification together with completion stability.
Formal definitions and the precise theorem statement are given in Section 3.
| Family | Packing amplification | Completion stability | Previous work |
|---|---|---|---|
| Ultrametrics | Yes (Lemma 4.1) | Yes (Lemma 5.2) | [PR03] |
| Strict ultrametrics | Yes (Corollary 4.9) | Yes (Corollary 5.3) | [BKW25] |
| Tree pseudometrics | Yes (Lemma 4.4) | Yes (Lemma 5.5) | [PR03] |
| Euclidean pseudometrics in | Yes (Lemma 4.6) | Yes (Lemma 5.7) | [PR03; KS03] |
| Strict tree metrics | Yes (Corollary 4.9) | No (Theorem 5.20) | [PR03] |
| Strict Euclidean metrics in | Yes (Corollary 4.9) | No (Theorem 5.20) | [PR03] |
| Bounded aspect ratio metrics | No (Theorem 4.11) | Yes (Theorem 5.13) | — |
| General metrics | No (Theorem 4.11) | — | [BKW25] |
Table 1: Packing amplification and completion stability for the metric families studied in this paper. The dimension is a fixed constant. Strictness requires positive distances between distinct labels. For metrics with bounded aspect ratio, off-diagonal entries lie in for a fixed .
Unified and simplified analysis for one-sided testability. We then apply this characterization to several metric families (see Table 1). Our framework recovers the qualitative one-sided testability results of [PR03; KS03; BKW25] for ultrametrics, strict ultrametrics, tree pseudometrics, and Euclidean pseudometrics in fixed dimension, with unified and simpler proofs via the packing amplification and the completion stability properties. For ultrametrics, these properties follow from elementary counting and partitioning arguments. For tree pseudometrics, both properties reduce to their ultrametric counterparts. For Euclidean pseudometrics of fixed dimension, both arguments use the rigidity of distances to a small affine anchor set. Therefore, the same testing argument applies across families, and parts of the proofs can be reused. The same framework identifies distinct reasons for non-testability. General metrics and metrics with bounded aspect ratio (entries in [1, C] for fixed C > 2) fail packing amplification. Strict tree and Euclidean metrics retain packing amplification but fail completion stability. Also, as metrics with bounded aspect ratio satisfy completion stability, these examples establish the independence of the two properties.
Quantitative testing bounds. Beyond giving a qualitative classification, our structural framework also gives new quantitative upper and lower bounds. Because our characterization reduces one-sided testability to two combinatorial properties, bounding completion stability and packing amplification yields explicit query upper bounds. For ultrametrics, strict ultrametrics, and tree pseudometrics, combining linear completion stability with quadratic packing amplification yields one-sided -query testers (Corollary 6.1), removing the logarithmic factors from the bounds of [BKW25]. We also provide novel bounds for general -point metrics and metrics with entries in [1, C]. To state the full tradeoff across all proximity regimes, define the rate function
Theorem 1.2. Fix and . For all sufficiently large and :
(1) Sharp nonadaptive complexity on (Theorem 6.8): For inputs with entries in , both one-sided and two-sided nonadaptive -testing of general metrics have query complexity .
(2) Adaptive lower bound on (Theorem 6.11): Any adaptive two-sided -tester for general metrics on requires queries.
(3) Transfer to general and -hyperbolic metrics: On arbitrary nonnegative inputs, nonadaptive and adaptive two-sided -testing require and queries, respectively, both for general metrics and pseudometrics (Theorem 6.12) and for -hyperbolic metrics with any fixed (Remark 4.12).
Previously, Bao, Kannan, and Waingarten [BKW25] gave a nonadaptive one-sided query lower bound of using Behrend graphs that applied only at vanishing proximity . Because our packing obstruction avoids progression-free sets, Theorem 1.2 eliminates the loss and establishes hardness at fixed constant even against two-sided and adaptive testers.
1.2 Related work, and comparison with our results
Parnas and Ron [PR03] first introduced metric property testing, giving one-sided testers with queries for tree pseudometrics and ultrametrics, and queries for Euclidean pseudometrics in . Krauthgamer and Sasson [KS03] improved the latter bound to using sampled points. For strict tree metrics and injective Euclidean realizations, Parnas and Ron proved query lower bounds even with two-sided error. Our proofs unify these qualitative results; our Euclidean bound has weaker -dependence than [KS03].
Bao, Kannan, and Waingarten [BKW25] established a nonadaptive one-sided -query tester for general metrics and improved the ultrametric testing bound to . They also studied tree metric testing. Their Behrend graph lower bound for general metrics applies at vanishing with . Our obstruction holds at fixed , even for entries in with any fixed . Onak [Ona08] studied tree metrics, ultrametrics, and line embeddings in a model measuring distance by point modifications.
For graphs, Goldreich and Trevisan [GT03] canonicalized constant-query testers using uniformly sampled induced subgraphs. Alon and Shapira [AS08] established one-sided testability of every hereditary graph property and characterized oblivious one-sided testability. Austin and Tao [AT10] developed testing and repair results for hereditary graph and hypergraph properties; Alon, Ben-Eliezer, and Fischer [ABF17] established testability for hereditary ordered graphs and finite-alphabet matrices. We decompose removability for real-valued matrices into two structural conditions; completion stability concerns existence of close completions and differs from the local repairability in [AT10].
Metric repair and the metric violation distance problem also aim at minimizing the number of changed entries [GJ17; FRV22] of an input matrix. Fan, Gilbert, Raichel, Sonthalia, and Van Buskirk [FGR+20] studied incomplete graphs using nonmetric cycles. Cohen-Addad, Fan, Lee, and de Mesmay [CFLM22] obtained an -approximation for metric violation distance and a constant-factor approximation for ultrametric violation distance. Bandyapadhyay, Lochet, Lokshtanov, Saurabh, Sonar, Surianarayanan, and Xue [BLL+26] gave a single-exponential fixed-parameter algorithm and a linear kernel for metric repair, and proved fixed-parameter tractability of tree metric repair. Our bounded range completion theorem controls the edits needed to fill sparse holes, including those forced by longer nonmetric cycles. Metric nearness instead minimizes a norm of the numerical perturbation [BDST08].
1.3 Organization of the paper
Section 2 introduces the testing model, local predicates, and the metric families considered in the paper. Section 3 proves the structural characterization of one-sided testability through removal, packing amplification, and completion stability. Section 4 establishes packing amplification for the geometric families and constructs a packing obstruction for general metrics. Section 5 proves the corresponding completion results and identifies the obstruction caused by injective realizations. Finally, Section 6 derives quantitative testing bounds, including sharp nonadaptive bounds for metrics with bounded aspect ratio and an adaptive lower bound.
2 Preliminaries
Fix an integer and a nonempty value set . For , let be the set of symmetric matrices with off-diagonal entries in and diagonal entries fixed to 0.
For , define the normalized Hamming distance between as
For a nonempty set , define .
For probability distributions , denote by the total variation distance between , where the supremum is over measurable events.
Local Predicates and Testability
Let be a permutation-invariant -point predicate. For , membership of in is interpreted after pulling back along any bijection .
Define
For , . Unless stated otherwise, we assume for every .
For with , define
Definition 2.1 (One-sided tester). A one-sided q-query -tester for is an information-theoretic randomized adaptive decision tree which queries at most q off-diagonal entries and satisfies:
(1) every is accepted with probability 1;
(2) every with is rejected with probability at least 2/3.
If the query bound in the above definition depends only on and but not , then we say that is one-sided testable.
Definition 2.2 (Two-sided tester). A two-sided q-query -tester for is an information-theoretic randomized adaptive decision tree which queries at most q off-diagonal entries and satisfies:
(1) every is accepted with probability at least 2/3;
(2) every with is rejected with probability at least 2/3.
Metric families and their extendability
Definition 2.3 (Extendability). A family is extendable if, for every and every , there exist and an injection such that for every .
We now define the principal metric and geometric families and verify their extendability. To distinguish arbitrary pseudometric realizations from injective realizations, we use a superscript + for predicates and families restricted to positive off-diagonal entries .
The tree and Euclidean symbols below denote local families with the preceding vacuous convention at orders below the predicate arity. Identifications with global geometric realization families are asserted at and above that arity. If global realizability is required at the finitely many smaller orders, those inputs can instead be inspected completely; none of the asymptotic conclusions is affected.
General and bounded aspect ratio metrics
Write for the positive-valued metrics on and for the nonnegative-valued pseudometrics on . For , define .
On the ambient value set with , the family is defined by
Metrics with bounded aspect ratio are extendable by assigning distance to every pair involving a new vertex. General metrics and pseudometrics are extendable by assigning the common value to every pair involving a new vertex.
Ultrametrics
Let k = 3 and define
Denote by the family. For , denote and for the strict ultrametrics.
Lemma 2.4. The family is extendable over any nonempty value set , and is extendable.
Proof. Let and . Set . For all distinct pairs of indices , define , otherwise define . Every triangle containing a new vertex has at least two edges of value , and its remaining edge has value at most . Thus . If is strict, then and is strict as well.
Tree pseudometrics and strict tree metrics
Set and . Define to consist of those symmetric, zero-diagonal matrices on [4] for which there exist a weighted tree , positive edge weights , and a not necessarily injective map satisfying for all .
Equivalently, by Buneman's characterization [Bun74], satisfies the four-point condition
with repeated indices allowed, thereby including triangle inequalities.
Let be the resulting local family. Define , and let be its local family. The strict predicate characterizes injective realizations in positively weighted trees, allowing labeled internal vertices and additional unlabeled vertices. By the classical local-to-global theorem [Bun74], for , and coincide with the matrices globally realized in weighted trees by arbitrary and injective maps, respectively. Edges of length zero in a representation with nonnegative edge weights may be contracted; positivity of all off-diagonal distances prevents distinct labels from being identified in the strict case.
Lemma 2.5. The families and are extendable.
Proof. Let and . Realize by a weighted tree. Attach each new label to the point representing label 1 by a new edge of length 1. Equivalently, define
and impose symmetry. This is a tree pseudometric preserving all old entries. If the old realization is injective, the new realization is injective as well.
d-dimensional Euclidean metrics
Fix an integer . Denote and . Define as the set of symmetric, zero-diagonal matrices on for which there exists a (not necessarily injective) mapping satisfying for all . Let be the resulting local family. Define , and let be its local family.
The affine dimension of a Euclidean distance matrix is well-defined. Indeed, after choosing a label , the Gram matrix where for all is determined by the distances, and its rank is the affine dimension of every realization. By the classical theorem of Schoenberg [Sch35] and Young and Householder [YH38], positive semidefiniteness and rank at most of characterize realization in . This also gives a rational decision procedure and Borel defining conditions.
Recall that vectors are affinely independent if and imply .
Lemma 2.6. Let vectors be affinely independent. If points satisfy for all , then . The same assertion holds inside the affine span of any affinely independent set, including a singleton.
Proof. Subtracting the squared-distance equality for from that for gives
These difference vectors span , so . The affine-span version is the same argument after identifying the affine span with a Euclidean space; the singleton case is immediate.
We record the finite local characterization of Menger [Men31; Blu53].
Lemma 2.7 (Local characterization of Euclidean metrics). Let and . Suppose every -point principal submatrix of is realized in . Then is realized in . If all off-diagonal entries of are positive, the realizing points are pairwise distinct.
Proof. Every principal submatrix of order at most is realizable, by extending its label set to a -set. Choose a set of maximum cardinality such that has an affinely independent realization in . Write , fix a realization , and let be its affine span.
For , the matrix is realizable. Two realizations of the affine basis have the same Gram matrix and can be aligned by a Euclidean isometry. After aligning with , the realization of lies in : otherwise would be affinely independent, contrary to maximality. Its position in is unique by Lemma 2.6. Denote it by , and use the prescribed points of for labels in .
For distinct , the set has size at most and is realizable. Align its realization on . Maximality again places both remaining points in , and uniqueness identifies them with and . Hence . All other distances are preserved by construction. Positive off-diagonal distances imply injectivity.
Lemma 2.8. The families and are extendable.
Proof. Let and . By Lemma 2.7, realize by points . Choose additional points that are pairwise distinct and distinct from every old point. Their Euclidean distance matrix extends and belongs to . If was strict, all realizing points are distinct, so the extension is strict.
3 Characterization of one-sided testing: Proof of Theorem 1.1
We characterize constant-query one-sided testability for extendable local matrix properties. We begin by showing that one-sided testability is equivalent to removability via a canonicalization framework (Theorem 3.4). We then establish our main structural characterization (Theorem 3.10), proving that removability decomposes into two combinatorial conditions: packing amplification and completion stability. Together, these results yield our main equivalence (Corollary 3.11) and isolate the two structural obstructions to testability (Corollary 3.12).
3.1 Canonical testers and removability
To prove Theorem 3.4, we first reduce arbitrary adaptive one-sided testers to canonical testers that inspect a uniformly random induced submatrix. The lazy permutation coupling in Lemma 3.1 and the resulting canonical reduction in Lemma 3.2 and Theorem 3.4 adapt the canonicalization framework of Goldreich and Trevisan [GT03, Section 4, cf. Lemma 4.1 and Theorem 4.5] from graph properties to extendable local matrix properties. This connects one-sided testability to removal lemmas for hereditary properties in the spirit of Alon and Shapira [AS08].
Lemma 3.1. Let . Fix an adaptive decision tree whose queries are unordered pairs of labels from and which touches at most distinct labels. For a fixed input , compare:
(1) choose a uniform permutation of , and answer with ;
(2) choose a uniform -set , assign each newly touched label to a uniformly random unused element of , and answer using the resulting partial injection.
The answer transcripts have the same distribution. Moreover, the experiments can be coupled to have the same sequence of images of newly touched labels.
Proof. Expose newly touched labels in a fixed order when a query introduces two of them. Suppose the exposed images are distinct vertices , where .
In the permutation experiment, the next image is uniform on the unused vertices of . In the -set experiment, conditional on these assignments, is uniform among the -sets containing : for each such , the probability of choosing and making these assignments is . Thus the next image is again uniform on the unused vertices of .
For a fixed input and decision tree, previous answers and subsequent query choices are determined by the exposed images. Conditioning on the complete partial history therefore adds no restriction on the remaining assignments. Induction proves the claim.
Lemma 3.2. Assume is extendable. Let be a one-sided -query -tester, and put . For , symmetrize by a uniform permutation of . Let query a uniform -set completely and lazily simulate within . Then
Proof. The equality follows from Lemma 3.1, conditional on the internal randomness of .
Fix with . Extendability gives a valid containing an induced copy of on some -set . Conditional on sampling in or in , the lazy simulations have the same transcript law. Since has positive sampling probability, positive conditional rejection probability on would contradict one-sided completeness on . Thus the conditional rejection probability on is zero.
Definition 3.3 (Removal modulus). For , define
We say that is removable if for every .
Equivalently, for every , there exists such that
for all and .
Theorem 3.4 (Testing-removal equivalence). Assume is measurable, and fix . If , then has a one-sided -tester using at most queries.
Conversely, suppose is extendable and has a one-sided -query -tester. Put . Querying a uniform -submatrix and rejecting if is a one-sided -tester using at most queries; when , query the whole matrix instead. Moreover,
Consequently, under extendability, removability is equivalent to one-sided testability with query complexity independent of .
Proof. For the forward implication, independently sample uniform -sets and reject if one violates . An -far input is accepted with probability at most .
For the converse, Lemma 3.2 implies that an -far input of order has an invalid uniform -submatrix with probability at least . Hence
For , an -far input has at least one violation, so . Taking the infimum proves the bound. Measurability makes the local membership decisions admissible.
3.2 Structural decomposition of removability
We now introduce the two combinatorial properties that govern removability: packing amplification and completion stability.
Definition 3.5 (Packing amplification). A family is edge-disjoint if no edge belongs to more than one member. Let be its maximum possible size. For , define
We say that has packing amplification if for every .
Definition 3.6 (Completion stability). A partial matrix on assigns values in to some pairs. Its set of unspecified edges is denoted ; these edges are called holes. The partial matrix is locally consistent if every fully specified -subset satisfies . For such a partial matrix with , define
For , define , where the supremum is over locally consistent partial matrices on vertices with . The function is non-decreasing. We say that is completion stable if as .
Lemma 3.7. For every with , we have . Consequently, for all .
Proof. A valid repair changes at least one edge in each member of an edge-disjoint family of violations, and these edits are distinct. If , then , so . Take the infimum.
Lemma 3.8. Let be locally consistent on vertices, and let be any completion of . If , then .
Proof. Every violating -set contains a hole, so . Thus .
Proposition 3.9 (Deterministic repair inequality). For every with ,
Proof. Take a maximum edge-disjoint family of violations and delete all its edges. The resulting hole set has size at most . The remaining partial matrix is locally consistent, since a fully specified violation would be edge-disjoint from .
A valid matrix attaining differs from on specified edges by at most and on holes by at most . Adding the two bounds completes the proof.
Theorem 3.10 (Structural characterization of removability). The predicate is removable if and only if it is completion stable and has packing amplification.
Proof. Suppose is removable. Fill the holes of a locally consistent partial matrix arbitrarily. If its hole density is at most , Lemma 3.8 implies that the resulting full matrix has violation density at most . Whenever , it has a valid repair at distance at most . Restricting discrepancies to the originally specified edges gives , so . Packing amplification follows from Lemma 3.7.
Conversely, choose such that . If is -far, Proposition 3.9 implies . Therefore , and taking the infimum gives the same positive lower bound for . This remains valid if there are no -far inputs.
Corollary 3.11 (Testing-structure equivalence). If is extendable and is measurable, the following are equivalent:
(1) has a one-sided constant-query -tester for every ;
(2) is removable;
(3) is completion stable and has packing amplification.
Proof. Apply Theorems 3.4 and 3.10.
Corollary 3.12 (Two obstructions to removal). The predicate is not removable if and only if at least one of the following exists:
(1) Packing obstruction. There are and matrices on vertices such that and .
(2) Completion obstruction. There are and locally consistent partial matrices on vertices such that and .
Proof. If , choose inputs with violation density less than . Each has a violation, so , forcing .
If completion stability fails, choose and with , then choose partial matrices of hole density at most and completion distance greater than . A bounded subsequence of their orders would eventually have no holes, a contradiction.
Conversely, either sequence makes the corresponding structural condition fail. Apply Theorem 3.10.
4 Packing amplification
We determine which metric and geometric families satisfy packing amplification. We first establish positive packing bounds for ultrametrics (Lemma 4.1) and tree pseudometrics (Lemma 4.4), reducing the tree case to the ultrametric setting via rooted products. Next, we develop an affine anchor repair method for -dimensional Euclidean pseudometrics (Proposition 4.5), yielding both packing amplification (Lemma 4.6) and quantitative removal bounds (Corollary 4.7). After confirming that packing amplification passes to edgewise restrictions, and thus to strict metric families (Corollary 4.9), we construct a robust metric face (Lemma 4.10) to prove that general metrics and metrics with bounded aspect ratio in with fail packing amplification and admit no constant-query one-sided testers (Theorem 4.11).
4.1 Ultrametrics and tree pseudometrics
Lemma 4.1 (Packing amplification for ultrametrics). For every ,
Proof. Let , and let be an edge-disjoint family of violating triangles. We prove .
Consider distinct sharing a vertex . By edge-disjointness, they share only . Orient the pair so that the unique maximum in is at least the unique maximum in . Write , with unique maximum edge of value . There is with , since one edge of incident with is not its unique maximum.
We claim that contains a violating triangle containing an edge of and the vertex . If , either or violates; otherwise both and are less than , so violates. If , either or violates; otherwise the first gives , the second gives , and violates. The case is symmetric.
Let . Using and Cauchy–Schwarz, the number of unordered intersecting pairs is .
If , then . If , then . Choose one mixed violation for every intersecting pair. A fixed is selected at most 27 times: choose its edge belonging to in at most three ways (which determines ), choose in at most three ways, and choose in at most three ways (where the edge determines by edge-disjointness). Hence when . The claimed bound follows in all cases.
If , then .
To extend this argument to tree pseudometrics, we use the classical correspondence between tree metrics and ultrametrics via the rooted Gromov product (or Farris transform) [Far72; Gro87].
Lemma 4.2. Let and fix . For , put , and for distinct , put . Then if and only if for every such pair, and the minimum of is attained at least twice for every triple of distinct labels outside .
Proof. The triangle inequalities involving are equivalent to the bounds . The four-point condition on is equivalent to the minimum condition, since .
Conversely, the bounds give all triangle inequalities involving . For a triangle outside , we have .
Choose and set off the diagonal and . The minimum condition makes a nonnegative ultrametric, which satisfies the four-point condition. To see this directly on four labels, let be their maximum distance and partition them by the relation . For partition types , , or , two opposite-edge sums equal and the third is at most . For type , the three opposite-edge sums are plus the three distances of an ultrametric triple, whose maximum is attained at least twice. The all-zero case is immediate.
For a quartet outside , the opposite-edge sums of are obtained from those of by multiplication by 2 and addition of the common constant . Thus satisfies the four-point condition on these quartets as well. The triangle inequalities handle repeated indices, so Buneman's characterization applies.
Lemma 4.3. Let have size , let , and let be a symmetric assignment on distinct pairs of . Call a triple rooted-bad if some pair violates , or if its minimum -value is attained uniquely. If an edge-disjoint family contains at least rooted-bad triples, where , then the density of rooted-bad triples is at least .
Proof. Let the family have size . If at least members contain a bounds violation, choose one such edge from each. These edges are distinct, and counting their incidences with triples gives at least rooted-bad triples, of density at least .
Otherwise, at least members satisfy the bounds and have a unique minimum. Choose and put . These triples form an edge-disjoint family of ultrametric violations. Lemma 4.1, in its counting form, gives at least such violations, of density at least . Since a feasible edge-disjoint triple packing has , the first case also satisfies the stated bound.
Lemma 4.4 (Packing amplification for tree pseudometrics). For every ,
Proof. Let , and let be an edge-disjoint family of violating quartets. For a root , let . Since , at most seven roots have . For , at least roots are good, meaning .
Fix a good root and form its rooted data. By Lemma 4.2, every not containing contains a rooted-bad triple. Choose one such triple from each . These triples are edge-disjoint and number at least , so their packing density on vertices is at least . Lemma 4.3 gives a rooted-bad triple density of at least . Each rooted-bad triple, together with , forms a violating quartet. Summing over good roots and dividing by the maximum multiplicity four gives . For , any violation gives density at least . Taking the infimum completes the proof.
4.2 Euclidean pseudometrics and edgewise restrictions
To bound the distance to in terms of -point violations, we adapt the affine anchor repair method of Parnas and Ron [PR03, Section 6] (see also Krauthgamer and Sasson [KS03] and Onak [Ona08]). In their analysis [PR03, Fact 2 and Lemma 6.1], given an anchor set realized with affine dimension , vertices whose distances to admit a realization in the same -dimensional affine span (strongly consistent points) have uniquely determined coordinates. A global Euclidean pseudometric is then obtained by placing those vertices at their forced coordinates and collapsing the remaining exceptional vertices. Whereas [PR03; KS03] locate a suitable dimension via adaptive or iterative phases that increment the dimension, we select a dimension level nonadaptively via a pigeonhole threshold on the -set dimension densities.
Proposition 4.5 (Euclidean repair and hitting-set bound). Let and with respect to . Put . There exists differing from on at most edges. In particular,
Proof. Let be the family of valid -sets of affine dimension , and put , so that . By averaging, some satisfies . Choose and let , which has size . By the maximality of and the lower bound on ,
Choose an ordered -tuple of distinct vertices uniformly, write , and condition on . Every fixed -set of positions is unconditionally uniform among all -sets, so its conditional probability of belonging to is at most . A union bound and averaging give a fixed for which the number of bad pairs satisfying is at most . Call the remaining pairs in good.
Fix a realization of , let be its -dimensional affine span, and choose an affine basis from . If is good, every -subset of is realizable, so Lemma 2.7 gives a realization of . After aligning , both new points must lie in ; otherwise an affinely independent subset of dimension greater than , padded to a -set, would belong to . By Lemma 2.6, their positions in are uniquely determined by the affine basis.
Let be the set of vertices outside incident to at least one good pair. Each therefore has a well-defined coordinate agreeing with all its prescribed distances to , and every good pair satisfies . Let . Every pair incident to inside is bad, so . Since , this implies .
Assign the points of their fixed realization, assign to , and collapse every vertex of to a single fixed basis point. The resulting Euclidean pseudometric differs from only on bad pairs outside and on edges between and , so . The normalized repair bound follows. Since every original violation contains a changed edge, edge-disjoint violations require distinct changed edges, yielding the packing bound.
Lemma 4.6 (Packing amplification for Euclidean pseudometrics). Put and . For every ,
Proof. Suppose . If , there is nothing to prove. Otherwise, positivity of gives , and the definition of forces . Proposition 4.5 then gives . Taking the infimum completes the proof.
Corollary 4.7 (Quantitative Euclidean removal). For every , with and as in Lemma 4.6, we have .
Proof. An -far input has positive violation density. If , then as in Lemma 4.6, and Proposition 4.5 implies . Taking the infimum proves the claim.
Proposition 4.8. Let and , regarding both predicates on the ambient value set . Then for every ,
Thus packing amplification passes to edgewise restrictions. The assertion concerns violation sets and remains meaningful even when a restricted valid family is empty at some orders.
Proof. Fix an edge-disjoint family of -violations with . For any , either at least members violate , or at least members satisfy but contain a value outside .
In the first case, . In the second, edge-disjointness gives a set of at least distinct edges with values outside . Counting incidences gives , and hence . Taking the infimum over and the supremum over yields the first inequality; setting gives the second.
Corollary 4.9 (Packing amplification for strict geometric families). On or , the strict predicates , , and all satisfy packing amplification.
Proof. Apply Proposition 4.8 with to Lemmas 4.1, 4.4, and 4.6. Restricting the infimum to positive inputs can only increase the modulus.
4.3 Robust metric faces and the packing obstruction for general metrics
Unlike the geometric families above, general triangle inequalities admit dense edge-disjoint families of tight triangles with every other slack strictly positive. In contrast to tripartite graph constructions for triangle-freeness (such as the Behrend graph construction of [AKKR08, Section 5.1], which also underlies the metric testing lower bound in [BKW25, Section 4]) that restrict edge steps to a progression-free set and incur an density loss, a metric face on a complete graph only requires unselected triangles to have strictly positive slack. The quadratic potential in Lemma 4.10 below (and its midpoint variant in Lemma 6.9) exploits this real-valued margin to achieve full edge-disjoint packing density without progression-free sets; Section 6 later combines these same faces with signed noise.
Lemma 4.10 (Robust metric face). Fix . There are a rational with and an absolute constant such that, for all sufficiently large , there exist a rational metric and an edge-disjoint family of at least triangles satisfying:
(1) each member of has one designated tight triangle inequality, and these are the only tight triangle inequalities of ;
(2) every other triangle inequality has slack at least , and every entry has distance at least from the endpoints of ;
(3) every entry has an -bit rational representation.
Proof. Choose a positive rational , and set and . First consider vertices partitioned into , , and . Put , assign value within each part, and set
Since , the index ranges imply , , and .
For a triangle meeting all three parts, the slack on is
while the other two slacks are at least . If two vertices lie in one part, their edge has value 3/2 and the two cross-part entries differ by at most , giving slacks at least and . Triangles within a part are equilateral and hence strict.
Thus the tight triangles are precisely , with designated long edge . Any two vertices in different parts determine at most one third vertex in , so is edge-disjoint and has size .
For arbitrary sufficiently large , take and add the at most three remaining vertices at distance from every other vertex; any triangle meeting a new vertex and an old edge of value has positive slacks . The strict slacks are at least and the endpoint margins are at least , both exceeding for large . Finally, , and the entries have logarithmic bit complexity.
Theorem 4.11 (Packing obstruction for general metrics). For with , the metric predicate admits a packing obstruction: for ,
The same holds for positive-valued general metrics on and nonnegative-valued general pseudometrics on . Consequently, none of these families has a constant-query one-sided tester.
Proof. Take from Lemma 4.10, with , and add to the designated long edge of each member of . Each selected triangle now has designated slack . Every formerly strict slack changes by at most , and the endpoint margins keep all entries in . Thus the resulting matrix has , which gives and .
Every metric or pseudometric repair changes at least one edge in each member of , while resetting the long edges restores . Hence . The removal claims follow immediately, and Theorem 3.4 together with extendability rules out constant-query one-sided testers.
Remark 4.12 (Transfer to -hyperbolicity). Following Gromov [Gro87], a metric is -hyperbolic if for all labels; the corresponding four-point predicate includes the triangle inequalities. Fix and a positive rational , with and as in the proof of Theorem 4.11. Because every entry of and is at most , the four-point hyperbolicity inequalities hold automatically, so the violations of are precisely the quartets containing a triangle of . Since any edge belongs to at most one triangle in and meets at most others at a single endpoint, each edge belongs to at most violating quartets. Greedy selection then yields at least edge-disjoint violating quartets for while the violation density remains , giving a packing obstruction for -hyperbolic metrics.
Moreover, because scaling preserves exact Hamming discrepancies, every scaled bad input remains at least -far from -hyperbolic metrics (with as a valid target). Applying the same scaling to the signed noise distributions in Section 6 for any fixed transfers our quantitative nonadaptive and adaptive query lower bounds for general metrics to -hyperbolic metrics.
5 Completion stability
We establish completion stability for our principal pseudometric and metric families and identify the completion obstructions created by injective geometric realization. We first prove linear completion stability for ultrametrics (Lemma 5.2) and tree pseudometrics (Lemma 5.5) via a recursive graph separation scheme, and establish completion stability for -dimensional Euclidean pseudometrics (Lemma 5.7) via affine anchor rigidity. We next analyze metrics with bounded aspect ratio on : after showing that is the exact completion threshold (Proposition 5.9), we use a cyclic entropy inequality to prove linear completion stability for every fixed (Theorem 5.13), which in turn yields uniform polynomial-time completion repair (Corollary 5.15) and a triangle packing bound for metric repair (Proposition 5.17). Finally, we use a collinear twin construction (Lemma 5.19) to prove that strict tree metrics and strict Euclidean metrics admit completion obstructions and are not constant-query one-sided testable (Theorem 5.20). Combining our results from Sections 4 and 5 shows that packing amplification and completion stability are logically independent (Corollary 5.22).
5.1 Ultrametrics and tree pseudometrics via recursive separation
Our recursive separation scheme for completing locally consistent partial ultrametrics and tree pseudometrics complements algorithmic work on fitting and repairing ultrametrics and tree metrics under edge disagreements or outlier deletions [SWW15; CFLM22; BLL+26]. We begin with a structural graph partitioning lemma that bounds the number of -edges cut when separating all -edges in an edge tripartition without forbidden triangles.
Lemma 5.1. Let partition , and suppose no triangle has two edges in and one in . There exist a partition of , a set , and a set such that:
(1) no part contains an R-edge;
(2) Z is the set of F-edges crossing ;
(3) every edge of Q crosses ;
(4) .
Proof. We first verify that if is a shortest path in a graph , then some satisfies , where denotes the set of vertices at distance exactly two from . For each vertex , let and . Because is a shortest path, no vertex is adjacent to both and , so . Moreover, if , then : for a path vertex this follows from the shortest-path property, and for any other vertex a transition between an adjacent and a nonadjacent consecutive path vertex yields distance two. Thus , and summing over proves the claim.
We now work separately in the connected components of and induct on . If a component contains no internal -edge, take it as a single part. Otherwise, choose and a shortest -path from to . Its length is at least three, as length one is impossible and length two would form a forbidden triangle. By the initial claim, some vertex among the first four path vertices satisfies . Set and . Every edge of lies in , since it is not in and membership in would create a forbidden triangle. Apply the induction hypothesis to the -components of , add as a singleton part, and adjoin and to the recursive sets. Since the new edges are incident to while the recursive edges are not, the cardinality bounds add and all four properties follow.
Lemma 5.2 (Completion stability for ultrametrics). Over any nonempty value set , a locally consistent partial ultrametric with holes can be completed to a valid ultrametric by changing at most 3h specified entries. Consequently,
This includes on and on .
Proof. Let be the specified assignment on a finite vertex set , and let be its hole set. We recursively process subsets with a cap bounding all specified values inside , initialized to the maximum specified value (or any element of if ).
If no edge inside is specified, assign to all edges of . Otherwise, let and partition into , , and . Local consistency rules out triangles with two -edges and one -edge. Apply Lemma 5.1, assign to all edges crossing the resulting partition, and recurse on each part with cap .
Because and no part contains an -edge, each recursive part is proper and the recursion terminates. Any triangle crossing a partition has at least two edges of value and its third edge at most , while triangles within a part are valid by induction; hence the output is a valid ultrametric in . Among specified edges, only the crossing -edges are modified, and Lemma 5.1 gives for a subset crossing the partition. The sets are pairwise disjoint across the recursion tree because every edge of crosses the partition of , whereas descendants lie within single parts and incomparable nodes occupy disjoint vertex sets. Thus at most specified edges are modified in total, yielding for .
Corollary 5.3. On the ambient value set , we have . On the positive ambient value set , the bound improves to .
Proof. The bound on follows from Lemma 5.2. On , let be locally consistent for with holes and specified zero edges. Every triple containing a specified zero edge must contain a hole, so in each triple the number of specified zero edges is at most twice the number of holes. Summing over all triples gives , so . Replacing all specified zeros with a positive value leaves every fully specified triple unchanged; applying Lemma 5.2 over then changes at most additional specified entries, for at most changes in total.
To extend Lemma 5.2 to tree pseudometrics, we pass to rooted Gromov products as in Lemma 4.2.
Lemma 5.4. Let be a finite set with heights , and let be a partial symmetric assignment on with hole set . Suppose for all , and every fully specified triple has its minimum -value attained at least twice. Then there exists a full assignment satisfying both conditions everywhere and differing from on at most specified entries.
Proof. Assume , and set and for . The specified -values lie in and are locally ultrametric, so Lemma 5.2 produces a full ultrametric in differing from on at most specified entries. For distinct , put and . Then is nonnegative, satisfies the height bounds, and inherits the minimum condition from via . Whenever on a specified pair, we have and hence , introducing no further discrepancies.
Lemma 5.5 (Completion stability for tree pseudometrics). For every ,
Proof. Let be locally consistent on with and . Choose a root of minimum hole degree , and set . If , then , so and . Assume henceforth that .
Let and . For specified pairs in , set and , and let be the set of specified pairs in violating , with . Any triple meeting must contain a hole in , as otherwise would be a fully specified quartet violating a triangle inequality. Thus for every ; summing over and dividing by gives .
Deleting leaves a partial assignment on with holes that satisfies the hypotheses of Lemma 5.4, since every remaining fully specified triple forms a valid quartet with . Lemma 5.4 yields a completion on changing at most remaining specified entries, so at most originally specified entries in are modified. Setting and for distinct defines a tree pseudometric on by Lemma 4.2. Identifying each of the vertices outside with alters at most additional specified entries, for a total of at most modified specified entries and .
Corollary 5.6. For every , we have , and in particular as .
Proof. For the lower bound, take disjoint four-vertex gadgets on vertices. In each gadget, specify a four-cycle with consecutive edge weights and leave both diagonals as holes; set all cross-gadget distances to 4. Since every triple inside a gadget contains a hole, any fully specified quartet meets each gadget in at most two vertices, so two of its opposite-edge sums equal 8, the third is at most 8, and all triangle inequalities hold. Thus the partial matrix is locally consistent for , yet every metric repair must edit at least one cycle edge per gadget because . This gives and , matching the upper bound of Lemma 5.5.
5.2 Euclidean pseudometrics via affine anchor rigidity
For -dimensional Euclidean pseudometrics, we adapt the affine anchor repair strategy of [PR03, Lemma 6.1] to partial matrices by selecting a fully specified -clique of maximum affine dimension among vertices of low hole degree.
Lemma 5.7 (Completion stability for Euclidean pseudometrics). For every ,
Proof. Let be locally consistent on with . The bound is trivial if or , so assume and ; in particular, . Let be the graph of specified pairs and , so by the handshake lemma. A greedy selection finds a -clique in : after choosing vertices, the number of common neighbors in is at least .
Choose a -clique in whose realization has maximum affine dimension , fix a realization in with affine basis , and set for all . Then and . For each , the submatrix on is fully specified and locally valid, so Lemma 2.7 yields a realization in . Its affine dimension cannot exceed , as otherwise padding an affinely independent -subset with vertices of would contradict the maximality of . After aligning , the image of lies in and is uniquely determined by Lemma 2.6; denote it by .
For any specified pair in , padding with vertices of forms a fully specified -set in of affine dimension at most , and aligning the affine basis forces .
Assigning every vertex outside to produces a global Euclidean pseudometric agreeing with on all specified pairs inside , so .
5.3 Metrics with bounded aspect ratio via cyclic entropy
For a partial matrix with specified values in , let denote its graph of specified edges. A simple cycle in is nonmetric (also called broken or unbalanced in the metric repair literature [BDST08; GJ17; FRV22; FGR+20]) if one edge weight strictly exceeds the sum of the remaining edge weights. We first record the bounded range form of the classical metric completion criterion [HY65; DL97].
Lemma 5.8. A partial matrix with specified values in has a metric completion in preserving all specified entries if and only if contains no nonmetric cycle.
Proof. Necessity is immediate from the triangle inequality along any cycle. Conversely, let denote shortest-path distance in (with between components), and set for and . If is specified, a strict inequality would yield a shorter simple path in and hence a nonmetric cycle, so preserves all specified entries. Moreover, every path between distinct vertices has length at least 1, and for any distinct , either gives , or else . Thus .
The number of edits to specified edges in is the sparse metric repair objective on normalized by , or equivalently the minimum size of a hitting set of specified edges for all nonmetric cycles [GJ17; FRV22; FGR+20]. We now bound this optimum in terms of the hole count under local consistency, beginning with the exact completion threshold at (which differs from the trivial threshold below which every complete input is already metric).
Proposition 5.9 (Exact completion threshold at ). If , every locally consistent partial matrix in has an exact metric completion, so for all . Conversely, for every , locally consistent partial matrices without exact completions exist, and for all .
Proof. Local consistency rules out nonmetric triangles, and when any cycle of length has maximum edge weight at most , excluding longer nonmetric cycles; Lemma 5.8 then gives an exact completion. For , fix and apply the -gadget four-cycle construction of Corollary 5.6 with cycle weights , diagonal holes, and cross-gadget distances . Every fully specified triangle is valid, each gadget requires at least one specified edit, and changing each weight- edge to 3 while filling the diagonals with 2 achieves on vertices. Setting completes the proof.
An entropy inequality on cycles
To bound the hitting number of shortest nonmetric cycles when , we establish an entropy inequality for random variables indexed by a cycle (using natural logarithms). The following conditional independence property is a cycle separator form of the global Markov property for maximum entropy graphical models [DLS80; Lau96] that also allows prescribed marginals with zero entries [Csi75; WJ08].
Lemma 5.10. Let be finite-valued random variables on a cycle with a feasible family of prescribed marginals on adjacent pairs. Any entropy-maximizing joint distribution with these marginals makes the interiors of complementary arcs conditionally independent given their two common endpoints.
Proof. An entropy maximizer exists by compactness. For separator endpoints and complementary arc interiors , the conditional-product law preserves the marginals on and and hence all adjacent-pair marginals, while . Maximality forces .
Lemma 5.11. Let and suppose finite-valued random variables satisfy conditional arc independence on the cycle. With cyclic indices, the average pair entropies satisfy for all .
Proof. Fix and , and write . Conditional arc independence gives and , so and . Expanding the nonnegative sum therefore yields . Averaging over gives . Since , the differences satisfy and , which rules out a negative interior minimum.
Unlike projection inequalities such as Shearer's inequality [CGFS86], Lemma 5.11 compares distinct averages of pair entropies and requires conditional arc independence: on a four-cycle with and for independent fair bits , one has .
Lemma 5.12. Let be a positively weighted simple graph on vertices with holes. If has no nonmetric cycle of length less than , where , then there is a set of at most edges meeting every nonmetric -cycle.
Proof. For each cyclic -tuple of adjacent vertices in , define the excess , and let . Assume . Because has no nonmetric cycle of length less than , every is a simple chordless cycle: a repeated vertex would yield a shorter closed subwalk and simple path of weight less than , and a chord would split into two shorter cycles at least one of which is nonmetric. In particular, every two-step pair along is a hole, so .
Over the compact feasible polytope for all , choose a fractional packing that first maximizes and second minimizes the total mass . By averaging with cycle reversal , we may assume is reversal-invariant. Let be the set of saturated edges; then meets every by score maximality, and .
Normalize , and let be the entropy-maximizing distribution on matching the ordered adjacent-pair marginals of . Then is supported on closed -walks in , satisfies for every , and has expected score . Since positive-score walks lie in and are simple, defines a feasible packing. If placed positive mass outside , restricting to would either strictly increase the score (if ) or preserve the optimal score while strictly reducing (if ), contradicting the choice of . Thus is supported on .
By reversal invariance, satisfies . Because is supported on simple cycles, , so and are distinct ordered occurrences of the undirected edge even when the cyclic indices and coincide. Hence , giving . On the other hand, because every is chordless, takes values in the ordered holes, so . Lemmas 5.10 and 5.11 therefore yield , so and .
Theorem 5.13 (Completion stability for metrics with bounded aspect ratio). For fixed , define , where the empty product is 1. Every locally consistent partial matrix in with holes becomes metrically completable after deleting at most specified edges. Consequently,
and for every fixed , we have as .
Proof. Local consistency excludes nonmetric triangles, and any nonmetric -cycle must satisfy , so . For in turn, delete a hitting set of specified edges for all nonmetric -cycles. Because edge deletion creates no new cycles, each stage has no nonmetric cycle of length less than ; if is the current hole count, Lemma 5.12 deletes at most edges, giving . After stage , the hole count is at most , at most specified edges have been deleted, and no nonmetric cycle remains, so Lemma 5.8 provides an exact completion. Normalizing the edit count yields the upper bound, while Proposition 5.9 gives for and the matching linear lower bound for .
Uniform polynomial-time completion and metric repair
We next show that the hitting sets of Lemma 5.12 and the resulting completions can be computed in polynomial time via linear programming duality.
Lemma 5.14. Under the hypotheses of Lemma 5.12, if the edge weights are rational, a hitting set of size at most can be computed in time polynomial in and the input bit length, with polynomial degree independent of .
Proof. If , return . Otherwise, consider the dual of the maximum-score packing linear program: minimize subject to and for all . For a candidate and each edge , dynamic programming computes the minimum of over -to- walks of at most edges. A constraint with dominant edge is violated if and only if this minimum is strictly less than : any violating walk has original weight less than , and shortcutting repeated vertices preserves the strict inequality (since ) and yields a nonmetric simple cycle of length at most , which must have length by hypothesis.
Since is feasible, we may restrict the dual to a rational box of polynomial bit complexity and compute an exact optimum in polynomial time via the ellipsoid method [GLS88]. If , then and suffices. Otherwise, let be the maximum-score, minimum-mass primal optimum from the proof of Lemma 5.12. Complementary slackness implies whenever , so , and every meets because .
Corollary 5.15. For every real , a locally consistent partial matrix with rational specified entries in and holes admits a rational metric completion in after changing at most specified entries, computable in time polynomial in and the input bit length with degree independent of (and without knowledge of ).
Proof. Set . If , output the all-ones off-diagonal matrix. Otherwise apply Lemma 5.14 for and complete the remaining graph via for .
For and , write for the edge-normalized Hamming distance. Clipping an arbitrary pseudometric to preserves both the triangle inequality and agreement with entries in , yielding the following transfer principle.
Lemma 5.16. For every , we have .
Proof. For any , setting for and preserves the triangle inequality (since and capping at preserves the triangle inequality as in Lemma 5.8) without altering agreement with .
Combining Theorem 5.13 with Proposition 3.9 and Lemma 5.16 bounds the metric repair distance on within a factor of of the maximum size of an edge-disjoint packing of violating triangles.
Proposition 5.17 (Triangle packing bound for metric repair). For and ,
Proof. The lower bound is Lemma 3.7. For the upper bound, deleting all edges of a maximal edge-disjoint family of violating triangles leaves a locally consistent partial matrix, which Theorem 5.13 completes after at most further deletions; Lemma 5.16 equates the repair targets.
Remark 5.18 (Support selection and bounded cycle approximation). When , Proposition 5.9 implies that the minimum number of metric repair edits equals the minimum size of an edge set hitting all violating triangles. Selecting an optimal hitting set is nevertheless NP-hard and APX-hard even for weights in [FRV22] (see also [BLL+26] for parameterized kernels). For any fixed , repeatedly deleting the edges of a shortest nonmetric cycle (found via shortest paths and having length at most ) and completing via Corollary 5.15 recovers the polynomial-time -approximation specialization of [FRV22; FGR+20], complementing the range-independent -approximation of Cohen-Addad, Fan, Lee, and de Mesmay [CFLM22].
5.4 Twin rigidity, completion obstructions, and logical independence
Whereas our pseudometric repairs in Lemmas 5.5 and 5.7 may identify distinct vertices, injective realization in trees or forbids zero off-diagonal distances. We now reformulate the deterministic collinear twin pair construction of Parnas and Ron [PR03, Section 7] as a locally consistent partial matrix with holes to show that injectivity creates a completion obstruction for and .
Lemma 5.19. Let and . On , write , leave the pairs within each class unspecified as holes, and set for . Every complete matrix differs from on at least specified edges, and hence satisfies .
Proof. For and , consider the four-vertex witness . If agrees with on all five specified edges of , then , , and . In , the three opposite-edge sums on are and twice , so the four-point condition forces , a contradiction. In , equality in the triangle inequality on and places both and at the unique point on the segment at distance from , forcing , again a contradiction.
Consequently, must differ from on at least one specified edge in each of the witnesses. A specified edge between classes belongs to witnesses, so double counting yields at least specified discrepancies, or after normalizing by .
Theorem 5.20 (Injective tree and Euclidean completion obstructions). The strict predicates and admit completion obstructions and are not removable. Consequently, neither nor has a constant-query one-sided tester.
Proof. Apply Lemma 5.19 with and . Every fully specified subset contains at most one vertex per twin class and embeds injectively on a line, while the hole density is and . Corollaries 3.12 and 3.11 complete the proof.
Remark 5.21 (Geodesic rigidity, injectivity, and two-sided testing). Filling the twin holes in Lemma 5.19 with zeros gives an exact non-injective line realization, showing that the completion obstruction arises from injectivity rather than from graph non-chordality (cf. [BJ95]). Specifically, in a tree or in , any intermediate point satisfying and for is uniquely determined, forcing twin vertices to coincide. The same double-counting argument (with clones per class) applies in any metric space where this two-distance system has at most solutions along a geodesic segment; by contrast, in , where infinitely many points satisfy the system simultaneously, twin vertices can be separated to positive distance without altering cross-class entries.
Ultrametrics avoid geodesic rigidity altogether: if , then , so no point satisfies the two-distance system above, and twin holes over a positive ultrametric can be filled by any sufficiently small positive value. Accordingly, strict ultrametrics satisfy both packing amplification and completion stability on and (Corollaries 4.9 and 5.3); in fact, for any nonnegative input with off-diagonal zero entries, replacing zeros in an optimal repair by a small below all positive entries of and shows that . Thus injectivity alone does not create a completion obstruction. Finally, for and , randomizing twin pairs on parallel lines or comb trees yields two-sided testing lower bounds [PR03, Theorem 9] (see also [KS03; Ona08]).
Finally, combining our results from Sections 4 and 5 demonstrates that neither structural condition in Theorem 3.10 implies the other.
Corollary 5.22 (Logical independence of the structural conditions). Packing amplification does not imply completion stability, and completion stability does not imply packing amplification.
Proof. For with , the metric predicate is completion stable by Theorem 5.13 (with for by Proposition 5.9), but fails packing amplification by Theorem 4.11. Conversely,
Although Bao, Kannan, and Waingarten [BKW25] claimed a constant-query upper bound on testing of strict tree metrics [Lemma 5.7, pg. 25-26], their upper bound proofs implicitly rely on non-injectivity.
on or , the strict predicates and satisfy packing amplification by Corollary 4.9, but fail completion stability by Theorem 5.20.
6 Quantitative testing bounds
We establish quantitative query complexity bounds for testing our geometric and metric families. We first combine our packing and completion bounds from Sections 4 and 5 to obtain explicit constant-query one-sided testers for all four removable geometric families: ultrametrics, strict ultrametrics, tree pseudometrics, and -dimensional Euclidean pseudometrics (Corollary 6.1). Turning to general metrics, for which Bao, Kannan, and Wainingten [BKW25] proved a nonadaptive one-sided upper bound of and a nonadaptive one-sided lower bound of at vanishing proximity , we introduce a signed noise perturbation scheme on robust metric faces (Lemmas 6.3 to 6.5) and pair it with density sensitive submatrix sampling and asymmetric faces to determine the sharp nonadaptive one-sided and two-sided query complexity on for across all four proximity regimes of (Theorem 6.8). Next, we introduce a contextual blow-up of our robust faces that prevents adaptive coordinate recovery, establishing an adaptive two-sided lower bound of queries (Theorem 6.11). Finally, we apply our clipping equivalence (Lemma 5.16) to transfer both the nonadaptive two-sided lower bound and the adaptive lower bound to unrestricted metrics and pseudometrics (Theorem 6.12).
6.1 Quantitative testing of removable geometric families
Combining Proposition 3.9 and Theorem 3.4 with the bounds of Sections 4 and 5 gives explicit query bounds for all four removable geometric families.
Corollary 6.1 (Quantitative geometric testers). For every , the removal moduli of , and satisfy
where and are as in Lemma 4.6; for strict ultrametrics , we have on and on . Consequently, , and admit one-sided -query -testers, and admits a one-sided -query -tester.
Proof. By Proposition 3.9, Lemma 5.2 gives , Corollary 5.3 gives on , and Lemma 5.5 gives . Substituting the resulting packing lower bounds , , and into Lemmas 4.1 and 4.4 and Proposition 4.8 (with ) yields the stated moduli for , and , while Corollary 4.7 gives the modulus for . Theorem 3.4 converts each removal modulus into the claimed one-sided query bound.
Remark 6.2 (Comparison with prior geometric testing bounds). For ultrametrics and tree pseudometrics, Parnas and Ron [PR03] gave nonadaptive -query testers, which Bao, Kannan, and Wainingten [BKW25] improved to queries on sampled vertices alongside an vertex sample lower bound and an two-sided query lower bound. Corollary 6.1 removes the logarithmic factors from the query bound of [BKW25] via uniform k-set sampling (and applying our linear completion stability bounds to an induced submatrix on vertices likewise recovers their single-submatrix sample bound). For d-dimensional Euclidean pseudometrics, our bound reflects the -point proximity-oblivious [GR11] removal modulus; when larger submatrices are queried, better -dependence is achieved by the -query tester of [PR03] and the -query tester of Krauthgamer and Sasson [KS03] (see also Onak [Ona08]).
6.2 Signed noise on robust metric faces
To convert our edge-disjoint tight-triangle constructions into two-sided testing lower bounds, we introduce a real-valued additive counterpart to the -parity lifting of Alon, Kaufman, Krivelevich, and Ron [AKKR08, Section 6.1] for triangle-freeness. Working directly on weighted matrices without vertex blow-up, we perturb the three edges of each designated tight triangle by correlated uniform shifts over . Because any two edges of a selected triangle have nearly identical joint distributions under the two signs (an additive analogue of the Independence Observation of [AKKR08]), a stopped transcript hybrid argument reduces two-sided distinguishing to the exposure event of querying all three edges of some selected triangle.
Lemma 6.3. Suppose a rational metric has an edge-disjoint family of designated tight triangles, every other triangle inequality has slack at least , every selected edge has endpoint margin at least , and all entries have -bit rational representations for a fixed . Fix an integer and set , , and . There exist finite-support distributions and , obtained by independent triangle perturbations followed by uniform vertex relabeling, such that:
(1) all entries lie in and have -bit rational representations (with constants allowed to depend on ;
(2) every instance in supp is metric;
(3) before relabeling, every instance in supp violates exactly the designated tight inequalities of ;
(4) every instance satisfies and .
Proof. For each triangle , independently draw uniformly from , add and to the two short edges of , and add to the designated long edge under . Each entry changes by at most and each formerly strict slack changes by at most , while the designated slack on each becomes . Thus is supported on metrics and violates precisely the edge-disjoint triangles in , requiring exactly edge edits (achieved by restoring the long edges under ).
Lemma 6.4. For a single triangle in Lemma 6.3, any adaptive procedure observing at most two of its edges (even with sign-independent side information) has transcript total variation distance at most between and . For a fixed projection onto at most two edges, the total variation distance is at most .
Proof. After subtracting the baseline entries and dividing by , the three triangle coordinates are under and under , where are independent and uniform. The marginal on is identical under both signs, while conditional on (or on ) the third coordinate is uniform on an interval shifted by 2, giving total variation . Conditioning on the side information and internal randomness fixes the first queried coordinate, and a union bound over the three possible two-coordinate pairs bounds the adaptive transcript variation by .
Lemma 6.5. Let query the distributions of Lemma 6.3, and let be the event that queries all three edges of some selected triangle in . Then
and the same bound holds when is drawn from a sign-independent distribution with almost surely. If is nonadaptive, then , where depends only on the query set, base template, and relabeling.
Proof. Condition on the base template and relabeling, and modify to halt immediately before any query that would reveal the third edge of a triangle in . Replacing the independent triangle laws one by one changes the stopped transcript distribution by at most per triangle by Lemma 6.4, and the unstoppable transcript agrees with the stopped transcript outside under each sign. For nonadaptive , conditioning on the random seed fixes the queried edges; outside , each triangle is observed on a fixed set of at most two edges, so the fixed-projection bound of Lemma 6.4 gives .
6.3 Density-sensitive sampling and asymmetric faces
To match our nonadaptive lower bounds across all proximity regimes, we pair a second-moment sub-matrix sampling bound on the upper-bound side with asymmetric and single-center robust face constructions on the lower-bound side.
Lemma 6.6. Let be an edge-disjoint family of triangles on . For a uniformly random -set with , we have . In particular, this probability is at least whenever , , and .
Proof. Let and , so . Each vertex belongs to at most triangles of , so there are at most ordered pairs of intersecting triangles. Since vertex-disjoint triangles have joint inclusion probability , we have . Using for gives , and the Paley-Zygmund inequality gives the result.
Lemma 6.7. Fix and let be as in Lemma 4.10. For sufficiently large , put . Given either and , or and any , there is a rational metric with an edge-disjoint family of tight triangles such that:
(1) every contains one of a designated centers, and the triangles of through each center form a matching of size on the remaining vertices;
(2) all other triangle inequalities and endpoint margins of selected edges are at least , and all entries are -bit rationals.
Proof. For with , take the construction of Lemma 4.10 on vertices, retain vertices of together with all of and , and pad to vertices with distance ; for each retained , the pairs () form a matching of size . For a single center with , set and as in Lemma 4.10, assign weight to the edges from the center to the leaves, weight to the edges between matched leaves, and weight to all remaining edges; the matched triangles satisfy and all other slacks and endpoint margins are bounded below by positive constants depending only on .
6.4 The full nonadaptive complexity on a bounded range
Write and for the nonadaptive one-sided and two-sided query complexities of metric testing on . For and , define the rate function
Theorem 6.8 (Sharp nonadaptive complexity on a known bounded range). For every fixed , we have for all and (and when ). Conversely, for and every fixed , there exist constants , , and an absolute constant such that
for all and . Moreover, the hard instances have -bit rational entries, and the bounds hold whether repairs are restricted to or allowed arbitrary positive metric values.
Proof. When , every matrix in is metric. For , set and . By Proposition 5.17, every -far input has . By Lemma 6.6, for , repeating a uniform -submatrix check times yields a nonadaptive one-sided tester using queries. For , choosing up to rounding and truncation at (using full inspection whenever , rounding reaches , or ) with for , for , and for gives query complexity .
For the lower bound, we apply Lemmas 6.3 and 6.5 with , , and to three face families, each having selected triangles so that every instance in supp is at distance from (and from by Lemma 5.16). Fix the random seed of a nonadaptive q-query algorithm , let be its query graph of at most edges, and write and for the degree and triangle count at vertex . By the classical spectral bound [Alo81] (used also in [BKW25, Section 4]), the total number of triangles in satisfies , while .
Case 1: . With , apply Lemma 4.10 on vertices and pad to vertices with distance . Then . Under uniform relabeling, each triangle of hits a selected triangle with probability , so a union bound gives .
Case 2: . Apply Lemma 6.7 with and , so . Conditional on a designated center mapping to , its selected leaf pairs form a uniform matching on , so the probability that contains a selected triangle through is at most . Summing over and the centers gives across both and .
Case 3: . Apply the single-center case of Lemma 6.7 with . Conditioning on the center mapping to and bounding the matching intersection probability by gives .
In all three regimes, Lemma 6.5 yields whenever for a sufficiently small absolute constant and large , ruling out two-sided testers.
6.5 Contextual blow-up and adaptive metric testing lower bounds
Unlike nonadaptive algorithms, an adaptive algorithm can use exact numerical distance answers to infer vertex coordinates and guide subsequent queries. To prevent global coordinate recovery, we blow up each vertex of a coarse robust face into clones and assign independent random coordinate bijections to each coarse tight-triangle context.
Lemma 6.9. Let be a robust face from Lemma 4.10 on vertices with slack and endpoint-margin bound (), and fix an integer . Replace each coarse vertex by clones and pad with distance to vertices. For sufficiently large , there is a random metric with an edge-disjoint family of tight triangles (so when ) such that all other triangle slacks and endpoint margins of selected edges are at least and all entries are -bit rationals.
Proof. For each incidence of a coarse vertex with a coarse triangle in , independently choose a uniform bijection from its clones to . Set and . For each coarse triangle with long edge and local clone coordinates , set , , and ; keep all other cross-cell distances equal to and set within-cell and padding distances to . Edge-disjointness of ensures that each coarse pair belongs to at most one context.
On , the slack of is , which vanishes precisely on the midpoint triples and is at least otherwise. Because any two coordinates of a midpoint triple determine the third and distinct contexts are disjoint on coarse edges, the resulting fine tight triangles are edge-disjoint. Every perturbation is in with , preserving all unselected slacks and endpoint margins.
Lemma 6.10. Apply the signed noise perturbation of Lemma 6.3 independently to the fine triangles of Lemma 6.9 and uniformly relabel [n]. For any adaptive q-query algorithm with and any integer , the event that queries all three edges of some fine triangle in satisfies under either sign.
Proof. Generate the signed noise table in abstract coordinate space for each coarse context before sampling the bijections from clones to coordinates, and strengthen the oracle so that querying any edge in a coarse selected context also reveals the coarse cells of both endpoints and their local context coordinates (disclosing at most two new local coordinates per query).
First, conditioning on a fixed full template, the strengthened oracle answers are functions of the template vertex images, so Lemma 3.1 embeds the 2q touched vertices into a uniformly random 2q-set. By a union bound over the s coarse cells, the probability that some cell has at least R touched clones is at most .
Second, condition on the random seed, the abstract noise table, and the coarse cell partition of [n]. Because numerical edge weights in a context are deterministic functions of the disclosed local coordinates and the fixed abstract noise table, the conditional law of the remaining undisclosed coordinates in each incidence between a cell and a context remains uniform over the unused values in [t]. Stop the process if any cell reaches R touched clones. Prior to stopping, each newly disclosed coordinate is uniform over at least t - R unused values, while the other two cells of its coarse context have at most R disclosed coordinates each and hence prescribe at most midpoint-completing values. A union bound over the at most 2q coordinate disclosures therefore bounds the probability of completing a midpoint triple before stopping by .
Theorem 6.11 (Adaptive lower bound on a bounded range). For every fixed , there exist constants and such that for all and , any adaptive two-sided -tester for general metrics on requires at least queries. The same lower bound holds for one-sided testers and unrestricted positive metric repairs, on inputs with -bit rational entries.
Proof. Set , , , and , and apply Lemma 6.9 with and followed by Lemma 6.3 with . For large , we have and , so every instance in supp is at distance from . Moreover, and whenever , so Lemmas 6.10 and 6.5 yield for with sufficiently small.
Finally, combining Theorems 6.8 and 6.11 for any fixed with Lemma 5.16 transfers both our nonadaptive two-sided lower bound across all proximity regimes and our adaptive two-sided lower bound directly to unrestricted metrics and pseudometrics.
Theorem 6.12 (Lower bounds for metric testing). On arbitrary nonnegative symmetric inputs, for all sufficiently large and , nonadaptive two-sided and adaptive two-sided -testing of general metrics require, respectively,
queries. Both lower bounds hold for either positive metric or nonnegative pseudometric repair targets, using hard inputs with -bit rational entries.
Proof. Fix in Theorems 6.8 and 6.11. All instances in supp are positive metrics in [1,3], and Lemma 5.16 ensures that every instance in supp has the same Hamming distance to and as to .
References
[ABF17] Noga Alon, Omri Ben-Eliezer, and Eldar Fischer. “Testing Hereditary Properties of Ordered Graphs and Matrices”. In: Proceedings of the IEEE Symposium on Foundations of Computer Science (FOCS). 2017, pp. 848–858. arXiv: 1704.02367.
[ABH+21] A. Aranda, D. Bradley-Williams, E. K. Hng, J. Hubička, M. Karamanlis, M. Kompatscher, M. Konečný, and M. Pawliuk. "Completing graphs to metric spaces". In: Contributions to Discrete Mathematics 16.2 (2021), pp. 71–89.
[AKKR08] Noga Alon, Tali Kaufman, Michael Krivelevich, and Dana Ron. "Testing Triangle-Freeness in General Graphs". In: SIAM Journal on Discrete Mathematics 22.2 (2008), pp. 786–819. DOI: 10.1137/07067917X.
[Alo81] Noga Alon. "On the number of subgraphs of prescribed type of graphs with a given number of edges". In: Israel Journal of Mathematics 38.1–2 (1981), pp. 116–130. DOI: 10.1007/BF02761855.
[AS08] Noga Alon and Asaf Shapira. "A characterization of the (natural) graph properties testable with one-sided error". In: SIAM Journal on Computing 37.6 (2008), pp. 1703–1727.
[AT10] Tim Austin and Terence Tao. "Testability and repair of hereditary hypergraph properties". In: Random Structures & Algorithms 36.4 (2010), pp. 373–463.
[BDST08] Justin Brickell, Inderjit S. Dhillon, Suvrit Sra, and Joel A. Tropp. "The metric nearness problem". In: SIAM Journal on Matrix Analysis and Applications 30.1 (2008), pp. 375–396.
[BJ95] Mihály Bakonyi and Charles R. Johnson. "The Euclidean distance matrix completion problem". In: SIAM Journal on Matrix Analysis and Applications 16.2 (1995), pp. 646–654.
[BKW25] Yiqiao Bao, Sampath Kannan, and Erik Waingarten. "Nearly tight bounds on testing of metric properties". In: Proceedings of the ACM–SIAM Symposium on Discrete Algorithms (SODA). 2025, pp. 403–445. arXiv: 2411.08989.
[BLL+26] Sayan Bandyapadhyay, William Lochet, Daniel Lokshtanov, Saket Saurabh, Chinmay Sonar, Vaishali Surianarayanan, and Jie Xue. How to Fix a Broken Metric: A Linear Kernel, Tight Bounds, and Tree Metrics. 2026. arXiv: 2610.07690 [cs.DS].
[Blu53] L. M. Blumenthal. Theory and Applications of Distance Geometry. Oxford: Clarendon Press, 1953.
[Bun74] Peter Buneman. "A note on the metric properties of trees". In: Journal of Combinatorial Theory, Series B 17.1 (1974), pp. 48–50.
[CFLM22] Vincent Cohen-Addad, Chenglin Fan, Euiwoong Lee, and Arnaud de Mesmay. "Fitting metrics and ultrametrics with minimum disagreements". In: Proceedings of the IEEE Symposium on Foundations of Computer Science (FOCS). 2022, pp. 301–311.
[CGFS86] Fan R. K. Chung, Ronald L. Graham, Peter Frankl, and James B. Shearer. "Some intersection theorems for ordered sets and graphs". In: Journal of Combinatorial Theory, Series A 43.1 (1986), pp. 23–37.
[Csi75] I. Csiszár. "I-divergence geometry of probability distributions and minimization problems". In: Annals of Probability 3.1 (1975), pp. 146–158.
[DL97] M. M. Deza and M. Laurent. Geometry of Cuts and Metrics. Springer, 1997.
[DLS80] John N. Darroch, Steffen L. Lauritzen, and Terry P. Speed. "Markov fields and log-linear interaction models for contingency tables". In: Annals of Statistics 8.3 (1980), pp. 522–539.
[Far72] James S. Farris. "Estimating phylogenetic trees from distance matrices". In: The American Naturalist 106.951 (1972), pp. 645–668. DOI: 10.1086/282802.
[FGR+20] Chenglin Fan, Anna C. Gilbert, Benjamin Raichel, Rishi Sonthalia, and Gregory Van Buskirk. "Generalized metric repair on graphs". In: Proceedings of the 17th Scandinavian Symposium and Workshops on Algorithm Theory (SWAT). Vol. 162. Leibniz International Proceedings in Informatics (LIPIcs). 2020, 25:1–25:16. arXiv: 1908.08411.
[FRV22] Chenglin Fan, Benjamin Raichel, and Gregory Van Buskirk. "Metric violation distance: Hardness and approximation". In: Algorithmica 84.5 (2022), pp. 1441–1465.
[GJ17] A. C. Gilbert and L. Jain. "If it ain't broke, don't fix it: Sparse metric repair". In: Proceedings of the 55th Annual Allerton Conference on Communication, Control, and Computing. 2017, pp. 612–619.
[GLS88] M. Grötschel, L. Lovász, and A. Schrijver. Geometric Algorithms and Combinatorial Optimization. Springer, 1988.
[GR11] Oded Goldreich and Dana Ron. "On proximity-oblivious testing". In: SIAM Journal on Computing 40.2 (2011), pp. 534–566.
[Gro87] Mikhael Gromov. "Hyperbolic groups". In: Essays in Group Theory. Ed. by S. M. Gersten. Vol. 8. Mathematical Sciences Research Institute Publications. New York: Springer, 1987, pp. 75–263. DOI: 10.1007/978-1-4613-9586-7_3.
[GT03] Oded Goldreich and Luca Trevisan. "Three theorems regarding testing graph properties". In: Random Structures & Algorithms 23.1 (2003), pp. 23–57.
[HY65] S. Louis Hakimi and Stephen S. Yau. "Distance matrix of a graph and its realizability". In: Quarterly of Applied Mathematics 22.4 (1965), pp. 305–317.
[KS03] R. Krauthgamer and O. Sasson. "Property testing of data dimensionality". In: Proceedings of the ACM-SIAM Symposium on Discrete Algorithms. 2003, pp. 18–27.
[Lau96] S. L. Lauritzen. Graphical Models. Oxford University Press, 1996.
[Men31] Karl Menger. "New foundations of Euclidean geometry". In: American Journal of Mathematics 53.4 (1931), pp. 721–745.
[Ona08] Krzysztof Onak. "Testing Properties of Sets of Points in Metric Spaces". In: Automata, Languages and Programming (ICALP). Vol. 5125. Lecture Notes in Computer Science. Springer, 2008, pp. 515–526. DOI: 10.1007/978-3-540-70575-8_42.
[PR03] M. Parnas and D. Ron. "Testing metric properties". In: Information and Computation 187.2 (2003), pp. 155–195.
[Sch35] I. J. Schoenberg. "Remarks to Maurice Fréchet's article "Sur la définition axiomatique d'une classe d'espace distanciés vectoriellement applicable sur l'espace de Hilbert"". In: Annals of Mathematics 36.3 (1935), pp. 724–732.
[SWW15] A. Sidiropoulos, D. Wang, and Y. Wang. Metric embeddings with relaxed guarantees. 2015. arXiv: 1508.03600.
[WJ08] Martin J. Wainwright and Michael I. Jordan. "Graphical models, exponential families, and variational inference". In: Foundations and Trends in Machine Learning 1.1–2 (2008), pp. 1–305.
[YH38] Gale Young and Alston S. Householder. "Discussion of a set of points in terms of their mutual distances". In: Psychometrika 3.1 (1938), pp. 19–22. DOI: 10.1007/BF02287916.