Documentation

Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic

Arithmetic leaves for proof-carrying binary routines #

This module exposes sound proof-carrying adapters for canonical binary arithmetic, fixed-polynomial evaluation, natural-code emission, and raw-gate emission. Each theorem connects the adapter's pure value effect, exact emitted word, time bound, and all-prefix space bound to its concrete Turing machine.

Main results #

theorem Complexity.BinaryRoutine.clear_sound {n : } (idx : Fin n) :
(clear idx).Sound

Clearing one canonical binary value is a sound routine leaf.

theorem Complexity.BinaryRoutine.addConst_sound {n : } (idx : Fin n) (constant : ) :
(addConst idx constant).Sound

Adding a hardwired natural to one canonical value is sound.

theorem Complexity.BinaryRoutine.set_sound {n : } (idx : Fin n) (value : ) :
(set idx value).Sound

Replacing one canonical binary value by a hardwired natural is sound.

theorem Complexity.BinaryRoutine.add_sound {n : } (srcIdx dstIdx counterIdx : Fin n) :
(add srcIdx dstIdx counterIdx).Sound

Preserved-source binary addition is sound on its explicit distinct-index and zero-counter domain.

theorem Complexity.BinaryRoutine.mulAdd_sound {n : } (leftIdx rightIdx accIdx mulCounterIdx addCounterIdx : Fin n) :
(mulAdd leftIdx rightIdx accIdx mulCounterIdx addCounterIdx).Sound

Binary multiply-add is sound on its explicit distinct-index and zero-counter domain.

theorem Complexity.BinaryRoutine.evalPolynomial_sound {n : } (inputIdx resultIdx scratchIdx mulCounterIdx addCounterIdx : Fin n) (p : Polynomial ) :
(evalPolynomial inputIdx resultIdx scratchIdx mulCounterIdx addCounterIdx p).Sound

Evaluation of a fixed natural polynomial is sound on its explicit distinct-index and zero-scratch domain.

theorem Complexity.BinaryRoutine.emitNatCode_sound {n : } (counterIdx valueIdx : Fin n) :
(emitNatCode counterIdx valueIdx).Sound

Terminated-unary natural-code emission is sound, preserves every pure value, and restores its zero scratch counter.

theorem Complexity.BinaryRoutine.emitRawGate_sound {n : } (op : AndOrOp) (negated₀ negated₁ : Bool) (emitCounterIdx input₀Idx input₁Idx : Fin n) :
(emitRawGate op negated₀ negated₁ emitCounterIdx input₀Idx input₁Idx).Sound

Raw-gate emission is sound, preserves every pure value, and emits exactly the encoded gate assembled from its two referenced values.