Documentation

CslibFrontier.Algorithms.Lean.Arborescence.PolyTime

Polynomial-time Chu–Liu/Edmonds arborescence and branching solvers (P) #

This file implements plain ComputableInPolyTime list-table versions of the Chu–Liu/Edmonds minimum-cost rooted arborescence algorithm and Edmonds's Theorem 1 maximum-weight branching solver [Edm67a], proving that the corresponding decision problems lie in P with binary integer arc weights (encIntBin).

Contraction modifies arc costs solely via otherCycleCost additions (no integer subtraction), so after i contraction rounds every intermediate table entry satisfies |cᵢ[u, w]| ≤ (n + 1) ^ i · M₀ and has binary bit length O(L²) in the input length L, keeping the contraction stack and all reachable ContractStates bounded by a polynomial in L.

Main definitions #

Main results #

References #

Problem instances and contraction state structures #

@[reducible, inline]

Row-major Boolean adjacency matrix encoding.

@[reducible, inline]

Row-major binary integer weight or cost matrix encoding.

@[reducible, inline]

Encoding of an optional list of unary vertex indices (Option (List ℕ)).

Instance of the minimum-cost spanning arborescence problem on vertices 0, …, n - 1 (n = adj.length), given by a Boolean adjacency table, a binary integer cost table, and a binary root vertex index.

  • adj : List (List Bool)

    n × n Boolean adjacency matrix (adj[u][v] = true for arc u → v).

  • cost : List (List ℤ)

    n × n binary integer arc-cost matrix.

  • root : ℕ

    Designated root vertex index (root < adj.length).

theorem Cslib.Algorithms.Lean.Arborescence.encArborescenceInstance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List (List Bool)} {T0 S0 : γ → ℕ} {x1 : γ → List (List ℤ)} {T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encAdjTable T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encIntTable T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encNat T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { adj := x0 x, cost := x1 x, root := x2 x }) encIn encArborescenceInstance (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Cslib.Algorithms.Lean.Arborescence.encArborescenceInstance_adj_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ArborescenceInstance} :
theorem Cslib.Algorithms.Lean.Arborescence.encArborescenceInstance_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List (List Bool)} {x1 : γ → List (List ℤ)} {x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encAdjTable budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encIntTable budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encNat budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { adj := x0 x, cost := x1 x, root := x2 x }) encIn encArborescenceInstance budget

Encoding of ArborescenceInstance with Boolean adjacency table, encIntBin cost matrix, and binary root index encNat.

theorem Cslib.Algorithms.Lean.Arborescence.encArborescenceInstance_cost_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ArborescenceInstance} :

Decision instance for minimum-cost spanning arborescence (arcCost ≤ threshold).

  • Underlying weighted digraph and root instance.

  • threshold : ℤ

    Binary integer cost upper bound.

theorem Cslib.Algorithms.Lean.Arborescence.encArborescenceDecInstance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ArborescenceInstance} {T0 S0 : γ → ℕ} {x1 : γ → ℤ} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encArborescenceInstance T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encIntBin T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { inst := x0 x, threshold := x1 x }) encIn encArborescenceDecInstance (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

Instance of the maximum-weight branching problem on vertices 0, …, n - 1.

  • adj : List (List Bool)

    n × n Boolean adjacency matrix.

  • weight : List (List ℤ)

    n × n binary integer arc-weight matrix.

Encoding of BranchingInstance with Boolean adjacency table and encIntBin weights.

theorem Cslib.Algorithms.Lean.Arborescence.encBranchingInstance_weight_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → BranchingInstance} :
theorem Cslib.Algorithms.Lean.Arborescence.encBranchingInstance_adj_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → BranchingInstance} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encBranchingInstance S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).adj) encIn✝ encAdjTable S✝
theorem Cslib.Algorithms.Lean.Arborescence.encBranchingInstance_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List (List Bool)} {x1 : γ → List (List ℤ)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encAdjTable budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encIntTable budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { adj := x0 x, weight := x1 x }) encIn encBranchingInstance budget
theorem Cslib.Algorithms.Lean.Arborescence.encBranchingInstance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List (List Bool)} {T0 S0 : γ → ℕ} {x1 : γ → List (List ℤ)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encAdjTable T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encIntTable T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { adj := x0 x, weight := x1 x }) encIn encBranchingInstance (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

Decision instance for maximum-weight branching (threshold ≤ arcCost).

  • Underlying weighted digraph instance.

  • threshold : ℤ

    Binary integer weight lower bound.

theorem Cslib.Algorithms.Lean.Arborescence.encBranchingDecInstance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → BranchingInstance} {T0 S0 : γ → ℕ} {x1 : γ → ℤ} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encBranchingInstance T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encIntBin T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { inst := x0 x, threshold := x1 x }) encIn encBranchingDecInstance (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Algorithms.Lean.Arborescence.encBranchingDecInstance_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → BranchingInstance} {x1 : γ → ℤ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encBranchingInstance budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encIntBin budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { inst := x0 x, threshold := x1 x }) encIn encBranchingDecInstance budget

One contraction level recorded by the forward pass of edmondsTableAuxList for bottom-up expansion of parent pointers.

  • parent : List ℕ

    Selected parent table f[v] before contraction (v < n).

  • inCycle : List Bool

    Cycle indicator mask inCycle[v] for the contracted directed cycle C.

  • bestEntry : List (Option ℕ)

    Best incoming vertex index into C from each u ∉ C, if any.

  • bestExit : List (Option ℕ)

    Best outgoing vertex x ∈ C to each w ∉ C, if any.

  • rep : ℕ

    Representative vertex x₀ ∈ C of the contracted cycle.

theorem Cslib.Algorithms.Lean.Arborescence.encContractLevel_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List ℕ} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List (Option ℕ)} {T2 S2 : γ → ℕ} {x3 : γ → List (Option ℕ)} {T3 S3 x4 T4 S4 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encUnary) 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.encOption Turing.MultiTapeTM.encUnary)) T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encUnary)) T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn Turing.MultiTapeTM.encUnary T4 S4) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { parent := x0 x, inCycle := x1 x, bestEntry := x2 x, bestExit := x3 x, rep := x4 x }) encIn encContractLevel (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + T4 x)))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + S4 x)))
theorem Cslib.Algorithms.Lean.Arborescence.encContractLevel_rep_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractLevel} :
theorem Cslib.Algorithms.Lean.Arborescence.encContractLevel_mk_deg :
Turing.MultiTapeTM.ComputableInDegree (fun (p : List ℕ × List Bool × List (Option ℕ) × List (Option ℕ) × ℕ) => { parent := p.1, inCycle := p.2.1, bestEntry := p.2.2.1, bestExit := p.2.2.2.1, rep := p.2.2.2.2 }) encContractLevelFields encContractLevel 1 1

Forward contraction state of the list-based Chu–Liu/Edmonds solver.

  • adj : List (List Bool)

    Current contracted adjacency matrix.

  • cost : List (List ℤ)

    Current contracted integer cost matrix.

  • root : ℕ

    Root vertex index (encUnary during table contraction).

  • done : Bool

    Whether contraction has terminated (acyclic solution found or infeasible).

  • result : Option (List ℕ)

    Base acyclic parent map when terminated cleanly, or none.

  • Contraction frames pushed innermost-first for backward foldl expansion.

theorem Cslib.Algorithms.Lean.Arborescence.encContractState_mk_deg :
Turing.MultiTapeTM.ComputableInDegree (fun (p : List (List Bool) × List (List ℤ) × ℕ × Bool × Option (List ℕ) × List ContractLevel) => { adj := p.1, cost := p.2.1, root := p.2.2.1, done := p.2.2.2.1, result := p.2.2.2.2.1, stack := p.2.2.2.2.2 }) encContractStateFields encContractState 1 1
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_cost_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractState} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encContractState S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).cost) encIn✝ encIntTable S✝
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_done_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractState} :
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_root_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractState} :
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List (List Bool)} {T0 S0 : γ → ℕ} {x1 : γ → List (List ℤ)} {T1 S1 x2 T2 S2 : γ → ℕ} {x3 : γ → Bool} {T3 S3 : γ → ℕ} {x4 : γ → Option (List ℕ)} {T4 S4 : γ → ℕ} {x5 : γ → List ContractLevel} {T5 S5 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encAdjTable T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encIntTable T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encUnary T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encBool T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn encParentOption T4 S4) (h5 : Turing.MultiTapeTM.ComputableInO x5 encIn (Turing.MultiTapeTM.encList encContractLevel) T5 S5) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { adj := x0 x, cost := x1 x, root := x2 x, done := x3 x, result := x4 x, stack := x5 x }) encIn encContractState (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + (T4 x + T5 x))))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + (S4 x + S5 x))))
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_result_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractState} :
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List (List Bool)} {x1 : γ → List (List ℤ)} {x2 : γ → ℕ} {x3 : γ → Bool} {x4 : γ → Option (List ℕ)} {x5 : γ → List ContractLevel} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encAdjTable budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encIntTable budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encUnary budget) (h3 : Turing.MultiTapeTM.ComputableInSpace x3 encIn Turing.MultiTapeTM.encBool budget) (h4 : Turing.MultiTapeTM.ComputableInSpace x4 encIn encParentOption budget) (h5 : Turing.MultiTapeTM.ComputableInSpace x5 encIn (Turing.MultiTapeTM.encList encContractLevel) budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { adj := x0 x, cost := x1 x, root := x2 x, done := x3 x, result := x4 x, stack := x5 x }) encIn encContractState budget
theorem Cslib.Algorithms.Lean.Arborescence.encContractState_adj_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractState} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encContractState S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).adj) encIn✝ encAdjTable S✝

Input bundle for parameterized edmondsTableAuxList.

  • fuel : ℕ

    Iteration bound (fuel) in unary.

  • root : ℕ

    Root vertex index in unary.

  • adj : List (List Bool)

    Boolean adjacency table.

  • cost : List (List ℤ)

    Integer arc-cost table.

theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_fuel_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableAuxInput} :
theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_cost_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableAuxInput} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encTableAuxInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).cost) encIn✝ encIntTable S✝
theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 : γ → ℕ} {x2 : γ → List (List Bool)} {x3 : γ → List (List ℤ)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encUnary budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn encAdjTable budget) (h3 : Turing.MultiTapeTM.ComputableInSpace x3 encIn encIntTable budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { fuel := x0 x, root := x1 x, adj := x2 x, cost := x3 x }) encIn encTableAuxInput budget
theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_adj_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableAuxInput} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encTableAuxInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).adj) encIn✝ encAdjTable S✝
theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 : γ → ℕ} {x2 : γ → List (List Bool)} {T2 S2 : γ → ℕ} {x3 : γ → List (List ℤ)} {T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encUnary T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn encAdjTable T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn encIntTable T3 S3) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { fuel := x0 x, root := x1 x, adj := x2 x, cost := x3 x }) encIn encTableAuxInput (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))

Encoding of TableAuxInput with unary fuel and root and binary integer costs.

theorem Cslib.Algorithms.Lean.Arborescence.encTableAuxInput_root_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableAuxInput} :

Intermediate workspace record for one contraction round (contractFromParent).

theorem Cslib.Algorithms.Lean.Arborescence.encContractWork_mk_deg :
Turing.MultiTapeTM.ComputableInDegree (fun (p : ContractState × List ℕ × ℕ × List Bool × List ℤ × List (Option ℕ) × List (Option ℕ)) => { state := p.1, parent := p.2.1, rep := p.2.2.1, inCycle := p.2.2.2.1, other := p.2.2.2.2.1, bestEntry := p.2.2.2.2.2.1, bestExit := p.2.2.2.2.2.2 }) encContractWorkFields encContractWork 1 1
theorem Cslib.Algorithms.Lean.Arborescence.encContractWork_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ContractState} {T0 S0 : γ → ℕ} {x1 : γ → List ℕ} {T1 S1 x2 T2 S2 : γ → ℕ} {x3 : γ → List Bool} {T3 S3 : γ → ℕ} {x4 : γ → List ℤ} {T4 S4 : γ → ℕ} {x5 : γ → List (Option ℕ)} {T5 S5 : γ → ℕ} {x6 : γ → List (Option ℕ)} {T6 S6 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encContractState T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encUnary) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encUnary T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBool) T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encIntBin) T4 S4) (h5 : Turing.MultiTapeTM.ComputableInO x5 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encUnary)) T5 S5) (h6 : Turing.MultiTapeTM.ComputableInO x6 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encUnary)) T6 S6) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { state := x0 x, parent := x1 x, rep := x2 x, inCycle := x3 x, other := x4 x, bestEntry := x5 x, bestExit := x6 x }) encIn encContractWork (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + (T4 x + (T5 x + T6 x)))))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + (S4 x + (S5 x + S6 x)))))
theorem Cslib.Algorithms.Lean.Arborescence.encContractWork_rep_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractWork} :
theorem Cslib.Algorithms.Lean.Arborescence.encContractWork_state_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ContractWork} :

