Documentation

CslibFrontier.Foundations.Data.BranchingVector

Search-tree recurrences and branching-vector bounds #

A branching algorithm that splits an instance of measure n into subproblems of measures at most n - a₁, …, n - a_b (with positive integer decreases aᵢ > 0) generates a search tree whose size is governed by the characteristic sum ∑ᵢ r ^ (-aᵢ) (Cslib.BranchingVector.charSum). Whenever 1 ≤ r satisfies charSum steps r ≤ 1, a recurrence satisfying T n ≤ max C (∑_{d ∈ steps, d ≤ n} T (n - d)) at every n, with C ≥ 0, satisfies T n ≤ C * r ^ n (Cslib.BranchingVector.BranchingRecurrence.le_mul_pow).

For explicit multi-way search trees (Cslib.BranchingVector.BranchingTree) where every non-leaf expansion decreases measure by at least some sublist of steps and 1 ≤ r satisfies charSum steps r ≤ 1:

Closed-form branching factors are supplied for binary splits [1, 1] (r = 2), Fibonacci splits [1, 2] (goldenBranchFactor = (1 + √5) / 2), and k-clause prefix splits [1, 2, …, k] (prefixBranchFactor k = 2 - (1 / 2) ^ k < 2 for k ≥ 1).

Main definitions #

Main results #

References #

Characteristic sums #

noncomputable def Cslib.BranchingVector.charSum (steps : List ℕ) (r : ℝ) :

Characteristic sum ∑_{d ∈ steps} r ^ (-(d : ℝ)) of a branching vector steps at base r.

@[simp]
theorem Cslib.BranchingVector.charSum_cons (d : ℕ) (steps : List ℕ) (r : ℝ) :
charSum (d :: steps) r = r ^ (-↑d) + charSum steps r
@[simp]
theorem Cslib.BranchingVector.charSum_append (s₁ s₂ : List ℕ) (r : ℝ) :
charSum (s₁ ++ s₂) r = charSum s₁ r + charSum s₂ r
theorem Cslib.BranchingVector.rpow_neg_natCast_eq_inv_pow {r : ℝ} (hr : 0 ≤ r) (d : ℕ) :
r ^ (-↑d) = r⁻¹ ^ d

For r ≥ 0, r ^ (-(d : ℝ)) agrees with (r⁻¹) ^ d.

theorem Cslib.BranchingVector.charSum_eq_sum_inv_pow (steps : List ℕ) {r : ℝ} (hr : 0 ≤ r) :
charSum steps r = (List.map (fun (d : ℕ) => r⁻¹ ^ d) steps).sum

For r ≥ 0, charSum steps r rewrites as the elementary inverse-power sum ∑ (r⁻¹) ^ d.

theorem Cslib.BranchingVector.charSum_nonneg (steps : List ℕ) {r : ℝ} (hr : 0 ≤ r) :
0 ≤ charSum steps r

Characteristic sums are nonnegative at nonnegative bases.

theorem Cslib.BranchingVector.charSum_sublist {s₁ s₂ : List ℕ} (hsub : s₁.Sublist s₂) {r : ℝ} (hr : 0 ≤ r) :
charSum s₁ r ≤ charSum s₂ r

Taking a sublist of branches can only decrease the characteristic sum for r ≥ 0.

theorem Cslib.BranchingVector.charSum_filter_le (p : ℕ → Bool) (steps : List ℕ) {r : ℝ} (hr : 0 ≤ r) :
charSum (List.filter p steps) r ≤ charSum steps r

Filtering a branching vector does not increase its characteristic sum for r ≥ 0.

theorem Cslib.BranchingVector.charSum_antitone (steps : List ℕ) {r₁ r₂ : ℝ} (hr₁ : 0 < r₁) (hle : r₁ ≤ r₂) :
charSum steps r₂ ≤ charSum steps r₁

charSum steps is antitone on (0, ∞).

Generic branching-vector recurrence #

structure Cslib.BranchingVector.BranchingRecurrence (T : ℕ → ℝ) (steps : List ℕ) (C : ℝ) :

A recurrence inequality representing a tree of recursive calls where each call branching on a node of size n spawns subproblems of size n - d for d ∈ steps. The base cost is bounded by C.

  • base_nonneg : 0 ≤ C

    Nonnegativity of the base factor C.

  • steps_pos (d : ℕ) : d ∈ steps → 0 < d

    Every branching decrease is strictly positive.

  • step_le (n : ℕ) (S : ℕ → ℝ) : (∀ m < n, T m ≤ S m) → T n ≤ max C (List.map (fun (d : ℕ) => S (n - d)) (List.filter (fun (x : ℕ) => decide (x ≤ n)) steps)).sum

    Inductive step bound.

