Parsing and comparing two canonical binary naturals takes linear stack time
ProvedTwoAgentSched.TotalTotal.ParseCompare.correct_and_totalbinary-encodingcomplexity-theorystack-programtwo-agent-scheduling
The five-stack parser/comparator has two properties.
- Given canonical natural-number codes followed by any suffix , it consumes the two blocks, leaves unread, and puts a less marker at the top of its result stack exactly when . It takes at most
source steps. 2. On every input word , including malformed or truncated codes, it terminates within source steps.
This is a reusable comparison component for a binary scheduling reduction. The second statement establishes termination only; it does not assert that the component rejects malformed input or that a complete sorting transducer has been built.
Preamble
import Mathlib import Definitions.Def_TwoAgentSched_TotalTotal_ParseCompare
Formal statement
namespace TwoAgentSched.TotalTotal.ParseCompare
open CookPvsNP ProjSchedTW.Complexity
theorem correct_and_total :
(∀ (m n : ℕ) (tail : List BSym),
∃ (steps : ℕ) (left right result : List BSym),
steps ≤ 3 * m.bits.length + 3 * n.bits.length +
3 * min m.bits.length n.bits.length + 21 ∧
parseCompare.Exec (store5 (encNat m ++ (encNat n ++ tail)) [] [] [] [.sep])
(store5 tail left right [.one, .one, .one, .one] result) steps ∧
(result.head? = some .zero ↔ m < n)) ∧
(∀ input : List BSym, ∃ (out : Fin 5 → List BSym) (steps : ℕ),
parseCompare.Exec (store5 input [] [] [] [.sep]) out steps ∧
steps ≤ 9 * input.length + 21) := by sorry
end TwoAgentSched.TotalTotal.ParseCompareSource
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 stack-program composition and its bounds are auxiliary formalization results, not statements of the paper.