Rational hitting lists: binary division #
Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a.
Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Computability/RationalHitting/BinaryDivision.lean
Imports, namespaces, module visibility, documentation, and formatting are adapted for complexitylib. The source theorem statements and mathematical arguments are retained.
Subtract the next pair of bits and update the borrow flag.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Repeat subtraction while the control flag remains set.
Equations
Instances For
Subtract and compare, destructively. Output register 2 has the little-endian fixed-width modular difference; singleton register 3 is exactly the comparison bit (true iff the first number was smaller).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Long division, scanning the original numerator most-significant-bit first. The quotient and remainder registers remain ordinary little-endian words.
Equations
Instances For
Rename every register occurring in a finite stack program.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.RationalHitting.StackLanguage.Program.rename f Complexity.RationalHitting.StackLanguage.Program.skip = Complexity.RationalHitting.StackLanguage.Program.skip
- Complexity.RationalHitting.StackLanguage.Program.rename f (Complexity.RationalHitting.StackLanguage.Program.push k b) = Complexity.RationalHitting.StackLanguage.Program.push (f k) b
- Complexity.RationalHitting.StackLanguage.Program.rename f (Complexity.RationalHitting.StackLanguage.Program.drop k) = Complexity.RationalHitting.StackLanguage.Program.drop (f k)
- Complexity.RationalHitting.StackLanguage.Program.rename f (Complexity.RationalHitting.StackLanguage.Program.transfer a b) = Complexity.RationalHitting.StackLanguage.Program.transfer (f a) (f b)
Instances For
Uniform register allocation: renaming injectively never changes time and preserves every register outside its finite image.