theorem Cslib.BranchingVector.BranchingRecurrence.of_step {T : ℕ → ℝ} {steps : List ℕ} {C : ℝ} (hC : 0 ≤ C) (hpos : ∀ d ∈ steps, 0 < d) (hstep : ∀ (n : ℕ), T n ≤ max C (List.map (fun (d : ℕ) => T (n - d)) (List.filter (fun (x : ℕ) => decide (x ≤ n)) steps)).sum) :

Build a BranchingRecurrence directly from the self-referential inequality T n ≤ max C (∑_{d ∈ steps, d ≤ n} T (n - d)) at every n.

theorem Cslib.BranchingVector.BranchingRecurrence.le_mul_pow {T : ℕ → ℝ} {steps : List ℕ} {C : ℝ} (hrec : BranchingRecurrence T steps C) {r : ℝ} (hr : 1 ≤ r) (hchar : charSum steps r ≤ 1) (n : ℕ) :
T n ≤ C * r ^ n

Generic branching-vector theorem. If 1 ≤ r satisfies charSum steps r ≤ 1, then every BranchingRecurrence T steps C satisfies T n ≤ C * r ^ n for all n.

theorem Cslib.BranchingVector.BranchingRecurrence.le_pow {T : ℕ → ℝ} {steps : List ℕ} (hrec : BranchingRecurrence T steps 1) {r : ℝ} (hr : 1 ≤ r) (hchar : charSum steps r ≤ 1) (n : ℕ) :
T n ≤ r ^ n

Unit-base specialization T n ≤ r ^ n when C = 1.

Terminating multi-way search trees with separate per-node work #

A terminating multi-way search tree on states σ with integer measure measure and positive step vector steps. Every non-leaf state s expands into children s whose measure drops dominate some sublist of steps.

  • isLeaf : σ → Bool

    Whether a state is a leaf of the search tree.

  • children : σ → List σ

    Child states generated when expanding an internal state.

  • measure : σ → ℕ

    Nonnegative complexity measure decreasing along every branch.

  • steps : List ℕ

    Nominal branching vector of positive measure decreases.

  • steps_pos (d : ℕ) : d ∈ self.steps → 0 < d

    Every entry of steps is strictly positive.

  • children_steps (s : σ) : self.isLeaf s = false → ∃ (steps' : List ℕ), steps'.Sublist self.steps ∧ List.Forall₂ (fun (child : σ) (d : ℕ) => self.measure child + d ≤ self.measure s) (self.children s) steps'

    Expanding a non-leaf state decreases measure by at least some sublist of steps.

theorem Cslib.BranchingVector.BranchingTree.measure_child_lt {σ : Type u_1} (T : BranchingTree σ) {s child : σ} (hleaf : T.isLeaf s = false) (hmem : child ∈ T.children s) :
T.measure child < T.measure s

Every child of a non-leaf state has strictly smaller measure.

@[irreducible]

Ordered list of leaves reached from s in the search tree T.

@[simp]
theorem Cslib.BranchingVector.BranchingTree.leaves_of_isLeaf {σ : Type u_1} (T : BranchingTree σ) {s : σ} (h : T.isLeaf s = true) :
T.leaves s = [s]
theorem Cslib.BranchingVector.BranchingTree.isLeaf_of_mem_leaves {σ : Type u_1} (T : BranchingTree σ) {s l : σ} (hl : l ∈ T.leaves s) :

Every state in T.leaves s is a leaf.

Number of leaves in the search tree rooted at s.

@[simp]
@[irreducible]

Total number of nodes (internal nodes plus leaves) in the search tree rooted at s.

@[simp]
@[irreducible]
def Cslib.BranchingVector.BranchingTree.workCost {σ : Type u_1} (T : BranchingTree σ) (nodeWork : σ → ℕ) (s : σ) :

Total work summed over all nodes of the search tree rooted at s for per-node cost nodeWork.

@[simp]
theorem Cslib.BranchingVector.BranchingTree.workCost_of_isLeaf {σ : Type u_1} (T : BranchingTree σ) (nodeWork : σ → ℕ) {s : σ} (h : T.isLeaf s = true) :
T.workCost nodeWork s = nodeWork s
theorem Cslib.BranchingVector.BranchingTree.workCost_of_not_isLeaf {σ : Type u_1} (T : BranchingTree σ) (nodeWork : σ → ℕ) {s : σ} (h : T.isLeaf s = false) :
T.workCost nodeWork s = nodeWork s + (List.map (T.workCost nodeWork) (T.children s)).sum
inductive Cslib.BranchingVector.BranchingTree.Reachable {σ : Type u_1} (T : BranchingTree σ) (s : σ) :
σ → Prop

Reachability of subtree states from s in T.

theorem Cslib.BranchingVector.BranchingTree.reachable_of_mem_leaves {σ : Type u_1} (T : BranchingTree σ) {s l : σ} (hl : l ∈ T.leaves s) :
T.Reachable s l

Every leaf in T.leaves s is reachable from s.

theorem Cslib.BranchingVector.BranchingTree.iff_exists_leaf {σ : Type u_1} (T : BranchingTree σ) {s : σ} {P : σ → Prop} (hstep : ∀ (u : σ), T.Reachable s u → T.isLeaf u = false → (P u ↔ ∃ c ∈ T.children u, P c)) :
P s ↔ ∃ l ∈ T.leaves s, P l

Whole-tree equivalence transport: if a property P is equivalent at every reachable internal state to holding on at least one child, then P s holds iff P holds at some leaf in T.leaves s.

theorem Cslib.BranchingVector.BranchingTree.sum_leaves_eq {σ : Type u_1} (T : BranchingTree σ) {s : σ} {w : σ → ℕ} (hadd : ∀ (u : σ), T.Reachable s u → T.isLeaf u = false → w u = (List.map w (T.children u)).sum) :
(List.map w (T.leaves s)).sum = w s

Additive weights conserved at every reachable internal expansion sum over T.leaves s to their root value w s.

theorem Cslib.BranchingVector.BranchingTree.le_sum_leaves {σ : Type u_1} (T : BranchingTree σ) {s : σ} {w : σ → ℕ} (hsub : ∀ (u : σ), T.Reachable s u → T.isLeaf u = false → w u ≤ (List.map w (T.children u)).sum) :
w s ≤ (List.map w (T.leaves s)).sum

Subadditive weights (w u ≤ ∑_{c ∈ children u} w c, as in covering rather than partitioning branching rules) are bounded above by their sum over T.leaves s.

theorem Cslib.BranchingVector.BranchingTree.leafCount_le_pow {σ : Type u_1} (T : BranchingTree σ) {r : ℝ} (hr : 1 ≤ r) (hchar : charSum T.steps r ≤ 1) (s : σ) :
↑(T.leafCount s) ≤ r ^ T.measure s

Search-tree leaf bound. If 1 ≤ r and charSum T.steps r ≤ 1, then the search tree rooted at s has at most r ^ T.measure s leaves.

theorem Cslib.BranchingVector.BranchingTree.nodeCount_le_mul_pow {σ : Type u_1} (T : BranchingTree σ) {r : ℝ} (hr : 1 ≤ r) (hchar : charSum T.steps r ≤ 1) (s : σ) :
↑(T.nodeCount s) ≤ (↑(T.measure s) + 1) * r ^ T.measure s

Search-tree node bound. If 1 ≤ r and charSum T.steps r ≤ 1, then the total number of nodes (internal and leaf) in the search tree rooted at s is at most (T.measure s + 1) * r ^ T.measure s.

theorem Cslib.BranchingVector.BranchingTree.workCost_le_mul_nodeCount {σ : Type u_1} (T : BranchingTree σ) {nodeWork : σ → ℕ} {W : ℕ} {s : σ} (hwork : ∀ (u : σ), T.Reachable s u → nodeWork u ≤ W) :
T.workCost nodeWork s ≤ W * T.nodeCount s

Separating per-node overhead. If nodeWork u ≤ W at every state reachable from s, then total tree work is at most W * T.nodeCount s.

theorem Cslib.BranchingVector.BranchingTree.workCost_le_mul_pow {σ : Type u_1} (T : BranchingTree σ) {nodeWork : σ → ℕ} {W : ℕ} {s : σ} (hwork : ∀ (u : σ), T.Reachable s u → nodeWork u ≤ W) {r : ℝ} (hr : 1 ≤ r) (hchar : charSum T.steps r ≤ 1) :
↑(T.workCost nodeWork s) ≤ ↑W * (↑(T.measure s) + 1) * r ^ T.measure s

Combined tree work bound. Per-node work ≤ W combined with charSum T.steps r ≤ 1 (1 ≤ r) bounds total tree work by W * (T.measure s + 1) * r ^ T.measure s.

Closed-form branching factors #

Binary [1, 1] branching has exact characteristic sum 1 at r = 2.

Golden-ratio Fibonacci branching factor (1 + √5) / 2 ≈ 1.6180 for [1, 2].

Fibonacci [1, 2] branching has exact characteristic sum 1 at goldenBranchFactor.

Prefix step vector [1, 2, …, k] arising from k-clause disjoint prefix branching.

Every entry of prefixSteps k is strictly positive.

prefixSteps b is a prefix (hence sublist) of prefixSteps k whenever b ≤ k.

Closed-form sub-2 branching factor 2 - (1 / 2) ^ k dominating prefixSteps k (k ≥ 1). For k = 1, 2, 3 this gives 3 / 2, 7 / 4, 15 / 8, all strictly below 2.

Closed-form k-clause branching bound. For every k ≥ 1, charSum (prefixSteps k) (prefixBranchFactor k) ≤ 1.