Part I · trunk A · linear programming · spine

01

Polyhedra, cones, and Farkas' lemma

The shape of a feasible region, three names for its corners, and a short proof that a linear system has no solution.

needs 00~2 h slides + 2½ h lablab: uv run co lab 01

01 · overview

The route

polyhedrahalfspaces, faces cornersvertex = extreme = BFS Minkowski–WeylH ⇔ V Fourier–Motzkinprojection Farkascertificates FTLPoptima at vertices

The destination is Farkas' lemma. Unit 03 builds LP duality on it, and through duality it reaches most of the course.

The surprise: the constructive proof of Farkas is a bookkeeping exercise on Fourier–Motzkin elimination. You will do it in lab step 5.

getting around

Words with a dotted underline are glossary terms: click one for its definition. G lists every term in the unit, N shows the notes, where the full proofs live. Optional extra: interactive figures, linked from the slides they support by a small ▸ chip; skip them freely.

section 1

Polyhedra

Finitely many linear inequalities, and the shapes they cut out.

01 · polyhedra

Halfspaces, polyhedra, polytopes

definitions

A halfspace is $\{x \in \mathbb{R}^n : a x \le \beta\}$ with $a \ne 0$: one side of a line (in 2-D) or a plane. Its boundary $\{a x = \beta\}$ is a hyperplane.

A polyhedron is what finitely many halfspaces have in common: $$P = \{x : Ax \le b\}.$$

A polytope is a polyhedron that doesn't run off to infinity.

Every polyhedron is convex (the segment between two of its points stays inside) and closed. Equalities, $\ge$, and sign constraints all fit this form.

one form to another

$a x = \beta \;\to\; a x \le \beta,\ -a x \le -\beta$

$a x \ge \beta \;\to\; -a x \le -\beta$

free $x_j \;\to\; x_j^+ - x_j^-,\ x_j^\pm \ge 0$

$a x \le \beta \;\to\; a x + s = \beta,\ s \ge 0$ (a slack variable)

Standard form $\{x : Ax = b,\ x \ge 0\}$ is what simplex works in (unit 02). This unit uses $Ax \le b$.

01 · polyhedra · example

The running example

Four constraints in $\mathbb{R}^2$, numbered 1–4 for the rest of the unit (constraint $i$ is row $i$ of $Ax \le b$). Every later slide comes back to this $P$. Underlined like constraint 3: hover to see it.

constraint$a_i x \le b_i$at $(1,1)$at $(3,2)$at $(2.5,1.5)$
1$-x \le 0$$-1$ ✓$-3$ ✓$-2.5$ ✓
2$-y \le 0$$-1$ ✓$-2$ ✓$-1.5$ ✓
3$x + y \le 4$$2$ ✓$5$ ✗$4$ =
4$x - y \le 1$$0$ ✓$1$ =$1$ =

Membership is plugging in. $(1,1)$ satisfies every constraint with room to spare: it is inside. $(3,2)$ breaks constraint 3: it is outside. $(2.5,1.5)$ satisfies everything, two constraints with no room at all: it sits on two walls at once.

Hold on to that last observation. "No room at all" is the idea the whole corners section is built on.

(1, 1) (3, 2) (2.5, 1.5) constraint 4 constraint 3 P

$P$ has corners $(0,0)$, $(1,0)$, $(2.5,1.5)$, $(0,4)$. Dashed: the lines where constraints 3 and 4 hold with equality.

01 · polyhedra

Faces

definition

An inequality $c x \le \delta$ is a valid inequality for $P$ if every point of $P$ satisfies it. The face it defines is the part of $P$ where it holds with equality: $F = P \cap \{x : c x = \delta\}$.

Picture pressing a ruler against $P$ from outside: the face is what the ruler touches.

valid inequalityface of the examplekind
$x - y \le 1$segment $(1,0)$–$(2.5,1.5)$edge, a facet
$-x + y \le 4$the single point $(0,4)$vertex
$x + y \le 5$nothing: never tightempty face
$0x + 0y \le 0$all of $P$$P$ itself

A 2-D polytope's facets are its edges. In general facets have dimension $\dim P - 1$, and a full-dimensional polyhedron needs one inequality per facet; any other constraint is a redundant inequality.

(2.5, 1.5) (0, 4) edge x − y = 1 P

Thick: the edge from $x - y \le 1$. Large dot: the vertex $(0,4)$, the only point where $-x + y \le 4$ is tight (dotted line).

section 2

Three names for a corner

