Documentation

CslibFrontier.Logics.Propositional.CSP.Edge.DAGSurgery

Surgery on timestamped edge-CSP DAGs #

This formalizes Lemmas 35 and 37, Corollary 36's graph argument, and Lemma 43 of [KKR18], arXiv:1602.03124v6, printed pp. 16–20. The four-coordinate exchange consequences are applied to actual positional tuples to prove preservation of both local feasibility and the full no-shortcut invariant. Common local parity may be odd.

delete_earliest_pair has the source's exact leaf and degree hypotheses and identifies the removed arcs. removeRootCopy and removeCopy prove stronger deletion variants that retain isolated supported nodes as appropriate. reroot_earliest retains every unselected outgoing child and proves the changed topological order, moving the selected variable before all others.

valid_flip_of_pairedCopies proves a stronger form of Corollary 36 by induction on constraint copies: every copy has precisely two incident arcs, at least one incoming. The path-to-Walk bridges are in DAGPaths. Nothing excludes revisits of an original constraint at different times.

flip_walk_of_no_prefix_extension is Lemma 43 with actual Walk.take/snoc hypotheses. Its proof is an alternative to the paper's temporary earlier timestamp: direct exchange gives external_pair, which is iterated over all variable-ended prefixes. Thus no assumption that a smaller natural timestamp exists is needed, including when a current timestamp is zero.

The local surgery arguments in fact hold for arbitrary occurrence-indexed CSP lists; an EdgeInstance identifies this positional extension with the source's no-repeat edge model. No surgery conclusion, path validity, comparison labeling, forest construction or solver is included among the six invariant assumptions. Algorithm 1 and its Lemma 34 are separate work.

Main results #

theorem Cslib.Logic.PL.CSP.DAG.pairFlip_comm {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (f : F.OccurrenceLabeling Bool) (a b : F.Occurrence) :
pairFlip f a b = pairFlip f b a

Cancelling pairs are symmetric, including equal occurrences.

theorem Cslib.Logic.PL.CSP.DAG.pairFlip_cancel {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (f : F.OccurrenceLabeling Bool) (a b c : F.Occurrence) :
pairFlip (pairFlip f a b) b c = pairFlip f a c

Two pair moves sharing their middle occurrence cancel that occurrence.

theorem Cslib.Logic.PL.CSP.DAG.validLabeling_pairFlip_iff {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} (hf : ValidLabeling sem f) (i : Fin (List.length F)) (a b : Fin F[i].2.length) (hab : a ≠ b) :
ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, b⟩) ↔ sem F[i].1 (List.ofFn (BitString.flipOn {a, b} fun (j : Fin F[i].2.length) => f ⟨i, j⟩)) = true

Feasibility of a two-port move is exactly local feasibility at its positional constraint.

theorem Cslib.Logic.PL.CSP.DAG.valid_pairFlip_pairFlip_of_no_cross {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} (hM : EdgeInstance.EvenConstraints sem F) {f : F.OccurrenceLabeling Bool} (hf : ValidLabeling sem f) (i : Fin (List.length F)) {a b c d : Fin F[i].2.length} (hab : a ≠ b) (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) (hcd : c ≠ d) (habf : ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, b⟩)) (hcdf : ValidLabeling sem (pairFlip f ⟨i, c⟩ ⟨i, d⟩)) (hacf : ¬ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, c⟩)) (hadf : ¬ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, d⟩)) :

The substantive property-(5) transfer in KKR Lemmas 35 and 37. The two forbidden old-incoming cross-pairs force the four-coordinate move.

theorem Cslib.Logic.PL.CSP.DAG.not_valid_pairFlip_pairFlip_of_no_cross {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} (hM : EdgeInstance.EvenConstraints sem F) {f : F.OccurrenceLabeling Bool} (hf : ValidLabeling sem f) (i : Fin (List.length F)) {a b c d : Fin F[i].2.length} (hab : a ≠ b) (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) (hcd : c ≠ d) (habf : ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, b⟩)) (hcdf : ¬ValidLabeling sem (pairFlip f ⟨i, c⟩ ⟨i, d⟩)) (hacf : ¬ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, c⟩)) (hadf : ¬ValidLabeling sem (pairFlip f ⟨i, a⟩ ⟨i, d⟩)) :

The substantive no-shortcut transfer in KKR Lemmas 35 and 37. Exchange toward the feasible base would produce one of three forbidden pairs.

theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.occurrence_ne_of_time_ne {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (ht : a.time ≠ b.time) :

Different timestamps cannot reuse an original incidence.

theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.occurrence_ne_of_orientation_ne {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (ht : a.incoming ≠ b.incoming) :

Opposite orientations cannot reuse an original incidence.

theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.feasible_after_earlier {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b x y : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hx : x ∈ T.arcs) (hy : y ∈ T.arcs) (hai : a.incoming = true) (hne : a.occurrence ≠ b.occurrence) (hab : a.copy = b.copy) (hxi : x.incoming = true) (hxy : x.copy = y.copy) (ht : a.time < x.time) :

Local feasibility at a later copy survives the earliest two-port move. All original-constraint revisits are retained; the four-coordinate exchange handles them.

theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.noShortcut_after_earlier {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b x y : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hx : x ∈ T.arcs) (hy : y ∈ T.arcs) (hai : a.incoming = true) (hne : a.occurrence ≠ b.occurrence) (hab : a.copy = b.copy) (hxi : x.incoming = true) (hxy : x.occurrence.fst = y.occurrence.fst) (ht : a.time < x.time) (hxytime : x.time < y.time) :

The no-shortcut prohibition between later copies survives the earliest two-port move.

def Cslib.Logic.PL.CSP.DAG.Earliest {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (T : F.DAG) (c : Copy F) :

A supported copy has minimum timestamp, including among isolated constraint copies.

Instances For
    theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.time_lt_of_earliest {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) {c : Copy F} (hc : T.Earliest c) {a : Arc F} (ha : a ∈ T.arcs) (hne : a.copy ≠ c) :
    c.2 < a.time

    A different copy is strictly later than a minimum copy: timestamps are globally unique.

    def Cslib.Logic.PL.CSP.DAG.Arc.reverse {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (a : Arc F) :
    Arc F

    Reverse one indexed incidence without changing its original port or timestamp.

    Instances For
      def Cslib.Logic.PL.CSP.DAG.reroot {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} [DecidableEq V] (T : F.DAG) (a b : Arc F) :
      F.DAG

      Delete the old root arc and reverse one selected child arc, retaining all other children.

      Instances For
        theorem Cslib.Logic.PL.CSP.DAG.mem_reroot_arcs {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {T : F.DAG} [DecidableEq V] {a b e : Arc F} :
        e ∈ (T.reroot a b).arcs ↔ e = b.reverse ∨ e ∈ T.arcs ∧ e ≠ a ∧ e ≠ b

        The new root arc is distinguished from the unchanged, retained old arcs.

        def Cslib.Logic.PL.CSP.DAG.removeRootCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} [DecidableEq V] (T : F.DAG) (u : V) (c : Copy F) :
        F.DAG

        Delete a variable root and a constraint copy, retaining all other supported nodes.

        Instances For
          theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.removeRootCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} [DecidableEq V] (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hai : a.incoming = true) (hbo : b.incoming = false) (hab : a.copy = b.copy) (he : T.Earliest a.copy) :

          Earliest-copy deletion preserves the full f-DAG invariant after its two-port move. This stronger form deletes every incident arc at the selected root and copy; the degree hypotheses in Lemma 35 identify these with precisely its two displayed arcs.

          theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.delete_earliest_pair {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} [DecidableEq V] (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hai : a.incoming = true) (hbo : b.incoming = false) (hab : a.copy = b.copy) (he : T.Earliest a.copy) (hleaf : ∀ e ∈ T.arcs, e.occurrence.var = a.occurrence.var → e = a) (hdegree : ∀ e ∈ T.arcs, e.copy = a.copy → e = a ∨ e = b) :

          Lemma 35, KKR v6, printed pp. 16–17: flip u C v, remove u,C^s and exactly the two displayed arcs. Both local feasibility and no shortcuts are proved by even exchange.

          theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.reroot_earliest {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} [DecidableEq V] (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hai : a.incoming = true) (hbo : b.incoming = false) (hab : a.copy = b.copy) (he : T.Earliest a.copy) (hleaf : ∀ e ∈ T.arcs, e.occurrence.var = a.occurrence.var → e = a) (hin : ∀ e ∈ T.arcs, e.incoming = true → e.copy = a.copy → e = a) :

          Lemma 37, KKR v6, printed pp. 18–19: an earliest copy with a single incoming root arc can be rerooted at any outgoing child. Other outgoing children are retained.

          def Cslib.Logic.PL.CSP.DAG.removeCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} [DecidableEq V] (T : F.DAG) (c : Copy F) :
          F.DAG

          Delete a constraint copy, retaining its variable endpoints as isolated nodes if necessary.

          Instances For
            theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.removeCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} [DecidableEq V] (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hai : a.incoming = true) (hne : a.occurrence ≠ b.occurrence) (hab : a.copy = b.copy) (he : T.Earliest a.copy) :

            The earliest-copy exchange argument also applies to two incoming ports. This covers the terminal meeting copy in Corollary 36(1).

            def Cslib.Logic.PL.CSP.DAG.PairedCopies {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (T : F.DAG) :

            Each supported constraint copy has precisely two incident arcs, at least one incoming. This purely graph-theoretic condition includes directed paths and two paths meeting at a copy. It places no restriction on revisits of an original constraint at different timestamps.

            Instances For
              theorem Cslib.Logic.PL.CSP.DAG.PairedCopies.removeCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {T : F.DAG} [DecidableEq V] (hp : T.PairedCopies) (hs : T.Supported) (c : Copy F) :

              Removing one copy preserves the two-arc condition at every remaining copy.

              def Cslib.Logic.PL.CSP.DAG.flip {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} (T : F.DAG) (f : F.OccurrenceLabeling Bool) :

              Flip every used original incidence of a DAG, independently of isolated node support.

              Instances For
                theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.flip_removeCopy {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} [DecidableEq V] (h : IsFDAG sem f T) {a b : Arc F} (ha : a ∈ T.arcs) (hb : b ∈ T.arcs) (hab : a.copy = b.copy) (hne : a.occurrence ≠ b.occurrence) (hp : ∀ e ∈ T.arcs, e.copy = a.copy → e = a ∨ e = b) :

                Removing a two-arc constraint copy factors the full DAG flip into its first pair move and the remaining incidence flip. Original incidences are not counted twice.

                theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.valid_flip_of_pairedCopies {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) (hp : T.PairedCopies) :

                Corollary 36 in a stronger graph form: if every copy has two incident arcs with at least one incoming, flipping the entire f-DAG is valid. Directed variable-to-variable paths and two otherwise-disjoint directed paths meeting at a constraint copy are special cases. The induction removes copies, and therefore permits repeated original constraints.

                theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.external_pair {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {a b : F.Occurrence} (hab : a.fst = b.fst) (hne : a ≠ b) (hv : ValidLabeling sem (pairFlip f a b)) (hdis : ∀ e ∈ T.arcs, a ≠ e.occurrence ∧ b ≠ e.occurrence) (hcross : ∀ e ∈ T.arcs, a.fst = e.occurrence.fst → ¬ValidLabeling sem (pairFlip f a e.occurrence)) :
                IsFDAG sem (pairFlip f a b) T

                A feasible external step preserves the same DAG when its first port cannot exchange with any used port. This is the direct local-exchange argument for Lemma 43: unlike the source's proof, it needs no new minimum timestamp, and therefore also handles existing timestamp zero.

                theorem Cslib.Logic.PL.CSP.DAG.IsFDAG.flip_walk_of_no_prefix_extension {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {sem : Rel → List Bool → Bool} {f : F.OccurrenceLabeling Bool} {T : F.DAG} (h : IsFDAG sem f T) (hM : EdgeInstance.EvenConstraints sem F) {w : F.Walk} (hw : Walk.IsFWalk sem f w) (hstart : w.start ∉ T.vars) (hvars : ∀ o ∈ w.edges, o.var ∉ T.vars) (hno : ∀ n < w.steps.length, ∀ e ∈ T.arcs, ∀ (o : F.Occurrence), o.var = (w.take n).finish → o.fst = e.occurrence.fst → ¬Walk.IsFWalk sem f ((w.take n).snoc o e.occurrence)) :
                IsFDAG sem (w.flip f) T

                Lemma 43, KKR v6, printed p. 20, with explicit occurrence-level avoidance and Walk.take/Walk.snoc extension conditions. Every used DAG arc is tested regardless of orientation. Direct four-coordinate exchange replaces the source proof's temporary earlier copy, so timestamp zero needs neither a nonexistent smaller natural nor a reindexing premise.