Documentation

CslibFrontier.Algorithms.Lean.Scheduling.Brent

Work, Span and Brent's Theorem #

The span span prec p of a job system is the largest total processing time of a precedence chain (the critical-path length). For unit processing times, Fintype.card J is the work W (the number of nodes of the computation DAG) and span prec (fun _ => 1) is its depth D. This module proves the work and span laws, the greedy-scheduler bound and Brent's scheduling lemma.

Main definitions #

Main results #

References #

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.nodup_of_isChain {J : Type u_1} {prec : J → J → Prop} (hwf : WellFounded prec) {c : List J} (hc : List.IsChain prec c) :

A precedence chain of a well-founded relation has no repeated job.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.sum_chain_le_sum {J : Type u_1} [Fintype J] {prec : J → J → Prop} (hwf : WellFounded prec) (p : J → ℕ) {c : List J} (hc : List.IsChain prec c) :
(List.map p c).sum ≤ ∑ j : J, p j

The weighted length of every chain is at most the total processing time.

noncomputable def Cslib.Algorithms.Lean.Scheduling.Precedence.span {J : Type u_1} (prec : J → J → Prop) (p : J → ℕ) :

The span (critical-path length) of a job system: the largest total processing time of a precedence chain. For unit processing times this is the number of jobs on a longest chain.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.sum_chain_le_span {J : Type u_1} {prec : J → J → Prop} [Finite J] (hwf : WellFounded prec) (p : J → ℕ) {c : List J} (hc : List.IsChain prec c) :
(List.map p c).sum ≤ span prec p

Every precedence chain has weighted length at most the span.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.exists_chain_sum_eq_span {J : Type u_1} {prec : J → J → Prop} [Finite J] (hwf : WellFounded prec) (p : J → ℕ) :
∃ (c : List J), List.IsChain prec c ∧ (List.map p c).sum = span prec p

The span is attained by a precedence chain (a critical path).

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible.span_le_makespan {J : Type u_1} [Fintype J] {prec : J → J → Prop} {m : ℕ} {p s : J → ℕ} (hf : IsFeasible m prec p s) :
span prec p ≤ makespan p s

Span law: every feasible schedule takes at least the span.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.mul_makespan_le_sum_add_span {J : Type u_1} [Fintype J] {prec : J → J → Prop} {m : ℕ} {p s : J → ℕ} (hg : IsGreedy m prec p s) (hwf : WellFounded prec) :
m * makespan p s ≤ ∑ j : J, p j + (m - 1) * span prec p

Greedy-scheduler bound ([CLRS09], Theorem 27.1, with Graham's refinement): m · C ≤ ∑ p + (m - 1) · span.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.mul_makespan_le_card_add_span {J : Type u_1} [Fintype J] {prec : J → J → Prop} {m : ℕ} {s : J → ℕ} (hg : IsGreedy m prec (fun (x : J) => 1) s) (hwf : WellFounded prec) :
m * makespan (fun (x : J) => 1) s ≤ Fintype.card J + (m - 1) * span prec fun (x : J) => 1

Brent's bound for a greedy schedule of a unit-time DAG with W = |J| nodes and span D (the number of nodes on a longest chain): m · T ≤ W + (m - 1) · D, i.e. T ≤ (W - D)/m + D ([Bre74], Lemma 2; [CLRS09], Theorem 27.1).

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.makespan_le_card_div_add_span {J : Type u_1} [Fintype J] {prec : J → J → Prop} {m : ℕ} {s : J → ℕ} (hg : IsGreedy m prec (fun (x : J) => 1) s) (hwf : WellFounded prec) (hm : 0 < m) :
makespan (fun (x : J) => 1) s ≤ Fintype.card J / m + span prec fun (x : J) => 1

Brent's bound in the form T ≤ ⌊W/m⌋ + D.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible.wellFounded {J : Type u_1} [Fintype J] {prec : J → J → Prop} {m : ℕ} {p s : J → ℕ} (hf : IsFeasible m prec p s) (hp : ∀ (j : J), 0 < p j) :

A feasible schedule with positive processing times forces the precedences to be well-founded.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.exists_isFeasible_mul_makespan_le {J : Type u_1} [Fintype J] {prec : J → J → Prop} (m : ℕ) (hm : 0 < m) (hwf : WellFounded prec) :
∃ (s : J → ℕ), IsFeasible m prec (fun (x : J) => 1) s ∧ m * makespan (fun (x : J) => 1) s ≤ Fintype.card J + (m - 1) * span prec fun (x : J) => 1

Brent's scheduling lemma ([Bre74], Lemma 2), in the unit-time DAG form: every finite DAG of W = |J| unit jobs with span D = span prec (fun _ => 1) (the number of jobs on a longest chain, i.e. the time needed with unboundedly many processors) has a feasible schedule on m ≥ 1 processors with m · T ≤ W + (m - 1) · D.