A geometric one, a convexity one, and an algebraic one, and why they agree.

01 · corners

Tight constraints, and counting them

definition

Constraint $i$ is tight at a point $x$ if $x$ lies on its line: $a_i x = b_i$, no slack. It depends on the point: constraint 3 is tight at $(2.5, 1.5)$ but not at $(1, 1)$. Write $I(x)$ for the set of constraints tight at $x$.

The rank of the tight constraints counts how many different directions those walls face: constraints 3 and 4 give rank 2, and a wall listed twice counts once.

pointtight constraintsrankwhere it is
$(1, 1)$none0inside
$(0, 2)$constraint 11on an edge
$(1.75, 0.75)$constraint 41on an edge
$(2.5, 1.5)$constraints 3, 42a corner

The pattern: with rank below $n$ you can still slide along the tight walls. With rank $n$ (here $n = 2$), the walls pin the point down completely. That is what a corner is.

(1, 1): free to move (0, 2) (1.75, 0.75) (2.5, 1.5): pinned

Thick: the directions a point on one wall can still slide in. At the corner there is none left.

01 · corners

Vertex, extreme point, basic feasible solution

Three ways to say what a corner of $P = \{x : Ax \le b\}$ is:

vertex · geometry

Some objective $c$ is maximized over $P$ at $x$ and nowhere else.

A ruler touches $P$ only at $x$.

extreme point · convexity

$x$ is not the midpoint (or any in-between point) of two other points of $P$.

No segment in $P$ passes through $x$.

BFS · algebra

The tight constraints at $x$ have rank $n$.

Enough walls meet to pin $x$ down.

theorem

For $x \in P$ the three are the same thing: a vertex is an extreme point is a basic feasible solution.

The geometric name is what optimization needs. The algebraic one is what a computer can check, and simplex walks on it.

01 · corners

Why the three agree

vertex ⇒ extreme

If $x$ were between two other points of $P$, the objective at $x$ would be the average of its values there. One of them would be at least as good as $x$, so $x$ couldn't be the only best point.

extreme ⇒ BFS

If the tight walls had rank below $n$, $x$ could slide a little both ways along them, as on the tight-constraints slide. Then $x$ is the midpoint of the two ends of that move: not extreme.

BFS ⇒ vertex: add up the tight constraints

Take $c$ = the sum of the tight constraints. Every point of $P$ scores at most the sum of their right-hand sides, and only a point where all of them are tight scores exactly that. Rank $n$ means that point is $x$ alone.

full proof in the notes (N)

a₃ = (1, 1) a₄ = (1, −1) c = a₃ + a₄ level set of c

At $(2.5, 1.5)$ constraints 3 and 4 are tight. Their sum $c = (2,0)$, i.e. maximize $2x$, is best at this corner and nowhere else: check the other corners, they score $0$, $2$ and $0$ against $5$.

01 · corners · example

Finding corners by trying pairs of constraints

In $\mathbb{R}^2$ a corner needs 2 independent tight constraints. So try every pair: set both to equality, solve, and keep the solution if it satisfies the other constraints.

constraintssolve as equalitiesother constraints
1, 2$(0, 0)$✓ corner
1, 3$(0, 4)$✓ corner
1, 4$(0, -1)$✗ constraint 2
2, 3$(4, 0)$✗ constraint 4
2, 4$(1, 0)$✓ corner
3, 4$(2.5, 1.5)$✓ corner

$\binom{4}{2} = 6$ basic solutions, 4 of them feasible: the 4 corners. Each pair of constraints is a basis. This is lab step 3.

one more constraint: a degenerate corner

Add constraint 5: $3x - y \le 6$. It cuts nothing off (check the four corners), but it also passes through $(2.5, 1.5)$.

Now three constraints are tight there, still rank 2. The pairs 3–4, 3–5 and 4–5 all solve to the same point: three bases, one corner.

That corner is a degenerate vertex. Enumerating pairs finds it three times, so the lab must deduplicate, and in unit 02 it is what can make simplex go round in circles.

In $\mathbb{R}^3$ the same thing happens at the apex of a square pyramid: four facets meet where three would do. The lab's pyramid test is this slide in one more dimension.

01 · corners

Not every polyhedron has a corner

$\{(x, y) : y \ge 0,\ y \le 1\}$ is a horizontal strip. Every point can slide left and right forever, so no point is extreme.

theorem

