Documentation

Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive

Direct-unrolling generator primitives #

Executable fixed-work helpers for recent-wire raw gates and numeric state, head, and cell configuration-wire references.

Fixed-offset preparation by copy and repeated positive predecessor is sound on its explicit routine domain.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.prepareRecentReference_spaceBoundByWidth (reference : Fin WorkCount) (offset : ) {initialSpace : } {values : BinaryValues WorkCount} {width : } (havailable : ∀ (inputLength : ), values inputLength Work.available width inputLength) (hreference : ∀ (inputLength : ), values inputLength reference width inputLength) (hoffset : ∀ (inputLength : ), offset values inputLength Work.available) :
(prepareRecentReference reference offset).SpaceBoundByWidthAt initialSpace values width

Fixed-offset recent-reference preparation has a pointwise width certificate when the source, old destination, and requested offset fit the shared width.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.prepareRecentReference_requires (reference : Fin WorkCount) (offset : ) (values : BinaryValues WorkCount) (havailableReference : Work.available reference) (havailableCounter : Work.available Work.copyCounter) (hreferenceCounter : reference Work.copyCounter) :
(prepareRecentReference reference offset).requires values values Work.copyCounter = 0 offset values Work.available

The recent-reference domain is exactly a zero copy counter and a valid offset, once the three framed-copy indices are known to be distinct.

@[simp]

Exact fixed-offset reference value.

@[simp]

Reference preparation emits no circuit-code bits.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitRecentGate_sound (op : AndOrOp) (negated₀ negated₁ : Bool) (offset₀ offset₁ : ) :
(emitRecentGate op negated₀ negated₁ offset₀ offset₁).Sound

A raw gate from two recent-wire offsets is sound.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitRecentGate_spaceBoundByWidth (op : AndOrOp) (negated₀ negated₁ : Bool) (offset₀ offset₁ : ) {initialSpace : } {values : BinaryValues WorkCount} {width : } (havailable : ∀ (inputLength : ), values inputLength Work.available width inputLength) (hreference₀ : ∀ (inputLength : ), values inputLength Work.reference₀ width inputLength) (hreference₁ : ∀ (inputLength : ), values inputLength Work.reference₁ width inputLength) (hoffset₀ : ∀ (inputLength : ), offset₀ values inputLength Work.available) (hoffset₁ : ∀ (inputLength : ), offset₁ values inputLength Work.available) :
(emitRecentGate op negated₀ negated₁ offset₀ offset₁).SpaceBoundByWidthAt initialSpace values width

A raw gate from two fixed recent-wire offsets has a pointwise width certificate when the frontier, old references, and offsets fit the shared width.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitRecentGate_requires (op : AndOrOp) (negated₀ negated₁ : Bool) (offset₀ offset₁ : ) (values : BinaryValues WorkCount) :
(emitRecentGate op negated₀ negated₁ offset₀ offset₁).requires values values Work.copyCounter = 0 offset₀ values Work.available offset₁ values Work.available values Work.emitCounter = 0

Exact dynamic domain for recent-wire gate emission.

@[simp]
theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitRecentGate_effect (op : AndOrOp) (negated₀ negated₁ : Bool) (offset₀ offset₁ : ) (values : BinaryValues WorkCount) :
(emitRecentGate op negated₀ negated₁ offset₀ offset₁).effect values = Function.update (Function.update (Function.update values Work.available (values Work.available + 1)) Work.reference₀ 0) Work.reference₁ 0

Recent-wire gate emission advances available once and clears both reference tapes.

@[simp]
theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitRecentGate_emitted (op : AndOrOp) (negated₀ negated₁ : Bool) (offset₀ offset₁ : ) (values : BinaryValues WorkCount) :
(emitRecentGate op negated₀ negated₁ offset₀ offset₁).emitted values = { op := op, input₀ := values Work.available - offset₀, input₁ := values Work.available - offset₁, negated₀ := negated₀, negated₁ := negated₁ }.encode

Exact raw gate emitted from the two prepared recent-wire references.

Numeric state-reference preparation is sound.

State-reference preparation needs exactly its framed addition counter.

@[simp]

State-reference preparation emits nothing.

Numeric head-reference preparation is sound.

Zero framed arithmetic counters discharge the complete head-reference domain.

@[simp]

Exact numeric head-wire reference, with its arithmetic temporary cleared.

@[simp]

Head-reference preparation emits nothing.

Numeric cell-reference preparation is sound.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.prepareCellReference_requires (stateCount tapeCount : ) (values : BinaryValues WorkCount) (hcopy : values Work.copyCounter = 0) (hadd : values Work.addCounter = 0) (hmultiply : values Work.multiplyCounter = 0) :
(prepareCellReference stateCount tapeCount).requires values

Zero copy, addition, and multiplication counters discharge the complete cell-reference domain.

