arXiv is now an independent nonprofit! Learn more
License: CC BY 4.0
arXiv:2609.24460v1 [cs.CG] 21 Sep 2026

Witness Set in Weak Visibility Polygons is Polynomial-Time Solvable

Udvas Das Affiliation: Advanced Computing and Microelectronics Unit (ACMU),
Indian Statistical Institute, Kolkata, India
E-mail udvas.das@gmail.com
   Shouvik Mondal Affiliation: Advanced Computing and Microelectronics Unit (ACMU),
Indian Statistical Institute, Kolkata, India
E-mail shouvik.math@gmail.com
   Sasanka Roy Affiliation: Advanced Computing and Microelectronics Unit (ACMU),
Indian Statistical Institute, Kolkata, India
E-mail sasanka.ro@gmail.com
Abstract

In the classical Art Gallery Problem (𝖠𝖦𝖯)(\mathsf{AGP}), guards are placed in a polygon to see every point together [35]. The Witness Set Problem (𝖶𝖲𝖯)(\mathsf{WSP}), introduced by the authors in [2], is a natural dual to the 𝖠𝖦𝖯\mathsf{AGP}. In this paper, we study the Witness Set Problem in weak visibility polygons (𝒲​𝒱​𝒫)(\mathscr{WVP}), the simple polygons in which every point is seen from one fixed edge. A witness set is a set of points whose visibility regions are pairwise disjoint, so that no single guard sees two of them. A maximum witness set, therefore, lower-bounds the guard number. Exact polynomial-time algorithms for 𝖶𝖲𝖯\mathsf{WSP} are known only for monotone mountains [13], which is a proper subclass of 𝒲​𝒱​𝒫\mathscr{WVP}s. We give the first exact polynomial-time algorithms for 𝖶𝖲𝖯\mathsf{WSP} in weak visibility polygons in two settings.

Discrete Witness Set Problem (𝙳𝚒𝚜𝚌𝚆𝚂𝙿)(\mathtt{DiscWSP}): Here, the witnesses come from a given set of mm points, and we find a maximum witness subset in 𝒪⁡(n+m​log⁡(n+m))\mathcal{O}(n+m\log(n+m)) time on an nn-vertex polygon. Crucially, the visibility intersection graph inside 𝒲​𝒱​𝒫\mathscr{WVP}s, where two points are adjacent if their visibility regions intersect, properly contains interval graphs and permutation graphs [23]. Moreover, this graph class turns out to be a subclass of trapezoid graphs, the intersection graph of trapezoids between two parallel lines [14, 18]. We also give a matching lower bound, so our algorithm for 𝙳𝚒𝚜𝚌𝚆𝚂𝙿\mathtt{DiscWSP} problem is optimum. The characterization of graphs could find interesting applications in graph theory.

Continuous Witness Set Problem (𝙲𝚘𝚗𝚝𝚆𝚂𝙿)(\mathtt{ContWSP}): Here, the witnesses are any point of the polygon, and we give an exact polynomial-time algorithm running in 𝒪⁡(n​log⁡n+ρ2​(n+ρ2))\mathcal{O}(n\log n+\rho^{2}(n+\rho^{2})) time, with ρ\rho reflex vertices.

Keywords: 
Witness set Weak visibility polygon Art gallery problem Trapezoid graph Exact algorithm

1 Introduction

Picture a long gallery with a glass wall on one side, a strait watched from one shore, or a valley overlooked by a road. In each case, the region to be watched is large and two-dimensional, but the cameras, guards, or sensors may sit only along one fixed edge of it. The geometric model for such a region is a weak visibility polygon, a simple polygon in which every point is seen from some point of one fixed edge, called the base edge.

The general form of this question is the classical Art Gallery Problem. Victor Klee posed it in 1973 and asked how many guards are needed to see all of a gallery with nn walls. Chvátal proved that ⌊n/3⌋\lfloor n/3\rfloor guards are always sufficient and sometimes necessary [12], and Fisk later gave a short proof by triangulation and three colouring [19]. The algorithmic version is much harder. Lee and Lin proved that computing a minimum guard set is NP-hard [33]. The authors in [17] proved APX-hardness for point, vertex, and edge guards, and the authors in [1] proved that the problem is ∃ℝ\exists\mathbb{R}-complete, so it is not even known to lie in NP. Bonnet and Miltzow proved W[1][1]-hard ness for the number of guards [9]. On the positive side, Ghosh gave an 𝒪⁡(log⁡n)\mathcal{O}(\log n) approximation algorithm for vertex and edge guards [21], King and Kirkpatrick improved the ratio to 𝒪⁡(log⁡log⁡OPT)\mathcal{O}(\log\log\mathrm{OPT}) [30], and an exact algorithm running in n𝒪⁡(k)n^{\mathcal{O}(k)} time follows from tools of real algebraic geometry, an observation of Sharir reported by Efrat and Har-Peled [16].

Weak Visibility Polygons.

This class is more than a convenient special case. The known constant factor approximation algorithms for simple polygons are built by cutting the polygon into a hierarchy of weak visibility polygons. It is also hard in its own right. The authors in [8] proved that point guarding a weak visibility polygon is NP-hard. In the same work, they gave a 66-approximation algorithm for vertex guarding such a polygon without holes, running in 𝒪⁡(n2)\mathcal{O}(n^{2}) time, and they showed that with holes, no polynomial time algorithm achieves a ratio better than ((1−ϵ)/12)​ln⁡n((1-\epsilon)/12)\ln n unless 𝖭𝖯=𝖯{\sf NP}=\mathsf{P}. Katz gave a PTAS for vertex guarding the vertices of a weak visibility polygon and for vertex guarding its boundary [29]. The authors in [4] gave a constant factor approximation algorithm for vertex guarding such a polygon, and the authors in [3] introduced terrain-like graphs, which yield further PTASs for guarding it from its vertices.

The Witness Set Problem.

All the results above bound the guard number from above. A practitioner also needs a certificate from below. The authors in [2] supplied one. They placed visibility-independent points, which they called witnesses, and used them to certify lower bounds on the guard number. A witness set is a set of points whose visibility regions are pairwise disjoint. No single guard sees two witnesses, so the size of a maximum witness set is a lower bound on the number of guards. This is the Witness Set Problem. A related packing notion is a hidden set, a set of points no two of which see each other; the authors in [10] gave the first constant factor approximation algorithms for it. A witness set is a stronger requirement, since it asks that the visibility regions be disjoint and not merely that the points fail to see one another.

The witness number is interesting for a second reason. Call a polygon perfect when its guard number equals its witness number. For a perfect polygon, the lower bound is tight, so computing a maximum witness set also solves the art gallery problem. Guarding a 1.51.5D terrain, the closest relative of a weak visibility polygon, is NP-hard, as King and Krohn proved [31]. Yet the authors in [13] gave an optimal linear time algorithm for guarding a terrain by guards on a horizontal line, and proved that the minimum guard number equals the maximum witness number. The same results apply to monotone mountains, which are xx-monotone polygons whose lower chain is a single edge. Every monotone mountain is therefore perfect, and this is the first non-trivial class of perfect polygons.

Two recent works widen the picture. The authors in [15] gave a polynomial time algorithm for the discrete version in general simple polygons, and for monotone polygons with rr reflex vertices, an exact algorithm running in r𝒪⁡(k)⋅n𝒪⁡(1)r^{\mathcal{O}(k)}\cdot n^{\mathcal{O}(1)} time for witness sets of size kk, together with a PTAS. The authors in [27] proved that the witness set problem in simple polygons lies in 𝖭𝖯∩𝖷𝖯{\sf NP}\cap{\sf XP}. This is a sharp contrast with the art gallery problem, which is not in NP unless 𝖭𝖯=∃ℝ{\sf NP}=\exists\mathbb{R}.

Monotone mountains are a proper subclass of weak visibility polygons. Outside that subclass, no exact polynomial-time algorithm for witness sets was known. This paper closes the gap.

1.1 Our Contributions

The Problem Statements are defined as follows.

Discrete Witness Set (𝙳𝚒𝚜𝚌𝚆𝚂𝙿)(\mathtt{DiscWSP}) in 𝖶𝖵−𝖯𝗈𝗅𝗒𝗀𝗈𝗇\mathsf{WV-Polygon} Input: A weak visibility polygon 𝒲​𝒱\mathcal{WV} with base edge e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and a finite set S={s1,…,sm}S=\{s_{1},\dots,s_{m}\} of points of 𝒲​𝒱\mathcal{WV}.
Task: Find a maximum-cardinality subset Q⊆SQ\subseteq S such that 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(w′)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(w^{\prime})=\emptyset for all distinct w,w′∈Qw,w^{\prime}\in Q, that is, a witness set 𝖶𝖲⁡(𝒲​𝒱,S)\mathsf{WS}(\mathcal{WV},S).
Continuous Witness Set (𝙲𝚘𝚗𝚝𝚆𝚂𝙿)(\mathtt{ContWSP}) in 𝖶𝖵−𝖯𝗈𝗅𝗒𝗀𝗈𝗇\mathsf{WV-Polygon} Input: A weak visibility polygon 𝒲​𝒱\mathcal{WV} with base edge e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}.
Task: Find a maximum-cardinality set W⊆𝒲​𝒱W\subseteq\mathcal{WV} such that 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(w′)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(w^{\prime})=\emptyset for all distinct w,w′∈Ww,w^{\prime}\in W, that is, a witness set 𝖶𝖲⁡(𝒲​𝒱,𝒲​𝒱)\mathsf{WS}(\mathcal{WV},\mathcal{WV}).

We give the first exact polynomial time algorithms for witness sets in weak visibility polygons.11 1 In a companion manuscript, we study the dual question for the same class, namely placing the fewest guards on the base edge so that together they see the whole polygon [34]. In 𝙳𝚒𝚜𝚌𝚆𝚂𝙿\mathtt{DiscWSP}, the witnesses come from a given set SS of mm points, and for this problem, our algorithm is near-linear and optimal. In 𝙲𝚘𝚗𝚝𝚆𝚂𝙿\mathtt{ContWSP}, a witness may be any point of the polygon. Throughout, 𝒲​𝒱\mathcal{WV} is a weak visibility polygon with nn vertices and ρ\rho reflex vertices. Our first result is structural.

Theorem 1.1 (Theorem 3.1)

The visibility intersection graph GSG_{S} of an instance (𝒲​𝒱,S)(\mathcal{WV},S) is the intersection graph of a family of trapezoids between two parallel lines. In particular, GSG_{S} is a trapezoid graph, and a trapezoid representation of it is read off from the anchors of the points of SS.

Theorem 1.2 (Theorem 3.3 and Theorem 3.4)

𝙳𝚒𝚜𝚌𝚆𝚂𝙿\mathtt{DiscWSP} in a weak visibility polygon is solvable in 𝒪⁡(n+m​log⁡(n+m))\mathcal{O}(n+m\log(n+m)) time and 𝒪⁡(n+m)\mathcal{O}(n+m) space. In the algebraic decision-tree model, it requires Ω⁡(k​log⁡k)\Omega(k\log k) operations in the worst case on instances with kk points in a polygon of 𝒪⁡(k)\mathcal{O}(k) vertices. For m=Θ⁡(n)m=\Theta(n) the problem is therefore solved in Θ⁡(n​log⁡n)\Theta(n\log n) time, and no algebraic decision-tree algorithm does better.

Theorem 1.3 (Theorem 3.5)

Let 𝖵𝖨𝖦\mathsf{VIG} be the class of visibility intersection graphs of weak visibility polygons, and let 𝖨𝗇𝗍\mathsf{Int}, 𝖯𝖾𝗋𝗆\mathsf{Perm} and 𝖳𝗋𝖺𝗉\mathsf{Trap} be the classes of interval, permutation, and trapezoid graphs. Then 𝖨𝗇𝗍⊊𝖵𝖨𝖦\mathsf{Int}\subsetneq\mathsf{VIG}, 𝖯𝖾𝗋𝗆⊊𝖵𝖨𝖦\mathsf{Perm}\subsetneq\mathsf{VIG} and 𝖵𝖨𝖦⊆𝖳𝗋𝖺𝗉\mathsf{VIG}\subseteq\mathsf{Trap}.

Theorem 1.4 (Theorem 4.1 and Theorem 5.1)

𝙲𝚘𝚗𝚝𝚆𝚂𝙿\mathtt{ContWSP} in a weak visibility polygon is solvable exactly in 𝒪⁡(n​log⁡n+ρ2​(n+ρ2))\mathcal{O}\!\left(n\log n+\rho^{2}(n+\rho^{2})\right) time.

Applications.

Witness sets are not only a proof device. Practical solvers for the art gallery problem are primal-dual or integer-programming methods, and they need a lower bound at every iteration to certify that a guard set is optimal. A witness set is exactly such a certificate, and the authors in [2] computed witnesses for this purpose. Exact solvers built on the same idea appear in [32, 37]. The underlying placement question is itself applied. The authors in [6] motivate terrain guarding by the placement of antennas for line-of-sight communication and of street lights and cameras along roads. González-Banos and Latombe used an art gallery formulation for sensor placement in robotics [24], and coverage of this kind is standard in sensor network design [38]. A weak visibility polygon models exactly the case where the sensors must sit along one fixed wall, shore, or road.

2 Preliminaries

We collect the definitions and notation used throughout. We begin with simple polygons and weak visibility polygons, then define witness sets and guard sets together with their cardinalities, and finally recall the anchors and the interval a point induces on the base edge.

Definition 1 (Simple Polygon)

A simple polygon 𝒫\mathcal{P} is the closed region bounded by a finite closed chain of straight, pairwise non-crossing edges that meet only at their common endpoints, the vertices. We write V⁡(𝒫)V(\mathcal{P}) for its vertex set and ∂(𝒫)\partial(\mathcal{P}) for its boundary. A vertex is reflex if the interior angle of 𝒫\mathcal{P} at it exceeds π\pi, and convex otherwise. Two points aa and bb of 𝒫\mathcal{P} see each other if the segment a​b¯\overline{ab} lies in 𝒫\mathcal{P}. We write 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p) for the set of points of 𝒫\mathcal{P} that pp sees.

For a segment, its relative interior is the segment without its two endpoints. A chord of a simple polygon 𝒫\mathcal{P} is a segment whose two endpoints lie on ∂(𝒫)\partial(\mathcal{P}) and whose relative interior lies in the interior of 𝒫\mathcal{P}. A chord splits 𝒫\mathcal{P} into two subpolygons, and it splits ∂(𝒫)\partial(\mathcal{P}) into two arcs, one on each side.

Definition 2 (Weak Visibility Polygon)

A simple polygon 𝒲​𝒱\mathcal{WV} is a weak visibility polygon (𝖶𝖵−𝖯𝗈𝗅𝗒𝗀𝗈𝗇)(\mathsf{WV-Polygon}) with respect to one of its edges e𝚋𝚊𝚜𝚎=u​v{e}_{\mathtt{base}}=uv, the base edge, if every point of 𝒲​𝒱\mathcal{WV} is visible from some point of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} [22]. We take the vertices of 𝒲​𝒱\mathcal{WV} to be v0,v1,…,vnv_{0},v_{1},\dots,v_{n} in clockwise order with e𝚋𝚊𝚜𝚎=v0​vn{e}_{\mathtt{base}}=v_{0}v_{n}, and we write u=v0u=v_{0} and v=vnv=v_{n} for the two endpoints of the base. The polygon has n+1n+1 vertices; we suppress this additive constant and call nn its size.

A base point is a point of the base edge e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}.

Definition 3 (Witness Set)

A set W⊆𝒲​𝒱W\subseteq\mathcal{WV} is a witness set [2] if no point of 𝒲​𝒱\mathcal{WV} sees two of its members, that is, if 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(w′)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(w^{\prime})=\emptyset for every two distinct w,w′∈Ww,w^{\prime}\in W. We write 𝖶𝖲⁡(𝒲​𝒱,Q)\mathsf{WS}(\mathcal{WV},Q) for a witness set in the polygon 𝒲​𝒱\mathcal{WV} with the witness points drawn from a set Q⊆𝒲​𝒱Q\subseteq\mathcal{WV}, and μW​S​(𝒲​𝒱,Q)\mu_{WS}(\mathcal{WV},Q) for the cardinality of such a set.

Definition 4 (Guard Set)

A set G⊆𝒲​𝒱G\subseteq\mathcal{WV} is a guard set [5] if every point of 𝒲​𝒱\mathcal{WV} is visible from some g∈Gg\in G. We write 𝖦𝖲⁡(𝒲​𝒱,A)\mathsf{GS}(\mathcal{WV},A) for a guard set in 𝒲​𝒱\mathcal{WV} with the guards drawn from A⊆𝒲​𝒱A\subseteq\mathcal{WV}, and μG​S​(𝒲​𝒱,A)\mu_{GS}(\mathcal{WV},A) for the cardinality of such a set.

A witness set and a guard set bound each other: one guard sees at most one witness, so μW​S​(𝒲​𝒱,Q)≤μG​S​(𝒲​𝒱,A)\mu_{WS}(\mathcal{WV},Q)\leq\mu_{GS}(\mathcal{WV},A) whenever QQ and AA range over all of 𝒲​𝒱\mathcal{WV}, which is why a maximum witness set certifies a guard lower bound.

For a point p∈𝒲​𝒱p\in\mathcal{WV}, let Π𝗎​(p)\mathsf{\Pi_{u}}(p) and Π𝗏​(p)\mathsf{\Pi_{v}}(p) denote the Euclidean shortest paths inside 𝒲​𝒱\mathcal{WV} from pp to uu and to vv, respectively. The next two notions, from [15], turn visibility on the base into one-dimensional data.

Definition 5 (Anchors)

The left anchor ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p) of a point p∈𝒲​𝒱p\in\mathcal{WV} is the first reflex vertex on Π𝗎​(p)\mathsf{\Pi_{u}}(p), and the right anchor 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p) is the first reflex vertex on Π𝗏​(p)\mathsf{\Pi_{v}}(p). If the shortest path is a straight segment, the anchor is the base endpoint it reaches.

Definition 6 (Window)

Let xx be a point of 𝒲​𝒱\mathcal{WV} and let μ\mu be a vertex of 𝒲​𝒱\mathcal{WV} that xx sees and at which the ray from xx through μ\mu enters the interior of 𝒲​𝒱\mathcal{WV}. The window of xx at μ\mu is the segment μ​𝗐𝗂𝗇​(x,μ)¯\overline{\mu\,\mathsf{win}(x,\mu)}, where 𝗐𝗂𝗇⁡(x,μ)\mathsf{win}(x,\mu) denotes the first point of ∂(𝒲​𝒱)\partial(\mathcal{WV}) that this ray meets after μ\mu. When μ\mu is an endpoint of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} we set 𝗐𝗂𝗇⁡(x,μ)=μ\mathsf{win}(x,\mu)=\mu, so that the window is the single point μ\mu.

Observation 1

A window of xx at a reflex vertex μ\mu is a chord of 𝒲​𝒱\mathcal{WV}, it is the edge of 𝖵𝗂𝗌⁡(x)\mathsf{Vis}(x) at which μ\mu blocks the view of xx, and the segment x​𝗐𝗂𝗇​(x,μ)¯\overline{x\,\mathsf{win}(x,\mu)} lies in 𝖵𝗂𝗌⁡(x)\mathsf{Vis}(x).

Definition 7 (Interval on the Base)

The base interval of a point p∈𝒲​𝒱p\in\mathcal{WV} is 𝙸𝚗𝚝⁡(p)=𝖵𝗂𝗌⁡(p)∩e𝚋𝚊𝚜𝚎\mathtt{Int}(p)=\mathsf{Vis}(p)\cap{e}_{\mathtt{base}}. It is a single nonempty closed segment [ℓ⁡(p),r⁡(p)]⊆e𝚋𝚊𝚜𝚎[\ell(p),r(p)]\subseteq{e}_{\mathtt{base}} [15], so a base point g∈e𝚋𝚊𝚜𝚎g\in{e}_{\mathtt{base}} sees pp if and only if g∈𝙸𝚗𝚝⁡(p)g\in\mathtt{Int}(p).

The two endpoints of the base interval are window endpoints, and we record this together with the two segments we use below.

Observation 2

For every p∈𝒲​𝒱p\in\mathcal{WV} the three points pp, ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p), ℓ⁡(p)\ell(p) are collinear and occur in this order, and so do pp, 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), r⁡(p)r(p); hence ℓ⁡(p)=𝗐𝗂𝗇⁡(p,ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p))\ell(p)=\mathsf{win}(p,\mathsf{\ell Anchor}(p)) and r⁡(p)=𝗐𝗂𝗇⁡(p,𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p))r(p)=\mathsf{win}(p,\mathsf{rAnchor}(p)). The boundary segments of pp are ℓ​𝖡𝖽𝗋𝗒​(p)=p​ℓ​(p)¯\mathsf{\ell Bdry}(p)=\overline{p\,\ell(p)} and 𝗋𝖡𝖽𝗋𝗒⁡(p)=p​r​(p)¯\mathsf{rBdry}(p)=\overline{p\,r(p)}; both lie in 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p).

Throughout the paper, we assume general position: no three vertices of 𝒲​𝒱\mathcal{WV} are collinear.

3 Discrete Witness Set Problem in 𝖶𝖵−𝖯𝗈𝗅𝗒𝗀𝗈𝗇\mathsf{WV-Polygon}

Restricting the witnesses to a finite input set turns the witness problem into a maximum independent set problem on a trapezoid graph, and the conflict relation among the input points is then decided by four numbers per point. We prove this correspondence and derive a near-linear-time exact algorithm from it; when the point set is proportional to the polygon the running time is Θ⁡(n​log⁡n)\Theta(n\log n), which we show is optimal in the algebraic decision-tree model.

Throughout this section, 𝒲​𝒱\mathcal{WV} is a simple polygon with vertices v0,v1,…,vnv_{0},v_{1},\dots,v_{n} in clockwise order that is weakly visible from its base edge e𝚋𝚊𝚜𝚎=v0​vn{e}_{\mathtt{base}}=v_{0}v_{n}. The vertex v0v_{0} is the left endpoint of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and the vertex vnv_{n} is the right endpoint, so v0,v1,…,vnv_{0},v_{1},\dots,v_{n} is the chain of 𝒲​𝒱\mathcal{WV} other than e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}. We call this chain the upper chain. For two points xx and yy of the upper chain we write x≺yx\prec y when xx precedes yy in the clockwise order. We orient e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} from v0v_{0} to vnv_{n}, and for two points xx and yy of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} we write x<yx<y when xx precedes yy in this orientation. The words left and right always refer to these two orders. We also write u=v0u=v_{0} and v=vnv=v_{n} for the two endpoints of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and Π𝗎​(p)\mathsf{\Pi_{u}}(p), Π𝗏​(p)\mathsf{\Pi_{v}}(p) for the shortest paths of Section 2 from pp to uu and to vv.

Definition 8 (Discrete Witness Set)

An instance of Discrete Witness Set consists of a weak visibility polygon 𝒲​𝒱\mathcal{WV} and a finite set S={s1,…,sm}S=\{s_{1},\dots,s_{m}\} of points of 𝒲​𝒱\mathcal{WV}. A subset Q⊆SQ\subseteq S is a witness set if 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(w′)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(w^{\prime})=\emptyset for every two distinct points ww and w′w^{\prime} of QQ. The problem asks for a witness set of maximum cardinality. This is a witness set 𝖶𝖲⁡(𝒲​𝒱,S)\mathsf{WS}(\mathcal{WV},S) in the notation of Section 2, and the problem asks for its size μW​S​(𝒲​𝒱,S)\mu_{WS}(\mathcal{WV},S).

In addition to the general position assumed in Section 2, no point of SS lies on a line through two vertices of 𝒲​𝒱\mathcal{WV}.

Figure 1: The Discrete Witness Set problem. Here S={w1,…,w8}S=\{w_{1},\dots,w_{8}\}, and not all points of SS lie on ∂(𝒲​𝒱)\partial(\mathcal{WV}). The subset Q={w1,w2,w4,w5,w7}Q=\{w_{1},w_{2},w_{4},w_{5},w_{7}\} is a valid witness set in 𝒲​𝒱\mathcal{WV}, and its visibility regions are pairwise disjoint, so μW​S​(𝒲​𝒱,S)=5\mu_{WS}(\mathcal{WV},S)=5.

The witness sets of an instance are the independent sets of one graph, which we now name.

Definition 9 (Visibility Intersection Graph)

The visibility intersection graph (VIG) GSG_{S} of an instance (𝒲​𝒱,S)(\mathcal{WV},S) has vertex set SS, and two distinct points ss and s′s^{\prime} of SS are adjacent if and only if 𝖵𝗂𝗌⁡(s)∩𝖵𝗂𝗌⁡(s′)≠∅\mathsf{Vis}(s)\cap\mathsf{Vis}(s^{\prime})\neq\emptyset.

A subset of SS is a witness set if and only if it is an independent set of GSG_{S}. The whole difficulty, therefore, lies in the structure of GSG_{S}. We show in Section 3.4 that GSG_{S} is a trapezoid graph, and that a trapezoid representation of it is read off from the anchors of the points of SS.

3.1 Windows and Base Intervals

We use the anchors ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p) and the base interval 𝙸𝚗𝚝⁡(p)=[ℓ⁡(p),r⁡(p)]\mathtt{Int}(p)=[\ell(p),r(p)] of Section 2, together with the boundary segments ℓ​𝖡𝖽𝗋𝗒​(p)=p​ℓ​(p)¯\mathsf{\ell Bdry}(p)=\overline{p\,\ell(p)} and 𝗋𝖡𝖽𝗋𝗒⁡(p)=p​r​(p)¯\mathsf{rBdry}(p)=\overline{p\,r(p)}. By Observation 2 the point pp has a window at each of its two anchors, and we write ℓ​𝖶𝗂𝗇​(p)=ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)​ℓ​(p)¯\mathsf{\ell Win}(p)=\overline{\mathsf{\ell Anchor}(p)\,\ell(p)} and 𝗋𝖶𝗂𝗇⁡(p)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)​r​(p)¯\mathsf{rWin}(p)=\overline{\mathsf{rAnchor}(p)\,r(p)} for them, see Figure 2. Both lie in 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p), and by Observation 1 each is a chord of 𝒲​𝒱\mathcal{WV} unless its anchor is an endpoint of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, in which case it is the single point v0v_{0} or vnv_{n}. These two are the leftmost and the rightmost windows of 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p), and they are the only ones the analysis uses.

Figure 2: Illustrative figure for Anchors and Windows (Definitions 5, 6)

General position gives ℓ⁡(p)<r⁡(p)\ell(p)<r(p) for every point pp of SS. Indeed, an equality would place ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p) on a common line through pp, and these are two vertices of 𝒲​𝒱\mathcal{WV}.

By Observation 1 the right window of pp is a chord of pp is a chord of 𝒲​𝒱\mathcal{WV} whenever it is not a single point. It therefore splits 𝒲​𝒱\mathcal{WV} into two closed subpolygons. We write 𝒲​𝒱r−​(p)\mathcal{WV}^{-}_{r}(p) for the one whose boundary arc contains v0v_{0} and 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p) for the one whose boundary arc contains vnv_{n}, and we set 𝒲​𝒱r−​(p)=𝒲​𝒱\mathcal{WV}^{-}_{r}(p)=\mathcal{WV} when r⁡(p)=vnr(p)=v_{n}. Symmetrically, ℓ​𝖶𝗂𝗇​(p)\mathsf{\ell Win}(p) splits 𝒲​𝒱\mathcal{WV} into 𝒲​𝒱l−​(p)\mathcal{WV}^{-}_{l}(p) and 𝒲​𝒱l+​(p)\mathcal{WV}^{+}_{l}(p), and we set 𝒲​𝒱l+​(p)=𝒲​𝒱\mathcal{WV}^{+}_{l}(p)=\mathcal{WV} when ℓ⁡(p)=v0\ell(p)=v_{0}.

We record one fact about chords that the proofs below reuse.

Observation 3

A chord of 𝒲​𝒱\mathcal{WV} splits 𝒲​𝒱\mathcal{WV} into two subpolygons. A second chord crosses it if and only if the two endpoints of the second chord lie on the two different boundary arcs. Equivalently, two chords cross if and only if their four endpoints interleave in the boundary order.

3.2 The Trapezoid Representation

The construction uses two horizontal parallel lines. Let LbL_{b} be the lower line and let LtL_{t} be the upper line. Let β:e𝚋𝚊𝚜𝚎→Lb\beta\colon{e}_{\mathtt{base}}\to L_{b} be an isometry that preserves the left to right order of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and let τ\tau map the vertex viv_{i} to the point of abscissa ii on LtL_{t}, for i=0,1,…,ni=0,1,\dots,n. The map τ\tau preserves the clockwise order of the upper chain by construction.

Definition 10 (Trapezoid of a point)

The trapezoid T⁡(p)T(p) of a point p∈Sp\in S is the convex hull of the upper side τ⁡(ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p))​τ​(𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p))¯\overline{\tau(\mathsf{\ell Anchor}(p))\,\tau(\mathsf{rAnchor}(p))} and the lower side β⁡(ℓ⁡(p))​β​(r⁡(p))¯\overline{\beta(\ell(p))\,\beta(r(p))}.

Figure 3: The trapezoid representation of Definition 10 for the instance of Figure 1. The base edge is drawn as the lower line LbL_{b} and the upper chain as the upper line LtL_{t}; by Theorem 3.1 two points of SS are witnesses exactly when their trapezoids are disjoint.

Figure 3 shows the representation built from the instance of Figure 1.

Definition 10 is legitimate only if the upper side has its left endpoint before its right endpoint. The following lemma supplies this, and the inequality ℓ⁡(p)<r⁡(p)\ell(p)<r(p) supplies the same for the lower side.

Lemma 1

Every point p∈Sp\in S satisfies ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)≺𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{\ell Anchor}(p)\prec\mathsf{rAnchor}(p).

Proof

If ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)=v0\mathsf{\ell Anchor}(p)=v_{0}, then the claim holds because 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p) is a reflex vertex or is vnv_{n}, and no such vertex is v0v_{0}. The case 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)=vn\mathsf{rAnchor}(p)=v_{n} is symmetric. So assume that both windows are chords. The windows are contained in ℓ​𝖡𝖽𝗋𝗒​(p)\mathsf{\ell Bdry}(p) and in 𝗋𝖡𝖽𝗋𝗒⁡(p)\mathsf{rBdry}(p) respectively, these two segments meet only at pp, and neither window contains pp. Hence, the two windows are disjoint, and their four endpoints are distinct. Read ∂(𝒲​𝒱)\partial(\mathcal{WV}) clockwise from v0v_{0}. The upper chain comes first in the order v0,v1,…,vnv_{0},v_{1},\dots,v_{n}, and the points of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} come afterward from right to left. Suppose that 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{rAnchor}(p)\prec\mathsf{\ell Anchor}(p). Since ℓ⁡(p)<r⁡(p)\ell(p)<r(p), the four endpoints then appear in the clockwise order 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p), r⁡(p)r(p), ℓ⁡(p)\ell(p). The four endpoints interleave in this order, so the two windows cross by Observation 3. This contradicts their disjointness.

3.3 The Algorithm

Here, we present the pseudocode of the algorithm.