For nonempty $P = \{x : Ax \le b\}$, the following are equivalent:

  • $P$ has a vertex (it is pointed);
  • $P$ contains no whole line;
  • $\operatorname{rank} A = n$.

The strip: its constraints $-y \le 0$ and $y \le 1$ have normals $(0, -1)$ and $(0, 1)$: rank 1 < 2. The direction $(1, 0)$ is invisible to every constraint, and that is the line.

why you rarely notice

Any polyhedron inside $x \ge 0$ is pointed: the constraints $x_j \ge 0$ already have rank $n$. Standard form is pointed by construction. So is the running example, thanks to constraints 1 and 2.

So "the optimum is at a vertex" needs a hypothesis. The fundamental theorem at the end of the unit states it.

01 · corners

Two descriptions: Minkowski–Weyl

theorem (Minkowski 1896, Weyl 1935)

$P$ is a polyhedron if and only if $\;P = \operatorname{conv}(V) + \operatorname{cone}(R)\;$ for finite sets $V, R$: every point is a blend of corners plus a push along some rays.

In particular, a polytope is the convex hull of its vertices, and the convex hull of finitely many points is a polytope.

H-descriptionV-description
$n$-cube$2n$ facets$2^n$ vertices
$n$-cross-polytope$2^n$ facets$2n$ vertices

Either description can be exponentially larger than the other.

definitions

$\operatorname{conv}(V) = \{\sum \lambda_v v : \lambda \ge 0,\ \sum \lambda_v = 1\}$: weighted averages.

$\operatorname{cone}(R) = \{\sum \mu_r r : \mu \ge 0\}$: nonnegative combinations, the conic hull.

For pointed $P$: $V$ = vertices, $R$ = extreme rays of the recession cone $\{d : Ad \le 0\}$.

01 · corners · example

Minkowski–Weyl, on two examples

a polytope: blend the corners

$(1, 1)$ in the running example is a weighted average of its corners:

$$(1,1) = 0.5\,(0,0) + 0.4\,(2.5,1.5) + 0.1\,(0,4)$$

Weights are $\ge 0$ and sum to 1. Check: $x = 0.4 \cdot 2.5 = 1$, $y = 0.4 \cdot 1.5 + 0.1 \cdot 4 = 1$.

0.5 0.4 0.1 (1, 1)
unbounded: corners plus rays

$Q = \{x \ge 0,\ y \ge 0,\ x + y \ge 1\}$ has corners $(1,0)$, $(0,1)$ and runs off along the rays $(1,0)$ and $(0,1)$.

$$(2, 3) = \underbrace{(1, 0)}_{\text{a corner}} + \underbrace{1\,(1,0) + 3\,(0,1)}_{\text{a push along the rays}}$$

(1, 0) (2, 3) Q

section 3

Fourier–Motzkin elimination

Gaussian elimination for inequalities. It is correct and complete, and its output explodes.

01 · fourier–motzkin

Eliminating one variable

Goal: the projection $\{x' : \exists x_k,\ (x', x_k) \in P\}$, the shadow of $P$ with $x_k$ dropped, described without $x_k$.

the idea

Fix the other variables. Every constraint that mentions $x_k$ is either a lower bound or an upper bound on it. A value of $x_k$ exists exactly when every lower bound is at most every upper bound.

So write down "lower ≤ upper" for each pair, and $x_k$ is gone.

tiny example

$x \ge 0,\quad x \le 3,\quad x \le 5 - y$

Lower: $0$. Upper: $3$ and $5 - y$. Pairs: $0 \le 3$ (always true) and $0 \le 5 - y$. So some $x$ exists iff $y \le 5$.

the rule (Fourier 1826, Motzkin 1936)

Sort the constraints by the sign of their $x_k$ coefficient: $Z$ (zero: keep as is), $U$ (positive: upper bounds), $L$ (negative: lower bounds).

For each $p \in U$, $q \in L$, add the two constraints with positive multipliers chosen so $x_k$ cancels: $$(-a_{qk})\,(a_p x \le b_p) \;+\; a_{pk}\,(a_q x \le b_q)$$

The projection is: the $Z$ constraints, plus one combined constraint per pair.

Both multipliers are positive. Inequalities survive nonnegative combinations and nothing else, and that is the whole difference from Gaussian elimination.

01 · fourier–motzkin

On the example: eliminate $x$

constraintas a bound on $x$class
1: $-x \le 0$$x \ge 0$$L$
2: $-y \le 0$no $x$$Z$
3: $x + y \le 4$$x \le 4 - y$$U$
4: $x - y \le 1$$x \le 1 + y$$U$

