0-1 integer programming

Lax799700.ZeroOneIP · concepts/Lax799700/ZeroOneIP.lean · lax-799700

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

    Theorem

    0-1 INTEGER PROGRAMMING: given a matrix CC and a vector dd, is there a 0-1 vector xx with Cx=dCx = d? It is the multi-row form of Knapsack and is written in binary like it. The vocabulary carries the columns, the rows, the bit positions, the bits of each coefficient (the catalog's one ternary symbol), the bits of each right-hand side, and a linear order fixing the place values. Entries are natural numbers: Karp states the problem over the integers, and this restriction is the one his reduction produces, so its NP-hardness gives his problem's a fortiori. Membership is by an existential second-order definition, hardness by an ordered first-order reduction from Knapsack.

    Concept map
    10 concepts
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

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

    1 hasZeroOneSolution_iso proven

    Lean source view on GitHub

    1import Mathlib.Algebra.BigOperators.Finprod
    2import Mathlib.ModelTheory.Semantics
    3import Mathlib.ModelTheory.Complexity
    4import Mathlib.Tactic.FinCases
    5import Mathlib.Data.Set.Finite.Lemmas
    6import Mathlib.Data.Fintype.EquivFin
    7import Mathlib.Data.Set.Card
    8import Mathlib.SetTheory.Cardinal.Finite
    9import Mathlib.Logic.Equiv.Prod
    10import Mathlib.ModelTheory.Syntax
    11import Lax799700.Common
    12import Lax904597.Machines
    13import Lax904597.Classes
    14import Lax799700.Problems
    15
    16/-!
    17---
    18title: 0-1 integer programming
    19type: theorem
    20---
    210-1 INTEGER PROGRAMMING: given a matrix CC and a vector dd, is there a
    220-1 vector xx with Cx=dCx = d? It is the multi-row form of Knapsack and is
    23written in binary like it. The vocabulary carries the columns, the rows,
    24the bit positions, the bits of each coefficient (the catalog's one
    25ternary symbol), the bits of each right-hand side, and a linear order
    26fixing the place values. Entries are natural numbers: Karp states the
    27problem over the integers, and this restriction is the one his reduction
    28produces, so its NP-hardness gives his problem's a fortiori. Membership
    29is by an existential second-order definition, hardness by an ordered
    30first-order reduction from Knapsack.
    31
    32-/
    33
    34namespace Lax799700.ZeroOneIP
    35
    36open Lax799700.Common Lax904597.Machines
    37
    38open FirstOrder
    39
    40open FirstOrder.Language
    41
    42/-- The relation symbols of the language. -/
    43inductive zeroOneIPRel : ℕ → Type where
    44/-- `col j`: `j` is a column, that is, a `0-1` variable. -/
    45 | col : zeroOneIPRel 1
    46/-- `row r`: `r` is a row, that is, an equation. -/
    47 | row : zeroOneIPRel 1
    48/-- `posn p`: `p` is a bit position. -/
    49 | posn : zeroOneIPRel 1
    50/-- `coef r j p`: the entry of row `r` in column `j` has bit 1 at `p`. -/
    51 | coef : zeroOneIPRel 3
    52/-- `rhs r p`: the right-hand side of row `r` has bit 1 at `p`. -/
    53 | rhs : zeroOneIPRel 2
    54/-- `le a b`: the linear order carrying the place values. -/
    55 | le : zeroOneIPRel 2
    56 deriving DecidableEq
    57
    58/-- The relational language of 0-1 integer programs: columns, rows and bit
    59positions, the bits of each entry and of each right-hand side, and a linear
    60order. -/
    61def zeroOneIP : FirstOrder.Language :=
    62 ⟨fun _ => Empty, zeroOneIPRel⟩
    63
    64instance instIsRelationalZeroOneIP : FirstOrder.Language.IsRelational zeroOneIP := fun _ =>
    65 (inferInstance : IsEmpty Empty)
    66
    67/-- `col j`: `j` is a column, that is, a `0-1` variable. -/
    68abbrev ipCol : zeroOneIP.Relations 1 :=
    69 .col
    70
    71/-- `row r`: `r` is a row, that is, an equation. -/
    72abbrev ipRow : zeroOneIP.Relations 1 :=
    73 .row
    74
    75/-- `posn p`: `p` is a bit position. -/
    76abbrev ipPosn : zeroOneIP.Relations 1 :=
    77 .posn
    78
    79/-- `coef r j p`: the entry of row `r` in column `j` has bit 1 at `p`. -/
    80abbrev ipCoef : zeroOneIP.Relations 3 :=
    81 .coef
    82
    83/-- `rhs r p`: the right-hand side of row `r` has bit 1 at `p`. -/
    84abbrev ipRhs : zeroOneIP.Relations 2 :=
    85 .rhs
    86
    87/-- `le a b`: the linear order carrying the place values. -/
    88abbrev ipLe : zeroOneIP.Relations 2 :=
    89 .le
    90
    91open FirstOrder
    92
    93open Language Structure
    94
    95section Shorthands
    96
    97variable {A : Type} [zeroOneIP.Structure A]
    98
    99/-- `col j`: `j` is a column, that is, a `0-1` variable. -/
    100def IPCol {A : Type} [zeroOneIP.Structure A] (a0 : A) : Prop :=
    101 FirstOrder.Language.Structure.RelMap ipCol ![a0]
    102
    103/-- `row r`: `r` is a row, that is, an equation. -/
    104def IPRow {A : Type} [zeroOneIP.Structure A] (a0 : A) : Prop :=
    105 FirstOrder.Language.Structure.RelMap ipRow ![a0]
    106
    107/-- `posn p`: `p` is a bit position. -/
    108def IPPosn {A : Type} [zeroOneIP.Structure A] (a0 : A) : Prop :=
    109 FirstOrder.Language.Structure.RelMap ipPosn ![a0]
    110
    111/-- `coef r j p`: the entry of row `r` in column `j` has bit 1 at `p`. -/
    112def IPCoef {A : Type} [zeroOneIP.Structure A] (a0 : A) (a1 : A) (a2 : A) : Prop :=
    113 FirstOrder.Language.Structure.RelMap ipCoef ![a0, a1, a2]
    114
    115/-- `rhs r p`: the right-hand side of row `r` has bit 1 at `p`. -/
    116def IPRhs {A : Type} [zeroOneIP.Structure A] (a0 : A) (a1 : A) : Prop :=
    117 FirstOrder.Language.Structure.RelMap ipRhs ![a0, a1]
    118
    119/-- `le a b`: the linear order carrying the place values. -/
    120def IPLe {A : Type} [zeroOneIP.Structure A] (a0 : A) (a1 : A) : Prop :=
    121 FirstOrder.Language.Structure.RelMap ipLe ![a0, a1]
    122
    123/-- The entry of a row in a column, decoded. -/
    124noncomputable def IPCoefVal (r j : A) : ℕ := binNum IPLe IPPosn (IPCoef r j)
    125
    126/-- The right-hand side of a row, decoded. -/
    127noncomputable def IPRhsVal (r : A) : ℕ := binNum IPLe IPPosn (IPRhs r)
    128
    129end Shorthands
    130
    131section Problem
    132
    133variable (A : Type) [zeroOneIP.Structure A]
    134
    135/-- A 0-1 integer program is a yes-instance when its order is a linear order
    136and some set of columns – the variables set to `1` – makes every equation
    137hold. -/
    138def HasZeroOneSolution : Prop :=
    139 Finite A ∧ IsLinOrd (IPLe (A := A)) ∧
    140 ∃ x : A → Prop, (∀ j, x j → IPCol j) ∧
    141 ∀ r, IPRow r → (∑ᶠ j ∈ {j | x j}, IPCoefVal r j) = IPRhsVal r
    142
    143end Problem
    144
    145open Lax904597.Problems Lax904597.Classes Lax799700.Problems
    146
    147/-- The property `HasZeroOneSolution` is isomorphism-invariant. -/
    148axiom hasZeroOneSolution_iso : ∀ {A B : Type} [Lax799700.ZeroOneIP.zeroOneIP.Structure A] [Lax799700.ZeroOneIP.zeroOneIP.Structure B],
    149 (A ≃[Lax799700.ZeroOneIP.zeroOneIP] B) → (HasZeroOneSolution A ↔ HasZeroOneSolution B)
    150
    151/-- The problem ZeroOneIP: does the structure satisfy `HasZeroOneSolution`? -/
    152def ZeroOneIP : DecisionProblem Lax799700.ZeroOneIP.zeroOneIP :=
    153 DecisionProblem.ofPred HasZeroOneSolution
    154
    155/-- The yes-instances of ZeroOneIP are exactly the structures satisfying
    156`HasZeroOneSolution`. -/
    157axiom zeroOneIP_iff : ∀ (A : Type) [Lax799700.ZeroOneIP.zeroOneIP.Structure A], ZeroOneIP A ↔ HasZeroOneSolution A
    158
    159/-- ZeroOneIP is NP-complete. -/
    160axiom zeroOneIP_NP_complete : NP.Complete ZeroOneIP
    161
    162end Lax799700.ZeroOneIP
    163
    Show ProofShow ProofShow Proof

    Discussion

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

    Loading discussion…