The largest of polynomially many values #
An algorithm reading a formula has to know how many variables it mentions, which is the largest index any literal names. More generally: given a rule that computes a value for each index, take the largest over a bounded range.
Values are carried in unary, so "largest" is "longest", and the comparison is the length test already in the toolkit.
Main definitions #
Complexity.maxStep— one step of the running maximumComplexity.maxOver— the value it computes
Main results #
Complexity.maxStep_iterate— the loop takes the maximumComplexity.maxFn_mem_FP,Complexity.maxFn_eq— the packaged loopComplexity.le_maxOver,Complexity.maxOver_attained— it is the maximum
The largest of the first n values, as a length.
Equations
- Complexity.maxOver f z 0 = 0
- Complexity.maxOver f z n.succ = max (Complexity.maxOver f z n) (f (Complexity.pair z (List.replicate n true))).length