Pairs, with multipliers $1$ and $1$:

$(x+y \le 4) + (-x \le 0) \;\Rightarrow\; y \le 4$ — "$0 \le 4 - y$"

$(x-y \le 1) + (-x \le 0) \;\Rightarrow\; -y \le 1$ — redundant

Keep $Z$: $-y \le 0$.   Projection: $\;0 \le y \le 4$. ✓

4 0 shadow on the y-axis P

Projecting along $x$: every $y \in [0, 4]$ has some $x$ that puts $(x,y)$ in $P$.

01 · fourier–motzkin

Deciding feasibility, and the explosion

algorithm

Eliminate $x_1, \dots, x_n$ in turn. Every remaining constraint reads $0 \le c$.

$Ax \le b$ is feasible $\iff$ every remaining $c \ge 0$.

On the example: eliminating $y$ from $0 \le y \le 4$ pairs $y \le 4$ with $-y \le 0$ and leaves $0 \le 4$. True, so $P$ is nonempty.

A complete decision procedure for linear feasibility, in ten lines of Python, needing no LP theory.

Nobody uses it for LP. The table shows why: the FM blow-up.

$n=6$, 14 random cuts + box. Pairwise worst case: $m \to m^2/4$ per step.

eliminatedFM constraintstrue facets
026—
16429
260138
370 99639
4~10⁹ pairs—

Reference run of uv run co then 01. True facet counts from qhull.

section 4

Farkas' lemma

A system with no solution always has a short, checkable reason why.

01 · farkas

A certificate of infeasibility

definition

$y \in \mathbb{R}^m$ is a Farkas certificate for $Ax \le b$ if $$y \ge 0, \qquad y^\top A = 0, \qquad y^\top b < 0.$$

In words: weights for the constraints that make every variable cancel and leave a negative right-hand side.

why it proves there is no solution

Adding true inequalities with weights $\ge 0$ gives a true inequality. These weights produce $0 \le (\text{something negative})$, which is false. So the constraints can't all be true at once.

example

$x \le 1$ and $-x \le -2$ (that is, $x \ge 2$).

Take $y = (1, 1)$ and add: $\;0 \le -1$. No $x$ can exist.

a two-variable one

$x + y \le 2,\quad -x \le -1,\quad -y \le -2$

$y = (1, 1, 1)$: $\;(x + y) - x - y \le 2 - 1 - 2$, i.e. $0 \le -1$.

Checking a certificate needs one matrix–vector product. No solver and no trust: lab step 4.

All three conditions matter. $y=0$ gives $0 \le 0$, and a negative $y_i$ flips an inequality.

01 · farkas

Farkas' lemma

theorem (Farkas, 1902) · inequality form

Exactly one of these holds:

$\quad$(I) $\;\exists\, x:\ Ax \le b$ $\qquad\qquad$ (II) $\;\exists\, y \ge 0:\ y^\top A = 0,\ y^\top b < 0$

Either the system has a solution, or a certificate shows it has none. Never both, never neither.

equivalent · standard form

Exactly one of these holds:

$\quad$(I′) $\;\exists\, x \ge 0:\ Ax = b$ $\qquad\qquad$ (II′) $\;\exists\, y:\ A^\top y \ge 0,\ b^\top y < 0$

Either $b$ is a nonnegative combination of $A$'s columns, or some direction $y$ sees every column as nonnegative and $b$ as negative.

"Not both" is the previous slide. "At least one" is the real theorem. Two ways to see it: by computation (run FM and watch), and by geometry (separate a point from a cone). Both are next.

01 · farkas

Farkas, constructively

why a certificate always exists, by running FM

1. Every constraint FM produces is a nonnegative combination of the original constraints: it only ever adds constraints with positive multipliers.

2. Run FM until no variable is left. Every final constraint reads $0 \le c$, and each carries the weights $y \ge 0$ that built it.

3. If some $c < 0$, its weights are a certificate. If every $c \ge 0$, FM says the system is feasible. One of the two always happens.

example

$x \le 1$, $-x \le -2$. Eliminating $x$ pairs the two constraints with multipliers $1, 1$: $\;0 \le -1$, built from $y = (1, 1)$. That is the certificate.

in code · lab step 5

To remember the weights, append the unit vector $e_i$ to constraint $i$ as $m$ extra columns that are never eliminated. FM combines constraints linearly, so the extra columns accumulate exactly $y$.

When a constraint with zero $x$-part and $b < 0$ appears, its tail is the certificate: the tail trick.

With tails, the example's constraints are $(1 \mid 1, 0) \le 1$ and $(-1 \mid 0, 1) \le -2$, and their sum is $(0 \mid 1, 1) \le -1$.

01 · farkas

Farkas, geometrically

a₁ a₂ b y cone(a₁, a₂) y·z = 0

$b \notin \operatorname{cone}(a_1, a_2)$, so a line through the origin separates them. Its normal $y$ has $y \cdot a_j \ge 0$ and $y \cdot b < 0$.

Read the standard form as a picture. With $a_j$ the columns of $A$:

(I′) says you can reach $b$ by stretching and adding the $a_j$: $b \in \operatorname{cone}(a_1, \dots, a_n)$.

(II′) says some line (a hyperplane $\{z : y^\top z = 0\}$) has every $a_j$ on one side and $b$ strictly on the other.

so farkas is

a point outside a cone built from finitely many arrows can be cut off from it by a separating hyperplane.

Here $a_1=(2,1)$, $a_2=(1,3)$, $b=(-1,2)$, $y=(3,-1)$: $y\cdot a_1 = 5$, $y \cdot a_2 = 0$, $y\cdot b = -5$.

01 · farkas

Why this is the root of the trunk

LP duality (unit 03). "No $x$ has $c^\top x > z$" is an infeasibility statement about $Ax \le b,\ -c^\top x \le -z$ with a small perturbation. Its Farkas certificate is a dual solution. Strong duality is Farkas applied once.

Solvers return certificates. Gurobi: set InfUnbdInfo=1 and read FarkasDual. HiGHS: getDualRay. An infeasible model comes with the $y$ you are building.

Cutting planes (unit 08). A Chvátal–Gomory cut is a nonnegative combination of constraints whose coefficients happen to be integers, with the right side rounded down. It is Farkas plus rounding.

The KKT conditions (unit 29) are the separation picture for curved sets.

Solvers compute in floating point, so their $y$ satisfies $y^\top A \approx 0$. Your integer $y$ satisfies it exactly. Exact verification of solver claims is a live research area.

01 · closing the loop

The fundamental theorem of LP

theorem

Let $P = \{x : Ax \le b\}$ be nonempty and pointed, and $c \in \mathbb{R}^n$. Then either $\max\{c^\top x : x \in P\}$ is unbounded, or it is attained at a vertex of $P$.

why

Every point of $P$ is a blend of corners plus a push along rays (Minkowski–Weyl). A linear objective of a blend is the same blend of the corners' values, so it can't beat the best corner. A push along a ray either helps forever (unbounded) or doesn't help at all.

full proof in the notes (N)

example: the best corner of the running example

Maximize $2x + y$ over $P$:

corner$2x + y$
$(0, 0)$0
$(1, 0)$2
$(2.5, 1.5)$6.5
$(0, 4)$4

The optimum is 6.5, at $(2.5, 1.5)$. Four evaluations, no calculus.

So an LP is infeasible, unbounded, or solved at a corner. There is no fourth case, and in particular no finite best value that is never reached.

01 · lab

Lab 01 — what you build

about 2½ hours · uv run co lab 01 · exact integers, no solver
  1. Eliminate one variable by Fourier–Motzkin. Tested by sampling points against the exact projection.
  2. Decide feasibility by eliminating everything. Agrees with HiGHS.
  3. Enumerate vertices over all $\binom{m}{n}$ bases, as on the pairs-of-constraints slide. Agrees with qhull, and survives a degenerate pyramid.
  4. Check a Farkas certificate.
  5. Find one, using your own eliminate and the tail trick.
uv run co test 01
uv run co then 01      # FM blow-up vs true facets · your vertices vs qhull · a proof printed

01 · checkpoint

Done when

checkpoint
  • All five lab steps are ✓.
  • Given the infeasible system that then prints, with the certificate hidden, you can produce a Farkas vector by hand and explain without reference to any solver why it proves infeasibility.
  • You can say, on a small example, why vertex, extreme point and BFS pick out the same points, and which of the three your vertices function computes.

Reading

Bertsimas & Tsitsiklis, ch. 2 (§2.1–2.6) and §4.6.
Gärtner & Matoušek, Understanding and Using LP, §6.1–6.4 (Farkas via FM).
Ziegler, Lectures on Polytopes, lecture 1 (optional).

Next

02 Simplex, honestly: walking between the vertices you just enumerated, instead of listing all of them.