Algorithm 1 Maximum witness subset of a finite point set in a weak visibility polygon.
Input: A weak visibility polygon 𝒲​𝒱\mathcal{WV} with vertices v0,…,vnv_{0},\dots,v_{n} in clockwise order and base edge e𝚋𝚊𝚜𝚎=v0​vn{e}_{\mathtt{base}}=v_{0}v_{n}, and a set S={s1,…,sm}S=\{s_{1},\dots,s_{m}\} of points of 𝒲​𝒱\mathcal{WV}.
Output: A maximum witness subset Q⊆SQ\subseteq S.
1 Triangulate 𝒲​𝒱\mathcal{WV};
2 Build the shortest path map of 𝒲​𝒱\mathcal{WV} with source v0v_{0} and the shortest path map with source vnv_{n}, each with a point location structure;
3 foreach s∈Ss\in S do
    4 ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(s)←\mathsf{\ell Anchor}(s)\leftarrow the second point of Π𝗎​(s)\mathsf{\Pi_{u}}(s), read from the map with source v0v_{0};
    5 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(s)←\mathsf{rAnchor}(s)\leftarrow the second point of Π𝗏​(s)\mathsf{\Pi_{v}}(s), read from the map with source vnv_{n};
    6 if ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(s)=v0\mathsf{\ell Anchor}(s)=v_{0} then ℓ⁡(s)←v0\ell(s)\leftarrow v_{0};
    7 else ℓ⁡(s)←\ell(s)\leftarrow the point in which the ray from ss through ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(s)\mathsf{\ell Anchor}(s) meets e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}};
    8 if 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(s)=vn\mathsf{rAnchor}(s)=v_{n} then r⁡(s)←vnr(s)\leftarrow v_{n};
    9 else r⁡(s)←r(s)\leftarrow the point in which the ray from ss through 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(s)\mathsf{rAnchor}(s) meets e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}};
10 Fix the two parallel lines LbL_{b} and LtL_{t}, the isometry β:e𝚋𝚊𝚜𝚎→Lb\beta\colon{e}_{\mathtt{base}}\to L_{b}, and the map τ\tau of Section 3.2;
11 foreach s∈Ss\in S do T⁡(s)←T(s)\leftarrow the trapezoid of Definition 10;
12 Q←Q\leftarrow a maximum independent set of the trapezoid graph represented by {T⁡(s):s∈S}\{T(s):s\in S\}, computed by the algorithm of [18];
13 return QQ;

3.4 Correctness

The correctness rests on two facts. The first one confines the visibility polygon of a point to one side of each of its two windows. The second one turns this confinement into a characterization of the conflict relation.

Lemma 2

Every point p∈Sp\in S satisfies 𝖵𝗂𝗌⁡(p)⊆𝒲​𝒱r−​(p)∩𝒲​𝒱l+​(p)\mathsf{Vis}(p)\subseteq\mathcal{WV}^{-}_{r}(p)\cap\mathcal{WV}^{+}_{l}(p).

Proof

We prove the inclusion 𝖵𝗂𝗌⁡(p)⊆𝒲​𝒱r−​(p)\mathsf{Vis}(p)\subseteq\mathcal{WV}^{-}_{r}(p), and the other inclusion is symmetric. The claim is trivial when r⁡(p)=vnr(p)=v_{n}, so assume that 𝗋𝖶𝗂𝗇⁡(p)\mathsf{rWin}(p) is a chord. Write C=𝗋𝖶𝗂𝗇⁡(p)C=\mathsf{rWin}(p).

We first place pp itself. Choose a point bb of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} with ℓ⁡(p)<b<r⁡(p)\ell(p)<b<r(p), which exists because ℓ⁡(p)<r⁡(p)\ell(p)<r(p). The point bb lies in 𝒲​𝒱r−​(p)\mathcal{WV}^{-}_{r}(p) and not on CC. The segment p​b¯\overline{pb} lies in 𝒲​𝒱\mathcal{WV}, since bb is visible from pp. It does not meet CC. Indeed, a common point of p​b¯\overline{pb} and CC would be collinear with pp and with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), and it would force bb onto the line through pp and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), whence b=r⁡(p)b=r(p). Hence pp and bb lie in the same subpolygon, and p∈𝒲​𝒱r−​(p)p\in\mathcal{WV}^{-}_{r}(p).

Now let qq be a point of 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p) that lies in the interior of 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p). The segment p​q¯\overline{pq} lies in 𝒲​𝒱\mathcal{WV} and joins 𝒲​𝒱r−​(p)\mathcal{WV}^{-}_{r}(p) to the interior of 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p), so it meets CC in some point yy. The three points pp, yy and qq are collinear, and yy lies on the line through pp and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p). Hence qq lies on that line too. The part of that line beyond r⁡(p)r(p) leaves 𝒲​𝒱\mathcal{WV}, because the line meets e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} transversally at r⁡(p)r(p) under general position. Therefore qq lies on 𝗋𝖡𝖽𝗋𝗒⁡(p)\mathsf{rBdry}(p), and no point of 𝗋𝖡𝖽𝗋𝗒⁡(p)\mathsf{rBdry}(p) lies in the interior of 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p). This contradiction shows that 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p) misses the interior of 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p), which is the claim.

Lemma 3

Two points pp and qq of SS satisfy 𝖵𝗂𝗌⁡(p)∩𝖵𝗂𝗌⁡(q)=∅\mathsf{Vis}(p)\cap\mathsf{Vis}(q)=\emptyset if and only if one of the following two conditions holds:

  1. (i)

    r⁡(p)<ℓ⁡(q)r(p)<\ell(q) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{rAnchor}(p)\prec\mathsf{\ell Anchor}(q);

  2. (ii)

    r⁡(q)<ℓ⁡(p)r(q)<\ell(p) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(q)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{rAnchor}(q)\prec\mathsf{\ell Anchor}(p).

Proof

We record first that the inequality r⁡(p)<ℓ⁡(q)r(p)<\ell(q) forces both windows involved to be chords. It gives r⁡(p)≠vnr(p)\neq v_{n}, since ℓ⁡(q)\ell(q) lies on e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and it gives ℓ⁡(q)≠v0\ell(q)\neq v_{0} for the same reason.

Assume condition (i), and write C=𝗋𝖶𝗂𝗇⁡(p)C=\mathsf{rWin}(p) and D=ℓ​𝖶𝗂𝗇​(q)D=\mathsf{\ell Win}(q). The four endpoints of CC and DD are distinct. Read ∂(𝒲​𝒱)\partial(\mathcal{WV}) clockwise from v0v_{0} as in the proof of Lemma 1. The two hypotheses of (i) place the four endpoints in the clockwise order 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{\ell Anchor}(q), ℓ⁡(q)\ell(q), r⁡(p)r(p). The chord CC joins the first endpoint to the fourth, and the chord DD joins the second to the third, so the two endpoint pairs do not interleave and the chords are disjoint. Both endpoints of DD lie on the boundary arc of CC that contains vnv_{n}, so D⊆𝒲​𝒱r+​(p)D\subseteq\mathcal{WV}^{+}_{r}(p). The boundary of 𝒲​𝒱l+​(q)\mathcal{WV}^{+}_{l}(q) consists of DD and of the boundary arc from ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{\ell Anchor}(q) to ℓ⁡(q)\ell(q) through vnv_{n}, and both lie in 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p) and miss CC. Hence 𝒲​𝒱l+​(q)⊆𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{l}(q)\subseteq\mathcal{WV}^{+}_{r}(p) and 𝒲​𝒱l+​(q)∩C=∅\mathcal{WV}^{+}_{l}(q)\cap C=\emptyset. The two subpolygons 𝒲​𝒱r−​(p)\mathcal{WV}^{-}_{r}(p) and 𝒲​𝒱r+​(p)\mathcal{WV}^{+}_{r}(p) meet exactly in CC, so 𝒲​𝒱r−​(p)\mathcal{WV}^{-}_{r}(p) and 𝒲​𝒱l+​(q)\mathcal{WV}^{+}_{l}(q) are disjoint. By Lemma 2 we get 𝖵𝗂𝗌⁡(p)⊆𝒲​𝒱r−​(p)\mathsf{Vis}(p)\subseteq\mathcal{WV}^{-}_{r}(p) and 𝖵𝗂𝗌⁡(q)⊆𝒲​𝒱l+​(q)\mathsf{Vis}(q)\subseteq\mathcal{WV}^{+}_{l}(q), and the two visibility polygons are disjoint. Condition (ii) is symmetric.

Conversely, assume that neither condition holds. We give a point of 𝖵𝗂𝗌⁡(p)∩𝖵𝗂𝗌⁡(q)\mathsf{Vis}(p)\cap\mathsf{Vis}(q) in each remaining case.

Suppose first that 𝙸𝚗𝚝⁡(p)∩𝙸𝚗𝚝⁡(q)≠∅\mathtt{Int}(p)\cap\mathtt{Int}(q)\neq\emptyset. A common point of the two base intervals is visible from pp and from qq, and the two visibility polygons meet.

Suppose next that 𝙸𝚗𝚝⁡(p)∩𝙸𝚗𝚝⁡(q)=∅\mathtt{Int}(p)\cap\mathtt{Int}(q)=\emptyset, and assume without loss of generality that r⁡(p)<ℓ⁡(q)r(p)<\ell(q). Both windows 𝗋𝖶𝗂𝗇⁡(p)\mathsf{rWin}(p) and ℓ​𝖶𝗂𝗇​(q)\mathsf{\ell Win}(q) are then chords. Since condition (i) fails, we have ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{\ell Anchor}(q)\preceq\mathsf{rAnchor}(p). If ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{\ell Anchor}(q)=\mathsf{rAnchor}(p), then this common vertex lies on 𝗋𝖡𝖽𝗋𝗒⁡(p)\mathsf{rBdry}(p) and on ℓ​𝖡𝖽𝗋𝗒​(q)\mathsf{\ell Bdry}(q), so it is visible from pp and from qq. If ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)≺𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{\ell Anchor}(q)\prec\mathsf{rAnchor}(p), then the four endpoints appear in the clockwise order ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{\ell Anchor}(q), 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), ℓ⁡(q)\ell(q), r⁡(p)r(p). The four endpoints interleave, so the chords cross by Observation 3. A crossing point lies on 𝗋𝖡𝖽𝗋𝗒⁡(p)\mathsf{rBdry}(p) and on ℓ​𝖡𝖽𝗋𝗒​(q)\mathsf{\ell Bdry}(q), so it is visible from pp and from qq. In both cases, the two visibility polygons meet, which completes the proof.

Remark 1

The base intervals alone do not decide the conflict relation. Two points can have disjoint base intervals and still see a common point, and by the proof above, this happens exactly when their two windows cross. The upper side of the trapezoid records precisely this case. Only the converse survives without it: disjoint visibility polygons do force disjoint base intervals, because 𝙸𝚗𝚝⁡(p)=𝖵𝗂𝗌⁡(p)∩e𝚋𝚊𝚜𝚎\mathtt{Int}(p)=\mathsf{Vis}(p)\cap{e}_{\mathtt{base}} for every pp.

We now transfer the separation lemma to the trapezoids.

Observation 4

Two points pp and qq of SS satisfy T⁡(p)∩T⁡(q)=∅T(p)\cap T(q)=\emptyset if and only if condition (i) or condition (ii) of Lemma 3 holds.

Proof

For a level yy in the closed strip bounded by LbL_{b} and LtL_{t}, the intersection of T⁡(p)T(p) with the horizontal line of level yy is a closed interval [ap​(y),bp​(y)][a_{p}(y),b_{p}(y)], and both endpoints are affine functions of yy. Put f=aq−bpf=a_{q}-b_{p} and g=ap−bqg=a_{p}-b_{q}, which are again affine. The two intervals of level yy are disjoint if and only if f⁡(y)>0f(y)>0 or g⁡(y)>0g(y)>0. The two conditions never hold together, so the sets {f>0}\{f>0\} and {g>0}\{g>0\} are disjoint, and each is relatively open in the strip. The strip is connected, so these two sets cover it only if one of them is the whole strip. Hence T⁡(p)T(p) and T⁡(q)T(q) are disjoint if and only if ff is positive on the whole strip or gg is positive on the whole strip. An affine function is positive on the strip if and only if it is positive on both bounding lines. On LbL_{b} the inequality f>0f>0 reads r⁡(p)<ℓ⁡(q)r(p)<\ell(q), and on LtL_{t} it reads 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{rAnchor}(p)\prec\mathsf{\ell Anchor}(q), because β\beta and τ\tau preserve the two orders. These are the two parts of condition (i), and gg gives condition (ii) in the same way.

Theorem 3.1

Let (𝒲​𝒱,S)(\mathcal{WV},S) be an instance of Discrete Witness Set. The visibility intersection graph GSG_{S} is the intersection graph of the trapezoids {T⁡(s):s∈S}\{T(s):s\in S\}. In particular, GSG_{S} is a trapezoid graph, and the family {T⁡(s):s∈S}\{T(s):s\in S\} is a trapezoid representation of it.

Proof

Let ss and s′s^{\prime} be two distinct points of SS. By Lemma 3 the visibility polygons of ss and s′s^{\prime} are disjoint if and only if condition (i) or condition (ii) holds, and by Observation 4 the same two conditions characterize disjointness of T⁡(s)T(s) and T⁡(s′)T(s^{\prime}). Hence ss and s′s^{\prime} are adjacent in GSG_{S} if and only if T⁡(s)T(s) and T⁡(s′)T(s^{\prime}) intersect. The trapezoids are well defined by Lemma 1, and they have their parallel sides on the two fixed lines LbL_{b} and LtL_{t}, so they form a trapezoid representation in the sense of [14, 18].

We show in Section 3.7 that this class strictly contains the interval graphs, so the trapezoid structure is not an artifact of the analysis.

Corollary 1

A subset Q⊆SQ\subseteq S is a witness set if and only if the trapezoids {T⁡(s):s∈Q}\{T(s):s\in Q\} are pairwise disjoint. The maximum witness subsets of SS are exactly the maximum independent sets of the trapezoid graph of Theorem 3.1.

Proof

Combine Definition 8 with Theorem 3.1.

Theorem 3.2

Algorithm 1 returns a maximum witness subset of SS.

Proof

The algorithm computes the anchors of Definition 5, and it computes ℓ⁡(s)\ell(s) and r⁡(s)r(s) from them by Observation 2. It then builds the trapezoids of Definition 10, which represent GSG_{S} by Theorem 3.1. A maximum independent set of that representation is a maximum witness subset of SS by Corollary 1, and the algorithm of [18] returns one.

3.5 Running Time

Theorem 3.3

Let 𝒲​𝒱\mathcal{WV} be a weak visibility polygon with nn vertices and let SS be a set of mm points of 𝒲​𝒱\mathcal{WV}. Algorithm 1 computes a maximum witness subset of SS in 𝒪⁡(n+m​log⁡(n+m))\mathcal{O}(n+m\log(n+m)) time and 𝒪⁡(n+m)\mathcal{O}(n+m) space.

Proof

We account for the four phases of algorithm 1.

The triangulation of 𝒲​𝒱\mathcal{WV} takes 𝒪⁡(n)\mathcal{O}(n) time [11]. Each of the two shortest path maps is built in 𝒪⁡(n)\mathcal{O}(n) time from the triangulation [25], and each has 𝒪⁡(n)\mathcal{O}(n) cells, so a point location structure with 𝒪⁡(log⁡n)\mathcal{O}(\log n) query time is built in 𝒪⁡(n)\mathcal{O}(n) additional time. This phase costs 𝒪⁡(n)\mathcal{O}(n) time.

The anchor phase performs two-point location queries per point of SS, at 𝒪⁡(log⁡n)\mathcal{O}(\log n) time each. Each cell of a shortest path map stores the last vertex on the shortest path from the source to the points of that cell, which is the anchor by Definition 5. Given the anchor, the endpoint ℓ⁡(s)\ell(s) or r⁡(s)r(s) is one intersection of a ray with the supporting line of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, computed in 𝒪⁡(1)\mathcal{O}(1) time by Observation 2. This phase costs 𝒪⁡(m​log⁡n)\mathcal{O}(m\log n) time.

The construction phase writes down one trapezoid per point of SS in 𝒪⁡(1)\mathcal{O}(1) time each, and it sorts the 2​m2m endpoints on LbL_{b} and the 2​m2m endpoints on LtL_{t}. This phase costs 𝒪⁡(m​log⁡m)\mathcal{O}(m\log m) time.

The last phase computes a maximum independent set of a trapezoid graph on mm trapezoids from its representation, in 𝒪⁡(m​log⁡m)\mathcal{O}(m\log m) time [18].

The four phases together take 𝒪⁡(n+m​log⁡n+m​log⁡m)\mathcal{O}(n+m\log n+m\log m) time, which is 𝒪⁡(n+m​log⁡(n+m))\mathcal{O}(n+m\log(n+m)). The triangulation, the two maps and their point location structures use 𝒪⁡(n)\mathcal{O}(n) space, the trapezoids use 𝒪⁡(m)\mathcal{O}(m) space, and the algorithm of [18] uses 𝒪⁡(m)\mathcal{O}(m) space.

Corollary 2

If the number of input points satisfies m=𝒪⁡(n)m=\mathcal{O}(n), then a maximum witness subset of SS is computed in 𝒪⁡(n​log⁡n)\mathcal{O}(n\log n) time.

Remark 2

Algorithm 1 never builds the visibility intersection graph GSG_{S} explicitly. The graph can have Θ⁡(m2)\Theta(m^{2}) edges, for instance when every point of SS sees a common point of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, so the bound of Theorem 3.3 is below the size of the object it optimizes over.

3.6 Optimality of the Running Time

The near-linear bound of Corollary 2 is best possible in the algebraic decision-tree model, already when the number of input points is proportional to the size of the polygon. The hardness comes from the witness side of the problem: a maximum witness subset is a maximum independent set of the visibility intersection graph, and the visibility intersection graphs of Theorem 3.1 are rich enough to contain every permutation graph.

Figure 4: The construction of Lemma 4 for π=(1,4,2,3)\pi=(1,4,2,3). Each witness wiw_{i} reaches the base only through its gateway reflex vertex, its common anchor ρi=ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi)\rho_{i}=\mathsf{\ell Anchor}(w_{i})=\mathsf{rAnchor}(w_{i}), so its trapezoid collapses to the segment from the base point bib_{i} up to τ⁡(ρi)\tau(\rho_{i}) on LtL_{t} (drawn as a thin pocket). The base points appear in the order of π\pi and the top points in the identity order, so two segments cross exactly at an inversion of π\pi; here w4w_{4} conflicts with w2w_{2} and w3w_{3}. A maximum independent set is a longest increasing subsequence of π\pi, for instance {w1,w2,w3}\{w_{1},w_{2},w_{3}\}.
Lemma 4 (Permutation Graphs are Visibility Intersection Graphs)

For every permutation π\pi of {1,…,k}\{1,\dots,k\} there is an instance (𝒲​𝒱π,Sπ)(\mathcal{WV}_{\pi},S_{\pi}) of Discrete Witness Set in which 𝒲​𝒱π\mathcal{WV}_{\pi} has 𝒪⁡(k)\mathcal{O}(k) vertices, |Sπ|=k\lvert S_{\pi}\rvert=k, and the visibility intersection graph GSπG_{S_{\pi}} is isomorphic to the permutation graph of π\pi. The instance is produced from π\pi in 𝒪⁡(k)\mathcal{O}(k) time.

Proof

Take the base e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} to be the horizontal segment from u=(0,0)u=(0,0) to v=(k+1,0)v=(k+1,0). We build the upper chain of 𝒲​𝒱π\mathcal{WV}_{\pi} so that it carries, in clockwise order, kk reflex vertices ρ1,ρ2,…,ρk\rho_{1},\rho_{2},\dots,\rho_{k} of strictly increasing abscissa, with one shallow pocket hanging behind each ρi\rho_{i}. Inside the pocket behind ρi\rho_{i} we place a single input point wiw_{i}, so deep in the pocket that ρi\rho_{i} is the only vertex of 𝒲​𝒱π\mathcal{WV}_{\pi} through which wiw_{i} sees the base; that is, the pocket has ρi\rho_{i} as its sole gateway to e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}. Both shortest paths Π𝗎​(wi)\mathsf{\Pi_{u}}(w_{i}) and Π𝗏​(wi)\mathsf{\Pi_{v}}(w_{i}) then leave the pocket through ρi\rho_{i}, so

ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi)=ρi.\mathsf{\ell Anchor}(w_{i})\;=\;\mathsf{rAnchor}(w_{i})\;=\;\rho_{i}.

By Observation 2 the endpoints ℓ⁡(wi)\ell(w_{i}) and r⁡(wi)r(w_{i}) both lie on the line wi​ρi¯\overline{w_{i}\,\rho_{i}}; hence they coincide with the single point bib_{i} where that line, extended, meets e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and 𝙸𝚗𝚝⁡(wi)={bi}\mathtt{Int}(w_{i})=\{b_{i}\}.

The pocket may be aimed freely. Choosing where wiw_{i} sits behind ρi\rho_{i} turns the ray wi​ρi¯\overline{w_{i}\,\rho_{i}} to any direction, so bib_{i} can be placed at any prescribed abscissa on e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, independently of the other pockets: the pockets are separated horizontally, and the region below the reflex vertices is empty, so the aiming rays may cross there without any pocket obstructing another’s single view of the base. We aim them so that the base points realize the order of π\pi,

x(bi)<x(bj)⟺π(i)<π(j).x(b_{i})<x(b_{j})\quad\Longleftrightarrow\quad\pi(i)<\pi(j).

Each pocket contributes 𝒪⁡(1)\mathcal{O}(1) vertices, so 𝒲​𝒱π\mathcal{WV}_{\pi} has 𝒪⁡(k)\mathcal{O}(k) vertices and is written down from π\pi in 𝒪⁡(k)\mathcal{O}(k) time; it is weakly visible from e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} because each pocket is seen from its base point bib_{i} and the remainder of 𝒲​𝒱π\mathcal{WV}_{\pi} lies directly above e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}.

It remains to read off the visibility intersection graph. Recall the two horizontal lines LbL_{b}, LtL_{t} and the order-preserving maps β:e𝚋𝚊𝚜𝚎→Lb\beta\colon{e}_{\mathtt{base}}\to L_{b} and τ\tau of Section 3.2. Because ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi)=ρi\mathsf{\ell Anchor}(w_{i})=\mathsf{rAnchor}(w_{i})=\rho_{i}, the upper side of the trapezoid T⁡(wi)T(w_{i}) is the single point τ⁡(ρi)\tau(\rho_{i}), and because ℓ⁡(wi)=r⁡(wi)=bi\ell(w_{i})=r(w_{i})=b_{i} its lower side is the single point β⁡(bi)\beta(b_{i}). Every trapezoid therefore degenerates to a segment

T⁡(wi)=β⁡(bi)​τ​(ρi)¯T(w_{i})\;=\;\overline{\beta(b_{i})\;\tau(\rho_{i})}

joining a point of LbL_{b} to a point of LtL_{t}. The reflex vertices were placed with increasing abscissa, so their clockwise indices increase with ii and the top endpoints τ⁡(ρ1),…,τ⁡(ρk)\tau(\rho_{1}),\dots,\tau(\rho_{k}) appear in this order along LtL_{t}; the bottom endpoints β⁡(b1),…,β⁡(bk)\beta(b_{1}),\dots,\beta(b_{k}) appear along LbL_{b} in the order of π\pi. Two segments spanning a pair of parallel lines cross if and only if their endpoints occur in opposite orders on the two lines, so T⁡(wi)T(w_{i}) and T⁡(wj)T(w_{j}) cross exactly when i<ji<j and π⁡(i)>π⁡(j)\pi(i)>\pi(j), that is, exactly when {i,j}\{i,j\} is an inversion of π\pi. By Theorem 3.1 the visibility intersection graph GSπG_{S_{\pi}} is the intersection graph of the family {T⁡(wi)}\{T(w_{i})\}, which is thus the permutation graph of π\pi.

Finally, replacing the single aiming ray of each pocket by the two bounding rays of a sufficiently narrow pocket makes each 𝙸𝚗𝚝⁡(wi)\mathtt{Int}(w_{i}) a short interval and each T⁡(wi)T(w_{i}) a thin trapezoid, without altering which pairs cross; this satisfies the general position assumption of Section 2 while preserving GSπG_{S_{\pi}}. Figure 4 shows the construction for π=(1,4,2,3)\pi=(1,4,2,3).

Theorem 3.4 (Lower Bound)

In the algebraic decision-tree model, Discrete Witness Set requires Ω⁡(k​log⁡k)\Omega(k\log k) operations in the worst case on instances with |S|=k\lvert S\rvert=k points in a weak visibility polygon of 𝒪⁡(k)\mathcal{O}(k) vertices.

Proof

A maximum independent set of the permutation graph of π\pi has size equal to the length of a longest increasing subsequence of π\pi, and computing this length requires Ω⁡(k​log⁡k)\Omega(k\log k) comparisons in the worst case [20]; the bound holds in the algebraic decision-tree model, as does the equivalent bound obtained by a reduction from Element Uniqueness [7, 36]. Suppose an algorithm solved Discrete Witness Set in o⁡(k​log⁡k)o(k\log k) operations on the stated instances. Given π\pi, build (𝒲​𝒱π,Sπ)(\mathcal{WV}_{\pi},S_{\pi}) in 𝒪⁡(k)\mathcal{O}(k) time by Lemma 4 and run the algorithm on it. By Corollary 1 the size of its output equals a maximum independent set of GSπG_{S_{\pi}}, hence the longest increasing subsequence length of π\pi, computed in o⁡(k​log⁡k)o(k\log k) operations, a contradiction.

Corollary 3

For instances with m=Θ⁡(n)m=\Theta(n), Discrete Witness Set in a weak visibility polygon is solvable in Θ⁡(n​log⁡n)\Theta(n\log n) time, and no algebraic decision-tree algorithm does better.

Proof

The upper bound is Corollary 2. For the lower bound, apply Theorem 3.4 with k=Θ⁡(n)k=\Theta(n): the polygon then has 𝒪⁡(n)\mathcal{O}(n) vertices and m=Θ⁡(n)m=\Theta(n) points, and k​log⁡k=Θ⁡(n​log⁡n)k\log k=\Theta(n\log n).

3.7 The Class of Visibility Intersection Graphs

By Theorem 3.1 every visibility intersection graph is a trapezoid graph. We now locate this class more precisely. It contains two familiar families, the interval graphs and the permutation graphs, and it contains each of them properly. The permutation graphs were already realized in Lemma 4; we treat the interval graphs next.

Lemma 5 (Interval Graphs are Visibility Intersection Graphs)

For every interval graph HH there is an instance (𝒲​𝒱,S)(\mathcal{WV},S) of Discrete Witness Set whose visibility intersection graph GSG_{S} is isomorphic to HH. The polygon 𝒲​𝒱\mathcal{WV} has 𝒪⁡(n)\mathcal{O}(n) vertices, where nn is the number of vertices of HH.

Proof

Fix an interval representation of HH: closed intervals I1,…,InI_{1},\dots,I_{n} on a horizontal line, with distinct endpoints, such that two vertices of HH are adjacent if and only if the corresponding intervals meet. Write Ii=[ai,bi]I_{i}=[a_{i},b_{i}]. Say that IiI_{i} is left of IjI_{j} when bi<ajb_{i}<a_{j}, that is, when IiI_{i} lies entirely to the left of IjI_{j}. This relation is a strict partial order, and we fix a linear extension σ\sigma of it, so that bi<ajb_{i}<a_{j} implies σ⁡(i)<σ⁡(j)\sigma(i)<\sigma(j).

We reuse the pocket construction of Lemma 4, with the single change that the pockets are wider. Put e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} on a horizontal segment and build the upper chain of 𝒲​𝒱\mathcal{WV} so that it carries nn pairwise disjoint shallow pockets, arranged from left to right in the order given by σ\sigma. The mouth of the pocket that holds vertex ii has a left reflex vertex λi\lambda_{i} and a right reflex vertex ρi\rho_{i}. Place a single input point wiw_{i} so deep in that pocket that the pocket is its only gateway to e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}. Then Π𝗎​(wi)\mathsf{\Pi_{u}}(w_{i}) leaves the pocket around λi\lambda_{i} and Π𝗏​(wi)\mathsf{\Pi_{v}}(w_{i}) leaves it around ρi\rho_{i}, so

ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi)=λi,𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi)=ρi.\mathsf{\ell Anchor}(w_{i})=\lambda_{i},\qquad\mathsf{rAnchor}(w_{i})=\rho_{i}.

Hence wiw_{i} sees on e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} exactly the interval bounded by the rays wi​λi¯\overline{w_{i}\,\lambda_{i}} and wi​ρi¯\overline{w_{i}\,\rho_{i}}, namely 𝙸𝚗𝚝⁡(wi)=[ℓ⁡(wi),r⁡(wi)]\mathtt{Int}(w_{i})=[\ell(w_{i}),r(w_{i})], where ℓ⁡(wi)\ell(w_{i}) and r⁡(wi)r(w_{i}) are the points in which these two rays meet e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}. As in Lemma 4 the pockets are separated horizontally, and the region below the reflex vertices is empty, so the two rays of each pocket may be aimed independently of the other pockets. Aim them so that ℓ⁡(wi)=ai\ell(w_{i})=a_{i} and r⁡(wi)=bir(w_{i})=b_{i}, giving 𝙸𝚗𝚝⁡(wi)=Ii\mathtt{Int}(w_{i})=I_{i}. Each pocket contributes 𝒪⁡(1)\mathcal{O}(1) vertices, so 𝒲​𝒱\mathcal{WV} has 𝒪⁡(n)\mathcal{O}(n) vertices; it is weakly visible from e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} because each pocket is seen from its own base interval, and the rest of 𝒲​𝒱\mathcal{WV} lies directly above e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}.

It remains to identify GSG_{S}. Recall the two parallel lines LbL_{b} and LtL_{t} and the order-preserving maps β\beta and τ\tau of Section 3.2. The pockets are disjoint and ordered by σ\sigma, so on LtL_{t} the upper sides τ⁡(λi)​τ​(ρi)¯\overline{\tau(\lambda_{i})\,\tau(\rho_{i})} of the trapezoids T⁡(wi)T(w_{i}) are pairwise disjoint and appear in the order of σ\sigma; on LbL_{b} the lower sides are the intervals 𝙸𝚗𝚝⁡(wi)=Ii\mathtt{Int}(w_{i})=I_{i}. Take two vertices ii and jj with σ⁡(i)<σ⁡(j)\sigma(i)<\sigma(j), so the upper side of T⁡(wi)T(w_{i}) lies entirely left of the upper side of T⁡(wj)T(w_{j}). Two trapezoids spanning LbL_{b} and LtL_{t} are disjoint if and only if one lies entirely left of the other; since the upper sides are already ordered, T⁡(wi)T(w_{i}) and T⁡(wj)T(w_{j}) are disjoint if and only if their lower sides are ordered the same way, that is bi<ajb_{i}<a_{j}. Now compare with HH. If IiI_{i} and IjI_{j} are disjoint, they are comparable in the left-of order; as σ\sigma extends that order and σ⁡(i)<σ⁡(j)\sigma(i)<\sigma(j), the interval IiI_{i} is left of IjI_{j}, so bi<ajb_{i}<a_{j} and the trapezoids are disjoint. If IiI_{i} and IjI_{j} meet, their lower sides overlap, and the trapezoids are not disjoint. By Theorem 3.1, the graph GSG_{S} is the intersection graph of the family {T⁡(wi)}\{T(w_{i})\}, so wiw_{i} and wjw_{j} are adjacent in GSG_{S} if and only if IiI_{i} and IjI_{j} meet, which is adjacency in HH. Therefore, GSG_{S} is isomorphic to HH.

Both containments are strict, and a single small graph separates the interval graphs from the visibility intersection graphs.

Together with Lemma 4 and Lemma 5, the trapezoid representation locates the visibility intersection graphs between two familiar classes.

Theorem 3.5 (Location of the Visibility Intersection Graphs)

Let 𝖵𝖨𝖦\mathsf{VIG} denote the class of visibility intersection graphs of instances of Discrete Witness Set in weak visibility polygons, and let 𝖨𝗇𝗍\mathsf{Int}, 𝖯𝖾𝗋𝗆\mathsf{Perm} and 𝖳𝗋𝖺𝗉\mathsf{Trap} denote the classes of interval graphs, permutation graphs, and trapezoid graphs respectively. Then

𝖨𝗇𝗍⊊𝖵𝖨𝖦,𝖯𝖾𝗋𝗆⊊𝖵𝖨𝖦,𝖵𝖨𝖦⊆𝖳𝗋𝖺𝗉.\mathsf{Int}\subsetneq\mathsf{VIG},\qquad\mathsf{Perm}\subsetneq\mathsf{VIG},\qquad\mathsf{VIG}\subseteq\mathsf{Trap}. (1)
Proof

The containment 𝖨𝗇𝗍⊆𝖵𝖨𝖦\mathsf{Int}\subseteq\mathsf{VIG} is Lemma 5, and the containment 𝖯𝖾𝗋𝗆⊆𝖵𝖨𝖦\mathsf{Perm}\subseteq\mathsf{VIG} is Lemma 4. The containment 𝖵𝖨𝖦⊆𝖳𝗋𝖺𝗉\mathsf{VIG}\subseteq\mathsf{Trap} is Theorem 3.1.

It remains to prove that the first two containments are proper. The interval graphs and the permutation graphs are incomparable, so neither class contains the other [23]. Choose a permutation graph G1G_{1} that is not an interval graph, and choose an interval graph G2G_{2} that is not a permutation graph. By Lemma 4 the graph G1G_{1} belongs to 𝖵𝖨𝖦\mathsf{VIG}, and it does not belong to 𝖨𝗇𝗍\mathsf{Int}. By Lemma 5 the graph G2G_{2} belongs to 𝖵𝖨𝖦\mathsf{VIG}, and it does not belong to 𝖯𝖾𝗋𝗆\mathsf{Perm}.

Remark 3

Whether the third containment in Equation 1 is proper is open. A positive answer would characterize the conflict structure of Discrete Witness Set exactly.

4 Continuous Witness Set Problem in 𝖶𝖵−𝖯𝗈𝗅𝗒𝗀𝗈𝗇\mathsf{WV-Polygon}

We now drop the interval restriction of Section 3. Two points of 𝒲​𝒱\mathcal{WV} are witnesses when their full visibility polygons are disjoint, not merely their base intervals. We give an exact algorithm that computes a maximum witness set, we prove that it is correct, and we bound its running time in Section 5.

Throughout, 𝒲​𝒱\mathcal{WV} is a simple polygon with nn vertices that is weakly visible from its base edge e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, and ρ\rho is the number of reflex vertices of 𝒲​𝒱\mathcal{WV}. The base has endpoints u=v0u=v_{0} and v=vnv=v_{n}, and we assume the general position of Section 2. We reuse the visibility polygon 𝖵𝗂𝗌⁡(p)\mathsf{Vis}(p), the base interval 𝙸𝚗𝚝⁡(p)=[ℓ⁡(p),r⁡(p)]=𝖵𝗂𝗌⁡(p)∩e𝚋𝚊𝚜𝚎\mathtt{Int}(p)=[\ell(p),r(p)]=\mathsf{Vis}(p)\cap{e}_{\mathtt{base}}, the anchors ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(p)\mathsf{\ell Anchor}(p) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)\mathsf{rAnchor}(p), and the clockwise order ≺\prec on the upper chain. The endpoints ℓ⁡(p)\ell(p) and r⁡(p)r(p) follow from the two anchors in 𝒪⁡(log⁡n)\mathcal{O}(\log n) time after linear-time preprocessing [25]. Lemma 3 and Observation 4 were stated for input points, but their proofs use only general position, so we apply them to arbitrary points of 𝒲​𝒱\mathcal{WV}.

A witness set is a set of points of 𝒲​𝒱\mathcal{WV} that are pairwise witnesses (Definition 3), meaning that no point of 𝒲​𝒱\mathcal{WV} sees two of them. A maximum witness set is one of the largest cardinality. The witness relation no longer lives on e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}, yet the base intervals still order the candidates soundly.

Observation 5

If 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(w′)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(w^{\prime})=\emptyset, then 𝙸𝚗𝚝⁡(w)∩𝙸𝚗𝚝⁡(w′)=∅\mathtt{Int}(w)\cap\mathtt{Int}(w^{\prime})=\emptyset.

Proof

Since 𝙸𝚗𝚝⁡(p)=𝖵𝗂𝗌⁡(p)∩e𝚋𝚊𝚜𝚎\mathtt{Int}(p)=\mathsf{Vis}(p)\cap{e}_{\mathtt{base}} for every p∈𝒲​𝒱p\in\mathcal{WV}, any common point of 𝙸𝚗𝚝⁡(w)\mathtt{Int}(w) and 𝙸𝚗𝚝⁡(w′)\mathtt{Int}(w^{\prime}) lies in both visibility polygons.

The converse fails. Interval disjointness is only a necessary filter, and full visibility disjointness must be checked separately. This is what makes the continuous problem harder than the discrete one.

The proof of correctness has five parts. A witness set is a chain in a partial order. The same points can always extend a shorter chain that ends further left than a longer one. Every witness can be moved to the boundary without changing the size of the witness set. On the boundary, every witness can be moved to one of finitely many candidate points. A small table over anchors and chain lengths then finds the longest chain among these candidates.

4.1 Witness Sets Are Chains

The separation lemma says that two visibility polygons are disjoint exactly when one trapezoid lies to the left of the other on both lines. We give this relation a name.

Definition 11 (left of)

Let pp and qq be points of 𝒲​𝒱\mathcal{WV}. We write p⊲qp\lhd q and say that pp is left of qq when

r⁡(p)<ℓ⁡(q)and𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q).r(p)<\ell(q)\qquad\text{and}\qquad\mathsf{rAnchor}(p)\prec\mathsf{\ell Anchor}(q).

The next lemma turns the witness problem into a question about chains.

Lemma 6

The relation ⊲\lhd is a strict partial order on the points of 𝒲​𝒱\mathcal{WV}. Two points pp and qq satisfy 𝖵𝗂𝗌⁡(p)∩𝖵𝗂𝗌⁡(q)=∅\mathsf{Vis}(p)\cap\mathsf{Vis}(q)=\emptyset if and only if p⊲qp\lhd q or q⊲pq\lhd p. A set W⊆𝒲​𝒱W\subseteq\mathcal{WV} is a witness set if and only if it is a chain under ⊲\lhd.

Proof

No point pp satisfies p⊲pp\lhd p, because ℓ⁡(p)≤r⁡(p)\ell(p)\leq r(p). Let p⊲qp\lhd q and q⊲sq\lhd s. Then

r⁡(p)<ℓ⁡(q)≤r⁡(q)<ℓ⁡(s).r(p)<\ell(q)\leq r(q)<\ell(s).

Every point qq satisfies ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(q)\mathsf{\ell Anchor}(q)\preceq\mathsf{rAnchor}(q), so

𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(p)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(q)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(s).\mathsf{rAnchor}(p)\prec\mathsf{\ell Anchor}(q)\preceq\mathsf{rAnchor}(q)\prec\mathsf{\ell Anchor}(s).

Hence p⊲sp\lhd s, and the relation is transitive. The second claim restates Lemma 3. For the third claim, a set is a witness set exactly when every two of its members are comparable under ⊲\lhd. This is the definition of a chain.

A witness set is therefore a chain, and a maximum witness set is a longest chain. Transitivity also justifies the test used by the algorithm. It suffices to compare a new point with the last point of a chain.

Lemma 7

Let x1⊲x2⊲⋯⊲xmx_{1}\lhd x_{2}\lhd\dots\lhd x_{m} be a chain and let ww be a point with xm⊲wx_{m}\lhd w. Then xj⊲wx_{j}\lhd w for every index jj, and the set {x1,…,xm,w}\{x_{1},\dots,x_{m},w\} is a witness set.

Proof

Transitivity gives xj⊲xm⊲wx_{j}\lhd x_{m}\lhd w for every j<mj<m. The set is a chain, so it is a witness set by Lemma 6.

Disjointness of two visibility polygons is a symmetric condition. A new point may be disjoint from the last point of a chain and still lie to its left. One extra comparison on the base, rules this out.

Lemma 8

Let xx and ww satisfy 𝖵𝗂𝗌⁡(x)∩𝖵𝗂𝗌⁡(w)=∅\mathsf{Vis}(x)\cap\mathsf{Vis}(w)=\emptyset and ℓ⁡(w)>r⁡(x)\ell(w)>r(x). Then x⊲wx\lhd w.

Proof

By Lemma 6 we have x⊲wx\lhd w or w⊲xw\lhd x. Suppose that w⊲xw\lhd x. Then r⁡(w)<ℓ⁡(x)r(w)<\ell(x). But r⁡(w)≥ℓ⁡(w)>r⁡(x)≥ℓ⁡(x)r(w)\geq\ell(w)>r(x)\geq\ell(x). This is a contradiction, so x⊲wx\lhd w.

4.2 Substitution

A chain leaves room to its right through two quantities. One is the right endpoint of the last base interval. The other is the right anchor of the last point. A point that is no larger in both can take the place of the last point without losing any successor.

Lemma 9

Let x⊲qx\lhd q, and let x′x^{\prime} be a point with r⁡(x′)≤r⁡(x)r(x^{\prime})\leq r(x) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x′)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)\mathsf{rAnchor}(x^{\prime})\preceq\mathsf{rAnchor}(x). Then x′⊲qx^{\prime}\lhd q.

Proof

From x⊲qx\lhd q we get r⁡(x)<ℓ⁡(q)r(x)<\ell(q) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q)\mathsf{rAnchor}(x)\prec\mathsf{\ell Anchor}(q). Hence

r⁡(x′)≤r⁡(x)<ℓ⁡(q)and𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x′)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(q),r(x^{\prime})\leq r(x)<\ell(q)\qquad\text{and}\qquad\mathsf{rAnchor}(x^{\prime})\preceq\mathsf{rAnchor}(x)\prec\mathsf{\ell Anchor}(q),

which is the statement x′⊲qx^{\prime}\lhd q.

Lemma 9 says that, among chains of the same length whose last points share a right anchor; only the smallest right endpoint matters. This is the reason the table in Section 4.6 is small.

4.3 Witnesses Can Be Moved to the Boundary

The algorithm’s candidates lie on the boundary. A maximum witness set may contain interior points. We show that every interior witness can be pushed to the boundary along a ray through its right anchor; see Figure 5. The push leaves rr and the right anchor unchanged and shrinks the trapezoid.

Definition 12 (Trapezoid Shadow)

The trapezoid shadow of a point ww is the set 𝗍𝗋𝖺𝗉𝖲𝗁𝖺𝖽𝗈𝗐⁡(w)\mathsf{trapShadow}(w) of all points x∈𝒲​𝒱x\in\mathcal{WV} whose trapezoid (Definition 10) satisfies T⁡(x)⊆T⁡(w)T(x)\subseteq T(w).

Replacing ww by a point of 𝗍𝗋𝖺𝗉𝖲𝗁𝖺𝖽𝗈𝗐⁡(w)\mathsf{trapShadow}(w) preserves every relation ⊲\lhd in which ww takes part; the next lemma records the consequence we use.

Lemma 10

Let x∈𝗍𝗋𝖺𝗉𝖲𝗁𝖺𝖽𝗈𝗐⁡(w)x\in\mathsf{trapShadow}(w) and let zz be a point with 𝖵𝗂𝗌⁡(w)∩𝖵𝗂𝗌⁡(z)=∅\mathsf{Vis}(w)\cap\mathsf{Vis}(z)=\emptyset. Then 𝖵𝗂𝗌⁡(x)∩𝖵𝗂𝗌⁡(z)=∅\mathsf{Vis}(x)\cap\mathsf{Vis}(z)=\emptyset.

Proof

By Observation 4 the trapezoids T⁡(w)T(w) and T⁡(z)T(z) are disjoint. Since T⁡(x)⊆T⁡(w)T(x)\subseteq T(w), the trapezoids T⁡(x)T(x) and T⁡(z)T(z) are disjoint as well. The same observation gives 𝖵𝗂𝗌⁡(x)∩𝖵𝗂𝗌⁡(z)=∅\mathsf{Vis}(x)\cap\mathsf{Vis}(z)=\emptyset.

We now name the boundary point to which we push a witness. Let w∈𝒲​𝒱w\in\mathcal{WV} and let 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) be a reflex vertex. By Observation 2 the points r⁡(w)r(w), 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w), ww lie on one ray in this order, and we set

𝖱𝖴𝖢⁡(w)=𝗐𝗂𝗇⁡(r⁡(w),𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)),\mathsf{RUC}(w)\;=\;\mathsf{win}(r(w),\mathsf{rAnchor}(w)),

the first point of ∂(𝒲​𝒱)\partial(\mathcal{WV}) on that ray after 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w). The point 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w) lies on the upper chain, because the ray moves away from the base.

Figure 5: The push to the boundary. The point ww is pushed along the ray from 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) through ww to the boundary point 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w). The right endpoint r⁡(w)r(w) and the right anchor 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) do not change, see Lemma 11.
Lemma 11

Let ww be a point of 𝒲​𝒱\mathcal{WV} whose right anchor is a reflex vertex, and let y=𝖱𝖴𝖢⁡(w)y=\mathsf{RUC}(w). Then

r⁡(y)=r⁡(w)and𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(y)=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w),\displaystyle r(y)=r(w)\qquad\text{and}\qquad\mathsf{rAnchor}(y)=\mathsf{rAnchor}(w),
ℓ⁡(y)≥ℓ⁡(w)andℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(y)⪰ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w).\displaystyle\ell(y)\geq\ell(w)\qquad\text{and}\qquad\mathsf{\ell Anchor}(y)\succeq\mathsf{\ell Anchor}(w).

Hence T⁡(y)⊆T⁡(w)T(y)\subseteq T(w), and yy lies in 𝗍𝗋𝖺𝗉𝖲𝗁𝖺𝖽𝗈𝗐⁡(w)\mathsf{trapShadow}(w).

Proof

Write LL for the line through ww and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w). The segment from yy to r⁡(w)r(w) lies on LL. It is the union of the segments from yy to ww, from ww to 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w), and from 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) to r⁡(w)r(w). Each of these lies in 𝒲​𝒱\mathcal{WV}. Hence yy sees r⁡(w)r(w), and the line of sight passes through the reflex vertex 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w). A line of sight through a reflex vertex bounds the visible part of the base. So r⁡(w)r(w) is an endpoint of 𝙸𝚗𝚝⁡(y)\mathtt{Int}(y) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) is the anchor at that endpoint. The vertex 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) blocks the same side of LL for yy as for ww, because both points lie on LL beyond 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w). This proves the first two equalities.

We now prove ℓ⁡(y)≥ℓ⁡(w)\ell(y)\geq\ell(w). Write L′L^{\prime} for the line through ww and ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w), and write c0=ℓ​𝖶𝗂𝗇​(w)c_{0}=\mathsf{\ell Win}(w) for the left window. By Observation 1 the window c0c_{0} is a chord. It splits 𝒲​𝒱\mathcal{WV} into the part 𝒲​𝒱l−​(w)\mathcal{WV}^{-}_{l}(w) that contains v0v_{0} and the part 𝒲​𝒱l+​(w)\mathcal{WV}^{+}_{l}(w) that contains vnv_{n}. The point ww lies in 𝒲​𝒱l+​(w)\mathcal{WV}^{+}_{l}(w), and the segment from ww to yy meets L′L^{\prime} only at ww. Hence yy lies in 𝒲​𝒱l+​(w)\mathcal{WV}^{+}_{l}(w) as well.

