Documentation

Examples.Language.Splay.Amortized

Summing measured splay-access bounds #

This module combines rotation certificates with an externally justified bound steps ≤ K * (rotations + 1). The latter premise must be supplied by a theorem about the actual implementation's execution, not by pricing this mathematical tree relation. The generic potential-sum theorem then accounts for all accesses.

Initial potential is charged explicitly; final potential can be retained or discarded using its nonnegativity. No theorem here claims logarithmic worst-case time for an individual access. The additive terms cover empty trees and empty sequences without a positivity restriction on the node count or sequence length.

theorem Complexity.Language.Examples.Splay.sum_steps_add_potential_le {α : Type u_1} {trees focus : ℕ → Tree α} {rotations steps : ℕ → ℕ} {m K : ℕ} (traces : ∀ i < m, SplayTrace (focus i) (trees i) (trees (i + 1)) (rotations i)) (costs : ∀ i < m, steps i ≤ K * (rotations i + 1)) :
↑(∑ i ∈ Finset.range m, steps i) + ↑K * potential (trees m) ≤ ↑K * (↑m * (3 * Real.logb 2 ↑((trees 0).numNodes + 1) + 2) + potential (trees 0))

Sum supplied implementation costs and retain the final scaled potential.

theorem Complexity.Language.Examples.Splay.sum_steps_le {α : Type u_1} {trees focus : ℕ → Tree α} {rotations steps : ℕ → ℕ} {m K : ℕ} (traces : ∀ i < m, SplayTrace (focus i) (trees i) (trees (i + 1)) (rotations i)) (costs : ∀ i < m, steps i ≤ K * (rotations i + 1)) :
↑(∑ i ∈ Finset.range m, steps i) ≤ ↑K * (↑m * (3 * Real.logb 2 ↑((trees 0).numNodes + 1) + 2) + potential (trees 0))

Discard nonnegative final credit while retaining the actual initial potential.

theorem Complexity.Language.Examples.Splay.sum_steps_le_log {α : Type u_1} {trees focus : ℕ → Tree α} {rotations steps : ℕ → ℕ} {m K : ℕ} (traces : ∀ i < m, SplayTrace (focus i) (trees i) (trees (i + 1)) (rotations i)) (costs : ∀ i < m, steps i ≤ K * (rotations i + 1)) :
↑(∑ i ∈ Finset.range m, steps i) ≤ ↑K * (↑m * (3 * Real.logb 2 ↑((trees 0).numNodes + 1) + 2) + ↑(trees 0).numNodes * Real.logb 2 ↑((trees 0).numNodes + 1))

A bound uniform over all initial shapes, including their initial credit.