Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Unpadded binary stack addition: exact execution and arithmetic correctness

Proved
TwoAgentSched.TotalTotal.BinaryAdder.adderFullLoop_correct_and_cost

by kmehltretter82 · Nov 1, 2026 · Mathlib 0df444a (Lean v4.33.1)

binary-encodingcomplexity-theorystack-programtwo-agent-scheduling

Let aaa and bbb be finite little-endian Boolean words, possibly of different lengths, and let ccc be an input carry bit. Write L=max⁡(∣a∣,∣b∣)L=\max(|a|,|b|)L=max(∣a∣,∣b∣). The unpadded finite-stack adder treats an absent input digit as zero and must satisfy both claims below.

  1. It consumes both input stacks in exactly 3L+13L+13L+1 source-program steps, leaves the emitted low sum bits in reverse order on the output stack, and leaves the final carry on top of the carry stack.
  2. If sss denotes the little-endian low output word and coutc_{\mathrm{out}}cout​ the final carry, then
val⁡(a)+val⁡(b)+c=val⁡(s)+2Lcout.\operatorname{val}(a)+\operatorname{val}(b)+c =\operatorname{val}(s)+2^L c_{\mathrm{out}}.val(a)+val(b)+c=val(s)+2Lcout​.

This unequal-length adder is needed to accumulate the integer scheduling thresholds in the binary transducer. The already verified equal-length adder does not cover this case. This statement does not by itself prove a complete polynomial-time reduction.

Preamble
import Mathlib
import Definitions.Def_TwoAgentSched_TotalTotal_BinaryAdder
Formal statement
namespace TwoAgentSched.TotalTotal.BinaryAdder

open CookPvsNP ProjSchedTW.Complexity

theorem adderFullLoop_correct_and_cost (left right : List Bool) (c : Bool)
    (output carries : List BSym) :
    ∃ finalCarryTail : List BSym,
      adderFullLoop.Exec
        (store (left.map bitSym) (right.map bitSym) output (bitSym c :: carries))
        (store [] [] (((addFullAux left right c).1.map bitSym).reverse ++ output)
          (bitSym (addFullAux left right c).2 :: finalCarryTail))
        (3 * max left.length right.length + 1) ∧
      bitWordValue left + bitWordValue right + bitValue c =
        bitWordValue (addFullAux left right c).1 +
          2 ^ (max left.length right.length) * bitValue (addFullAux left right c).2 := by sorry

end TwoAgentSched.TotalTotal.BinaryAdder
Source
Supporting binary arithmetic for Agnetis, Mirchandani, Pacciarelli and Pacifici, Scheduling Problems with Two Competing Agents, Operations Research 52(2), 2004, Theorem 9.2, pp. 237–238. The concrete adder and exact execution bound are auxiliary formalization obligations, not claims from the paper.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me