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

Binary encoding of a scheduling instance

Lax470956.BinaryEncoding · concepts/Lax470956/BinaryEncoding.lean · lax-470956

definition

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

    A scheduling instance as a binary word, the representation classical complexity measures running time against. A number is written as its binary digits preceded by its length in unary, which makes the encoding self-delimiting; an instance is the number of jobs, the number of machines, the three arrays of processing times, deadlines and weights, and the n×mn \times m eligibility matrix, in that order.

    Concept map
    3 concepts; 3 descendants hidden
    100%
    Open claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax470956.Scheduling
    2import Lax434930.PolynomialTime
    3import Mathlib.Data.List.FinRange
    4import Mathlib.Data.Nat.Bits
    5
    6/-!
    7---
    8title: Binary encoding of a scheduling instance
    9type: definition
    10---
    11A scheduling instance as a binary word, the representation classical complexity measures
    12running time against. A number is written as its binary digits preceded by its length in
    13unary, which makes the encoding self-delimiting; an instance is the number of jobs, the
    14number of machines, the three arrays of processing times, deadlines and weights, and the
    15n×mn \times m eligibility matrix, in that order.
    16
    17# Formalization notes
    18
    19This encoding exists beside the word encoding of `InstanceEncoding` and does not replace
    20it. They answer different questions. A word RAM is handed numbers and charges one
    21instruction per operation on them, so its input is a list of numbers and its running time
    22is measured in their count; a Turing machine is handed bits, so a claim of polynomial
    23time is a claim about the number of bits. The two statements of this submission that
    24quantify over all of NP are Turing-machine statements and use this encoding; the
    25fixed-parameter statement is a word RAM statement and uses the other.
    26
    27Numbers are written in binary rather than unary. The difference is not cosmetic for a
    28hardness claim: under a unary encoding the input is exponentially longer, which makes a
    29polynomial-time reduction easier to achieve and the resulting hardness claim
    30correspondingly weaker — it would be a claim of *strong* NP-hardness only. Binary is
    31what the unqualified statement means.
    32
    33The eligibility matrix is written in full, one bit per job-machine pair, rather than as
    34adjacency lists. At nmnm bits it is within a polynomial of any other reasonable choice,
    35and polynomial time is invariant under polynomial changes of encoding; the matrix is the
    36simpler object and matches the encoding of a graph elsewhere in the archive.
    37
    38The encoding need not be injective on instances that differ only in inaccessible data,
    39and nothing here claims it is. What the statements need is that it is computable in
    40polynomial time and that the reduction's image is determined, both of which are
    41obligations of the proof layer.
    42-/
    43
    44namespace Lax470956.BinaryEncoding
    45
    46open Lax470956.Scheduling Lax434930.PolynomialTime
    47
    48/-- A natural number as a binary word: its digits, least significant first, preceded by
    49their number in unary. The unary prefix makes the code self-delimiting. -/
    50def encodeNat (n : ℕ) : Word :=
    51 List.replicate n.bits.length true ++ [false] ++ n.bits
    52
    53/-- An instance as a binary word: the two counts, the processing times, the deadlines,
    54the weights, and the eligibility matrix in row order. -/
    55def encodeInstance (I : Instance) : Word :=
    56 encodeNat I.jobs ++ encodeNat I.machines ++
    57 (List.finRange I.jobs).flatMap (fun j => encodeNat (I.p j)) ++
    58 (List.finRange I.jobs).flatMap (fun j => encodeNat (I.d j)) ++
    59 (List.finRange I.jobs).flatMap (fun j => encodeNat (I.w j)) ++
    60 (List.finRange I.jobs).flatMap
    61 (fun j => (List.finRange I.machines).map fun i => decide (i ∈ I.eligible j))
    62
    63end Lax470956.BinaryEncoding
    64
    Formalization notes

    This encoding exists beside the word encoding of InstanceEncodingInstanceEncoding and does not replace it. They answer different questions. A word RAM is handed numbers and charges one instruction per operation on them, so its input is a list of numbers and its running time is measured in their count; a Turing machine is handed bits, so a claim of polynomial time is a claim about the number of bits. The two statements of this submission that quantify over all of NP are Turing-machine statements and use this encoding; the fixed-parameter statement is a word RAM statement and uses the other.

    Numbers are written in binary rather than unary. The difference is not cosmetic for a hardness claim: under a unary encoding the input is exponentially longer, which makes a polynomial-time reduction easier to achieve and the resulting hardness claim correspondingly weaker — it would be a claim of strong NP-hardness only. Binary is what the unqualified statement means.

    The eligibility matrix is written in full, one bit per job-machine pair, rather than as adjacency lists. At nmnm bits it is within a polynomial of any other reasonable choice, and polynomial time is invariant under polynomial changes of encoding; the matrix is the simpler object and matches the encoding of a graph elsewhere in the archive.

    The encoding need not be injective on instances that differ only in inaccessible data, and nothing here claims it is. What the statements need is that it is computable in polynomial time and that the reduction's image is determined, both of which are obligations of the proof layer.

    Discussion

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

    Loading discussion…