The Fairness Parameter One Below the Number of Days
Lax117284.Theorem9 · concepts/Lax117284/Theorem9.lean · lax-117284
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Theorem
Theorem 9. The problem is solvable in polynomial time when .
Associate with every day and client a variable , read as "client 's job is executed on day ". Two families of clauses express the two requirements. For every day and every two distinct clients whose jobs conflict on that day, the conflict clause forbids executing both. For every client and every two distinct days , the validation clause forbids rejecting the client on both. A schedule satisfies the first family exactly when it is feasible and the second exactly when no client is rejected twice, which at is fairness. The formula is a 2-CNF formula of variables and clauses, and 2-satisfiability is decidable in linear time.
The parameter is exactly the value at which two literals suffice: " is served on at least days" says "of any two days, is served on one of them", a binary constraint.
Concept map
Evidence
In the paper
- page 2 of this submission's paper
Lean source view on GitHub
| 1 | import Lax117284.Problems |
| 2 | import Lax117284.TwoSatisfiability |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: The Fairness Parameter One Below the Number of Days |
| 7 | type: theorem |
| 8 | --- |
| 9 | **Theorem 9.** The problem is solvable in |
| 10 | polynomial time when . |
| 11 | |
| 12 | Associate with every day and client a variable , read as "client 's job |
| 13 | is executed on day ". Two families of clauses express the two requirements. For every day |
| 14 | and every two distinct clients whose jobs conflict on that day, the |
| 15 | *conflict clause* forbids executing both. For every |
| 16 | client and every two distinct days , the *validation clause* |
| 17 | forbids rejecting the client on both. A schedule satisfies the |
| 18 | first family exactly when it is feasible and the second exactly when no client is rejected |
| 19 | twice, which at is fairness. The formula is a 2-CNF formula of variables and |
| 20 | clauses, and 2-satisfiability is decidable in linear time. |
| 21 | |
| 22 | The parameter is exactly the value at which two literals suffice: " is served |
| 23 | on at least days" says "of any two days, is served on one of them", a binary |
| 24 | constraint. |
| 25 | |
| 26 | # Formalization Notes |
| 27 | |
| 28 | Clauses are numbered rather than enumerated: a slot is allocated for every day and ordered |
| 29 | pair of clients, and for every client and ordered pair of days, and a slot whose pair is |
| 30 | inadmissible — two equal clients, two non-conflicting jobs, two equal days — carries the |
| 31 | tautology on the variable it names. A closed formula for the index of a |
| 32 | clause is what an algorithm can compute; enumerating only the admissible pairs would require |
| 33 | a search. Ordered pairs make each constraint appear twice, which is harmless. |
| 34 | |
| 35 | The variables are numbered , with one further variable that no meaningful clause |
| 36 | names, so that the numbering is a total function of two numbers and needs no proof that its |
| 37 | arguments are in range. |
| 38 | -/ |
| 39 | |
| 40 | namespace Lax117284.Theorem9 |
| 41 | |
| 42 | open Lax117284.Scheduling Lax117284.Problems Lax117284.TwoSatisfiability |
| 43 | open Lax434930.PolynomialTime Lax429075.Reductions |
| 44 | |
| 45 | /-- The variable "client `j`'s job is executed on day `i`", numbered `i·n + j`. The one |
| 46 | further variable, which no meaningful clause names, is the value on indices out of |
| 47 | range. -/ |
| 48 | def varIdx (I : Instance) (i j : ℕ) : Fin (I.days * I.clients + 1) := |
| 49 | ⟨min (i * I.clients + j) (I.days * I.clients), Nat.lt_succ_of_le (min_le_right _ _)⟩ |
| 50 | |
| 51 | /-- The `α`-th literal of clause `c`: the conflict clauses come first, one slot for every |
| 52 | day and ordered pair of clients, then the validation clauses, one slot for every client and |
| 53 | ordered pair of days. An inadmissible slot carries a tautology. -/ |
| 54 | def clauseLit (I : Instance) (c : ℕ) (α : Fin 2) : Fin (I.days * I.clients + 1) × Bool := |
| 55 | if c < I.days * I.clients * I.clients then |
| 56 | let i := c / (I.clients * I.clients) |
| 57 | let r := c % (I.clients * I.clients) |
| 58 | let j₁ := r / I.clients |
| 59 | let j₂ := r % I.clients |
| 60 | if j₁ ≠ j₂ ∧ I.ConflictAt i j₁ j₂ then |
| 61 | (varIdx I i (if α = 0 then j₁ else j₂), false) |
| 62 | else (varIdx I i j₁, α = 0) |
| 63 | else |
| 64 | let c' := c - I.days * I.clients * I.clients |
| 65 | let j := c' / (I.days * I.days) |
| 66 | let r := c' % (I.days * I.days) |
| 67 | let i₁ := r / I.days |
| 68 | let i₂ := r % I.days |
| 69 | if i₁ ≠ i₂ then (varIdx I (if α = 0 then i₁ else i₂) j, true) |
| 70 | else (varIdx I i₁ j, α = 0) |
| 71 | |
| 72 | /-- **The 2-CNF formula of Theorem 9.** -/ |
| 73 | def formula (I : Instance) : Formula where |
| 74 | vars := I.days * I.clients + 1 |
| 75 | clauses := I.days * I.clients * I.clients + I.clients * I.days * I.days |
| 76 | lit c α := clauseLit I c α |
| 77 | |
| 78 | /-- **The construction is correct**: at the fairness parameter `m - 1` an instance is a |
| 79 | yes-instance exactly when its formula is satisfiable. -/ |
| 80 | axiom correct (I : Instance) (k : ℕ) (hk : k + 1 = I.days) : |
| 81 | I.HasKFairSchedule k ↔ (formula I).Satisfiable |
| 82 | |
| 83 | open Classical in |
| 84 | /-- **The reduction**, as a map on words: a word encoding an instance with the fairness |
| 85 | parameter one below its number of days is sent to the encoding of its formula, and every |
| 86 | other word to the encoding of an unsatisfiable formula. -/ |
| 87 | noncomputable def reduce (w : Word) : Word := |
| 88 | if h : ∃ (I : Instance) (k : ℕ), encodeUniform I k = w ∧ k + 1 = I.days then |
| 89 | encodeFormula (formula h.choose) |
| 90 | else encodeFormula unsatisfiable |
| 91 | |
| 92 | /-- **The reduction is correct.** -/ |
| 93 | axiom reduce_correct (w : Word) : |
| 94 | w ∈ Uniform (fun I k => k + 1 = I.days) ↔ reduce w ∈ TwoSat |
| 95 | |
| 96 | /-- **The reduction runs in polynomial time.** -/ |
| 97 | axiom reduce_polyTime : Nonempty (Turing.TM2ComputableInPolyTime id id reduce) |
| 98 | |
| 99 | /-- **Theorem 9.** The problem at the fairness parameter one below the number of days |
| 100 | reduces in polynomial time to 2-SAT. -/ |
| 101 | axiom manyOne_twoSat : ManyOne (Uniform fun I k => k + 1 = I.days) TwoSat |
| 102 | |
| 103 | end Lax117284.Theorem9 |
| 104 |
Formalization Notes
Clauses are numbered rather than enumerated: a slot is allocated for every day and ordered pair of clients, and for every client and ordered pair of days, and a slot whose pair is inadmissible — two equal clients, two non-conflicting jobs, two equal days — carries the tautology on the variable it names. A closed formula for the index of a clause is what an algorithm can compute; enumerating only the admissible pairs would require a search. Ordered pairs make each constraint appear twice, which is harmless.
The variables are numbered , with one further variable that no meaningful clause names, so that the numbering is a total function of two numbers and needs no proof that its arguments are in range.
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments