While this submission is a draft, it cannot be used by other submissions.

The instance of AUX(p, q) built from a formula

Lax391470.SatConstruction · concepts/Lax391470/SatConstruction.lean · lax-391470

proven

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    The instance of AUX(p,q)\mathrm{AUX}(p, q) built from a formula in conjunctive normal form with nn variables and mm clauses C0,,Cm1C_0, \dots, C_{m-1}.

    The time line is cut into 2n2n sections of equal length S=(p+2q)+m(p+q)+1+qS = (p + 2q) + m(p + q) + 1 + q, one for every literal, in the order x0,¬x0,x1,¬x1,x_0, \neg x_0, x_1, \neg x_1, \dots A section consists of a literal block of total job length p+2qp + 2q, then one clause block of total job length p+qp + q for every clause, then one unit of idle time, then a separator: an ordinary short job whose availability interval is exactly the last qq time units of the section.

    Relative to the start of its section, the literal block of a positive literal, of type V+V^+, consists of the ordinary jobs ([1,2q],q)([1, 2q],\, q) and ([0,p+2q+1],q)([0,\, p + 2q + 1],\, q) and a long pending job with early deadline p+q+1p + q + 1 and late deadline p+2qp + 2q. The block of a negative literal, of type VV^-, consists of the ordinary jobs ([q+1,p+q],q)([q + 1,\, p + q],\, q) and ([0,p+2q+1],p)([0,\, p + 2q + 1],\, p) and a short pending job with early deadline qq and late deadline p+2qp + 2q. 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 p+2q+j(p+q)p + 2q + j(p + q) of its section, the clause block of the clause CjC_j consists of a long and a short pending job, both with late deadline p+q+1p + q + 1 and both with early deadline p+qp + q if the literal of the section occurs in CjC_j — the block is then active — and p+q1p + q - 1 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 xix_i is connected with the short pending job of the literal block of ¬xi\neg x_i. 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 00.

    A connected pair of literal blocks forces a delay of one unit in the section of xix_i or in that of ¬xi\neg x_i; 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
    5 concepts; 2 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    This concept declares 4 statements. Each proof establishes one of them relative to its assumptions.

    Lean source view on GitHub

    1import Lax391470.AuxiliaryProblem
    2import Lax429075.CNF
    3
    4/-!
    5---
    6title: The instance of AUX(p, q) built from a formula
    7type: definition
    8---
    9The instance of AUX(p,q)\mathrm{AUX}(p, q) built from a formula in conjunctive normal form
    10with nn variables and mm clauses C0,,Cm1C_0, \dots, C_{m-1}.
    11
    12The time line is cut into 2n2n *sections* of equal length
    13S=(p+2q)+m(p+q)+1+qS = (p + 2q) + m(p + q) + 1 + q, one for every literal, in the order
    14x0,¬x0,x1,¬x1,x_0, \neg x_0, x_1, \neg x_1, \dots A section consists of a *literal block* of total job
    15length p+2qp + 2q, then one *clause block* of total job length p+qp + q for every clause,
    16then one unit of idle time, then a *separator*: an ordinary short job whose availability
    17interval is exactly the last qq time units of the section.
    18
    19Relative to the start of its section, the literal block of a positive literal, of type
    20V+V^+, consists of the ordinary jobs ([1,2q],q)([1, 2q],\, q) and ([0,p+2q+1],q)([0,\, p + 2q + 1],\, q) and
    21a long pending job with early deadline p+q+1p + q + 1 and late deadline p+2qp + 2q. The block
    22of a negative literal, of type VV^-, consists of the ordinary jobs
    23([q+1,p+q],q)([q + 1,\, p + q],\, q) and ([0,p+2q+1],p)([0,\, p + 2q + 1],\, p) and a short pending job with
    24early deadline qq and late deadline p+2qp + 2q. In either block the pending job can
    25complete early only at the price of one unit of idle time that no other job can fill.
    26
    27Relative to the point p+2q+j(p+q)p + 2q + j(p + q) of its section, the clause block of the clause
    28CjC_j consists of a long and a short pending job, both with late deadline p+q+1p + q + 1 and
    29both with early deadline p+qp + q if the literal of the section occurs in CjC_j — the
    30block is then *active* — and p+q1p + q - 1 otherwise. Both jobs of an active block can
    31complete early if the section has not been delayed; in a delayed section, or in an
    32inactive block, only one of them can.
    33
    34Pending jobs are connected as follows. The long pending job of the literal block of xix_i
    35is connected with the short pending job of the literal block of ¬xi\neg x_i. For every
    36clause, the long pending job of its clause block in a section is connected with the short
    37pending job of its clause block in the next section. This leaves the long pending jobs
    38of the clause blocks of the last section and the short ones of the first section
    39unconnected; they are required to meet their early deadline, which makes them ordinary
    40jobs released at 00.
    41
    42A connected pair of literal blocks forces a delay of one unit in the section of xix_i or
    43in that of ¬xi\neg x_i; the literal whose section is not delayed is the one set to true.
    44The chain of clause blocks of a clause through all sections can be scheduled only if the
    45clause block is active in some section that is not delayed, that is, if the clause
    46contains a true literal.
    47
    48# Formalization notes
    49
    50A formula is a list of clauses over variables named by natural numbers, as elsewhere in
    51the archive. Its variables are taken to be x0,,xn1x_0, \dots, x_{n-1} with nn one more than
    52the largest index that occurs, and n=1n = 1 when no literal occurs at all, so that the
    53construction always has at least one variable. Variables that do not occur receive
    54sections like any other. A clause is a list, in which a repeated literal counts once and
    55which may be empty; an empty clause has no active block and makes the instance
    56unsolvable, as it makes the formula unsatisfiable.
    57
    58Everything is numbered, because an instance is something a machine is handed as a word.
    59Section ss belongs to the variable s/2\lfloor s/2 \rfloor and is positive when ss is
    60even. The ordinary jobs of section ss are 3s3s, 3s+13s + 1 and 3s+23s + 2: the two ordinary
    61jobs of the literal block and the separator. They are followed by the mm unconnected
    62long jobs of the last section and the mm unconnected short jobs of the first. The
    63connected pairs are listed in the order of their deadlines, in nn groups of 1+2m1 + 2m:
    64pair (1+2m)v(1 + 2m)\,v is the literal pair of the variable vv, the next mm pairs connect
    65the clause blocks of the section of xvx_v with those of ¬xv\neg x_v, and the following
    66mm connect those of ¬xv\neg x_v with those of xv+1x_{v+1}. The last group lacks these
    67final mm pairs, which leaves N=n+(2n1)mN = n + (2n - 1)m.
    68-/
    69
    70namespace Lax391470.SatConstruction
    71
    72open Lax391470.AuxiliaryProblem Lax429075.CNF
    73
    74variable (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. -/
    78def numVars : ℕ := (F.flatMap id).foldr (fun l n => max (l.index + 1) n) 1
    79
    80/-- The number `m` of clauses. -/
    81def numClauses : ℕ := F.length
    82
    83/-- The length `S` of a section. -/
    84def sectionLength : ℕ := p + 2 * q + numClauses F * (p + q) + 1 + q
    85
    86/-- The start of section `s`. -/
    87def sectionStart (s : ℕ) : ℕ := sectionLength p q F * s
    88
    89/-- The literal of section `s`: the sections run `x₀, ¬x₀, x₁, ¬x₁, …`. -/
    90def 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
    93occurs in the clause. -/
    94def active (s j : ℕ) : Bool := decide (literalOf s ∈ F.getD j [])
    95
    96/-- The start of the clause block of clause `j` in section `s`. -/
    97def 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. -/
    100def 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. -/
    104def 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
    107pending jobs. -/
    108def numOrdinary : ℕ := 6 * numVars F + 2 * numClauses F
    109
    110/-- The release time of the ordinary job `o`. -/
    111def 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`. -/
    120def 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⁻`,
    132and the unconnected long jobs of the last section. -/
    133def 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. -/
    138def numPairs : ℕ := numVars F + (2 * numVars F - 1) * numClauses F
    139
    140/-- The variable whose group the pair `i` belongs to. -/
    141def groupOf (i : ℕ) : ℕ := i / (1 + 2 * numClauses F)
    142
    143/-- The position of the pair `i` in its group: `0` for the literal pair. -/
    144def posOf (i : ℕ) : ℕ := i % (1 + 2 * numClauses F)
    145
    146/-- The section holding the long job of the clause pair `i`. -/
    147def pairSection (i : ℕ) : ℕ := 2 * groupOf F i + (posOf F i - 1) / numClauses F
    148
    149/-- The clause of the clause pair `i`. -/
    150def pairClause (i : ℕ) : ℕ := (posOf F i - 1) % numClauses F
    151
    152/-- The early deadline of the long job of pair `i`. -/
    153def 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`. -/
    158def 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. -/
    163def 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`. -/
    168def 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`. -/
    173def 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
    185the auxiliary problem requires. -/
    186axiom 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
    189has a solution. -/
    190axiom 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`
    194is satisfiable. -/
    195axiom 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
    199deadline is at most the length `2nS` of the time line, a polynomial in the size of the
    200formula. Together with `StackedConstruction.times_le`, this bounds every number of the
    201composed reduction; it is the ingredient of strong NP-hardness. -/
    202axiom 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
    208end Lax391470.SatConstruction
    209
    Show ProofShow ProofShow ProofShow Proof
    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 x0,,xn1x_0, \dots, x_{n-1} with nn one more than the largest index that occurs, and n=1n = 1 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 ss belongs to the variable s/2\lfloor s/2 \rfloor and is positive when ss is even. The ordinary jobs of section ss are 3s3s, 3s+13s + 1 and 3s+23s + 2: the two ordinary jobs of the literal block and the separator. They are followed by the mm unconnected long jobs of the last section and the mm unconnected short jobs of the first. The connected pairs are listed in the order of their deadlines, in nn groups of 1+2m1 + 2m: pair (1+2m)v(1 + 2m)\,v is the literal pair of the variable vv, the next mm pairs connect the clause blocks of the section of xvx_v with those of ¬xv\neg x_v, and the following mm connect those of ¬xv\neg x_v with those of xv+1x_{v+1}. The last group lacks these final mm pairs, which leaves N=n+(2n1)mN = n + (2n - 1)m.

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…