Suppose that yy sees a base point bb with b<ℓ⁡(w)b<\ell(w). The point bb lies in 𝒲​𝒱l−​(w)\mathcal{WV}^{-}_{l}(w). So the segment from yy to bb crosses the chord c0c_{0} at a point cc. We first show that c≠ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)c\neq\mathsf{\ell Anchor}(w). The two edges of 𝒲​𝒱\mathcal{WV} at ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) lie in one closed half plane of L′L^{\prime}, because the interior angle at ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) contains both directions of L′L^{\prime}. The base points left of ℓ⁡(w)\ell(w) lie in the same half plane, and so does yy. If c=ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)c=\mathsf{\ell Anchor}(w), then the ray from yy through ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) leaves this half plane at ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) and meets the base on the other side, that is, at a point right of ℓ⁡(w)\ell(w). This contradicts b<ℓ⁡(w)b<\ell(w). So cc lies in the relative interior of c0c_{0}, and ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) lies between ww and cc on L′L^{\prime}.

Consider the triangle Δ\Delta with corners yy, ww, and cc. Its three sides lie in 𝒲​𝒱\mathcal{WV}. The boundary of 𝒲​𝒱\mathcal{WV} meets these sides only at yy and at ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w). The two edges at ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) enter the interior of Δ\Delta. Follow the boundary of 𝒲​𝒱\mathcal{WV} from ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) along either edge. It cannot cross a side of Δ\Delta so that it can leave Δ\Delta only through the corner yy. Hence, the whole boundary of 𝒲​𝒱\mathcal{WV} lies in Δ\Delta. But the base point ℓ⁡(w)\ell(w) lies on L′L^{\prime} beyond cc, outside Δ\Delta. This is a contradiction. So yy sees no base point to the left of ℓ⁡(w)\ell(w), and ℓ⁡(y)≥ℓ⁡(w)\ell(y)\geq\ell(w).

Finally, we compare the left anchors. The shortest path from yy to v0v_{0} starts in 𝒲​𝒱l+​(w)\mathcal{WV}^{+}_{l}(w) and ends in 𝒲​𝒱l−​(w)\mathcal{WV}^{-}_{l}(w), so it crosses c0c_{0}. If its first bend comes before the crossing, then ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(y)\mathsf{\ell Anchor}(y) is a reflex vertex on the boundary of 𝒲​𝒱l+​(w)\mathcal{WV}^{+}_{l}(w) other than ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w), and this boundary arc follows ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w) in clockwise order. If the first segment of the path reaches c0c_{0}, then it reaches ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(w), because the argument above rules out a first segment that ends in the relative interior of c0c_{0}. In both cases ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(y)⪰ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w)\mathsf{\ell Anchor}(y)\succeq\mathsf{\ell Anchor}(w).

The trapezoid T⁡(y)T(y) has upper side τ⁡(ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(y))​τ​(𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w))¯\overline{\tau(\mathsf{\ell Anchor}(y))\,\tau(\mathsf{rAnchor}(w))} and lower side β⁡(ℓ⁡(y))​β​(r⁡(w))¯\overline{\beta(\ell(y))\,\beta(r(w))}. Both sides are contained in the corresponding sides of T⁡(w)T(w). Convex hulls of nested sides on two parallel lines are nested. So T⁡(y)⊆T⁡(w)T(y)\subseteq T(w).

When 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) is the base endpoint vnv_{n}, the point ww sees vnv_{n}. The same proof works with the ray from vnv_{n} through ww, and we use the same name 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w) for the resulting boundary point.

Corollary 4

Every witness set has the same size as a witness set that lies in ∂(𝒲​𝒱)\partial(\mathcal{WV}) and whose members are the points 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w) for the members ww of the original set.

Proof

Let WW be a witness set and let W′W^{\prime} be the set of points 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w) with w∈Ww\in W. Let w1w_{1} and w2w_{2} be two members of WW. Their visibility polygons are disjoint. By Lemma 11 and Lemma 10, the point 𝖱𝖴𝖢⁡(w1)\mathsf{RUC}(w_{1}) has a visibility polygon disjoint from 𝖵𝗂𝗌⁡(w2)\mathsf{Vis}(w_{2}). A second application gives that 𝖱𝖴𝖢⁡(w1)\mathsf{RUC}(w_{1}) and 𝖱𝖴𝖢⁡(w2)\mathsf{RUC}(w_{2}) have disjoint visibility polygons. In particular, they are distinct points. So W′W^{\prime} is a witness set of the same size.

4.4 Discretization

The push lands on a window endpoint in the sense of Definition 6: the base point r⁡(w)r(w) sees 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w), because 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w) lies on the segment from ww to r⁡(w)r(w) and this segment lies in 𝒲​𝒱\mathcal{WV}, and the ray grazes the reflex vertex 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(w)\mathsf{rAnchor}(w), so it supports a window of 𝖵𝗂𝗌⁡(r⁡(w))\mathsf{Vis}(r(w)) whose far endpoint is 𝖱𝖴𝖢⁡(w)\mathsf{RUC}(w). We now describe the finite set of static candidates that the algorithm uses in addition.

We next fix the finite set of points at which the anchors of a boundary point can change.

Definition 13 (Transition Points)

Let QQ be the set consisting of the reflex vertices of 𝒲​𝒱\mathcal{WV} and the two endpoints of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}. The set 𝒳\mathcal{X} of transition points consists of the points 𝗐𝗂𝗇⁡(a,b)\mathsf{win}(a,b) over all ordered pairs (a,b)(a,b) of distinct points of QQ for which Definition 6 defines this point.

The set 𝒳\mathcal{X} has at most (ρ+2)​(ρ+1)(\rho+2)(\rho+1) members. A point of the upper chain that is not a vertex and not a transition point has the same anchors as its neighbors on the chain.

Lemma 12

Remove the vertices and the transition points from the upper chain. Each remaining open arc is called a piece. On a piece, the anchors ℓ​𝖠𝗇𝖼𝗁𝗈𝗋\mathsf{\ell Anchor} and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋\mathsf{rAnchor} are constant. Along a piece, the functions ℓ\ell and rr are continuous, and each is either constant or strictly monotone. When both are strictly monotone, they increase in the same direction.

Proof

Let xx move along a piece. The left anchor ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x) is the first reflex vertex on the shortest path from xx to v0v_{0}. It changes only when xx becomes collinear with ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x) and the next vertex on that path, or with ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x) and v0v_{0}. At such a point xx is a transition point, because xx sees ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x) and the ray through the two vertices enters 𝒲​𝒱\mathcal{WV} there. The same holds for the right anchor. So both anchors are constant on the piece. The piece lies on one edge of 𝒲​𝒱\mathcal{WV}. The value ℓ⁡(x)\ell(x) is the image of xx under the central projection from the edge to the baseline with center ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x), and r⁡(x)r(x) is the image under the projection with center 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)\mathsf{rAnchor}(x). A central projection between two lines whose center is not on either line is continuous and strictly monotone. Both centers lie between the edge and the base, so both projections reverse the orientation. Hence, the two functions increase in the same direction. When an anchor is a base endpoint, the corresponding function is constant.

(a) The set Q={v0,v3,v5,v7}Q=\{v_{0},v_{3},v_{5},v_{7}\} (disks) and the transition points x1,…,x6x_{1},\dots,x_{6} (squares). Each xix_{i} is 𝗐𝗂𝗇⁡(a,b)\mathsf{win}(a,b) for the dotted segment from aa through bb.
(b) The pieces of the upper chain, coloured by their anchor pair (ℓ​𝖠𝗇𝖼𝗁𝗈𝗋,𝗋𝖠𝗇𝖼𝗁𝗈𝗋)(\mathsf{\ell Anchor},\mathsf{rAnchor}), and the static candidates (circles).
Figure 6: Transition points (Definition 13) and static candidates (Definition 14) in a weak visibility polygon with base e𝚋𝚊𝚜𝚎=v0​v7{e}_{\mathtt{base}}=v_{0}v_{7} and reflex vertices v3v_{3} and v5v_{5}. The upper chain is not monotone. The pairs whose second point is v0v_{0} or v7v_{7} contribute the base endpoints themselves to 𝒳\mathcal{X}. The anchors are constant on every piece, but they need not change at a transition point, as the points x1x_{1} and x6x_{6} show. Every candidate other than v0v_{0} and v7v_{7} ends two pieces and therefore appears twice in 𝒞\mathcal{C}.
Definition 14 (Static Candidates)

The set 𝒞\mathcal{C} of static candidates consists of the endpoints of all pieces (Lemma 12). Each static candidate carries the two anchors of its piece and the limits of ℓ\ell and rr along that piece. A boundary point that ends two pieces appears twice in 𝒞\mathcal{C}, once for each piece.

The set 𝒞\mathcal{C} has at most 2​(n+|𝒳|)2(n+|\mathcal{X}|) members. The window endpoints are not static. They depend on the base point that is fired, and the algorithm creates them as it runs.

4.5 Firing

To fire a base point gg means to return 𝗐𝗂𝗇⁡(g,μ)\mathsf{win}(g,\mu) for every reflex vertex μ\mu that supports a window of 𝖵𝗂𝗌⁡(g)\mathsf{Vis}(g).

Observation 6

Firing a base point returns at most ρ\rho points, in clockwise boundary order, and it runs in 𝒪⁡(n+ρ​log⁡n)\mathcal{O}(n+\rho\log n) time. The visibility polygon of a base point is computed in 𝒪⁡(n)\mathcal{O}(n) time [28], and each returned point costs 𝒪⁡(log⁡n)\mathcal{O}(\log n) to locate its base interval by the anchor queries of Section 2.

The next lemma describes the base interval of a returned point.

Lemma 13

Let gg be a base point, let μ\mu be a reflex vertex that supports a window of 𝖵𝗂𝗌⁡(g)\mathsf{Vis}(g), and let t=𝗐𝗂𝗇⁡(g,μ)t=\mathsf{win}(g,\mu). Then gg is an endpoint of 𝙸𝚗𝚝⁡(t)\mathtt{Int}(t), and μ\mu is the anchor of tt at that endpoint. Either ℓ⁡(t)=g\ell(t)=g and ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(t)=μ\mathsf{\ell Anchor}(t)=\mu, or r⁡(t)=gr(t)=g and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(t)=μ\mathsf{rAnchor}(t)=\mu. In the first case, r⁡(t)>gr(t)>g.

Proof

The segment from gg to tt lies in 𝒲​𝒱\mathcal{WV} and passes through the reflex vertex μ\mu. So tt sees gg, and the line of sight grazes μ\mu. Base points on one side of gg are hidden from tt by μ\mu. Hence gg is an endpoint of 𝙸𝚗𝚝⁡(t)\mathtt{Int}(t), and μ\mu is the reflex vertex on the line of sight to that endpoint. This gives the two cases. In the first case, r⁡(t)>ℓ⁡(t)=gr(t)>\ell(t)=g by general position.

Chains grow to the right in a second sense. Their right anchors move clockwise.

Lemma 14

Let x1⊲x2⊲⋯⊲xmx_{1}\lhd x_{2}\lhd\dots\lhd x_{m} be a chain. Then 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x1)≺𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x2)≺⋯≺𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xm)\mathsf{rAnchor}(x_{1})\prec\mathsf{rAnchor}(x_{2})\prec\dots\prec\mathsf{rAnchor}(x_{m}). Consequently m≤ρ+1m\leq\rho+1.

Proof

For consecutive points, xj⊲xj+1x_{j}\lhd x_{j+1} gives 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xj)≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(xj+1)\mathsf{rAnchor}(x_{j})\prec\mathsf{\ell Anchor}(x_{j+1}), and every point satisfies ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(xj+1)⪯𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xj+1)\mathsf{\ell Anchor}(x_{j+1})\preceq\mathsf{rAnchor}(x_{j+1}). So the right anchors strictly increase. A right anchor is a reflex vertex or the endpoint vnv_{n}. There are at most ρ+1\rho+1 such points.

By Lemma 6 and Lemma 14, no witness set has more than ρ+1\rho+1 members.

4.6 The State Table

Let 𝒜\mathcal{A} be the set of possible right anchors. It consists of the reflex vertices and of vnv_{n}, so |𝒜|≤ρ+1|\mathcal{A}|\leq\rho+1. Let h=ρ+1h=\rho+1. A state is a pair (i,μ)(i,\mu) with 1≤i≤h1\leq i\leq h and μ∈𝒜\mu\in\mathcal{A}.

Definition 15 (Table Entries)

For a state (i,μ)(i,\mu), let r∗​(i,μ)r^{*}(i,\mu) be the infimum of r⁡(xi)r(x_{i}) over all chains x1⊲⋯⊲xix_{1}\lhd\dots\lhd x_{i} of points of 𝒲​𝒱\mathcal{WV} with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xi)=μ\mathsf{rAnchor}(x_{i})=\mu. When no such chain exists, we set r∗​(i,μ)=+∞r^{*}(i,\mu)=+\infty.

The largest index ii with a finite entry in row ii is the size of a maximum witness set. This follows from Lemma 6. We show that the table can be filled row by row from finitely many candidates. Row i+1i+1 is determined by row ii.

For a state (i,μ)(i,\mu) with finite entry and for μ′∈𝒜\mu^{\prime}\in\mathcal{A}, let S⁡(i,μ,μ′)S(i,\mu,\mu^{\prime}) be the set of all points x∈𝒲​𝒱x\in\mathcal{WV} that satisfy

ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)≻μ,ℓ⁡(x)>r∗​(i,μ),𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)=μ′.\mathsf{\ell Anchor}(x)\succ\mu,\qquad\ell(x)>r^{*}(i,\mu),\qquad\mathsf{rAnchor}(x)=\mu^{\prime}.

When r∗​(i,μ)=+∞r^{*}(i,\mu)=+\infty the set S⁡(i,μ,μ′)S(i,\mu,\mu^{\prime}) is empty.

Lemma 15

For every state (i+1,μ′)(i+1,\mu^{\prime}),

r∗​(i+1,μ′)=min⁡infμ∈𝒜⁡{r⁡(x)|x∈S⁡(i,μ,μ′)}.r^{*}(i+1,\mu^{\prime})\;=\;\min_{\mu\in\mathcal{A}}\;\inf\bigl\{\,r(x)\bigm|x\in S(i,\mu,\mu^{\prime})\,\bigr\}.
Proof

Write SS for the right-hand side. Let x1⊲⋯⊲xi+1x_{1}\lhd\dots\lhd x_{i+1} be a chain with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xi+1)=μ′\mathsf{rAnchor}(x_{i+1})=\mu^{\prime}, and let μ=𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xi)\mu=\mathsf{rAnchor}(x_{i}). Then ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(xi+1)≻μ\mathsf{\ell Anchor}(x_{i+1})\succ\mu and ℓ⁡(xi+1)>r⁡(xi)≥r∗​(i,μ)\ell(x_{i+1})>r(x_{i})\geq r^{*}(i,\mu). So xi+1x_{i+1} belongs to S⁡(i,μ,μ′)S(i,\mu,\mu^{\prime}), and r⁡(xi+1)≥Sr(x_{i+1})\geq S. Hence r∗​(i+1,μ′)≥Sr^{*}(i+1,\mu^{\prime})\geq S.

Conversely, let μ∈𝒜\mu\in\mathcal{A} and let xx belong to S⁡(i,μ,μ′)S(i,\mu,\mu^{\prime}). Since ℓ⁡(x)>r∗​(i,μ)\ell(x)>r^{*}(i,\mu), there is a chain x1⊲⋯⊲xix_{1}\lhd\dots\lhd x_{i} with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xi)=μ\mathsf{rAnchor}(x_{i})=\mu and r⁡(xi)<ℓ⁡(x)r(x_{i})<\ell(x). Also 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xi)=μ≺ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{rAnchor}(x_{i})=\mu\prec\mathsf{\ell Anchor}(x). So xi⊲xx_{i}\lhd x, and the chain extends by xx. This gives r∗​(i+1,μ′)≤r⁡(x)r^{*}(i+1,\mu^{\prime})\leq r(x). Taking the infimum over xx and the minimum over μ\mu gives r∗​(i+1,μ′)≤Sr^{*}(i+1,\mu^{\prime})\leq S.

