Removable sets for Newtonian Sobolev spaces and a characterization of p -path almost open sets

. We study removable sets for Newtonian Sobolev functions in metric measure spaces satisfying the usual (local) assumptions of a doubling measure and a Poincaré inequality. In particular, when restricted to Euclidean spaces, a closed set E (cid:26) R n with zero Lebesgue measure is shown to be removable for W 1;p . R n n E/ if and only if R n n E supports a p -Poincaré inequality as a metric space. When p > 1 , this recovers Koskela’s result ( Ark. Mat. 37 (1999), 291–304), but for p D 1 , as well as for metric spaces, it seems to be new. We also obtain the corresponding characterization for the Dirichlet spaces L 1;p . To be able to include p D 1 , we first study extensions of Newtonian Sobolev functions in the case p D 1 from a noncom-plete space X to its completion y X . In these results, p -path almost open sets play an important role, and we provide a characterization of them by means of p -path open, p -quasiopen and p -finely open sets. We also show that there are nonmeasurable p - path almost open subsets of R n , n (cid:21) 2 , provided that the continuum hypothesis is assumed to be true. Furthermore, we extend earlier results about measurability of functions with L p -integrable upper gradients, about p -quasiopen, p -path open and p -finely open sets, and about Lebesgue points for N 1;1 -functions, to spaces that only satisfy local assumptions.


Introduction
The recent development in analysis on metric spaces has made it possible to define Sobolev type spaces also on nonopen subsets of R n . This, in particular, leads to questions about extensions and restrictions of Sobolev functions, as well as about the gradients of such restrictions in arbitrary (possibly nonmeasurable) sets. In this paper, we address some of these questions in rather general metric spaces and sets.
Standard assumptions in the area are that the metric space is complete and equipped with a globally doubling measure supporting a global p-Poincaré inequality. The integrability exponent for Sobolev functions and their gradients is often assumed to be p > 1, since this gives reflexive spaces and provides useful tools. At the same time, in many concrete situations, it is desirable to consider noncomplete spaces and to relax the global assumptions to local ones. Last, but not least, the case p = 1 is also attracting a lot of interest.
It was shown by Koskela [44, Theorem C] that a closed set E ⊂ R n of zero Lebesgue measure is removable for the Sobolev space W 1,p (R n \ E), with p > 1, if and only if R n \ E supports a p-Poincaré inequality. One of our results is that a similar equivalence holds also for p = 1 and for metric spaces, even noncomplete ones and with only local Poincaré inequalities. Moreover, we do not require E to be closed, only that its complement Ω is p-path almost open, i.e. for p-almost every curve γ, the preimage γ −1 (Ω) is a union of an open set and a set of zero 1-dimensional Lebesgue measure.
When specialized to weighted Euclidean spaces, as in Heinonen-Kilpeläinen-Martio [36], these results (obtained in Theorems 5.4 and 5.9) can be formulated as follows. Here we follow the notation of [36] and denote the weighted Sobolev and Dirichlet spaces by H 1,p (Ω, µ) and L 1,p (Ω, µ), respectively. These spaces coincide with N 1,p (Ω) and D p (Ω), with respect to µ, as defined in Section 5, see the discussion after Theorem 5.4. Theorem 1.1. Let 1 ≤ p < ∞ and dµ = w dx, where w is a p-admissible weight on R n in the sense of [36]. Let Ω = R n \ E, where µ(E) = 0. Assume that Ω is p-path almost open, which in particular holds if Ω is open.
When Ω is not open and in the metric setting, the Sobolev and Dirichlet spaces have to be interpreted by means of upper gradients as in Section 2.
Removable sets for Sobolev spaces is a classical topic, also related to sets of capacity zero and to singularities of quasiconformal mappings. We refer to Koskela [44] for further references and a much more extensive discussion. Among other results in [44], p-porous sets contained in a hyperplane were shown to be removable for H 1,p (and equivalently for the p-Poincaré inequality).
Removable sets for Poincaré inequalities in metric spaces were studied in Koskela-Shanmugalingam-Tuominen [46]. Their results on porous sets, together with our Theorems 1.1, 5.4 and 5.9, therefore provide examples of removable sets for Sobolev and Dirichlet spaces, see [46, Theorems A, B and Proposition 3.3]. Removability for Dirichlet spaces was not discussed in [44] or [46].
As mentioned in [46, p. 335], Koskela's proof can be generalized to metric spaces with global assumptions, provided that E is compact, its complement is connected and p > 1. We approach the problem from a different angle, though similar methods lie behind some of our arguments as well. Namely, we rely on extensions of Newtonian (Sobolev) functions from a noncomplete metric space X to its completion X, recently considered in [8] for p > 1.
To be able to handle also p = 1, we therefore first prove the following extension result. In addition, as in [8], we replace the global assumptions of a doubling measure and a 1-Poincaré inequality by weaker local conditions. These local assumptions, as well as the Newtonian and Dirichlet spaces N 1,p (X) and D p (X), will be defined in Section 2. Theorem 1.2. Assume that the doubling property and the 1-Poincaré inequality hold within an open set Ω ⊂ X in the sense of Definition 2.5. Let u ∈ D 1 (Ω). Let Ω ∧ = X \ X \ Ω, where the closure is taken in the completion X of X. Then there iŝ u ∈ D 1 (Ω ∧ ) such thatû = u C X 1 -q.e. in Ω and the minimal 1-weak upper gradients g u := g u,Ω of u and gû := gû ,Ω ∧ ofû, with respect to Ω and Ω ∧ , respectively, satisfy gû ≤ A 0 g u a.e. in Ω, where A 0 is a constant depending only on the doubling constant and both constants in the 1-Poincaré inequality within Ω. In particular, the functionû can be taken to beû (x) = lim sup If Ω is also 1-path open in X then we can, in the above conclusion (except for (1.1)), takeû ≡ u and gû ≡ g u in Ω.
The idea of the proof is to approximate u by discrete convolutions that immediately extend to Ω ∧ . This goes back to the aforementioned paper by Koskela [44,Theorem C] and is similar to [8] and Heikkinen-Koskela-Tuominen [34]. When 1 < p < ∞, one can use the reflexivity of L p to extract a weakly converging subsequence from the p-weak upper gradients of these discrete convolutions. In the case p = 1, we instead show that the sequence of 1-weak upper gradients is equi-integrable, and then apply the Dunford-Pettis theorem to obtain a weakly converging subsequence. In this way, at the limit we obtain the desired function u ∈ D 1 (Ω ∧ ). Just as in the case p > 1 considered in [8], we do not know whether it is ever necessary to have A 0 > 1.
To replace the usual global assumptions by similar local ones in our results, we apply a recent result of Rajala [51] about approximations by uniform domains. In particular, we extend results about measurability of functions with L p -integrable upper gradients (from [41]), about p-quasiopen, p-path and p-finely open sets (from [10], [11] and [48]), and about Lebesgue points for N 1,1 -functions (from [43]), to spaces that only satisfy local assumptions, see Section 3 and Proposition 4.11. These localized results are useful later on in the paper.
Observe that in Theorem 1.2 we do not require Ω to be measurable in X, see Section 4 for details. It is not known if Ω can satisfy the assumptions in Theorem 1.2 and at the same time be nonmeasurable in X. Nevertheless, in Section 6 we construct a measurable set in R 2 , with full measure and satisfying the conclusions in Theorems 1.1 and 1.2 (except for the last part), but which is not even p-path almost open in R 2 .
The role of p-path (almost) open sets in our arguments is that they preserve minimal p-weak upper gradients and sets with zero capacity, see Lemmas 4.1, 4.2 and Björn-Björn [5,Proposition 3.5]. In Section 7, we study these sets in more detail and prove the following characterization, which combines Theorems 3.7 and 7.3. Theorem 1.3. Assume that X is locally compact and that µ is locally doubling and supports a local p-Poincaré inequality, 1 ≤ p < ∞. Let U ⊂ X be measurable. Then the following are equivalent : is not possible for nonmeasurable p-path almost open sets. At the same time, we show that there are nonmeasurable p-path almost open subsets of R n , n ≥ 2, provided that the continuum hypothesis is assumed. Together with Theorem 1.3 and Example 7.7, this answers Open problem 3.4 in [5].
Quasiopen and finely open sets have earlier been used in various areas of mathematics. For example, quasiopen sets appear naturally as minimizing sets in shape optimization problems, see e.g. Buttazzo-Dal Maso [19], Buttazzo-Shrivastava [20,Examples 4.3 and 4.4] and Fusco-Mukherjee-Zhang [28]. They are also level sets of Sobolev functions and are thus (together with p-finely open sets) suitable for the theory of Sobolev spaces, see , Malý-Ziemer [49] and Fuglede [26], [27]. In this context, our Theorems 1.1, 5.4 and 5.9 fully characterize removable singularities with zero measure for Sobolev (and Dirichlet) spaces on p-quasiopen (and thus also p-finely open) sets. Finely open sets define the fine topology and are closely related to superharmonic functions. Fine potential theory on finely open sets has been studied since the 1940s, see Cartan [22] (the linear case, p = 2).
Acknowledgement. The authors wish to thank two anonymous referees for a very careful reading of the paper and for suggesting several improvements. The first two authors were supported by the Swedish Research Council, grants 2016-03424 and 2020-04011 resp. 621-2014-3974 and 2018-04106. This research began while the third author visited Linköping University in 2017 and 2018; he thanks the Department of Mathematics for its warm hospitality.

Upper gradients and Newtonian spaces
We assume throughout the paper, except for Section 5, that 1 ≤ p < ∞ and that X = (X, d, µ) is a metric space equipped with a metric d and a positive complete Borel measure µ such that 0 < µ(B) < ∞ for all balls B ⊂ X.
It follows that X is separable and Lindelöf. To avoid pathological situations we assume that X contains at least two points. Proofs of the results in this section can be found in the monographs Björn-Björn [4] and Heinonen-Koskela-Shanmugalingam-Tyson [38].
A curve is a continuous mapping from an interval, and a rectifiable curve is a curve with finite length. Unless said otherwise, we will only consider curves that are nonconstant, compact and rectifiable, and thus each curve can be parameterized by its arc length ds. A property is said to hold for p-almost every curve if it fails only for a curve family Γ with zero p-modulus. Here the p-modulus of Γ is with the infimum taken over all nonnegative Borel functions ρ on X such that γ ρ ds ≥ 1 for each γ ∈ Γ. Following Heinonen-Koskela [37], we next introduce upper gradients (called very weak gradients in [37]).
where the left-hand side is considered to be ∞ whenever at least one of the terms therein is infinite. If g : X → [0, ∞] is measurable and (2.1) holds for p-almost every curve, then g is a p-weak upper gradient of u.
The p-weak upper gradients were introduced in Koskela-MacManus [45]. It was also shown therein that if g ∈ L p loc (X) is a p-weak upper gradient of u, then one can find a sequence {g j } ∞ j=1 of upper gradients of u such that g j − g L p (X) → 0. If u has an upper gradient in L p loc (X), then it has an a.e. unique minimal p-weak upper gradient g u ∈ L p loc (X) in the sense that g u ≤ g a.e. for every p-weak upper gradient g ∈ L p loc (X) of u, see Shanmugalingam [54] and Haj lasz [30]. Following Shanmugalingam [53], we define a version of Sobolev spaces on the metric space X.
where the infimum is taken over all upper gradients g of u. The Newtonian space on X is , is a Banach space and a lattice, see Shanmugalingam [53]. We also define D p (X) = {u : u is measurable, finite a.e. and has an upper gradient in L p (X)}.
This definition deviates from the definition in [4,Definition 1.54] in that it requires the functions to be finite a.e., which will be useful in e.g. Theorem 5.7, see Remark 5.8. The two definitions coincide whenever X supports a local p-Poincaré inequality, since any measurable function with an upper gradient in L p (X) then belongs to L 1 loc (X), see [4,Proposition 4.13] and [8, p. 50]. In this paper we assume that functions in N 1,p (X) and D p (X) are defined everywhere (with values in R), not just up to an equivalence class in the corresponding function space. This is important for upper gradients to make sense.
For a measurable set E ⊂ X, the Newtonian space N 1,p (E) is defined by considering (E, d| E , µ| E ) as a metric space in its own right. We say that u ∈ N 1,p loc (E) if for every x ∈ E there exists a ball B x ∋ x such that u ∈ N 1,p (B x ∩ E). The spaces L p (E), L p loc (E), D p (E) and D p loc (E) are defined similarly. If u, v ∈ D p loc (X), then g u = g v a.e. in the set {x ∈ X : u(x) = v(x)}, in particular for c ∈ R we have g min{u,c} = g u χ {u<c} a.e. Moreover, if u, v ∈ D p (X), then |u|g v + |v|g u is a p-weak upper gradient of uv.
It is easily verified by gluing curves together that if g 1 and g 2 are upper gradients for a function u in the open sets G 1 and G 2 , respectively, then g 1 χ G1 + g 2 χ G2 is an upper gradient for u in G 1 ∪ G 2 . From this it follows that if u ∈ N 1,p (G j ), j = 1, 2, then u ∈ N 1,p (G 1 ∪ G 2 ). A similar sheaf property holds for D p .
where the infimum is taken over all u ∈ N 1,p (X) such that u = 1 on E.
We say that a property holds C X p -quasieverywhere (C X p -q.e.) if the set of points for which the property fails has zero C X p -capacity. The capacity is the correct gauge for distinguishing between two Newtonian functions. Namely, if v ∈ N 1,p (X) then u ∼ v if and only if u = v C X p -q.e. Moreover, if u, v ∈ D p loc (X) and u = v a.e., then u = v C X p -q.e. In this paper we will use many different C X p -capacities with respect to different metric spaces X; this will always be carefully denoted in the superscript.
Definition 2.4. An R-valued function u, defined on a set E ⊂ X, is C X p -quasicontinuous if for every ε > 0 there is an open set G ⊂ X such that C X p (G) < ε and u| E\G is R-valued and continuous.
For a ball B = B(x, r) with centre x and radius r, we let λB = B(x, λr). In metric spaces it can happen that balls with different centres and/or radii denote the same set. We will, however, make the convention that a ball comes with a predetermined centre and radius. In this paper, balls are assumed to be open.
Similarly, the p-Poincaré inequality holds within an open set Ω if there are constants C > 0 and λ ≥ 1 (depending on Ω) such that for all balls B ⊂ Ω, all integrable functions u on λB, and all upper gradients g of u in λB, where u B := B u dµ := B u dµ/µ(B) and r B is the radius of B.
Each of these properties is called local if for every x ∈ X there is r > 0 (depending on x) such that the property holds within B(x, r). The property is called semilocal if it holds within every ball B(x 0 , r 0 ) in X. If moreover C and λ are independent of x 0 and r 0 , then it is called global.
Note that there is a difference between a property holding within Ω ⊂ X (i.e. for balls taken in the underlying space X) and on Ω, seen as a metric space in its own right, where balls are taken with respect to Ω.
The p-Poincaré inequality can equivalently be defined using p-weak upper gradients. We will need the following characterization of the p-Poincaré inequality showing that it is enough to test with bounded u ∈ N 1,p (X). Lemma 2.6. Let Ω ⊂ X be open. Assume that there are constants C > 0 and λ ≥ 1 such that (2.2) holds for all balls B ⊂ Ω and all bounded u ∈ N 1,p (X). Then the p-Poincaré inequality holds within Ω with the same constants C and λ.
Proof. Let B = B(x, r) ⊂ Ω be a ball, u be an integrable function on λB, and g be an upper gradient of u in λB. We may assume that g ∈ L p (λB), as otherwise there is nothing to prove. Thus u ∈ D p (λB). For extended by zero outside λB. Then v j ∈ N 1,p (X) is bounded and g is an upper gradient of v j in λB j . Thus (2.2) applied to v j and B j gives The result now follows from the fact that u j → u in L 1 (B) as j → ∞.

From global to local assumptions
In this section we show how a recent result due to Rajala [51, Theorem 1.1] can be used to lift results, that have earlier been obtained under global assumptions, to spaces with only local assumptions. This will be useful later in our considerations. The main idea in this localization approach is to see suitable neighbourhoods of points in X as "good" metric spaces in their own right. Since balls may be disconnected and need not support a Poincaré inequality, they do not in general serve as such good neighbourhoods. Even when a ball, or its closure, is connected it can fail to support a Poincaré inequality and the measure may fail to be globally doubling on it. Instead, closures of the uniform domains constructed by Rajala [51] will do the job, since they are compact, support global Poincaré inequalities and the measure is globally doubling on them.
Recall that a space is geodesic if every pair of points can be connected by a curve whose length equals the distance between the points, and that a domain is an open connected set. A domain G ⊂ X is uniform if there is a constant A ≥ 1 such that for every pair x, y ∈ G there is a curve γ : [0, l γ ] → G with γ(0) = x and γ(l γ ) = y such that l γ ≤ Ad(x, y) and As usual, dist(x, ∅) = ∞. Moreover, X is globally doubling if there is a constant N such that every ball B(x, r) can be covered by N balls with radii 1 2 r. The following result was proved in [51] under the assumption that X is quasiconvex. In particular, it applies to geodesic spaces because their quasiconvexity constant is 1. ) Let X be a geodesic metric space and let U ⊂ X be a bounded domain. If U is globally doubling and ε > 0, then there is a uniform domain G such that Note that if U = X then X itself is a uniform domain and G = U = X above. In the definition of uniform domains it is often assumed that G X. Allowing G = X, as in [51], is convenient when formulating Theorems 3.1 and 3.2.
In [51] it is assumed that X is globally doubling, and approximation from outside by uniform domains is also deduced. However, when approximating from inside as in Theorem 3.1, it is easy to see that in the proof in [51] it is enough to apply [51, Lemma 2.1] with respect to U . It is therefore enough to assume that U is globally doubling, which makes it possible to deduce the following result.
Theorem 3.2. Assume that the p-Poincaré inequality and the doubling property for µ hold (with constants C PI , λ and C µ ) within B 1 = B(x 1 , r 1 ). Also assume that ΛB 1 is compact, where Λ = 3C 3 µ C PI . Then there is a bounded uniform domain G such that .
Moreover, µ| G and µ| G are globally doubling and support global p-Poincaré inequalities on the metric spaces G and G, respectively.

