Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Nat.Max

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 #

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_min' {α : Type} {input : α ↪ List Bool} {left right : α → ℕ} (hleft : ComputableInPolyTime left input encUnary) (hright : ComputableInPolyTime right input encUnary) :
ComputableInPolyTime (fun (a : α) => min (left a) (right a)) 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) :
ComputableInPolyTime (fun (a : α) => max (left a) (right a)) 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.