The infimum in the recursion ranges over all points of 𝒲​𝒱\mathcal{WV}. The next lemma shows that finitely many candidates suffice. For a state (i,μ)(i,\mu) with finite entry we write g=r∗​(i,μ)g=r^{*}(i,\mu), and we call a point xx a successor of the state when ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)≻μ\mathsf{\ell Anchor}(x)\succ\mu and ℓ⁡(x)>g\ell(x)>g. The set S⁡(i,μ,μ′)S(i,\mu,\mu^{\prime}) consists of the successors with right anchor μ′\mu^{\prime}.

Lemma 16

Let (i,μ)(i,\mu) be a state with finite entry gg, and let μ′∈𝒜\mu^{\prime}\in\mathcal{A}. The infimum of r⁡(x)r(x) over all successors xx with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)=μ′\mathsf{rAnchor}(x)=\mu^{\prime} equals the minimum of the following two quantities.

  1. 1.

    The minimum of r⁡(t)r(t) over the points t=𝗐𝗂𝗇⁡(g,ν)t=\mathsf{win}(g,\nu) returned by firing gg that satisfy ℓ⁡(t)=g\ell(t)=g, ν≻μ\nu\succ\mu, and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(t)=μ′\mathsf{rAnchor}(t)=\mu^{\prime}.

  2. 2.

    The minimum of the limit of rr over the static candidates c∈𝒞c\in\mathcal{C} whose piece has anchors ℓ​𝖠𝗇𝖼𝗁𝗈𝗋≻μ\mathsf{\ell Anchor}\succ\mu and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋=μ′\mathsf{rAnchor}=\mu^{\prime} and whose limit of ℓ\ell exceeds gg.

Each minimum is +∞+\infty when its set is empty.

Proof

Both quantities are at least the infimum. A returned point tt with ℓ⁡(t)=g\ell(t)=g is the limit of successors along its piece, and its value r⁡(t)r(t) is the limit of their values by Lemma 12. A static candidate is a limit of successors along its piece in the same way. So the infimum is at most each of the quantities.

Now let xx be a successor with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)=μ′\mathsf{rAnchor}(x)=\mu^{\prime}. We find a point in one of the two sets with value at most r⁡(x)r(x). Let y=𝖱𝖴𝖢⁡(x)y=\mathsf{RUC}(x). By Lemma 11, the point yy is a successor with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(y)=μ′\mathsf{rAnchor}(y)=\mu^{\prime} and r⁡(y)=r⁡(x)r(y)=r(x). So we may assume that xx lies on the upper chain. If xx is a static candidate, we are done. Otherwise, xx lies on a piece. Move xx along the piece in the direction that decreases rr. By Lemma 12 the value ℓ\ell decreases as well, and the anchors do not change. The motion stops at the first of two events. Either xx reaches an endpoint of the piece, which is a static candidate with the required anchors and with limit of ℓ\ell at least gg, or ℓ⁡(x)\ell(x) reaches gg. In the second event, xx lies on the ray from gg through ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)\mathsf{\ell Anchor}(x), and xx sees gg along this ray. So x=𝗐𝗂𝗇⁡(g,ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x))x=\mathsf{win}(g,\mathsf{\ell Anchor}(x)), with ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(x)≻μ\mathsf{\ell Anchor}(x)\succ\mu and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(x)=μ′\mathsf{rAnchor}(x)=\mu^{\prime}. In both events, the value of rr did not increase.

We illustrate the entire construction on a single polygon. Figure 7 shows a weak visibility polygon with six pockets, the visibility cone of the apex of each pocket, and the trapezoid that Definition 10 assigns to each apex; the apices are the points w1,…,w6w_{1},\dots,w_{6} are used in the rest of this example.

w1w_{1}w2w_{2}w3w_{3}w4w_{4}w5w_{5}w6w_{6}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v0v_{0}v21v_{21}e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}
(a) The polygon 𝒲​𝒱\mathcal{WV} has n=21n=21 and twelve reflex vertices, and it is weakly visible from e𝚋𝚊𝚜𝚎=v21​v0{e}_{\mathtt{base}}=v_{21}v_{0}. Each witness wiw_{i} sits at the apex of a pocket. The shaded region is 𝖵𝗂𝗌⁡(wi)\mathsf{Vis}(w_{i}), whose intersection with the base is the interval 𝙸𝚗𝚝⁡(wi)\mathtt{Int}(w_{i}). Its two bounding rays pass through the anchors ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi)\mathsf{\ell Anchor}(w_{i}) and 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi)\mathsf{rAnchor}(w_{i}). The pockets of w2w_{2} and w4w_{4} lean in opposite directions, so these two witnesses look across each other, and their visibility polygons meet.
LtL_{t}LbL_{b}v0v_{0}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v21v_{21}T⁡(w1)T(w_{1})T⁡(w2)T(w_{2})T⁡(w3)T(w_{3})T⁡(w4)T(w_{4})T⁡(w5)T(w_{5})T⁡(w6)T(w_{6})
(b) The trapezoid T⁡(wi)T(w_{i}) has upper side τ⁡(ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(wi))​τ​(𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(wi))¯\overline{\tau(\mathsf{\ell Anchor}(w_{i}))\,\tau(\mathsf{rAnchor}(w_{i}))} on LtL_{t} and lower side β⁡(ℓ⁡(wi))​β​(r⁡(wi))¯\overline{\beta(\ell(w_{i}))\,\beta(r(w_{i}))} on LbL_{b}. By Theorem 3.1, two witnesses conflict if and only if their trapezoids meet. In particular, T⁡(w2)T(w_{2}) and T⁡(w4)T(w_{4}) cross because the two orders disagree: on LtL_{t} the trapezoid T⁡(w2)T(w_{2}) lies to the left, whereas on LbL_{b} it lies to the right. The vertices of the upper chain that bound the pockets are drawn at a common height for clarity; an arbitrarily small perturbation restores the general position assumed in Section 2 and changes none of the values shown.
Figure 7: A weak visibility polygon and its trapezoid representation.
LtL_{t}LbL_{b}v0v_{0}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v21v_{21}ℓ⁡(w1)\ell(w_{1})r⁡(w1)r(w_{1})ℓ⁡(w3)\ell(w_{3})ℓ⁡(w3′)\ell(w_{3}^{\prime})r⁡(w3)r(w_{3})r⁡(w3′)r(w_{3}^{\prime})T⁡(w1)T(w_{1})T⁡(w3)T(w_{3})T⁡(w3′)T(w_{3}^{\prime})g=r∗​(2,v10)=r⁡(w3)g=r^{*}(2,v_{10})=r(w_{3})
(a) The value g=r∗​(2,v10)=r⁡(w3)g=r^{*}(2,v_{10})=r(w_{3}), attained by w1⊲w3w_{1}\lhd w_{3}, defines the dashed frontier from β⁡(g)\beta(g) to τ⁡(v10)\tau(v_{10}), here the right side of T⁡(w3)T(w_{3}); the competing w3′w_{3}^{\prime} shares the anchors of w3w_{3} but has a larger rr, so Lemma 9 discards it.
LtL_{t}LbL_{b}v0v_{0}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v21v_{21}ggℓ⁡(w5)\ell(w_{5})r⁡(w5)r(w_{5})ℓ⁡(w6)\ell(w_{6})r⁡(w6)r(w_{6})T⁡(w5)T(w_{5})T⁡(w6)T(w_{6})
(b) T⁡(w5)T(w_{5}) and T⁡(w6)T(w_{6}) lies strictly right of the frontier on both lines, so w5w_{5} and w6w_{6} are successors and contribute r⁡(w5)r(w_{5}) and r⁡(w6)r(w_{6}) to row 33.
LtL_{t}LbL_{b}v0v_{0}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v21v_{21}ℓ⁡(w4)\ell(w_{4})r⁡(w4)r(w_{4})ggℓ⁡(w2)\ell(w_{2})r⁡(w2)r(w_{2})T⁡(w2)T(w_{2})T⁡(w4)T(w_{4})ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(w2)≺v10\mathsf{\ell Anchor}(w_{2})\prec v_{10}ℓ⁡(w4)≤g\ell(w_{4})\leq g
(c) Here w2w_{2} fails the anchor condition and w4w_{4} the base condition, each satisfying the other.
LtL_{t}LbL_{b}v0v_{0}v2v_{2}v4v_{4}v5v_{5}v7v_{7}v8v_{8}v10v_{10}v11v_{11}v13v_{13}v14v_{14}v16v_{16}v17v_{17}v19v_{19}v21v_{21}T⁡(w1)T(w_{1})T⁡(w3)T(w_{3})T⁡(w5)T(w_{5})T⁡(w6)T(w_{6})
(d) Iterating gives w1⊲w3⊲w5⊲w6w_{1}\lhd w_{3}\lhd w_{5}\lhd w_{6}, a witness set by Lemma 6.
Figure 8: One step of the recursion of Lemma 15 and Lemma 16 from the state (2,v10)(2,v_{10}), on the polygon of Figure 7(a).

Figure 8 carries out one step of the recursion on the instance of Figure 7, from the state (2,v10)(2,v_{10}).

The algorithm fills the table by Lemma 15 and Lemma 16. It records for each finite entry the candidate that achieved the minimum and the state it came from; Figure 9 shows the completed table for the instance of Figure 7.

Algorithm 2 The state table algorithm.
compute 𝒳\mathcal{X}, the pieces, and the static candidates 𝒞\mathcal{C}
1 set every entry r∗​(i,μ)r^{*}(i,\mu) to +∞+\infty
2 foreach static candidate c∈𝒞c\in\mathcal{C} with anchors (ν,μ′)(\nu,\mu^{\prime}) do
    3 r∗​(1,μ′)←min⁡{r∗​(1,μ′),r⁡(c)}r^{*}(1,\mu^{\prime})\leftarrow\min\{r^{*}(1,\mu^{\prime}),\ r(c)\}
4 for i←1i\leftarrow 1 to h−1h-1 do
    5 foreach μ∈𝒜\mu\in\mathcal{A} with r∗​(i,μ)<+∞r^{*}(i,\mu)<+\infty do
       6 g←r∗​(i,μ)g\leftarrow r^{*}(i,\mu)
       7 fire gg and compute the anchors of every returned point
       8 foreach returned point tt with ℓ⁡(t)=g\ell(t)=g and ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(t)≻μ\mathsf{\ell Anchor}(t)\succ\mu do
          9 r∗​(i+1,𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(t))←min⁡{r∗​(i+1,𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(t)),r⁡(t)}r^{*}(i+1,\mathsf{rAnchor}(t))\leftarrow\min\{r^{*}(i+1,\mathsf{rAnchor}(t)),\ r(t)\}
       10 foreach static candidate cc with anchors (ν,μ′)(\nu,\mu^{\prime}), ν≻μ\nu\succ\mu, and limit of ℓ\ell above gg do
          11 r∗​(i+1,μ′)←min⁡{r∗​(i+1,μ′),r⁡(c)}r^{*}(i+1,\mu^{\prime})\leftarrow\min\{r^{*}(i+1,\mu^{\prime}),\ r(c)\}
12 k←k\leftarrow the largest ii with a finite entry in row ii
13 return a witness set of size kk built from the recorded candidates by Lemma 17
v4v_{4}v7v_{7}v10v_{10}v13v_{13}v16v_{16}v19v_{19}v21v_{21}i\μi\,\backslash\,\mu11223344552.82.814148.88.88.58.517.617.621212424+∞+\infty14148.88.88.58.517.617.62121+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty17.617.62121+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty2121+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\infty+∞+\inftyw3w_{3}w5w_{5}w6w_{6}
Figure 9: The state table for the polygon of Figure 7(a), filled row by row by Lemmas 15 and 16. A column is shown for each anchor that is the 𝗋𝖠𝗇𝖼𝗁𝗈𝗋\mathsf{rAnchor} of some point of 𝒲​𝒱\mathcal{WV}; the remaining six columns of 𝒜\mathcal{A} are identically +∞+\infty, as are the rows below the fifth, and both are omitted. The arrows record, for each shaded entry, the candidate that achieved the minimum and the state it came from. Row 55 is empty, so the largest index with a finite entry is k=4k=4, which by Lemmas 6 and 14 is the size of a maximum witness set; following the records backward, as in Lemma 17, returns the chain w1⊲w3⊲w5⊲w6w_{1}\lhd w_{3}\lhd w_{5}\lhd w_{6}.
Theorem 4.1 (Correctness)

Algorithm 2 computes every entry r∗​(i,μ)r^{*}(i,\mu) of the table. The number kk that it returns is the size of a maximum witness set of 𝒲​𝒱\mathcal{WV}.

Proof

We use induction on the row index. Row 11 is correct. The entry r∗​(1,μ′)r^{*}(1,\mu^{\prime}) is the infimum of rr over all points with right anchor μ′\mu^{\prime}. By Lemma 11, the infimum over 𝒲​𝒱\mathcal{WV} equals the infimum over the upper chain. By Lemma 12 the infimum over the upper chain is attained in the limit at a piece endpoint, that is, at a static candidate. Now assume that row ii is correct. For each state of row ii with a finite entry, the algorithm performs the update of Lemma 16. By Lemma 15 this yields row i+1i+1. The claim about kk follows from Lemma 6, Lemma 14, and Definition 15.

The recorded candidates form a chain in a weak sense. Two consecutive candidates may touch on the base. A small shift removes the contact.

Lemma 17

Let r∗​(k,μ)<+∞r^{*}(k,\mu)<+\infty. Following the records backward from (k,μ)(k,\mu) gives candidates y1,…,yky_{1},\dots,y_{k} with 𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(yk)=μ\mathsf{rAnchor}(y_{k})=\mu. These candidates can be shifted along their pieces into points x1⊲x2⊲⋯⊲xkx_{1}\lhd x_{2}\lhd\dots\lhd x_{k}. The set {x1,…,xk}\{x_{1},\dots,x_{k}\} is a witness set of size kk.

Proof

Each record was produced by Lemma 16. So for every index j<kj<k, the candidate yj+1y_{j+1} is a limit of successors of the state that contains yjy_{j}, along a piece αj+1\alpha_{j+1}. In particular ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(yj+1)≻𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(yj)\mathsf{\ell Anchor}(y_{j+1})\succ\mathsf{rAnchor}(y_{j}) and ℓ⁡(yj+1)≥r⁡(yj)\ell(y_{j+1})\geq r(y_{j}), where the inequality may be an equality. We process j=2,…,kj=2,\dots,k in this order. Move yjy_{j} along αj\alpha_{j} into the direction that increases ℓ\ell, by a positive distance small enough that ℓ⁡(yj)>r⁡(yj−1)\ell(y_{j})>r(y_{j-1}) holds for the shifted point. Such a distance exists because yjy_{j} is a limit of successors along αj\alpha_{j}. The shift increases r⁡(yj)r(y_{j}) by a small amount, and the next step will move yj+1y_{j+1} past the new value. After the last step, consecutive points satisfy ℓ⁡(xj+1)>r⁡(xj)\ell(x_{j+1})>r(x_{j}) and ℓ​𝖠𝗇𝖼𝗁𝗈𝗋​(xj+1)≻𝗋𝖠𝗇𝖼𝗁𝗈𝗋⁡(xj)\mathsf{\ell Anchor}(x_{j+1})\succ\mathsf{rAnchor}(x_{j}), because anchors do not change along a piece. Hence xj⊲xj+1x_{j}\lhd x_{j+1} for every jj, and the points form a chain by transitivity. By Lemma 6 they form a witness set.

Corollary 5

Algorithm 2 returns a maximum witness set of 𝒲​𝒱\mathcal{WV}.

Backtracking through the records of Figure 9 returns the four points drawn in Figure 10, which is a maximum witness set of that polygon.

