Documentation

CslibFrontier.Computability.Probabilistic.Fold

Strict PPT list folds #

An ordinary List.foldlM is strict PPT when its list and initial accumulator are computable in polynomial time, its step is strict PPT, and every supported step increases the encoded accumulator by at most a constant. The oracle rule charges request construction and reply access, and preserves shared oracle state. The closed rule specializes it without introducing a second fold implementation.

Main results #

theorem Cslib.Probability.IsOraclePPTOn.foldlM_of_bounded_growth {Operation α Item Acc : Type} [DecidableEq Operation] {input : α ↪ List Bool} {element : Item ↪ List Bool} {output : Acc ↪ List Bool} (fallback : Item) {list : α → List Item} {initial : α → Acc} {step : Acc → Item → WordOracleComp Operation Acc} (hlist : Turing.MultiTapeTM.ComputableInPolyTime list input (Turing.MultiTapeTM.encList element)) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input output) (hstep : IsOraclePPTOn (Turing.MultiTapeTM.encPair output element) output (Function.uncurry step)) {growth : ℕ} (hgrowth : ∀ (acc : Acc) (item : Item), ∀ next ∈ OracleComp.support (step acc item), (output next).length ≤ (output acc).length + growth) :
IsOraclePPTOn input output fun (a : α) => List.foldlM step (initial a) (list a)

Fold a strict oracle PPT step over an efficiently computed list. Constant growth bounds every supported outcome, including under arbitrary external replies. The fallback only totalizes the internal loop step; an empty list never executes it.

theorem Cslib.Probability.IsPPTOn.foldlM_of_bounded_growth {α Item Acc : Type} {input : α ↪ List Bool} {element : Item ↪ List Bool} {output : Acc ↪ List Bool} (fallback : Item) {list : α → List Item} {initial : α → Acc} {step : Acc → Item → ProbComp Acc} (hlist : Turing.MultiTapeTM.ComputableInPolyTime list input (Turing.MultiTapeTM.encList element)) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input output) (hstep : IsPPTOn (Turing.MultiTapeTM.encPair output element) output (Function.uncurry step)) {growth : ℕ} (hgrowth : ∀ (acc : Acc) (item : Item), ∀ next ∈ (step acc item).eval.support, (output next).length ≤ (output acc).length + growth) :
IsPPTOn input output fun (a : α) => List.foldlM step (initial a) (list a)

Fold a strict PPT step over an efficiently computed list, with a constant bound on the encoded accumulator's growth on every supported execution.