Abstract decreasing-argument recursive specifications
DefinitionCallCountPOPBR_Supplement_DecSpecp2o-gran-per-chapterp2o-plan-paperp2o-v1recursive-algorithmstheoretical-computer-science
An abstract decreasing-argument recursive specification assigns to every a finite ordered list of immediate calls , each with . The list may repeat an argument, and no computability or branching bound is imposed.
The associated invocation count includes the root and is defined recursively by
Since no natural number is below zero, is automatically a base case.
Definition code
import Mathlib
set_option autoImplicit false
namespace CallCountPOPBR.Supplement
/-- **An abstract decreasing-argument recursive specification** (§5.1). Swain, *Recursive Call-Count Sequences: Structural Realisability, Periodic Branching, and
Partial-Observation Reconstruction*, STOC 2027 submission (manuscript sha256 79135884…), §5.1, p.9:
"Consider the model in which R(0) is a base case and each invocation R(n) may call R(k) only for
k < n. A rule may make repeated calls to the same k."
`calls n` is the list of immediate calls `R(k)` made by `R(n)` (repetitions allowed); every called
argument is smaller than `n`.
**Formalization Note.** `calls 0 = []` (R(0) is a base case) follows from `dec`. No bound is placed
on the number of calls (unrestricted branching); bounded branching is the extra condition
`(calls n).length ≤ b`. The specification is an arbitrary function, not necessarily computable
(the paper's "abstract" specification); effectivity is the extra condition `Computable calls`. -/
structure DecSpec where
/-- The immediate calls made by `R(n)`. -/
calls : ℕ → List ℕ
/-- Every call is to a strictly smaller argument. -/
dec : ∀ n, ∀ k ∈ calls n, k < n
/-- **The call count `c_n` of a specification** (§5, p.9: "c_n = |V(T_n)|", the number of
invocations on input `n`, root counted): `c_n = 1 + ∑_{k ∈ calls n} c_k`. -/
def DecSpec.count (s : DecSpec) (n : ℕ) : ℕ :=
1 + ((s.calls n).attach.map (fun k => s.count k.1)).sum
termination_by n
decreasing_by exact s.dec n k.1 k.2
end CallCountPOPBR.Supplement
Source
Swain, Recursive Call-Count Sequences: Structural Realisability, Periodic Branching, and Partial-Observation Reconstruction, STOC 2027 submission (manuscript sha256 79135884…), Section 5.1, p.9