w2w_{2}w4w_{4}w1w_{1}w3w_{3}w5w_{5}w6w_{6}v0v_{0}v21v_{21}e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}}
Figure 10: The maximum witness set {w1,w3,w5,w6}\{w_{1},w_{3},w_{5},w_{6}\} returned by algorithm 2 on the polygon of Figure 7(a), so that μW​S​(𝒲​𝒱,𝒲​𝒱)=4\mu_{WS}(\mathcal{WV},\mathcal{WV})=4. The four visibility polygons are pairwise disjoint, as Definition 3 demands, and the four base intervals 𝙸𝚗𝚝⁡(wi)\mathtt{Int}(w_{i}) drawn in bold are pairwise disjoint and ordered from left to right, in agreement with Observation 5. The two witnesses marked with a cross are excluded: each of them conflicts with a member of the set, and no witness set of this polygon has five members. The optimum is not unique, since {w1,w2,w5,w6}\{w_{1},w_{2},w_{5},w_{6}\} is a second maximum witness set.

4.7 Termination

The algorithm processes each state at most once and fires one base point per state. The number of anchors bounds the number of states. This gives termination without any hypothesis on the polygon.

Theorem 4.2

Algorithm 2 fires at most (ρ+1)2(\rho+1)^{2} base points, creates at most ρ​(ρ+1)2\rho(\rho+1)^{2} window endpoints, and stops.

Proof

A base point is fired once for each state with a finite entry. There are at most h⋅|𝒜|≤(ρ+1)2h\cdot|\mathcal{A}|\leq(\rho+1)^{2} states. Each firing returns at most ρ\rho points by Observation 6. Every loop of the algorithm runs over a finite set, so the algorithm stops.

We close with a remark on why such a bound is needed. Firing produces points whose right endpoints move to the right by Lemma 13. Firing a returned point again can produce a further point with the same two anchors, and so on. This cascade consists of points that touch each other on the base, and their base intervals tile a part of e𝚋𝚊𝚜𝚎{e}_{\mathtt{base}} from left to right. The cascade can be infinite. Its points all share one right anchor, and their right endpoints increase. By Lemma 9 the first point of the cascade can replace every later one. Algorithm 2 never fires a point of such a cascade after the first, because it fires only table entries, and a table entry is the smallest right endpoint of its anchor. This is the reason why the algorithm is stated in terms of states rather than in terms of individual candidates.

5 Running Time

We bound the running time of algorithm 2.

Preprocessing.

We triangulate 𝒲​𝒱\mathcal{WV} in 𝒪⁡(n)\mathcal{O}(n) time [11] and build the shortest path trees from v0v_{0} and from vnv_{n} in 𝒪⁡(n)\mathcal{O}(n) time [25]. These trees answer an anchor query for any point of ∂(𝒲​𝒱)\partial(\mathcal{WV}) in 𝒪⁡(log⁡n)\mathcal{O}(\log n) time. A ray shooting structure with 𝒪⁡(n)\mathcal{O}(n) preprocessing answers a query in 𝒪⁡(log⁡n)\mathcal{O}(\log n) time [26]. The set 𝒳\mathcal{X} has 𝒪⁡(ρ2)\mathcal{O}(\rho^{2}) members, and a single ray-shooting query finds each. We sort the vertices and the transition points along the upper chain in 𝒪⁡((n+ρ2)​log⁡n)\mathcal{O}((n+\rho^{2})\log n) time. This yields the pieces. For each piece, we query the anchors of an interior point once, and we compute the limits of ℓ\ell and rr at its two endpoints by two projections. The preprocessing therefore takes 𝒪⁡((n+ρ2)​log⁡n)\mathcal{O}((n+\rho^{2})\log n) time.

One state.

Consider a state (i,μ)(i,\mu) with finite entry gg. The visibility polygon of the base point gg is computed in 𝒪⁡(n)\mathcal{O}(n) time [28]. Its windows and their far endpoints are read simultaneously. There are at most ρ\rho returned points, and the anchors of each cost 𝒪⁡(log⁡n)\mathcal{O}(\log n). The scan over the static candidates takes 𝒪⁡(n+ρ2)\mathcal{O}(n+\rho^{2}) time. So one state costs 𝒪⁡(n+ρ2+ρ​log⁡n)\mathcal{O}(n+\rho^{2}+\rho\log n) time, which is 𝒪⁡(n+ρ2)\mathcal{O}(n+\rho^{2}).

All states.

By Theorem 4.2 there are at most (ρ+1)2(\rho+1)^{2} states with a finite entry. The output step of Lemma 17 shifts k≤ρ+1k\leq\rho+1 points, each in 𝒪⁡(log⁡n)\mathcal{O}(\log n) time. Adding the preprocessing gives the bound.

Theorem 5.1 (Running Time)

Algorithm 2 computes a maximum witness set of a weak visibility polygon with nn vertices and ρ\rho reflex vertices in

𝒪⁡(n​log⁡n+ρ2​(n+ρ2))\mathcal{O}\bigl(\,n\log n+\rho^{2}(n+\rho^{2})\,\bigr)

time.

For polygons with ρ=𝒪⁡(n)\rho=\mathcal{O}(\sqrt{n}) reflex vertices the bound is 𝒪⁡(n2)\mathcal{O}(n^{2}). The term ρ2​n\rho^{2}n comes from computing one visibility polygon per state. Replacing this computation by ρ\rho ray shooting queries per state, and replacing the scan over 𝒞\mathcal{C} by a two-dimensional range minimum structure, lowers the bound to 𝒪⁡(n​log⁡n+ρ3​log2​n)\mathcal{O}(n\log n+\rho^{3}\log^{2}n). We do not need this refinement for the results of this paper.

6 Conclusion

We gave the first exact polynomial time algorithms for witness sets in weak visibility polygons, in both the discrete and the continuous model. The discrete algorithm is near-linear and optimal, and it rests on a structural fact of independent interest: the visibility intersection graph of a weak visibility polygon is a trapezoid graph, and the class of these graphs in turn properly contains the interval graphs and the permutation graphs.

Monotone mountains are perfect: their guard number equals their witness number [13]. Weak visibility polygons are not. There are such polygons on nn vertices that require Ω⁡(n)\Omega(n) guards and whose maximum witness set is a single point, so the certificate a maximum witness set provides can be as weak as the trivial one. The witness number of a weak visibility polygon is therefore worth computing in its own right, and not as a proxy for the guard number.

Our work leaves three concrete questions.

  1. 1.

    Is every trapezoid graph a visibility intersection graph of some weak visibility polygon? A positive answer would characterize the conflict structure of 𝙳𝚒𝚜𝚌𝚆𝚂𝙿\mathtt{DiscWSP} exactly.

  2. 2.

    Our lower bound for 𝙳𝚒𝚜𝚌𝚆𝚂𝙿\mathtt{DiscWSP} is tight when m=Θ⁡(n)m=\Theta(n). For larger mm the picture changes, because a witness set has at most ρ+1\rho+1 members, and most of the input is therefore discarded. What is the exact complexity in that regime?

  3. 3.

    Can the running time for 𝙲𝚘𝚗𝚝𝚆𝚂𝙿\mathtt{ContWSP} be improved? Replacing each visibility polygon computation by ρ\rho ray shooting queries, and the scan over the static candidates by a two-dimensional range minimum structure, appears to give 𝒪⁡(n​log⁡n+ρ3​log2​n)\mathcal{O}(n\log n+\rho^{3}\log^{2}n).

Declaration on the use of AI.

The authors used Claude (Anthropic) to assist with drafting and revising portions of the manuscript text. All mathematical results, proofs, and technical content are the authors’ own.

References

  • [1] M. Abrahamsen, A. Adamaszek, and T. Miltzow (2022) The art gallery problem is ∃\existsR-complete. J. ACM 69 (4), pp. 29:1–29:70. External Links: Document Cited by: §1.
  • [2] Y. Amit, J. S. B. Mitchell, and E. Packer (2010) Locating guards for visibility coverage of polygons. Int. J. Comput. Geom. Appl. 20 (5), pp. 601–630. External Links: Document Cited by: §1, §1.1, Definition 3, Abstract.
  • [3] S. Ashur, O. Filtser, M. J. Katz, and R. Saban (2022) Terrain-like graphs: PTASs for guarding weakly-visible polygons and terrains. Computational Geometry 101, pp. 101832. External Links: Document Cited by: §1.
  • [4] S. Ashur, O. Filtser, and M. J. Katz (2021) A constant-factor approximation algorithm for vertex guarding a WV-polygon. J. Comput. Geom. 12 (1), pp. 128–144. External Links: Document Cited by: §1.
  • [5] P. Belleville (1991) Computing two-covers of simple polygons. Master’s Thesis, McGill University. Cited by: Definition 4.
  • [6] B. Ben-Moshe, M. J. Katz, and J. S. B. Mitchell (2007) A constant-factor approximation algorithm for optimal 1.5D terrain guarding. SIAM Journal on Computing 36 (6), pp. 1631–1647. External Links: Document Cited by: §1.1.
  • [7] M. Ben-Or (1983) Lower bounds for algebraic computation trees (preliminary report). In Proceedings of the 15th Annual ACM Symposium on Theory of Computing, 25-27 April, 1983, Boston, Massachusetts, USA, D. S. Johnson, R. Fagin, M. L. Fredman, D. Harel, R. M. Karp, N. A. Lynch, C. H. Papadimitriou, R. L. Rivest, W. L. Ruzzo, and J. I. Seiferas (Eds.), pp. 80–86. External Links: Document Cited by: Proof.
  • [8] P. Bhattacharya, S. K. Ghosh, and B. Roy (2017) Approximability of guarding weak visibility polygons. Discrete Applied Mathematics 228, pp. 109–129. Note: CALDAM 2015 External Links: Document Cited by: §1.
  • [9] É. Bonnet and T. Miltzow (2020) Parameterized hardness of art gallery problems. ACM Transactions on Algorithms 16 (4), pp. 42:1–42:23. External Links: Document Cited by: §1.
  • [10] R. Browne, P. N. Kasthurirangan, J. S. B. Mitchell, and V. Polishchuk (2023) Constant-factor approximation algorithms for convex cover and hidden set in a simple polygon. In 64th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2023, pp. 1357–1365. External Links: Document Cited by: §1.
  • [11] B. Chazelle (1991) Triangulating a simple polygon in linear time. Discrete & Computational Geometry 6 (5), pp. 485–524. External Links: Document Cited by: §5, Proof.
  • [12] V. Chvátal (1975) A combinatorial theorem in plane geometry. J. Comb. Theory, Ser. B 18 (1), pp. 39–41. External Links: Document Cited by: §1.
  • [13] O. Daescu, S. Friedrichs, H. Malik, V. Polishchuk, and C. Schmidt (2019) Altitude terrain guarding and guarding uni-monotone polygons. Computational Geometry 84, pp. 22–35. Note: Special Issue on the 34th European Workshop on Computational Geometry External Links: Document Cited by: §1, §6, Abstract.
  • [14] I. Dagan, M. C. Golumbic, and R. Y. Pinter (1988) Trapezoid graphs and their coloring. Discrete Applied Mathematics 21 (1), pp. 35–46. External Links: Document Cited by: item, Proof.
  • [15] U. Das, B. Dutta, S. Jana, D. Pal, and S. Roy (2025) Witness set in monotone polygons: exact and approximate. CoRR abs/2511.10224. External Links: Document Cited by: §1, §2, Definition 7.
  • [16] A. Efrat and S. Har-Peled (2006) Guarding galleries and terrains. Information Processing Letters 100 (6), pp. 238–245. External Links: Document Cited by: §1.
  • [17] S. J. Eidenbenz, C. Stamm, and P. Widmayer (2001) Inapproximability results for guarding polygons and terrains. Algorithmica 31 (1), pp. 79–113. External Links: Document Cited by: §1.
  • [18] S. Felsner, R. Müller, and L. Wernisch (1997) Trapezoid graphs and generalizations, geometry and algorithms. Discrete Applied Mathematics 74 (1), pp. 13–32. External Links: Document Cited by: item, Proof, Proof, Proof, Proof, 12.
  • [19] S. Fisk (1978) A short proof of Chvátal’s watchman theorem. Journal of Combinatorial Theory, Series B 24 (3), pp. 374. External Links: Document Cited by: §1.
  • [20] M. L. Fredman (1975) On computing the length of longest increasing subsequences. Discrete Mathematics 11 (1), pp. 29–35. External Links: Document Cited by: Proof.
  • [21] S. K. Ghosh (2010) Approximation algorithms for art gallery problems in polygons. Discrete Applied Mathematics 158 (6), pp. 718–722. External Links: Document Cited by: §1.
  • [22] S. Ghosh (2007) Visibility algorithms in the plane. Cambridge University Press, USA. Cited by: Definition 2.
  • [23] M. C. Golumbic (2004) Algorithmic graph theory and perfect graphs. 2nd edition, Annals of Discrete Mathematics, Vol. 57, Elsevier. External Links: Document Cited by: item, Proof.
  • [24] H. González-Banos and J. Latombe (2001) A randomized art-gallery algorithm for sensor placement. In Proceedings of the 17th Annual Symposium on Computational Geometry (SoCG 2001), pp. 232–240. External Links: Document Cited by: §1.1.
  • [25] L. J. Guibas, J. Hershberger, D. Leven, M. Sharir, and R. E. Tarjan (1987) Linear-time algorithms for visibility and shortest path problems inside triangulated simple polygons. Algorithmica 2 (1–4), pp. 209–233. External Links: Document Cited by: §4, §5, Proof.
  • [26] J. Hershberger and S. Suri (1995) A pedestrian approach to ray shooting: shoot a ray, take a walk. J. Algorithms 18 (3), pp. 403–431. External Links: Document Cited by: §5.
  • [27] S. Jana, D. Pal, B. Roy, and S. Roy (2026) Witness set: A visibility problem in NP ∩\cap XP. CoRR abs/2605.01592. External Links: Document Cited by: §1.
  • [28] B. Joe and R. B. Simpson (1987) Corrections to Lee’s visibility polygon algorithm. BIT Numerical Mathematics 27 (4), pp. 458–473. External Links: Document Cited by: §5, Observation 6.
  • [29] M. J. Katz (2018) A PTAS for vertex guarding weakly-visible polygons, an extended abstract. CoRR abs/1803.02160. Cited by: §1.
  • [30] J. King and D. G. Kirkpatrick (2011) Improved approximation for guarding simple galleries from the perimeter. Discrete & Computational Geometry 46 (2), pp. 252–269. External Links: Document Cited by: §1.
  • [31] J. King and E. Krohn (2011) Terrain guarding is NP-hard. SIAM Journal on Computing 40 (5), pp. 1316–1339. Cited by: §1.
  • [32] A. Kröller, T. Baumgartner, S. P. Fekete, and C. Schmidt (2012) Exact solutions and bounds for general art gallery problems. ACM Journal of Experimental Algorithmics 17 (1), pp. 2.3:1–2.3:23. External Links: Document Cited by: §1.1.
  • [33] D. Lee and A. K. Lin (1986) Computational complexity of art gallery problems. IEEE Trans. Inf. Theory 32 (2), pp. 276–282. External Links: Document Cited by: §1.
  • [34] S. Mondal, U. Das, and S. Roy (2026) Perfectly guarding straits: exact algorithms for weak visibility polygons. CoRR abs/2609.15510. External Links: Document Cited by: footnote 1.
  • [35] J. O’Rourke (1987) Art gallery theorems and algorithms. Oxford University Press. Cited by: Abstract.
  • [36] F. P. Preparata and M. I. Shamos (1985) Computational geometry - an introduction. Texts and Monographs in Computer Science, Springer. External Links: Document Cited by: Proof.
  • [37] D. C. Tozoni, P. J. de Rezende, and C. C. de Souza (2016) Algorithm 966: a practical iterative algorithm for the art gallery problem using integer linear programming. ACM Transactions on Mathematical Software 43 (2), pp. 16:1–16:27. External Links: Document Cited by: §1.1.
  • [38] B. Wang (2011) Coverage problems in sensor networks: a survey. ACM Computing Surveys 43 (4), pp. 32:1–32:53. External Links: Document Cited by: §1.1.