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 (any number of sets) | convex |
| affine image | convex |
| affine preimage | convex |
| Minkowski sum | convex |
| Cartesian product | convex |
| union | not convex in general |
A polyhedron is an intersection of halfspaces, so it is convex. The set of with is the affine preimage of a ball, so it is convex. A linear matrix inequality is the preimage of the PSD cone under an affine map, so its solution set is convex too.
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 .
The separating hyperplane theorem
If and are disjoint convex sets, there is a nonzero and a number with
For two closed bounded sets the construction is concrete: find the closest pair , ; the hyperplane through their midpoint, perpendicular to , 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:
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 of a convex set there is a supporting hyperplane: for all . 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 has no solution, a separating hyperplane gives a vector with and (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
.
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 and the disk of radius centred at the origin?
Answer
The square grown by on every side with rounded corners (a "rounded square"); its area is .
Solution
Every point within distance of the square is reached. The extra area is four strips plus four quarter disks of radius , which make one full disk.
Exercise 3: Find a separator (code)
Separate the points from : check that , works.
Answer
Yes: is 0 on the first set and 2 or 3 on the second.
Solution
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 separates the two sets; any strictly between 0 and 2 works.
Test yourself
Which operation can destroy convexity?
- Intersection
- Affine image
- Union
- Cartesian product
The separating hyperplane theorem says that two disjoint convex sets…
- always intersect
- can be separated by a hyperplane
- are both bounded
- have the same dimension
The image of the unit ball under with invertible is…
- a ball
- an ellipsoid
- a polyhedron
- not convex