The quadrangle inequality and monotone optimal roots #
An interval weight f : ℕ → ℕ → β satisfies the quadrangle inequality (QuadrangleIneq) if
f i j + f i' j' ≤ f i j' + f i' j whenever i ≤ i' ≤ j ≤ j', and is monotone on intervals
(MonotoneOnIntervals) if f i' j ≤ f i j' whenever [i', j] ⊆ [i, j']. Yao proved that if the
weight w has both properties, then the optimal cost c = optCost w of the interval recurrence
satisfies the quadrangle inequality (quadrangleIneq_optCost), and that the quadrangle
inequality for c makes the largest optimal root K = optRoot w monotone:
K(i, j - 1) ≤ K(i, j) ≤ K(i + 1, j) (optRoot_mono). For optimal binary search trees this
monotonicity is Knuth's theorem; Knuth's weight knuthWeight p q satisfies the quadrangle
inequality with equality (knuthWeight_add_knuthWeight), and is monotone on intervals when the
weights are nonnegative (monotoneOnIntervals_knuthWeight).
The monotonicity of roots is stated for the largest optimal root. It uses cancellation in β
(IsOrderedCancelAddMonoid), which holds for ℕ, ℤ, ℚ and ℝ.
Main definitions #
Cslib.Algorithms.Lean.OptimalBST.QuadrangleIneq: the quadrangle inequality.Cslib.Algorithms.Lean.OptimalBST.MonotoneOnIntervals: monotonicity on the lattice of intervals.
Main results #
Cslib.Algorithms.Lean.OptimalBST.quadrangleIneq_optCost: Yao's lemma, the optimal cost inherits the quadrangle inequality.Cslib.Algorithms.Lean.OptimalBST.optRoot_mono: monotonicity of the largest optimal roots.Cslib.Algorithms.Lean.OptimalBST.quadrangleIneq_knuthWeight,Cslib.Algorithms.Lean.OptimalBST.monotoneOnIntervals_knuthWeight: Knuth's weight satisfies both hypotheses.
References #
Yao's lemma: if w satisfies the quadrangle inequality and is monotone on intervals, then
the optimal cost c = optCost w of the interval recurrence satisfies the quadrangle inequality.
Root monotonicity in the right endpoint, K(i, j) ≤ K(i, j + 1), for the largest optimal root
whenever the optimal cost satisfies the quadrangle inequality.
Root monotonicity in the left endpoint, K(i, j + 1) ≤ K(i + 1, j + 1) for i < j, for the
largest optimal root whenever the optimal cost satisfies the quadrangle inequality.
Monotonicity of optimal roots (Knuth for binary search trees, Yao in general): under the
quadrangle inequality and interval monotonicity of w, the largest optimal roots satisfy
K(i, j - 1) ≤ K(i, j) ≤ K(i + 1, j) for i + 1 < j.
Knuth's weight satisfies the quadrangle inequality with equality.
With nonnegative access and failure weights, Knuth's weight is monotone on intervals.