The instance of AUX(p, q) built from a formula
Lax391470.SatConstruction · concepts/Lax391470/SatConstruction.lean · lax-391470
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
The instance of built from a formula in conjunctive normal form with variables and clauses .
The time line is cut into sections of equal length , one for every literal, in the order A section consists of a literal block of total job length , then one clause block of total job length for every clause, then one unit of idle time, then a separator: an ordinary short job whose availability interval is exactly the last time units of the section.
Relative to the start of its section, the literal block of a positive literal, of type , consists of the ordinary jobs and and a long pending job with early deadline and late deadline . The block of a negative literal, of type , consists of the ordinary jobs and and a short pending job with early deadline and late deadline . In either block the pending job can complete early only at the price of one unit of idle time that no other job can fill.
Relative to the point of its section, the clause block of the clause consists of a long and a short pending job, both with late deadline and both with early deadline if the literal of the section occurs in — the block is then active — and otherwise. Both jobs of an active block can complete early if the section has not been delayed; in a delayed section, or in an inactive block, only one of them can.
Pending jobs are connected as follows. The long pending job of the literal block of is connected with the short pending job of the literal block of . For every clause, the long pending job of its clause block in a section is connected with the short pending job of its clause block in the next section. This leaves the long pending jobs of the clause blocks of the last section and the short ones of the first section unconnected; they are required to meet their early deadline, which makes them ordinary jobs released at .
A connected pair of literal blocks forces a delay of one unit in the section of or in that of ; the literal whose section is not delayed is the one set to true. The chain of clause blocks of a clause through all sections can be scheduled only if the clause block is active in some section that is not delayed, that is, if the clause contains a true literal.
Concept map
Evidence
Lean source view on GitHub
| 1 | import Lax391470.AuxiliaryProblem |
| 2 | import Lax429075.CNF |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: The instance of AUX(p, q) built from a formula |
| 7 | type: definition |
| 8 | --- |
| 9 | The instance of built from a formula in conjunctive normal form |
| 10 | with variables and clauses . |
| 11 | |
| 12 | The time line is cut into *sections* of equal length |
| 13 | , one for every literal, in the order |
| 14 | A section consists of a *literal block* of total job |
| 15 | length , then one *clause block* of total job length for every clause, |
| 16 | then one unit of idle time, then a *separator*: an ordinary short job whose availability |
| 17 | interval is exactly the last time units of the section. |
| 18 | |
| 19 | Relative to the start of its section, the literal block of a positive literal, of type |
| 20 | , consists of the ordinary jobs and and |
| 21 | a long pending job with early deadline and late deadline . The block |
| 22 | of a negative literal, of type , consists of the ordinary jobs |
| 23 | and and a short pending job with |
| 24 | early deadline and late deadline . In either block the pending job can |
| 25 | complete early only at the price of one unit of idle time that no other job can fill. |
| 26 | |
| 27 | Relative to the point of its section, the clause block of the clause |
| 28 | consists of a long and a short pending job, both with late deadline and |
| 29 | both with early deadline if the literal of the section occurs in — the |
| 30 | block is then *active* — and otherwise. Both jobs of an active block can |
| 31 | complete early if the section has not been delayed; in a delayed section, or in an |
| 32 | inactive block, only one of them can. |
| 33 | |
| 34 | Pending jobs are connected as follows. The long pending job of the literal block of |
| 35 | is connected with the short pending job of the literal block of . For every |
| 36 | clause, the long pending job of its clause block in a section is connected with the short |
| 37 | pending job of its clause block in the next section. This leaves the long pending jobs |
| 38 | of the clause blocks of the last section and the short ones of the first section |
| 39 | unconnected; they are required to meet their early deadline, which makes them ordinary |
| 40 | jobs released at . |
| 41 | |
| 42 | A connected pair of literal blocks forces a delay of one unit in the section of or |
| 43 | in that of ; the literal whose section is not delayed is the one set to true. |
| 44 | The chain of clause blocks of a clause through all sections can be scheduled only if the |
| 45 | clause block is active in some section that is not delayed, that is, if the clause |
| 46 | contains a true literal. |
| 47 | |
| 48 | # Formalization notes |
| 49 | |
| 50 | A formula is a list of clauses over variables named by natural numbers, as elsewhere in |
| 51 | the archive. Its variables are taken to be with one more than |
| 52 | the largest index that occurs, and when no literal occurs at all, so that the |
| 53 | construction always has at least one variable. Variables that do not occur receive |
| 54 | sections like any other. A clause is a list, in which a repeated literal counts once and |
| 55 | which may be empty; an empty clause has no active block and makes the instance |
| 56 | unsolvable, as it makes the formula unsatisfiable. |
| 57 | |
| 58 | Everything is numbered, because an instance is something a machine is handed as a word. |
| 59 | Section belongs to the variable and is positive when is |
| 60 | even. The ordinary jobs of section are , and : the two ordinary |
| 61 | jobs of the literal block and the separator. They are followed by the unconnected |
| 62 | long jobs of the last section and the unconnected short jobs of the first. The |
| 63 | connected pairs are listed in the order of their deadlines, in groups of : |
| 64 | pair is the literal pair of the variable , the next pairs connect |
| 65 | the clause blocks of the section of with those of , and the following |
| 66 | connect those of with those of . The last group lacks these |
| 67 | final pairs, which leaves . |
| 68 | -/ |
| 69 | |
| 70 | namespace Lax391470.SatConstruction |
| 71 | |
| 72 | open Lax391470.AuxiliaryProblem Lax429075.CNF |
| 73 | |
| 74 | variable (p q : ℕ) (F : Formula) |
| 75 | |
| 76 | /-- The number `n` of variables: one more than the largest index occurring in `F`, and |
| 77 | `1` if no literal occurs. -/ |
| 78 | def numVars : ℕ := (F.flatMap id).foldr (fun l n => max (l.index + 1) n) 1 |
| 79 | |
| 80 | /-- The number `m` of clauses. -/ |
| 81 | def numClauses : ℕ := F.length |
| 82 | |
| 83 | /-- The length `S` of a section. -/ |
| 84 | def sectionLength : ℕ := p + 2 * q + numClauses F * (p + q) + 1 + q |
| 85 | |
| 86 | /-- The start of section `s`. -/ |
| 87 | def sectionStart (s : ℕ) : ℕ := sectionLength p q F * s |
| 88 | |
| 89 | /-- The literal of section `s`: the sections run `x₀, ¬x₀, x₁, ¬x₁, …`. -/ |
| 90 | def literalOf (s : ℕ) : Literal := ⟨s / 2, decide (s % 2 = 0)⟩ |
| 91 | |
| 92 | /-- The clause block of clause `j` in section `s` is *active*: the literal of the section |
| 93 | occurs in the clause. -/ |
| 94 | def active (s j : ℕ) : Bool := decide (literalOf s ∈ F.getD j []) |
| 95 | |
| 96 | /-- The start of the clause block of clause `j` in section `s`. -/ |
| 97 | def clauseStart (s j : ℕ) : ℕ := sectionStart p q F s + p + 2 * q + j * (p + q) |
| 98 | |
| 99 | /-- The early deadline of both pending jobs of a clause block. -/ |
| 100 | def clauseEarly (s j : ℕ) : ℕ := |
| 101 | clauseStart p q F s j + (if active F s j then p + q else p + q - 1) |
| 102 | |
| 103 | /-- The late deadline of both pending jobs of a clause block. -/ |
| 104 | def clauseDue (s j : ℕ) : ℕ := clauseStart p q F s j + p + q + 1 |
| 105 | |
| 106 | /-- The number of ordinary jobs: three for every section, and the `2m` unconnected |
| 107 | pending jobs. -/ |
| 108 | def numOrdinary : ℕ := 6 * numVars F + 2 * numClauses F |
| 109 | |
| 110 | /-- The release time of the ordinary job `o`. -/ |
| 111 | def ordRelease (o : ℕ) : ℕ := |
| 112 | if o < 6 * numVars F then |
| 113 | match o % 3 with |
| 114 | | 0 => sectionStart p q F (o / 3) + (if (o / 3) % 2 = 0 then 1 else q + 1) |
| 115 | | 1 => sectionStart p q F (o / 3) |
| 116 | | _ => sectionStart p q F (o / 3) + sectionLength p q F - q |
| 117 | else 0 |
| 118 | |
| 119 | /-- The deadline of the ordinary job `o`. -/ |
| 120 | def ordDue (o : ℕ) : ℕ := |
| 121 | if o < 6 * numVars F then |
| 122 | match o % 3 with |
| 123 | | 0 => sectionStart p q F (o / 3) + (if (o / 3) % 2 = 0 then 2 * q else p + q) |
| 124 | | 1 => sectionStart p q F (o / 3) + p + 2 * q + 1 |
| 125 | | _ => sectionStart p q F (o / 3) + sectionLength p q F |
| 126 | else if o < 6 * numVars F + numClauses F then |
| 127 | clauseEarly p q F (2 * numVars F - 1) (o - 6 * numVars F) |
| 128 | else |
| 129 | clauseEarly p q F 0 (o - 6 * numVars F - numClauses F) |
| 130 | |
| 131 | /-- Whether the ordinary job `o` is long: the second ordinary job of a block of type `V⁻`, |
| 132 | and the unconnected long jobs of the last section. -/ |
| 133 | def ordLong (o : ℕ) : Bool := |
| 134 | if o < 6 * numVars F then decide (o % 3 = 1 ∧ (o / 3) % 2 = 1) |
| 135 | else decide (o < 6 * numVars F + numClauses F) |
| 136 | |
| 137 | /-- The number `N = n + (2n - 1) m` of connected pairs. -/ |
| 138 | def numPairs : ℕ := numVars F + (2 * numVars F - 1) * numClauses F |
| 139 | |
| 140 | /-- The variable whose group the pair `i` belongs to. -/ |
| 141 | def groupOf (i : ℕ) : ℕ := i / (1 + 2 * numClauses F) |
| 142 | |
| 143 | /-- The position of the pair `i` in its group: `0` for the literal pair. -/ |
| 144 | def posOf (i : ℕ) : ℕ := i % (1 + 2 * numClauses F) |
| 145 | |
| 146 | /-- The section holding the long job of the clause pair `i`. -/ |
| 147 | def pairSection (i : ℕ) : ℕ := 2 * groupOf F i + (posOf F i - 1) / numClauses F |
| 148 | |
| 149 | /-- The clause of the clause pair `i`. -/ |
| 150 | def pairClause (i : ℕ) : ℕ := (posOf F i - 1) % numClauses F |
| 151 | |
| 152 | /-- The early deadline of the long job of pair `i`. -/ |
| 153 | def longEarly (i : ℕ) : ℕ := |
| 154 | if posOf F i = 0 then sectionStart p q F (2 * groupOf F i) + p + q + 1 |
| 155 | else clauseEarly p q F (pairSection F i) (pairClause F i) |
| 156 | |
| 157 | /-- The late deadline of the long job of pair `i`. -/ |
| 158 | def longDue (i : ℕ) : ℕ := |
| 159 | if posOf F i = 0 then sectionStart p q F (2 * groupOf F i) + p + 2 * q |
| 160 | else clauseDue p q F (pairSection F i) (pairClause F i) |
| 161 | |
| 162 | /-- The early deadline of the short job of pair `i`, one section after the long job. -/ |
| 163 | def shortEarly (i : ℕ) : ℕ := |
| 164 | if posOf F i = 0 then sectionStart p q F (2 * groupOf F i + 1) + q |
| 165 | else clauseEarly p q F (pairSection F i + 1) (pairClause F i) |
| 166 | |
| 167 | /-- The late deadline of the short job of pair `i`. -/ |
| 168 | def shortDue (i : ℕ) : ℕ := |
| 169 | if posOf F i = 0 then sectionStart p q F (2 * groupOf F i + 1) + p + 2 * q |
| 170 | else clauseDue p q F (pairSection F i + 1) (pairClause F i) |
| 171 | |
| 172 | /-- **The instance of `AUX(p, q)`** built from the formula `F`. -/ |
| 173 | def inst : AuxiliaryProblem.Instance where |
| 174 | ordinary := numOrdinary F |
| 175 | r o := ordRelease p q F o |
| 176 | d o := ordDue p q F o |
| 177 | long o := ordLong F o |
| 178 | pairs := numPairs F |
| 179 | longEarly i := longEarly p q F i |
| 180 | longDue i := longDue p q F i |
| 181 | shortEarly i := shortEarly p q F i |
| 182 | shortDue i := shortDue p q F i |
| 183 | |
| 184 | /-- For job lengths `p > q > 1`, the deadlines of the constructed instance are ordered as |
| 185 | the auxiliary problem requires. -/ |
| 186 | axiom ordered (hq : 1 < q) (hqp : q < p) : (inst p q F).Ordered |
| 187 | |
| 188 | /-- **From an assignment to a schedule.** If `F` is satisfiable, the constructed instance |
| 189 | has a solution. -/ |
| 190 | axiom solvable_of_satisfiable (hq : 1 < q) (hqp : q < p) : |
| 191 | Satisfiable F → (inst p q F).Solvable p q |
| 192 | |
| 193 | /-- **From a schedule to an assignment.** If the constructed instance has a solution, `F` |
| 194 | is satisfiable. -/ |
| 195 | axiom satisfiable_of_solvable (hq : 1 < q) (hqp : q < p) : |
| 196 | (inst p q F).Solvable p q → Satisfiable F |
| 197 | |
| 198 | /-- **The numbers of the constructed instance are small**: every release time and every |
| 199 | deadline is at most the length `2nS` of the time line, a polynomial in the size of the |
| 200 | formula. Together with `StackedConstruction.times_le`, this bounds every number of the |
| 201 | composed reduction; it is the ingredient of strong NP-hardness. -/ |
| 202 | axiom times_le : |
| 203 | (∀ o, (inst p q F).r o ≤ 2 * numVars F * sectionLength p q F ∧ |
| 204 | (inst p q F).d o ≤ 2 * numVars F * sectionLength p q F) ∧ |
| 205 | (∀ i, (inst p q F).longDue i ≤ 2 * numVars F * sectionLength p q F ∧ |
| 206 | (inst p q F).shortDue i ≤ 2 * numVars F * sectionLength p q F) |
| 207 | |
| 208 | end Lax391470.SatConstruction |
| 209 |
Formalization notes
A formula is a list of clauses over variables named by natural numbers, as elsewhere in the archive. Its variables are taken to be with one more than the largest index that occurs, and when no literal occurs at all, so that the construction always has at least one variable. Variables that do not occur receive sections like any other. A clause is a list, in which a repeated literal counts once and which may be empty; an empty clause has no active block and makes the instance unsolvable, as it makes the formula unsatisfiable.
Everything is numbered, because an instance is something a machine is handed as a word. Section belongs to the variable and is positive when is even. The ordinary jobs of section are , and : the two ordinary jobs of the literal block and the separator. They are followed by the unconnected long jobs of the last section and the unconnected short jobs of the first. The connected pairs are listed in the order of their deadlines, in groups of : pair is the literal pair of the variable , the next pairs connect the clause blocks of the section of with those of , and the following connect those of with those of . The last group lacks these final pairs, which leaves .
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments