Documentation

CslibFrontier.Computability.PolyTime.CSP.Edge.Augmenting

Finite buffers for the two-phase edge-CSP augmentation #

The input contains the existing explicit-table CSP, two occurrence bit buffers, and an excluded starting variable. Positions retain constraint and scope order. All scans traverse actual lists; no loop is paid for by a binary variable name or a table's declared arity.

This module compiles the two phases of Lemma 31 of [KKR18], arXiv v6, Section 6.1, printed p. 15. The improving comparison is supplied as input; this routine does not find it or solve the CSP. Walk codes represent the existing CSP.Walk, without introducing another trail predicate.

Main definitions #

Main results #

Complete augmentation input, with bits in constraint-then-scope occurrence order.

  • The original CSP, with explicit table relations and binary variable names.

  • labels : List Bool

    Original occurrence labels.

  • comparison : List Bool

    Supplied improving comparison, in the same positional order.

  • excluded : ℕ

    Variable excluded only as the start, not as the terminal variable.

Instances For
    theorem Cslib.Complexity.CSP.EdgeAugmenting.encInput_excluded_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :
    theorem Cslib.Complexity.CSP.EdgeAugmenting.encInput_comparison_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :
    theorem Cslib.Complexity.CSP.EdgeAugmenting.encInput_body_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :
    theorem Cslib.Complexity.CSP.EdgeAugmenting.encInput_labels_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :

    The CSP, original bits and comparison bits are framed in field order; the final variable name is binary. Tables include their binary arity and explicitly framed Boolean rows.

    Instances For
      theorem Cslib.Complexity.CSP.EdgeAugmenting.encInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Logic.PL.CSP Logic.PL.CSP.Table ℕ} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 x3 T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (encCSP encTable Turing.MultiTapeTM.encNat) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBool) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBool) T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encNat T3 S3) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { body := x0 x, labels := x1 x, comparison := x2 x, excluded := x3 x }) encIn encInput (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))

      A representation of an existing walk by global occurrence indices.

      • start : ℕ

        Starting variable, encoded in binary.

      • steps : List (ℕ × ℕ)

        Global occurrence indices in each ordered exchange, retaining repeated constraints.

      Instances For
        @[reducible, inline]

        The tuple of the fields of encWalkCode.

        Instances For
          theorem Cslib.Complexity.CSP.EdgeAugmenting.encWalkCode_start_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WalkCode} :

          A binary start, framed, followed by framed pairs of binary global occurrence indices.

          Instances For
            theorem Cslib.Complexity.CSP.EdgeAugmenting.encWalkCode_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → List (ℕ × ℕ)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encNat Turing.MultiTapeTM.encNat)) T1 S1) :
            Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { start := x0 x, steps := x1 x }) encIn encWalkCode (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

            Project the existing walk to global occurrence indices.

            Instances For

              First phase on finite buffers. The unary clock counts actual occurrence disagreements.

              Instances For

                Read an actual incidence record at a global position, defaulting to (0, 0, 0) when that position is outside the finite original occurrence list.

                Instances For

                  Read the last output port's original variable. An empty walk retains its original start; an invalid last position uses the same zero-record default as recordAt.

                  Instances For

                    Second phase on finite buffers. A stopped bit preserves the first reached original defect; an exhausted or unsuccessful scan rejects.

                    Instances For

                      Total finite implementation of the two phases. Both buffers must have exactly the actual occurrence count; malformed widths reject before either phase.

                      Instances For
                        @[reducible, inline]

                        The tuple of the fields of encWalkCodeWork.

                        Instances For
                          theorem Cslib.Complexity.CSP.EdgeAugmenting.encWalkCodeWork_start_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WalkCode} :

                          Work representation: the binary start is framed, and bounded occurrence positions are unary. This internal representation is converted to the binary encWalkCode on output.

                          Instances For
                            theorem Cslib.Complexity.CSP.EdgeAugmenting.encWalkCodeWork_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → List (ℕ × ℕ)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary)) T1 S1) :
                            Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { start := x0 x, steps := x1 x }) encIn encWalkCodeWork (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

                            Uniform native polynomial time on complete framed inputs, without validity, edge-instance, even-delta-matroid or improvement assumptions. Width errors reject; all other data are processed by list scans and occurrence clocks.

                            Decode global positions into the existing dependent occurrence type. Out-of-range indices reject. This is a representation bridge, with no additional mathematical walk predicate.

                            Instances For

                              The walk representation is lossless, including empty walks and repeated constraint visits.

                              Looking up the binary position of an actual occurrence recovers its exact positional record, including both original local coordinates and its original variable name.

                              theorem Cslib.Complexity.CSP.EdgeAugmenting.finish_eq (input : Input) (w : input.body.Walk) :
                              finish input (code w) = w.finish

                              The finite binary-position endpoint of an encoded actual walk is exactly its original mathematical endpoint, including the length-zero fallback.

                              Exact compilation of the mathematical two-phase routine, including its deterministic scan order, both Hamming clocks and failure cases. Only the two exact buffer-width guards are needed.

                              A valid improving comparison yields an actual augmenting walk, decoded into the existing model. The start alone avoids the excluded variable; the exchange bound is the original one.

                              Repair flips bits without changing the comparison buffer's width, on every input.

                              Every successful output has at most the original buffer's length in steps, independently of semantic validity. With the width guard this is the actual occurrence count.

                              The width guard rejects either short or long original/comparison buffers.