Proof of Theorem 3.2. Define the inner metric
where the infimum is taken over all curves γ ⊂ ΛB 1 connecting x and y. Let be the rectifiably connected component of ΛB 1 containing x 1 . As ΛB 1 is compact, it follows from Ascoli's theorem that (Y, d in,ΛB1 ) is a geodesic metric space. By Björn-Björn [6,Lemma 4.9], every pair of points x, y ∈ 1 5 B 1 can be connected by a curve in ΛB 1 , of length at most 9Λd(x, y). Hence, both 1 6 B 1 and The reason for using the inner metric is that inner balls are always connected, while standard balls, such as 1 6 B 1 , need not be connected.
By [6,Proposition 3.4], the ball 1 6 B 1 is globally doubling. As d and d in,ΛB1 are comparable within 1 6 B 1 , also (B in , d in,ΛB1 ) is globally doubling. Since (B in , d in,ΛB1 ) is connected, we can therefore apply Theorem 3.1 with respect to (Y, d in,ΛB1 ) and obtain a uniform domain G such that τ B 1 ⋐ G ⊂ B in . Note that since d and d in,ΛB1 are comparable within 1 5 B 1 and dist( 1 6 B 1 , X \ Y ) ≥ 1 30 r 1 , uniformity is the same with respect to (Y, d in,ΛB1 ) and (X, d) (although the uniformity constants may be different).
By Björn-Shanmugalingam [17, Lemmas 2.5 and 4.2], µ| G is globally doubling on G. Next, we use [17,Theorem 4.4], to see that µ| G supports a global p-Poincaré inequality on G. Since the proof of [17,Theorem 4.4] only uses balls contained (together with their dilations) in G, the proof applies under our assumptions. As µ(∂G) = 0, by Remark 3.3, the same conclusions hold for µ| G . (To see that the Poincaré inequality holds on G, one only needs to observe that if g is an upper gradient of u on G, then g| G is an upper gradient of u| G on G, see also [8,Proposition 3.6] for further details.) One result that can be obtained using Theorem 3.2 is the following extension of Theorem 1.11 in Järvenpää-Järvenpää-Rogovin-Rogovin-Shanmugalingam [41]. Since local assumptions are inherited by open subsets, it directly applies also to open Ω ⊂ X (in place of X), cf. Remark 4.8.
Theorem 3.4. Assume that X is locally compact and that µ is locally doubling and supports a local p-Poincaré inequality. Let g ∈ L p loc (X) be an upper gradient of u : X → R. Then u ∈ L p loc (X) and u is in particular measurable.
Proof. Let x ∈ X. It follows from Theorem 3.2 that there is a bounded uniform domain G x ∋ x such that G x is compact and µ| G x is globally doubling and supports a global p-Poincaré inequality on G x . In particular, g| Gx ∈ L p (G x ) is an upper gradient of u| Gx in G x and Theorem 1.11 in [41] shows that u| Gx is measurable and belongs to L p loc (G x ). As X is Lindelöf it follows that u is measurable on X and u ∈ L p loc (X).
Another consequence of Rajala's theorem is a characterization of p-path open sets under local assumptions. These sets will play a prominent role in our studies, since they preserve minimal p-weak upper gradients and sets with zero capacity, see Lemmas 4.1 and 4.2 below and Björn-Björn [5,Proposition 3.5]. The relation between p-path open and p-path almost open sets will be studied in Section 7. The p-modulus Mod p (Γ) of the exceptional curve family Γ can equivalently be measured within X or A, provided that A is equipped with the appropriate restrictionμ of µ to A. Since A may be nonmeasurable,μ is defined by letting for Borel sets E in A, and then completingμ. This makesμ into a complete Borel regular measure on A, which coincides with the restriction µ| A when A is µmeasurable. It also follows that every Borel functionρ on A has a Borel extension ρ to X such that Hence Mod p,A (Γ) = Mod p,X (Γ) as claimed. The relation betweenμ and µ is quite similar to the relation between µ andμ as discussed in the beginning of Section 4 and in the corrigendum of Björn-Björn [8], and the relation between µ X and µ Y in Section 5.
The two properties in Definition 3.5 are transitive, as shown by the following result. Note also that it follows from [4,Proposition 2.45 The corresponding result also holds if "p-path almost open" is replaced by "p-path open" throughout.
Proof. If G 1 is p-path almost open in G 3 , then it is p-path almost open in G 2 (in view of the discussion above) simply because every curve in G 2 is a curve in G 3 .
Conversely, assume that G 1 is p-path almost open in G 2 . Let Γ j , j = 1, 2, be the family of curves γ in G j+1 such that γ −1 (G j ) is not a union of an open set and a set of measure zero. Let Γ ′ be the family of curves in G 3 which contain a subcurve in Γ 1 . Then by assumption, [4, Lemma 1.34 (c)] and the discussion above, is a union of an open set A and a set of measure zero. Since A ⊂ R, it can be written as a countable or finite union of pairwise disjoint open intervals A j . Each A j can be written as an increasing countable union of compact intervals, and since γ / ∈ Γ ′ we see that A j ∩ γ −1 (G 1 ) is a union of an open set and a set of measure zero. Hence γ −1 (G 1 ) is a union of an open set and a set of measure zero. As The p-path open case is similar.
Next, we shall characterize p-path open sets in terms of p-quasiopen and p-finely open sets, under local assumptions. Such characterizations have been done under global assumptions, and as earlier in this section we will show how to "lift" them to local assumptions.
Every p-quasiopen set is measurable by [5,Lemma 9.3]. The family of p-quasiopen sets does not form a topology (in general) but it is closed under countable unions.
If E ⊂ A are bounded subsets of X, then the variational capacity of E with respect to A is where the infimum is taken over all u ∈ N 1,p (X) such that u ≥ 1 on E and u = 0 when p = 1. (The quotients in (3.1) and (3.2) are interpreted as 1 if the denominators therein are zero.) Note that, under the assumptions of Theorem 3.7 below, cap X p (B(x, r), B(x, 2r)) is comparable to µ(B(x, r))/r p for sufficiently small r, by e.g. [4, the proof of Proposition 6.16], and so the latter quantity could also be used in (3.1) and (3.2), as was done in e.g. Lahti [48].
The family of p-finely open sets forms the p-fine topology.
The following theorem gives the equivalence of (b)-(d) in Theorem 1.3, since µ(Z) = 0 whenever C X p (Z) = 0 (this follows directly from Definition 2.3).
Theorem 3.7. Assume that X is locally compact and that µ is locally doubling and supports a local p-Poincaré inequality. Let U ⊂ X. Then the following are equivalent. ]. We will use these results, and the proof below just shows how to lift them to local assumptions, without repeating the arguments.
Proof. We start by some preliminary observations. By Theorem 3.2, for every x ∈ X there is a bounded uniform domain G x ∋ x such that G x is compact and µ| Gx is globally doubling and supports a global p-Poincaré inequality on G x . As X is Lindelöf, there is a countable cover {G j } ∞ j=1 of X, where G j = G xj . We also note for later use that Proposition 3.3 in [11] (applied both to G j and to X as the underlying space) implies that U ∩ G j is p-quasiopen with respect to G j if and only if it is p-quasiopen with respect to G j , which in turn is equivalent to it being p-quasiopen with respect to X.
(a) ⇒ (b) For each j, the set U j := U ∩G j is p-path open in G j . By Theorem 1.1 in [11], we see that U j is p-quasiopen with respect to G j , and by the above argument also with respect to X. Hence U = ∞ j=1 U j is p-quasiopen in X.

(b) ⇒ (a) This is proved in Shanmugalingam [54, Remark 3.5], without any assumptions on X.
To prove the equivalence with (c), note that in the case p > 1, a set W ⊂ G j is p-finely open with respect to G j if and only if for every Moreover, it follows from e.g. [4, Lemma 2.24] that the capacities C Gj p and C X p have the same zero sets in G j and so It then follows from [ is p-quasiopen with respect to G j , and thus also with respect to X, by the above argument. Hence, U = ∞ j=1 U j is p-quasiopen in X.

Extending N 1,1 -functions to the completion X
The main goal of this section is to prove Theorem 1.2. We let X be the completion of X with respect to the metric d. The metric immediately extends to X. We extend the measure to X by defininĝ and then complete it to obtain a Borel regular measureμ. Saksman [52, Lemma 1] used a similar construction when studying globally doubling measures. Now X \ X either has zeroμ-measure or isμ-nonmeasurable. In both cases, µ in ( X \ X) = 0, where the inner measureμ in is defined bŷ (4.1) The latter equality follows from the fact thatμ is a complete Borel regular measure. Moreover,μ and thus for E ⊂ X we have It also follows that every µ-measurable (resp. Borel) function u : X → R has â µ-measurable (resp. Borel) extensionû : X → R such thatû| X = u and whenever at least one of the integrals exists. Conversely, it follows from the above definition ofμ that v| X is µ-measurable (resp. Borel) and whenever v : X → R isμ-measurable (resp. Borel) and one of the integrals exists. See the corrigendum of Björn-Björn [8] for further details; theμ-nonmeasurable case was unfortunately overlooked in the original paper.
The following two auxiliary results relate notions on X to the same notions on p-path (almost) open sets. Proof. This is proved verbatim as in Proposition 3.5 in Björn-Björn [5], with the obvious interpretations of the integrals with respect toμ. The only additional observation needed is that if Γ is a family of curves in G then by (4.3) and (4.4), where the infima are taken over all ρ ∈ L p (G, µ), ρ ∈ L p (Ω ∩ X, µ) andρ ∈ L p (Ω,μ) satisfying for all γ ∈ Γ, γ ρ ds ≥ 1 and γρ ds ≥ 1, respectively.
Since G is p-path open in X, for Mod p, X -almost all curves in Γ X E , the preimage γ −1 (G) is relatively open in [0, l γ ] and nonempty, and thus γ contains a nonconstant subcurve γ ′ ∈ Γ G E . Hence, by [4, Lemma 1.34 (c)] and (4.5), The reverse inequality is trivial. Together with (4.2), this concludes the proof.
The following examples show that there is no hope to obtain Lemma 4.2 for µ-measurable sets that are only p-path almost open in X.
Then G is the union of an open set and a set of Lebesgue measure zero, and is thus p-path almost open for all p ≥ 1, by Theorem 1.3. Moreover, and has zero as a p-weak upper gradient with respect to G. At the same time, the (n − 1)-dimensional Hausdorff measure of E is nonzero, and so by Adams [1, (12) Note that µ is globally doubling and supports a global 1-Poincaré inequality on R n , by Corollary 15.35 in Heinonen-Kilpeläinen-Martio [36] and Theorem 1 in Björn [16]. Since G is the union of an open set and a set of Lebesgue measure zero, it is p-path almost open for all p ≥ 1, by Theorem 1.3. Testing with u j (x) = min{1, −(log x n )/j} shows that Recall that for an open set Ω in X, we let where the closure is taken in X. This makes Ω ∧ into the largest open set in X such that Ω = Ω ∧ ∩ X. Note that X ∧ = X. We denote balls with respect to X by B or B(x, r) = {y ∈ X : d(x, y) < r}, and balls with respect to X by B. The inclusion B(x, r) ⊂ B(x, r) ∧ can be strict. If a function u : X → R has a (1-weak) upper gradient g on X, then clearly g| X is a (1-weak) upper gradient of u| X . The converse is not true in general, as seen e.g. in X = R \ Q ⊂ R = X, but Theorem 1.2 provides a converse under suitable assumptions.
For p > 1 the result corresponding to Theorem 1.2 was obtained in Björn-Björn [8,Theorem 4.1], where the reflexivity of L p was used through the application of [4, Lemma 6.2]). We shall now explain how Theorem 1.2 can be obtained for p = 1 using the Dunford-Pettis theorem (see e.g. Ambrosio-Fusco-Pallara [2, Theorem 1.38]) instead of reflexivity. In both cases, the proof is based on discrete convolutions and their gradients, as in Koskela [44, Proof of Theorem C] and Heikkinen-Koskela-Tuominen [34].
Let λ ≥ 1 and Ω ⊂ X be an open set such that the doubling property holds within Ω. For each k = 1, 2, ... , consider a Whitney-type covering of Ω by balls {B ik } i with radii r ik ≤ 1/k and a subordinate Lipschitz partition of unity {ϕ ik } i so that (i) the balls 1 5 B ik are pairwise disjoint, and 80λB ik ⊂ Ω for all i; Here m and C are constants depending only on λ and the doubling constant C µ of µ within Ω.
For each fixed k, we can construct the covering as follows: For each x ∈ Ω, let t x be the smallest nonnegative integer such that Since X is separable and {B(x, r x )} x∈Ω covers Ω, we can use the 5B-covering lemma (see e.g. Heinonen-Koskela-Shanmugalingam-Tyson [38, p. 60]) to find an at most countable cover of Ω by balls B ik := B(x ik , r ik ), r ik = r x ik , such that the balls 1 5 B ik are pairwise disjoint. Property (i) is now easy to verify. For (iii) we have from (4.7), when 10λB ik ∩ 10λB jk = ∅, so that 7r jk ≤ dist(x ik , X \ Ω)/10λ + r ik . From (4.7) we get Combining these gives and, by construction, the quotient r jk /r ik can only take dyadic values. For a fixed i, let J i = {j : 10λB ik ∩ 10λB jk = ∅}. If j ∈ J i then it follows from (iii) that B jk ⊂ 40λB ik . The ball 40λB ik is a globally doubling metric space, by Björn-Björn [6,Proposition 3.4], with a doubling constant only depending on C µ . As the balls {B(x jk , 1 10 r ik )} j∈Ji are pairwise disjoint, property (ii) is satisfied with m only depending on λ and C µ .
Finally, a Lipschitz partition of unity satisfying (iv) and (v) can now be constructed as in [38, pp. 104-105]. The Then the sequence {g k } ∞ k=1 is equi-integrable. Moreover, a subsequence of g k converges weakly in L 1 (Ω) to a functiong satisfyingg ≤ mg a.e. in Ω, where m is as in (4.6).
Proof of Theorem 1.2. We want to extend u ∈ D 1 (Ω) and its minimal 1-weak upper gradient g u := g u,Ω to Ω ∧ . Consider the above Whitney-type covering and Lipschitz partition of unity (extended continuously to Ω ∧ ). As is an upper gradient of u k in Ω ∧ . Moreover, by (4.6) and the doubling property of µ, we have for every Lebesgue point x ∈ Ω of u that as k → 0. Since µ is doubling within Ω and u ∈ L 1 loc (Ω) (see Remark 4.8 below), u has Lebesgue points a.e., by e.g. Heinonen [35,Theorem 1.8]. We thus conclude that u k → u a.e. in Ω.
Lemma 4.6 shows that the sequence {g k } ∞ k=1 ⊂ L 1 (Ω) is equi-integrable and there exists a subsequence (also denoted {g k } ∞ k=1 ) converging weakly in L 1 (Ω) (and hence also in L 1 (Ω ∧ )) to a function g such that g ≤ C 0 mg u a.e. in Ω.
If Ω is 1-path open in X then also the capacities C Ω 1 and C X 1 have the same zero sets in Ω, by Lemma 4.2. This shows that we may chooseû = u in Ω. Lemma 4.1 then shows that g u = gû a.e. within Ω.
Finally, ifũ is defined to be the right-hand side of (1.1), thenû =ũ at all Lebesgue points ofû, i.e. C X p -q.e. in Ω ∧ , by the proof of Proposition 4.11 below with G = Ω ∧ . Hence,û may also be chosen so that it satisfies (1.1).  Proposition 4.9. Assume that µ is locally doubling and supports a local 1-Poincaré inequality on X. Then for every u ∈ N 1,1 loc (X) there is an open set G ⊃ X in X and a functionû ∈ N 1,1 loc ( G) such that u =û C X 1 -q.e. on X. Moreover, G is locally compact and µ| G is locally doubling and supports a local 1-Poincaré inequality.
If X is 1-path open in X, then one can chooseû ≡ u and gû ≡ g u in X.
Note that the set G in general depends on u, cf. Björn-Björn [8,Example 4.7].
Proof. Since X is Lindelöf, we can find a countable cover of X by balls B j = B(x j , r j ) ⊂ X such that u ∈ N 1,1 (B j ) and both the 1-Poincaré inequality and the doubling property for µ hold within each B j , j = 1, 2, ... . Let B j = B(x j , r j ) and G = ∞ j=1 B j . Using Theorem 1.2, we can extend u| Bj toû j ∈ N 1,1 ( B j ) so thatû j = u C X 1 -q.e. in B j , j = 1, 2, ... . Thenû i =û j a.e. (and hence C X 1 -q.e.) in B i ∩ B j for all i, j. We can thus constructû ∈ N 1,p loc ( G) so thatû = u C X 1 -q.e. in X and gû ≤ A j g u a.e. in B j , where A j is the constant provided by Theorem 1.2 in B j . Henceû ∈ N 1,1 loc ( G). If X is 1-path open in X, then it follows from the last part of Theorem 1.2 that we can chooseû ≡ u and gû ≡ g u in X.
The following two results are now relatively easy consequences of the above extension to G ⊂ X and the corresponding results in complete spaces. Recall the definition of quasicontinuity from Definition 2.4. Corollary 4.10. Assume that µ is locally doubling and supports a local 1-Poincaré inequality on X, and that X is 1-path open in X. Then every u ∈ N 1,1 loc (X) is C X 1 -quasicontinuous.
Proof. Find a locally compact open set G ⊂ X and a functionû ∈ N 1,1 loc ( G) as in Proposition 4.9 withû ≡ u in X and so that µ| G is locally doubling and supports a local 1-Poincaré inequality. It then follows from Theorem 9.1 in Björn-Björn [6] thatû is C G 1 -quasicontinuous on G, which immediately yields that u is C X 1 -quasicontinuous on X, since C X 1 is dominated by C G 1 .
Proposition 4.11. Assume that µ is locally doubling and supports a local 1-Poincaré inequality on X. Then every u ∈ N 1,1 loc (X) has Lebesgue points C X 1 -q.e., and moreover the extensionû in Proposition 4.9 can be given bŷ The proof below shows that the limit lim r→0 B(x,r) u dµ actually exists for C X 1 -q.e. x ∈ X, even though it only equals u(x) for C X 1 -q.e. x. In general, C X 1 ≤ C X 1 , but it follows from Lemma 4.2 that they have the same zero sets if X is 1-path open in X. and [43, Theorem 4.1 and Remark 4.7] implies thatũ has Lebesgue points at C X 1 -q.e. x ∈ X. Clearly, for 0 < r < 1, 2rµ(B(x, r)), which implies that x ∈ X is a Lebesgue point of u if and only if (x, t) ∈ X is a Lebesgue point ofũ for some (and equivalently all) t ∈ (−1, 1). Hence, if E ⊂ X is the set of non-Lebesgue points of u, then C X 1 (E × (−1, 1)) = 0 and for every ε > 0 there existsṽ ∈ N 1,1 ( X), with an upper gradient g, such thatṽ ≥ 1 on E × (−1, 1) and Then there exists t ∈ (−1, 1) such that X (|v(x, t)| + g(x, t)) dµ(x) < ε. (4.9) Clearly, g(·, t) is an upper gradient of v(·, t) with respect to X and v(·, t) is admissible for C X 1 (E). It therefore follows from (4.9) that C X 1 (E) < ε. Letting ε → 0 now shows that C X 1 (E) = 0 and so u has Lebesgue points C X 1 -q.e. in X.
Proof of Proposition 4.11. Find G andû ∈ N 1,1 loc ( G) as in Proposition 4.9. Let x ∈ G. As G is locally compact, it follows from Theorem 3.2 that there is a bounded uniform domain G x in X such that x ∈ G x ⋐ G and such that µ| G x is globally doubling and supports a global p-Poincaré inequality on G x , where the closure is taken with respect to X. In particular,û ∈ N 1,1 (G x ).
By [ and C X 1 have the same zero sets in G x . Hence as G is Lindelöf,û has Lebesgue points C X 1 -q.e. in G, and so u has Lebesgue points C X 1 -q.e. in X. Finally, ifũ is given by the right-hand side of (4.8), thenû =ũ at all Lebesgue points ofû, i.e. C X p -q.e. in G. Hence,û may also be chosen so that it satisfies (4.8).
Even for u ∈ N 1,1 (X), (the proof of) Proposition 4.9 only guarantees an extension in the local Newtonian space N 1,1 loc ( G) (but with G independent of u), unless X is 1-path open in X. However, under slightly stronger uniform assumptions we can obtain the following partial nonlocal conclusion, which also includes p > 1, see [8,Remark 4.10].
Proposition 4.13. Assume that there are constants C µ , C PI and λ such that for each x ∈ X, there is r x > 0 such that µ is doubling within B x = B(x, r x ) with constant C µ and µ supports a p-Poincaré inequality within B x with constants C PI and λ.
Then there is an open set G ⊃ X in X such that for every u ∈ N 1,p (X), the functionû given by (4.8) satisfiesû = u C X p -q.e. on X and belongs to N 1,p ( G). If also r x is independent of x then we may choose G = X.
Such assumptions are called semiuniformly local, and uniformly local in the case where r x is independent of x, in [6, Definition 6.1]. Riemannian manifolds always support at least semiuniformly local assumptions and often uniformly local ones. Uniformly local assumptions are natural e.g. on Gromov hyperbolic spaces, see Björn-Björn-Shanmugalingam [14], [15] and Butler [18]. Semiuniformly local assumptions were also used by e.g. Holopainen-Shanmugalingam [39].
Proof. Let B x = B(x, r x ) and G = x∈X B x . By [8, Proposition 4.8 and the proof of Lemma 4.6] (for p > 1) or Proposition 4.11 and the proof of Proposition 4.9 (for p = 1), we get thatû ∈ N 1,p loc ( G). By [8, Theorem 4.1] (for p > 1) and Theorem 1.2 (for p = 1), we see that gû ≤ A 0 g u a.e. in X, where A 0 only depends on p, C µ , C PI and λ. Thus i.e.û ∈ N 1,p ( G). If r x is independent of x, then clearly G = X.

Removable sets for Newtonian spaces
We assume in this section that 1 ≤ p < ∞ and that Y = (Y, d, µ Y ) is a metric measure space equipped with a metric d and a positive complete Borel measure µ Y such that 0 < µ Y (B) < ∞ for all balls B ⊂ Y . Moreover, X ⊂ Y is such that Y ⊂ X. We also let E = Y \ X and assume that the inner measure satisfies Our main interest in this section is removability of sets with zero measure, i.e. when X ⊂ Y are two metric spaces with µ Y (Y \ X) = 0. In order to be able (as before) to include the case when Y = X and X is a nonmeasurable subset of Y , we merely impose the condition (5.1). This will only necessitate a little extra care in some of the formulations. At the end of this section we give examples of nonmeasurable removable sets with zero inner measure. Removability of sets with positive measure is a different topic, related to extension domains, see e.g. Haj lasz-Koskela-Tuominen [31] and Björn-Shanmugalingam [17, Section 5]. As in (4.1), it follows that Since we want Y to satisfy our standing assumption that balls have positive measure, necessarily Y ⊂ X = Y . In the nonmeasurable case, we cannot just let µ X = µ Y | X , but need to define µ X by letting This is well-defined since µ Y,in (E) = 0, and makes µ X into a complete Borel regular measure on X, which coincides with the restriction µ Y | X when X is µ Y -measurable. We note that q.e. defined equivalence classes may depend on whether the capacity is C X p or C Y p , whereas the a.e. condition coincides in both spaces, due to (4.2). So for simplicity we restrict the discussion to removability with respect to the following spaces, where we implicitly assume that u : X → R is defined pointwise in X: In both cases we define g u = g v . This is well-defined a.e. and independent of the choice of v such that v = u a.e. The spaces N 1,p (Y ) and D p (Y ) are defined similarly.
Definition 5.1. The set E = Y \X is removable for N 1,p (X) if N 1,p (X) = N 1,p (Y ) in the sense that N 1,p (X) = {u| X : u ∈ N 1,p (Y )}. If moreover, g u,X = g u,Y a.e. in X for every u ∈ N 1,p (Y ), then E is isometrically removable for N 1,p (X).
Removability and isometric removability for D p (X) are defined similarly.
It is easily seen that removability for N 1,p is the same as for the corresponding spaces of a.e.-equivalence classes e. However to make it clearer what exactly is meant, especially in the nonmeasurable case, we prefer to work with the spaces N 1,p of pointwise defined functions. In fact, the proofs below show that when E is removable then any µ Y -measurable extension of u from X to Y will do the job.
Note also that the quotient spaces in (5.3) are Banach spaces. Since clearly u N 1,p (X) ≤ u N 1,p (Y ) , the bounded inverse theorem shows that the norms in these spaces are equivalent when E is removable for N 1,p (X).
As a first observation we deduce the following result.
Note that no assumptions on Y are needed (other than the standing assumptions from the beginning of this section) and that X is automatically measurable in this case, since µ Y (E) = 0 (which follows directly from Definition 2.3).
Proof. Letû ∈ D p (X) and let u ∈ D p (X) be such that u =û a.e. in X. Let g be any p-weak upper gradient of u in X. Extend u and g by 0 to Y \X. Note that as X is measurable so are u and g. Since C Y p (E) = 0, it follows from [4, Proposition 1.48] that p-almost no curve in Y hits E. Hence g is a p-weak upper gradient of u also on Y . Since u =û a.e. in X, any extension ofû to Y will coincide with u a.e. in Y and so belongs to D p (Y ). Thus E is isometrically removable both for N 1,p (X) and D p (X). Example 5.3. Let Y = R n , n ≥ 2, 1 ≤ p ≤ n and let E ⊂ R n be a countable or finite set. Then it is well known that C R n p (E) = 0, and thus E is isometrically removable for N 1,p (R n \ E) and D p (R n \ E), by Proposition 5.2.
If E ⊂ H is dense in a hyperplane H, then E = H is not removable for N 1,p (R n \ E) nor for D p (R n \ E). This follows from Theorem 5.4 below since R n \ H is disconnected and hence does not support any global Poincaré inequality.
This shows that removability for nonclosed sets cannot be achieved by only studying removability of their closures. In Proposition 6.4 we give a much more general result which includes this example as a special case.
The following is the main result in this section.
Theorem 5.4. Assume that µ Y is globally doubling and supports a global p-Poincaré inequality on Y . Consider the following statements: (e) X supports a global p-Poincaré inequality with the same C and λ as on Y .
(f) X supports a global p-Poincaré inequality.
If in addition X is p-path almost open in Y , then (a)-(f) are all equivalent.
As mentioned in the introduction, this generalizes Theorem C in Koskela [44], see also p. 335]. Koskela obtained such a characterization of removability for W 1,p (R n \ E) on unweighted R n , with p > 1 and E closed (and thus X = R n \ E open and hence p-path almost open). In the classical situation, on unweighted R n , our result thus extends Koskela's result to p = 1. The classical Sobolev spaces W 1,p (R n ) and W 1,p (R n \ E), for E closed, coincide with N 1,p (R n )/ ae ∼ and N 1,p (R n \ E)/ ae ∼ (with the same norm), respectively, by Theorem 7.13 in Haj lasz [30] (or [4,Corollary A.4]). This is true also in weighted Euclidean spaces, for p-admissible weights when p > 1, see [4,Proposition A.12]. (A weight w is p-admissible if dµ = w dx is a globally doubling measure supporting a global p-Poincaré inequality.) For p = 1 and a 1-admissible weight, Proposition 4.26 in Cheeger [23], together with the arguments in [4,Propositions A.11 and A.12], implies that the norms are comparable, see also Eriksson-Bique-Soultanis [24].
Theorem 6.1 below shows that the assumptions in Theorem 5.4 can be fulfilled without X being p-path almost open in Y = X, and that even in this case it is possible that (a)-(f) all hold. Some of the implications hold under weaker assumptions and we begin with deducing them.
Proof. Let u ∈ N 1,p (X). Since u ∈ D p (X) and E is removable for D p (X), there existsû ∈ D p (Y ) such thatû = u in X. As û L p (Y ) = u L p (X) < ∞ by (5.2), we see thatû ∈ N 1,p (Y ). Hence E is removable for N 1,p (X).
Proposition 5.6. Assume that µ X is doubling and supports a p-Poincaré inequality within an open set Ω ⊂ X. Then E ∩ Ω ∧ is removable both for N 1,p (Ω) and D p (Ω).
Theorem 5.7. The set E is isometrically removable for N 1,p (X) if and only if it is isometrically removable for D p (X).
Proof. Assume first that E is isometrically removable for D p (X). By Proposition 5.5, the set E is removable for N 1,p (X). As the removability for D p (X) is isometric, it follows directly from the definition that E is isometrically removable also for N 1,p (X).
Conversely, assume that E is isometrically removable for N 1,p (X). Let u ∈ D p (X) and let v ∈ D p (X) be such that v = u a.e. in X. First consider the case when u ≥ 0, so that we can assume also v ≥ 0. Fix x 0 ∈ X and let Then u k ∈ N 1,p (X) and there isû k ∈ N 1,p (Y ) such thatû k = u k a.e. in X, and thus C X p -q.e. in X. Asû k+1 ≥û k a.e., it follows from Corollary 1.60 in [4] that u k+1 ≥û k C Y p -q.e., and thus we can chooseû k+1 so thatû k+1 ≥û k everywhere. Henceû = lim k→∞ûk is well-defined pointwise.
Next, letĝ = g u,X , extended measurably to Y \X. By the isometric removability and truncation, gû k ,Y = g u k ,X ≤ĝ a.e. in B Y (x 0 , k), and thusĝ is a p-weak upper gradient ofû k in B Y (x 0 , k). Since by (5.2), it follows from Lemma 1.52 in [4] thatĝ is a p-weak upper gradient ofû in each B Y (x 0 , k) and hence in Y . Thereforeû ∈ D p (Y ), and clearlyû = u a.e. in X. Now any µ Y -measurable extension of u will coincide withû a.e. in Y and so belongs to D p (Y ). For general u we write u = u+ − u−, extend u+ and u− as above, and take their difference. Thus E is isometrically removable for D p (X).
Remark 5.8. In the proof of Theorem 5.7, we used the fact that functions in D p (X) are finite a.e. when applying [4,Lemma 1.52]. This is the reason why our definition of D p (X) slightly deviates from the one in [4], see Section 2. It may also be more natural to only consider functions that are finite a.e. (c) ⇒ (e) Let u ∈ N 1,p (X) ⊂ N 1,p (X). As E is isometrically removable for N 1,p (X), there isû ∈ N 1,p (Y ) such thatû = u a.e. in X and gû ,Y = gû ,X = g u,X a.e. in X, see Section 2. Let B X = B X (x, r) be a ball in X, and B Y = B Y (x, r) be the corresponding ball in Y . Then in view of (5.2) and using the Poincaré inequality on Y , Thus X supports a global p-Poincaré inequality with the same constants C and λ as on Y , by Lemma 2.6. (e) ⇒ (f) This is trivial. (f) ⇒ (b) It follows directly from (5.2) that µ X is globally doubling on X. Hence this implication follows from Proposition 5.6. Under local assumptions we obtain the following result. Recall that local assumptions are inherited by open sets and thus X and Y in the following theorem can be replaced by Ω ∩ X and Ω, respectively, for any open set Ω ⊂ Y , cf. Remark 4.8.
Theorem 5.9. (Local version) Assume that µ Y is locally doubling and supports a local p-Poincaré inequality on Y . Consider the following statements: (a) E is removable for N 1,p (X).
(e) Whenever x ∈ X and the Poincaré inequality (2.2) holds for a ball B Y (x, r) in Y , it holds for the ball B X (x, r) in X with the same constants C and λ. (f) There is a cover of Y by at most countably many balls B Y,j = B Y (x j , r j ), x j ∈ X, such that the p-Poincaré inequality holds within each ball B X,j = B X (x j , r j ).
If in addition X is p-path almost open in Y , then (a)-(f) are all equivalent.
Note that Y = R with E = {0} shows that in order for the equivalences in the last part to hold it is not possible to replace (f) by the assumption that "X supports a local p-Poincaré inequality". (f) ⇒ (b) Since µ Y is locally doubling on Y , we may assume that the cover B Y,j has been chosen so that µ Y is doubling within each B Y,j . It follows directly from (5.2) that µ X is doubling within each B X,j . Letû ∈ D p (X). Then there is u ∈ D p (X) such that u =û a.e. in X. Note that Y ⊂ X.
Using Theorem 1.2 (when p = 1) and [8, Theorem 4.1] (when p > 1), we can find u j ∈ D p (B Y,j ) such that u j = u C X p -q.e. in B X,j , j = 1, 2, ... . As u i , u j ∈ D p (B Y,i ∩ B Y,j ) and the set {y ∈ B Y,i ∩ B Y,j : u i (y) = u j (y)} has measure zero, it must be of zero C Y p -capacity for all i, j. We can thus construct v ∈ D p loc (Y ) such that v = u j C Y p -q.e. in B Y,j , j = 1, 2, ... , and hence v = u C X p -q.e. in X. Since X is p-path almost open in Y , we have g uj ,Y = g u,X a.e. in B X,j , by Lemma 4.1. As every curve γ in Y is compact, it can be covered by finitely many B Y,j . From this it follows that g u,X (extended measurably to Y \ X) is a p-weak upper gradient also of v in Y , and thus v ∈ D p (Y ). Since v =û a.e. in X, any µ Y -measurable extension ofû will belong to D p (Y ). Hence E is removable for D p (X).
The following result, albeit a bit trivial, gives us plenty of examples of nonmeasurable removable sets with zero inner measure. Consider e.g. Y to be the von Koch snowflake curve (see e.g. [4, Example 1.23]) and X ⊂ Y be any nonmeasurable subset with full outer measure.
Proposition 5.10. Assume that there are no or p-almost no curves in Y , i.e. that Mod p,Y (Γ) = 0, where Γ is the collection of all nonconstant rectifiable curves in Y . Then any E ⊂ Y satisfying (5.1) is isometrically removable for N 1,p (X) and D p (X).
Proof. In this case g u = 0 a.e. for every measurable function u on X or Y , and so N 1,p (X) = N 1,p (X) = L p (X) and N 1,p (Y ) = N 1,p (Y ) = L p (Y ). It thus follows directly from (5.2) that E is removable for N 1,p (X). Since g u,X = g u,Y a.e. in X, the removability is isometric. By Theorem 5.7, E is isometrically removable also for D p (X).

Extension from a non-p-path almost open set
We are now going to construct a set X ⊂ R 2 which satisfies the assumptions in Theorem 1.2 but is not p-path almost open in R 2 . However, its complement is isometrically removable for N 1,p (X) and D p (X).
We first construct a planar Cantor set C ⊂ [0, 1] × [0, 1] as follows. Let H 0 = [0, 1] and for every k = 0, 1, ... , let H k+1 be the set obtained by removing from the centre of every interval in H k the open interval of length 2 −2k−1 . Then let C = ∞ k=1 (H k × H k ) which is a planar Cantor set. This set projects (orthogonally) onto full intervals on the lines y = ± 1 2 x + c and y = ±2x + c, (6.1) but has zero length projections on all other lines. This is easy to check by sketching the set H 1 ×H 1 and then noting the self-similarity of the construction. In particular, C has 1-dimensional Hausdorff measure 0 < H 1 (C) < ∞ (where the latter inequality is easy to show). The Cantor set C is often called the four corners Cantor set, as well as the Garnett-Ivanov set in complex analysis, since Garnett [29] and Ivanov [40, footnote on p. 346] (independently) showed that it is removable for bounded analytic functions. 1 Let next {q j } ∞ j=1 be an enumeration of Q 2 and define i.e. we shift C by all rational numbers and take the union. We are now going to show the following properties for X = R 2 \ A. Proof. (a) Let u ∈ N 1,p (Ω). Then u is absolutely continuous on p-almost every curve in Ω, by Proposition 3.1 in Shanmugalingam [53] (or [4, Theorem 1.56]). Let l be any line which is not among those in (6.1). The orthogonal projection of C, and thus of A, on l has zero length. Hence almost every line in R 2 , which is perpendicular to l, does not intersect A. Thus, by [4, Lemmas 2.14 and A.1], u is absolutely continuous along the intersection of almost every such line with Ω ′ and the corresponding directional derivative u ′ d of u satisfies |u ′ d | ≤ g u,Ω a.e. (Note that L 2 (Ω ′ \ Ω) = 0.) In particular, u ∈ ACL(Ω ′ ) and thus u ∈ W 1,p (Ω ′ ) = N 1,p (Ω ′ )/ ae ∼, by e.g. Theorem 2.1.4 in Ziemer [57]. Since we have only excluded four directions of lines for l, the distributional gradient of u satisfies |∇u| ≤ g u,Ω a.e. in Ω ′ . Thus, Fix γ ∈ Γ 0 , t ∈ R and ε > 0. We then find i, j such that 4 −i < ε/2 and γ(t) ∈ q j + [0, 4 −i ] × [0, 4 −i ]. As explained above, the line γ intersects q j + 4 −i C and so there is s ∈ R with |s − t| < ε such that γ(s) ∈ q j + 4 −i C ⊂ A. It follows that γ −1 (A) is dense in R but of zero 1-dimensional Lebesgue measure. The lines γ ∈ Γ 0 are not rectifiable curves since they are not of finite length, but we can define Γ as the collection of all compact line segments on these lines that also belong to Ω ′ . Let γ : [0, l γ ] → Ω ′ , γ ∈ Γ, be an arc-length parameterized curve. Then by the above argument, γ We equip Y with the Lebesgue measure, which is globally doubling on Y . Then Y supports a global p-Poincaré inequality, by [4,Example A.23]. The same proof also shows that X supports a global p-Poincaré inequality. By Theorem 1.3, X is p-path almost open in Y . Thus, by Theorem 5.4, E is isometrically removable for N 1,p (X). Note that the closure E (taken in Y or, equivalently, R 2 ) separates Y and thus is not removable for N 1,p (Y \ E).
Since p > 2 it is well known that By adding a weight, we now modify the previous example to cover all p ≥ 1. Example 6.3. Let Y , E and X be as in Example 6.2, but this time we equip Y with the measure dµ = w dx, where w(x) = |x| −1 , which is globally doubling on Y . Then Y supports a global 1-Poincaré inequality, by [4,Example A.24]. The same proof also shows that X supports a global 1-Poincaré inequality. By Theorem 1.3, X is p-path almost open in Y for every p ≥ 1. Thus, by Theorem 5.4, E is isometrically removable for N 1,p (X). Note that E separates Y and thus is not removable for We shall see that X is not p-path open in Y for any p ≥ 1. This will be done by showing that E is not 1-thin at 0 = (0, 0) and hence that X is not 1-finely open.  (E ∩ B(0, b), B(0, 2b)) and let g be an upper gradient of u. Then for each 0 < a < b, since g is an upper gradient, u(a, 0) = 1 and u(a, 2b) = 0. It follows that Hence, by taking infimum over all such u and g, we see that Testing with u(x) = min{(2b − |x|)/b, 1}+ shows that cap Y 1 (B(0, b), B(0, 2b)) ≤ π, and so E is not 1-thin at 0 by the definition (3.2), and thus X is not 1-path open in Y .
With a bit more work we can create similar examples of removable sets E with non-p-path open complements in unweighted R n . Moreover, it can be done so that any E ′ ⊃ E with p-path open complement is not removable.
We start with the following result. As in Example 5.3 this gives a lot of examples of removable sets whose closure is not removable.
Let p > 2 − d, where 0 ≤ d ≤ 1 is the Hausdorff dimension of A. Note that all p > 1 are included when dim H A = 1 and L 1 (A) = 0. It follows from Proposition 6.4 that E is removable for N 1,p (X). As E is contained in the hyperplane H := R n−1 × {0}, X is a union of the open set R n \ H and a set of measure zero, and thus p-path almost open in R n , by Theorem 1.3. We shall now show that X is not p-path open in R n .
By Theorem 3.7, this amounts to showing that C R n p (X \ fine-int X) > 0, where fine-int X denotes the p-fine interior of X, which consists of all points x ∈ X for which see Theorem 2.136]. We alert the reader that it is not enough to show that C R n p (X \ int X) > 0, since e.g. the complement of any countable dense set in R n , n ≥ p, is p-path open but has empty interior.
Then, by the scaling property and translation invariance of cap R n p together with the construction of E, B(0, 1), B(0, 5)) =: C 0 r n−p .
Since A 0 is (d + n − 2)-dimensional and p > 2 − d, it follows from e.g. Heinonen-Kilpeläinen-Martio [36,Theorem 2.26] that C 0 > 0. It is crucial here that C 0 , by its definition above, only depends on the set A fixed at the beginning, and not on the ball B(x, r). Similarly, , r), B(x, 2r)) = Cr n−p for some C > 0.
Hence for all r = 2 1−i , i = 1, 2, ... , and inserting this into the Wiener criterion (6.3) shows that x / ∈ fine-int X, and hence fine-int X = R n \ H. Moreover, H \ E has infinite (n − 1)-dimensional Hausdorff measure and thus by e.g. [36,Theorem 2.26] again, i.e. X is not p-path open, by Theorem 3.7. It also follows that if E ′ ⊃ E is any set such that X ′ = R n \ E ′ is p-path open (and L n (E ′ ) = 0), then C R n p (H ∩ X ′ ) = 0. Since H ∩ X ′ separates X ′ , it follows that X ′ cannot support a p-Poincaré inequality and thus E ′ is not removable for N 1,p (X ′ ), by Theorem 5.4. Thus the removability of E cannot be achieved by considering larger sets with p-path open complements.

p-path almost open sets
Despite the example given in Theorem 6.1, p-path almost open sets played a rather central role in our studies of removable sets in Section 5. In this section, we therefore characterize p-path almost open sets, and in particular answer Open problem 3.4 in Björn-Björn [5], which asked whether every p-path almost open set can be written as a union of a p-path open set and a set of a measure zero. We give an affirmative answer for measurable sets, under natural assumptions. At the same time, we also answer it in the negative for nonmeasurable sets in unweighted R n , n ≥ 2, and give a measurable counterexample with a nondoubling underlying measure on R.
We call a set N ⊂ X p-path negligible if for p-almost every arc-length parameterized curve γ we have L 1 (γ −1 (N )) = 0, where L 1 denotes the Proposition 7.1. Assume that µ is locally doubling and supports a local p-Poincaré inequality. Let N ⊂ X be measurable and p-path negligible. Then µ(N ) = 0.
Proposition 7.5 below shows that the measurability assumption cannot be dropped.
Proof. First we make the following observation: if u ∈ N 1,p (X), then the minimal p-weak upper gradient satisfies g u = 0 a.e. in N . To see this, note that for p-almost every curve γ, we have L 1 (γ −1 (N )) = 0 and so γ g u ds = γ g u χ X\N ds.
Thus g u χ X\N is also a p-weak upper gradient of u, and then by the minimality of g u , we must have g u = 0 a.e. in N .
By the local p-Poincaré inequality, we have for all sufficiently large i that the sphere ∂ 5 2 B i is nonempty and where c i := 3Bi η i dµ is the integral average. Considering the cases c i ≤ 1 2 and c i ≥ 1 2 separately, we conclude that the left-hand side satisfies by the local doubling property (and for large i). On the other hand, the right-hand side satisfies 1 i 3Bi , which tends to zero as i → ∞, since x is a density point of N . This contradicts (7.1), and so we have the result.
Next we prove the following characterization of p-path almost open sets. Note that it applies also to nonmeasurable sets. Proof. If U = V ∪ N , where V is p-path open and N is p-path negligible, then it is easy to see that U is p-path almost open.
Conversely, suppose that U is p-path almost open. Now the family Γ of curves γ, for which γ −1 (U ) is not the union of an open set and a set of zero 1-dimensional Lebesgue measure, has zero p-modulus, i.e. there is a Borel function 0 ≤ ρ ∈ L p (X) such that γ ρ ds = ∞ for every γ ∈ Γ, see [4,Proposition 1.37].
Assume first that U is bounded and let B be a ball containing a 1-neighbourhood of U . Define where the infimum is taken over all rectifiable curves (including constant curves) from x to X \U . Then u = 0 in X \U , and ρ+χ B is an upper gradient of u, by Björn-Björn-Shanmugalingam [ [41] (or Theorem 3.4), u is measurable. As u and U are bounded and ρ ∈ L p (X), it follows that u ∈ N 1,p (X). Let V = {x ∈ U : u(x) > 0} = {x ∈ X : u(x) > 0} and N = U \ V . Then V is p-path open, since u ∈ N 1,p (X) is (absolutely) continuous on p-almost every curve in X, by Proposition 3.1 in Shanmugalingam [53] (or [4,Theorem 1.56]). It remains to show that N is p-path negligible. Assume it is not. Then there necessarily is an arc-length parameterized curve γ for which L 1 (D) > 0, where D := γ −1 (N ), but γ ρ ds < ∞.
Since B contains a 1-neighbourhood of U , necessarily l γj ≤ 2 −j−1 δ. We define a curve γ x as follows. Let L 0 = 0 and for i = 1, 2 ... , and γ x (L) := x. Then γ x : [0, L] → X is an arc-length parameterized curve with γ x (0) = x = γ x (L j ) = γ x (L) and γ x (L j + l γj+1 ) ∈ X \ U for all j = 1, 2 ... , with L j + l γj+1 → L as j → ∞. Also, length(γ x ) = L ≤ δ and γx ρ ds ≤ δ. In essence, γ x is a short "zigzagging loop" at x which intersects X \ U arbitrarily close to its end point. Now take a dense set {s k } ∞ k=1 ⊂ D. For every k = 1, 2, ... , we find such a zigzagging loop γ k := γ x k at x k = γ(s k ), with l γ k ≤ 2 −k and γ k ρ ds ≤ 2 −k . Next we define a curve γ that is obtained from γ by adding the "loops" γ k at the points x k , for k = 1, 2, ... . More precisely, first let l = ∞ k=1 l γ k . Then define the function where δ s k are Dirac measures at the points s k . Now f −1 is defined on a subset of [0, l γ + l] and is 1-Lipschitz. We define a curve γ on [0, l γ + l] as follows. For , then for some k = 1, 2 ... , the number t belongs to an interval of length l γ k which does not intersect f ([0, l γ ]) apart from the right end point f (s k ). Define γ to be the curve γ k on this interval. Note that γ is a 1-Lipschitz mapping and that length(γ) = l γ + l. Thus γ is arc-length parameterized, and so it is indeed a "curve" in our sense.
Since γ(D) ⊂ N , we also get γ(f (D)) ⊂ N . Moreover, since f −1 is 1-Lipschitz, L 1 (f (D)) ≥ L 1 (D) > 0 and so γ travels a positive length in N . Let t := f (ξ) ∈ f (D) and ε > 0. Then by the construction of f , together with the density of {s k } ∞ k=1 in D, we can find k and j 0 (k) such that lim k→∞ j 0 (k) = ∞ and By the construction of the zigzagging loop γ k , there is a sequence t l ր f (s k ) such that γ(t l ) ∈ X \ U for l = 1, 2, ... . Since ε > 0 was arbitrary, we conclude that t is not in the interior of γ −1 (U ). Thus no t ∈ f (D) is an interior point of γ −1 (U ), and since we had L 1 (f (D)) > 0, γ −1 (U ) is not the union of a relatively open set and a set of zero L 1 -measure. This shows that γ ∈ Γ.
At the same time, This contradicts the choice of ρ. Thus N is in fact a p-path negligible set and we have the result for bounded sets U . If U is p-path almost open and unbounded, we know that each U ∩ B(x 0 , j) is a disjoint union of a p-path open set V j and a p-path negligible set N j , j = 1, 2 ... , where x 0 ∈ X is fixed. Now we can write U as the union where ∞ j=1 V j is obviously p-path open and ∞ j=1 N j is p-path negligible. Finally, we obtain the following natural characterization of measurable p-path almost open sets. This answers Open problem 3.4 in Björn-Björn [5] in the affirmative for measurable sets, under natural assumptions. Theorem 7.3. Assume that X is locally compact and that µ is locally doubling and supports a local p-Poincaré inequality. Suppose that U ⊂ X is measurable. Then Under these assumptions, it follows from Theorem 3.7 that every p-path open set is p-quasiopen and thus measurable. Hence it follows from Proposition 7.5 below that the measurability assumption in Theorem 7.3 cannot be dropped.
Proof. If U is p-path almost open, then by Theorem 7.2 we know that it is a union U = V ∪ N ′ where V is p-path open and N ′ is p-path negligible. Then U = V ∪ N , where N = N ′ \ V is also p-path negligible. By Theorem 3.7, V is measurable. As U is measurable by assumption, so is N = U \ V . Thus by Proposition 7. The same argument applies to any connected metric graph X equipped with a locally doubling measure µ supporting a local p-Poincaré inequality, where each edge is considered to be a segment. To see this, first note that there are at most a countable number of vertices and edges, and that µ({x}) = 0 for each x ∈ X, see [4,Corollary 3.9]. It follows that the set of vertices has zero measure. On each open edge, µ is given by a locally p-admissible weight, by [13,Theorem 4.6], and we can apply the argument above.
On the contrary, in higher dimensions there always exist nonmeasurable p-path almost open sets, at least if we assume the continuum hypothesis.
Proposition 7.5. Assume that the continuum hypothesis is true. Let X = R n , n ≥ 2, be equipped with a measure dµ = w dx such that 0 < w ∈ L 1 loc (R n ). Then there is a nonmeasurable dense p-path negligible set S. In particular, S is a nonmeasurable dense p-path almost open set.
In particular, Proposition 7.5 applies to p-admissible weights w, as studied extensively in Heinonen-Kilpeläinen-Martio [36] when p > 1. Note that µ and the Lebesgue measure L n have the same measurable sets.
We shall use Sierpiński sets to prove Proposition 7.5. A Sierpiński set S is an uncountable subset of R n such that E ∩ S is at most countable for every set E of Lebesgue measure L n (E) = 0. Such sets exist if we assume the continuum hypothesis, see Sierpiński [55] (Proposition C 26 in [55, p. 80] gives the existence for R, while in the paragraph just before Proposition C 26 a in [55, p. 81] it is explained how to deduce the existence for R 2 ) and Morgan [50,Theorem 7,p. 86] (for R n ). On the other hand, there are other models of set theory containing ZFC (Zermelo-Fraenkel's system plus the axiom of choice) for which the existence of Sierpiński sets fails, e.g. if one adds Martin's axiom for ℵ 1 , see Kunen [47,Exercise V.6.29].
Let S ⊂ R n , n ≥ 2, be a Sierpiński set and A ⊂ S. Then A∩H ⊂ S∩H is at most countable for every hyperplane H. If A is measurable, then it follows from Fubini's theorem that L n (A) = 0, but then A = A ∩ S is at most countable. Thus every uncountable subset of S is nonmeasurable. In particular S itself is nonmeasurable. Conversely it is easy to show that if S ⊂ R n , n ≥ 1, is an uncountable set such that every uncountable subset is nonmeasurable, then S is a Sierpiński set.
In fact, there exist Sierpiński sets with additional, perhaps surprising, properties. For example, Bienias-G l ֒ ab-Ra lowski-Żeberski [3, Theorem 5.5] have shown that in R 2 there is a Sierpiński set that intersects every line in at most two points. (This is again assuming the continuum hypothesis.) When proving Proposition 7.5 we will need the following lemma, which is no doubt well known. As we have not found a good reference, we provide a short proof.
Proof of Proposition 7.5. By the assumptions on the measure µ, it has the same zero sets and the same measurable sets as the Lebesgue measure L n . As mentioned above, there exists a Sierpiński set S ′ ⊂ R n . It is easy to see that a countable union of Sierpiński sets is a Sierpiński set, and hence S = q∈Q n (S ′ + q) is a dense Sierpiński set. If γ : [0, l γ ] → R n is an arc-length parameterized curve, then γ([0, l γ ]) ∩ S is at most countable, since L n (γ([0, l γ ])) = 0. Lemma 7.6 and the countable additivity of the Lebesgue measure L 1 then imply that L 1 (γ −1 (S)) = 0. As this holds for every curve γ, the set S is p-path negligible for every p. However, S is nonmeasurable with respect to L n , and thus also with respect to µ.
We end the paper by constructing a measurable p-path almost open set which cannot be written as a union of an open set and a set of measure zero. Note that the measure is not doubling and does not support a Poincaré inequality.
Example 7.7. Let X = R, equipped with the measure L 1 + δ 0 , where δ 0 is the Dirac measure at 0. Then C p ({x}) ≥ 2 for all x ∈ X and hence all quasiopen sets in X are open. The interval [0, 1) cannot therefore be written as a union of a quasiopen set and a set of measure zero. However, it is still p-path almost open for any p ≥ 1, by Lemma 7.6.