Encoding of ContractWork for assembling step certificates without nested pair projections.

Table semantics and decision problems #

Read entry (u, w) of a Boolean adjacency table, defaulting out-of-bounds to false.

Read (u, w) entry of an integer cost table, defaulting out-of-bounds entries to 0.

Integer arc-cost function on Fin n extracted from costAt c.

Decision language for minimum-cost spanning in-arborescence (arcCost T ≤ threshold).

Decision language for minimum-cost spanning out-arborescence (arcCost T ≤ threshold).

Decision language for maximum-weight branching (threshold ≤ arcCost B).

List-based Chu–Liu/Edmonds operations #

def Cslib.Algorithms.Lean.Arborescence.argMinStep (pred : ℕ → Bool) (key : ℕ → ℤ) (acc : Option ℕ) (j : ℕ) :

Single step in scanning List.range n for the first index satisfying pred with minimum key.

First index in List.range n satisfying pred with minimum key.

Select cheapest valid incoming parent for each v ≠ r (some r at v = r), returning none when some v ≠ r has no valid candidate arc.

Follow parent table f from x, defaulting out-of-bounds lookups to 0.

Test whether x reaches itself within n steps of followParent f (in 1 .. n steps).

Find the first vertex x < n with x ≠ r lying on a cycle of followParent f.

Boolean mask of vertices y < n in the n-step orbit of x0 under followParent f.

Subtraction-free sum ∑ y ∈ C \ {x}, c[y, f[y]] for x ∈ C, and 0 outside C.

Best cycle vertex y ∈ C maximizing cheapness of u → y for each u < n.

Best exit vertex x ∈ C minimizing c[x, w] + otherCycleCost[x] for each w < n.

def Cslib.Algorithms.Lean.Arborescence.contractAdjList (n : ℕ) (inCycle : List Bool) (a : List (List Bool)) (bEntry bExit : List (Option ℕ)) (x0 r : ℕ) :

Contracted n × n adjacency table.

def Cslib.Algorithms.Lean.Arborescence.contractCostList (n : ℕ) (inCycle : List Bool) (c : List (List ℤ)) (other : List ℤ) (bEntry bExit : List (Option ℕ)) (x0 : ℕ) :

Contracted n × n subtraction-free integer cost table.

Expand a contracted parent list q using one saved ContractLevel.

Perform one cycle-contraction step given selected parent table f and cycle witness x0.

Perform one step of the iterative forward contraction pass.

Iterative list-table Chu–Liu/Edmonds solver running fuel forward steps followed by stack expansion.

Normalize inst.root to a unary-bounded index (0 when out of bounds).

Solve minimum-cost spanning in-arborescence for inst, returning none if root ≥ n or no spanning in-arborescence exists.

Transpose an n × n Boolean matrix (n = a.length).

Transpose an n × n integer matrix (c[w, u] for u, w < n).

Solve minimum-cost spanning out-arborescence by reversing all arcs and costs.

(n + 1) × (n + 1) super-root adjacency matrix with reversed real arcs (v < n, u < n: adj[u, v]) and fallback arcs v → n (v < n).

(n + 1) × (n + 1) super-root cost matrix with negated reversed weights -wt[w, u] and 0 on fallback arcs incident to vertex n.

Optimum branching parent map on 0, …, n - 1 computed via Edmonds's super-root reduction (p[v] = v denotes a root of a component tree).

Polynomial-time certificates for list operations #

Bit-length invariant and polynomial-time certificate for edmondsTableAuxList #

Polynomial-time certificates for solvers and deciders #

Correctness equivalence and P membership #