Polynomial-time prefix scans #
First-match indices and taking or dropping an initial segment are polynomial-time, including when the predicate captures the input. The first-match rule is extracted from the native edge-CSP walk API; the prefix rule also serves its ancestry construction.
theorem Turing.MultiTapeTM.ComputableInPolyTime.findIdxWithInput {α β : Type} {enc : α ↪ List Bool} {encB : β ↪ List Bool} {xs : α → List β} {pred : α → β → Bool} (hx : ComputableInPolyTime xs enc (encList encB)) (hp : ComputableInPolyTime (fun (p : α × β) => pred p.1 p.2) (encPair enc encB) encBool) :
Find the first matching position, in unary; if there is none, return the list length.
theorem Turing.MultiTapeTM.ComputableInPolyTime.takeWhileWithInput {α β : Type} {enc : α ↪ List Bool} {encB : β ↪ List Bool} {xs : α → List β} {pred : α → β → Bool} (hx : ComputableInPolyTime xs enc (encList encB)) (hp : ComputableInPolyTime (fun (p : α × β) => pred p.1 p.2) (encPair enc encB) encBool) :
Take the maximal prefix passing an input-dependent polynomial-time predicate.
theorem Turing.MultiTapeTM.ComputableInPolyTime.dropWhileWithInput {α β : Type} {enc : α ↪ List Bool} {encB : β ↪ List Bool} {xs : α → List β} {pred : α → β → Bool} (hx : ComputableInPolyTime xs enc (encList encB)) (hp : ComputableInPolyTime (fun (p : α × β) => pred p.1 p.2) (encPair enc encB) encBool) :
Drop the maximal prefix passing an input-dependent polynomial-time predicate.