@[simp]

Exact numeric cell-symbol wire reference, with all three arithmetic temporaries cleared.

@[simp]

Cell-reference preparation emits nothing.

Any sound preparation routine composes soundly with prepared-reference copy emission.

Prepared numeric state-reference emission is sound.

Prepared numeric head-reference emission is sound.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitCellReference_sound (stateCount tapeCount : ) (negated : Bool) :
(emitCellReference stateCount tapeCount negated).Sound

Prepared numeric cell-reference emission is sound.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitStateReference_spaceBoundByWidth (stateIndex : ) (negated : Bool) {initialSpace : } {values : BinaryValues WorkCount} {width : } (hvalues : ∀ (inputLength : ) (index : Fin WorkCount), values inputLength index width inputLength) (hcap : ∀ (inputLength : ), transitionStateRef (values inputLength Work.configBase) stateIndex width inputLength) :
(emitStateReference stateIndex negated).SpaceBoundByWidthAt initialSpace values width

State-reference emission has a pointwise width certificate when every incoming register and the resulting absolute reference fit the width.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitHeadReference_spaceBoundByWidth (stateCount : ) (negated : Bool) {initialSpace : } {values : BinaryValues WorkCount} {width : } (hvalues : ∀ (inputLength : ) (index : Fin WorkCount), values inputLength index width inputLength) (hcap : ∀ (inputLength : ), transitionHeadRef stateCount (values inputLength Work.horizon) (values inputLength Work.configBase) (values inputLength Work.tapeIndex) (values inputLength Work.position) + values inputLength Work.tapeIndex + values inputLength Work.horizon + 1 width inputLength) :
(emitHeadReference stateCount negated).SpaceBoundByWidthAt initialSpace values width

Head-reference emission has a pointwise width certificate under one envelope covering all arithmetic intermediates.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitCellReference_spaceBoundByWidth (stateCount tapeCount : ) (negated : Bool) {initialSpace : } {values : BinaryValues WorkCount} {width : } (hvalues : ∀ (inputLength : ) (index : Fin WorkCount), values inputLength index width inputLength) (hcap : ∀ (inputLength : ), transitionCellRef stateCount tapeCount (values inputLength Work.horizon) (values inputLength Work.configBase) (values inputLength Work.tapeIndex) (values inputLength Work.position) (values inputLength Work.symbolIndex) + (values inputLength Work.tapeIndex * (values inputLength Work.horizon + 2) + values inputLength Work.position) + (values inputLength Work.horizon + 2) + tapeCount + values inputLength Work.tapeIndex + 4 width inputLength) :
(emitCellReference stateCount tapeCount negated).SpaceBoundByWidthAt initialSpace values width

Cell-reference emission has a pointwise width certificate under one envelope covering its base, offset, and final-reference arithmetic.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitStateReference_requires (stateIndex : ) (negated : Bool) (values : BinaryValues WorkCount) (hadd : values Work.addCounter = 0) (hemit : values Work.emitCounter = 0) :
(emitStateReference stateIndex negated).requires values

Zero addition and emission counters discharge state-reference emission.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitHeadReference_requires (stateCount : ) (negated : Bool) (values : BinaryValues WorkCount) (hadd : values Work.addCounter = 0) (hmultiply : values Work.multiplyCounter = 0) (hemit : values Work.emitCounter = 0) :
(emitHeadReference stateCount negated).requires values

Zero arithmetic and emission counters discharge head-reference emission.

theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitCellReference_requires (stateCount tapeCount : ) (negated : Bool) (values : BinaryValues WorkCount) (hcopy : values Work.copyCounter = 0) (hadd : values Work.addCounter = 0) (hmultiply : values Work.multiplyCounter = 0) (hemit : values Work.emitCounter = 0) :
(emitCellReference stateCount tapeCount negated).requires values

Zero arithmetic, copy, and emission counters discharge cell-reference emission.

@[simp]

State-reference emission advances available and clears the reference.

@[simp]

Head-reference emission advances available and clears both scratches.

@[simp]

Cell-reference emission advances available and clears all four reference/arithmetic scratch tapes.

@[simp]

Exact state-wire copy gate emitted by the executable helper.

@[simp]

Exact head-wire copy gate emitted by the executable helper.

@[simp]
theorem Complexity.CircuitUnrolling.Serializer.DirectGenerator.emitCellReference_emitted (stateCount tapeCount : ) (negated : Bool) (values : BinaryValues WorkCount) :
(emitCellReference stateCount tapeCount negated).emitted values = (CircuitCode.RawGate.copy (transitionCellRef stateCount tapeCount (values Work.horizon) (values Work.configBase) (values Work.tapeIndex) (values Work.position) (values Work.symbolIndex)) negated).encode

Exact cell-symbol wire copy gate emitted by the executable helper.