TExcelTAD
Home › Optimization › Operations on Convex Sets and Separation

Operations on Convex Sets and Separation

Proving convexity from the definition is tedious. In practice you build convex sets from simple ones with operations that are known to preserve convexity. This lesson lists those operations and then proves the fact that makes duality and certificates work: two disjoint convex sets can be separated by a hyperplane.

Operations that preserve convexity

Operation Result
intersection C1∩C2C_1 \cap C_2 (any number of sets) convex
affine image {Ax+b:x∈C}\{A\mathbf{x} + \mathbf{b} : \mathbf{x} \in C\} convex
affine preimage {x:Ax+b∈C}\{\mathbf{x} : A\mathbf{x} + \mathbf{b} \in C\} convex
Minkowski sum C1+C2={x+y}C_1 + C_2 = \{\mathbf{x} + \mathbf{y}\} convex
Cartesian product C1×C2C_1 \times C_2 convex
union C1∪C2C_1 \cup C_2 not convex in general

A polyhedron is an intersection of halfspaces, so it is convex. The set of x\mathbf{x} with ∥Ax−b∥≤1\lVert A\mathbf{x} - \mathbf{b} \rVert \le 1 is the affine preimage of a ball, so it is convex. A linear matrix inequality x1A1+⋯+xnAn⪯Bx_1A_1 + \dots + x_nA_n \preceq B is the preimage of the PSD cone under an affine map, so its solution set is convex too.

python · try it yourself
import numpy as np

# Affine image of the unit disk: an ellipse. Its points satisfy x^T (A A^T)^{-1} x <= 1.
A = np.array([[2.0, 1.0], [0.0, 1.0]])
theta = np.linspace(0, 2 * np.pi, 8, endpoint=False)
disk_pts = np.stack([np.cos(theta), np.sin(theta)])        # on the unit circle
img = A @ disk_pts
P_inv = np.linalg.inv(A @ A.T)
vals = np.einsum("ij,ik,kj->j", img, P_inv, img)
print("x^T P^-1 x on the image of the circle:", np.round(vals, 6))
x^T P^-1 x on the image of the circle: [1. 1. 1. 1. 1. 1. 1. 1.]

The image of the unit circle lands exactly on the boundary of the ellipsoid with P=AATP = AA^T.

The separating hyperplane theorem

If CC and DD are disjoint convex sets, there is a nonzero a\mathbf{a} and a number bb with

aTx≤b for all x∈C,aTx≥b for all x∈D\mathbf{a}^T\mathbf{x} \le b \ \text{for all } \mathbf{x} \in C, \qquad \mathbf{a}^T\mathbf{x} \ge b \ \text{for all } \mathbf{x} \in D

For two closed bounded sets the construction is concrete: find the closest pair c∈C\mathbf{c} \in C, d∈D\mathbf{d} \in D; the hyperplane through their midpoint, perpendicular to d−c\mathbf{d} - \mathbf{c}, separates them. For two polytopes given by points, the closest pair of their hulls is a small QP; here we just search over convex combinations with projected gradient steps:

python · try it yourself
import numpy as np

C = np.array([[0.0, 0.0], [2.0, 0.0], [0.0, 2.0]])          # triangle
D = np.array([[3.0, 3.0], [5.0, 2.0], [4.0, 5.0]])          # another triangle

def project_simplex(v):
    u = np.sort(v)[::-1]; css = np.cumsum(u)
    k = np.nonzero(u * np.arange(1, len(v) + 1) > css - 1)[0][-1]
    return np.maximum(v - (css[k] - 1) / (k + 1), 0)

lam, mu = np.full(3, 1 / 3), np.full(3, 1 / 3)
for _ in range(2000):
    diff = C.T @ lam - D.T @ mu
    lam = project_simplex(lam - 0.05 * (C @ diff))
    mu = project_simplex(mu + 0.05 * (D @ diff))
c, d = C.T @ lam, D.T @ mu
a = d - c; b = a @ (c + d) / 2
print("closest points:", np.round(c, 4), np.round(d, 4))
print("max a^T x on C:", round(float((C @ a).max()), 4), "<= b =", round(float(b), 4), "<= min on D:", round(float((D @ a).min()), 4))
closest points: [1. 1.] [3. 3.]
max a^T x on C: 4.0 <= b = 8.0 <= min on D: 12.0

Supporting hyperplanes

At every boundary point x0\mathbf{x}_0 of a convex set there is a supporting hyperplane: aTx≤aTx0\mathbf{a}^T\mathbf{x} \le \mathbf{a}^T\mathbf{x}_0 for all x∈C\mathbf{x} \in C. For a smooth convex function, the tangent plane is a supporting hyperplane of its epigraph, which is the geometric content of the first-order condition in the next lesson.

Why separation matters

  • Certificates of infeasibility: if a system Ax≤bA\mathbf{x} \le \mathbf{b} has no solution, a separating hyperplane gives a vector y≥0\mathbf{y} \ge 0 with ATy=0A^T\mathbf{y} = 0 and bTy<0\mathbf{b}^T\mathbf{y} < 0 (Farkas' lemma), which a solver can return as proof.
  • Duality: strong duality is proved by separating two convex sets built from the problem (Weak and Strong Duality).
  • Classification: a linear classifier is a separating hyperplane between two point clouds; the SVM picks the one with the widest margin.

In software

  • Linear SVMs (sklearn.svm.LinearSVC) compute a maximum-margin separating hyperplane.
  • The GJK algorithm in physics engines finds the closest points of two convex shapes, exactly the construction above, to detect collisions.
  • LP solvers return a Farkas certificate when a problem is infeasible (HiGHS, Gurobi FarkasDual).

Exercises

Exercise 1: Union

Give two convex sets on the real line whose union is not convex.

Answer

[0,1]∪[2,3][0, 1] \cup [2, 3].

Solution

1 and 2 are in the union, but their midpoint 1.5 is not.

Exercise 2: Minkowski sum

What is the Minkowski sum of the square [0,1]2[0, 1]^2 and the disk of radius rr centred at the origin?

Answer

The square grown by rr on every side with rounded corners (a "rounded square"); its area is 1+4r+πr21 + 4r + \pi r^2.

Solution

Every point within distance rr of the square is reached. The extra area is four 1×r1 \times r strips plus four quarter disks of radius rr, which make one full disk.

Exercise 3: Find a separator (code)

Separate the points {(0,0),(1,0)}\{(0, 0), (1, 0)\} from {(0,2),(1,3)}\{(0, 2), (1, 3)\}: check that a=(0,1)\mathbf{a} = (0, 1), b=1b = 1 works.

Answer

Yes: aTx=y\mathbf{a}^T\mathbf{x} = y is 0 on the first set and 2 or 3 on the second.

Solution
python · try it yourself
import numpy as np
C = np.array([[0, 0], [1, 0]]); D = np.array([[0, 2], [1, 3]]); a = np.array([0, 1])
print((C @ a).max() <= 1 <= (D @ a).min())
True

The line y=1y = 1 separates the two sets; any bb strictly between 0 and 2 works.

Test yourself

Which operation can destroy convexity?

  1. Intersection
  2. Affine image
  3. Union
  4. Cartesian product

The separating hyperplane theorem says that two disjoint convex sets…

  1. always intersect
  2. can be separated by a hyperplane
  3. are both bounded
  4. have the same dimension

The image of the unit ball under x↦Ax\mathbf{x} \mapsto A\mathbf{x} with invertible AA is…

  1. a ball
  2. an ellipsoid
  3. a polyhedron
  4. not convex