Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Terminal Fair-Bit Sampling

Abstract

Finite first-hit fair-bit executions return native legal words almost surely.

A word is a literal Boolean function on Fin h. The native scanner has fuel further consecutive true bits available; false resets fuel to maxTrue, and true decreases positive fuel. CompletionCount is the cardinality of this native completion layer. The original order k and tail length s correspond to maxTrue=k-1 and fuel=k-1-s. The output budget h and source cursor are separate.

A draw decodes consecutive h-bit blocks from one iid fair Boolean tape. It rejects integers outside the completion range and keeps the first accepted integer. Every retry advances the source cursor by h while preserving the output state. Acceptance emits one bit, advances past its block, and reduces the remaining output budget. The zero threshold is the count after a false bit.

Theorem 1.1 (Literal executions and consumed-source cylinders).

Proof. Machine-checked in Lean as D5/S0/Tower/DBonacci/TerminalSampling.terminal_sampling_execution_cylinders (✓ std3). ∎

Source. Repository-derived.

Commentary.

The finite Run relation and partial sample evaluator return the same word and final cursor. Returned words pass the native scanner, and agreement on the consumed source interval preserves the full result. A consumed interval of length L has fair mass 2^(-L).

In the formula, N denotes natural numbers, Words(h) is Fin h to Bool, C(m,f,h) is completionCount, and mu is fairTape. Legal and Illegal mean the native scanner returns true and false. Result fixes word and final cursor; Return existentially quantifies the final cursor. Draw fixes retry and accepted integer; AcceptedValue existentially quantifies retry. RejectedForever means draw is none. ZeroBranch is the union of draws whose integer is below C(m,m,h-1). Cylinder is traceCylinder. Replay quantifies every tape agreeing on [c,e), preserving sample’s full result. MeasurableSample uses the discrete Option codomain. SuccessfulLegalReturn is the event that some word and finite cursor are returned and that word is native legal. All rows of the displayed statement hold jointly.

Writing D for the completion count and Q=2^h, acceptance of a specified integer at retry t has mass ((Q-D)/Q)^t/Q. Summing the disjoint retry events gives each accepted integer mass 1/D. D is positive and at most Q by the native cardinality results. Infinite rejection has mass zero.

Every returned-word event is measurable. Illegal words have empty return events. A countable simultaneous acceptance event at all fixed states and cursors, followed by induction on h, proves whole termination almost surely. At h=0 the evaluator returns the unique empty word without drawing a branch. The denotation is noncomputable and partial; it supplies no deterministic uniform retry or fair-bit bound.

References