Counting nonzero binary blocks: correctness and total time bound
ProvedTwoAgentSched.TotalTotal.CountPositive.correct_and_totalbinary-encodingcomplexity-theorystack-programtwo-agent-scheduling
The positive-block counter has two properties.
- On the canonical encoding of a finite list of natural weights, with an initial success marker, it consumes all blocks and adds one unary count marker for each nonzero weight. It records two success markers per parsed block and halts in at most source steps, where is the encoded input.
- For every symbol input and every initial status and count stack, including malformed or truncated input, it terminates within source steps.
The counter supplies the number of positive weights used by the no-sort ordered PARTITION gadget. The second clause establishes termination only; the complete reduction still must reject malformed words and actually remove zero weights.
Preamble
import Mathlib import Definitions.Def_TwoAgentSched_TotalTotal_CountPositive
Formal statement
namespace TwoAgentSched.TotalTotal.CountPositive
open CookPvsNP ProjSchedTW.Complexity
theorem correct_and_total :
(∀ (xs : List ℕ) (status count : List BSym), status.head? = some .one →
∃ steps : ℕ,
countPositive.Exec (store4 (encNats xs) [] status count)
(store4 [] [] (List.replicate (2 * xs.length) .one ++ status)
(List.replicate (xs.filter (fun m => m ≠ 0)).length .one ++ count)) steps ∧
steps ≤ 14 * (encNats xs).length + 1) ∧
(∀ input status count : List BSym, ∃ (out : Fin 4 → List BSym) (steps : ℕ),
countPositive.Exec (store4 input [] status count) out steps ∧
steps ≤ 10 * (input.length + 1) ^ 2) := by sorry
end TwoAgentSched.TotalTotal.CountPositiveSource
Supporting implementation for Agnetis, Mirchandani, Pacciarelli and Pacifici, Scheduling Problems with Two Competing Agents, Operations Research 52(2), 2004, Theorem 9.2, pp. 237–238. This counter and its bounds are additional formalization results, not claims of the paper.