Minimum and maximum of unary naturals in polynomial time #
Plain Turing.MultiTapeTM.ComputableInPolyTime certificates for binary min and max on unary
naturals, their shared-input composition rules unary_min' and unary_max', and the list fold
unary_foldl_max (a max fold over a framed list of unary naturals never exceeds its initial
value plus the length of the encoded list, so the polynomial-bounded fold applies).
Main results #
Turing.MultiTapeTM.ComputableInPolyTime.unary_min,Turing.MultiTapeTM.ComputableInPolyTime.unary_max: pairwiseminandmaxon unary naturals.Turing.MultiTapeTM.ComputableInPolyTime.unary_min',Turing.MultiTapeTM.ComputableInPolyTime.unary_max':minandmaxof two computed unary naturals with a shared input context.Turing.MultiTapeTM.ComputableInPolyTime.unary_foldl_max:l.foldl max initis polynomial-time, in unary.
theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_min' {α : Type} {input : α ↪ List Bool} {left right : α → ℕ} (hleft : ComputableInPolyTime left input encUnary) (hright : ComputableInPolyTime right input encUnary) :
Take the smaller of two computed unary naturals with the same full input context. Kept explicit
so Min.min search on encUnary does not branch against binary_min_unary'.
theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_max' {α : Type} {input : α ↪ List Bool} {left right : α → ℕ} (hleft : ComputableInPolyTime left input encUnary) (hright : ComputableInPolyTime right input encUnary) :
Take the larger of two computed unary naturals with the same full input context.
The maximum l.foldl max init of a list of unary naturals is polynomial-time, in unary.