Rational hitting lists: binary addition #
Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a.
Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Computability/RationalHitting/BinaryAddition.lean
Imports, namespaces, module visibility, documentation, and formatting are adapted for complexitylib. The source theorem statements and mathematical arguments are retained.
Grade-school addition, scanning the second operand one bit at a time. The first operand is shifted after adding the incoming low bit.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.RationalHitting.StackLanguage.addWord x✝ [] = x✝
- Complexity.RationalHitting.StackLanguage.addWord x✝ (false :: b) = x✝.headD false :: Complexity.RationalHitting.StackLanguage.addWord x✝.tail b
Instances For
Emits one least-significant bit, supplying zero for an exhausted operand.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Output invariant for the single pass: a reversed low part is on out.
Equations
Instances For
Consume one addend bit, propagating its contribution to the accumulator.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Repeat the addition step until the addend stack is empty.
Equations
- Complexity.RationalHitting.StackLanguage.addLoop a b out tmp flag = Complexity.RationalHitting.StackLanguage.Program.loop b (Complexity.RationalHitting.StackLanguage.addBody a b out tmp flag)
Instances For
Destructive binary addition. The second operand and all scratch words are cleared; the first register holds the exact sum.
Equations
- One or more equations did not get rendered due to their size.