TorchLean API

FloatLib.Kernels.FixedWord.RestoringSqrt.Compiler

Compiler certificates for restoring square root #

Four word accumulators implement the two-limb recurrence for every radicand, initial state, and digit count. The compiler substitutions preserve wrapping arithmetic outside the numeric bounds of RestoringSqrt.Proof.

theorem FloatLib.Numerics.FixedWord.RestoringSquareRoot.rootLoopWords_eq (radicand : UInt256) (steps : ) (root remainder : UInt128) :
rootLoopWords radicand steps root.hi root.lo remainder.hi remainder.lo = rootLoop radicand steps { root := root, remainder := remainder }

The accumulator and state recurrences agree without capacity or digit-count hypotheses.

theorem FloatLib.Numerics.FixedWord.RestoringSquareRoot.rootLoopImpl_eq_rootLoop (radicand : UInt256) (steps : ) (state : RestoringRootState UInt128) :
rootLoopImpl radicand steps state = rootLoop radicand steps state

The word implementation preserves every initial state and iteration count.

@[csimp]

Compile the state recurrence through its equal word-accumulator recurrence.

@[csimp]

Compile the zero-initialized loop through the same word accumulators.