Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions research/current-flat-guide-lifecycle/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# A complete local flat-guide lifecycle

## Domain and machine

Let N and W be positive integers and L=N(2W+3). The caller supplies their
canonical positive binary encodings, least significant bit first, between
LEFT and RIGHT markers. Their heads start at the first bit. N is the
complete record count, including spectators. Its production from root
geometry, and the derivation of W, are outside this result.

There are seven distinct tapes: two preserved descriptors, reusable binary
work, unary N, unary W, an owned guide and an owned target. The three work
tapes start blank at their origins. The guide has an exact granted window
of L+2 cells. Its old cells can be arbitrary. The target has L arbitrary
payload cells between fixed LEFT and RIGHT guards. Guide and target heads
start at their origins. Exterior cells are borrowed and must be preserved.
No hidden old private tail is admitted by this contract.

The unchanged David Arias machine and counter are declared inputs. The
machine has seven symbols and six instruction forms: branch on a scanned
symbol, write, unit move, fixed goto, halt and reject. Only the external
interpreter stores head coordinates and resource statistics. The emitted
program cannot inspect them. Assembly accepts no runtime N or W. The
producer has 210 instructions; INIT and CLEAR each have 40; retirement has
16. All use the same seven physical tapes for every input size.

The current source guide is encoded by

| Source guide value | Tape symbol |
| --- | --- |
| left boundary | LEFT |
| right boundary | RIGHT |
| numeric zero cell | ZERO |
| real/imaginary separator | UNIT |
| end-of-record separator | MARK |
| represented blank cell | BLANK |

This map is injective on the current zero-template format. Interior BLANK
is a legitimate guide value, not an end marker. The two consumers are the
unchanged PR7663 reset graph restricted to these produced values and
lowered by this symbol map. They are not callbacks into the source simulator.

## Production and complete return

Install LEFT at each of the three work origins. Apply the retained binary
converter first to N and then to W, reusing its fully cleared binary work.
It emits unary N and W, preserves the binary descriptors and returns all
three participating heads to their first cells. The converter's canonical
decrement proof covers every positive integer, including powers of two.

Write LEFT at the guide origin. For each unary N mark, traverse unary W
twice. Write W numeric zero symbols, the first separator, another W zeros,
the second separator and one represented blank. Rewind W after each pass.
Advance the unary N head once per complete record. At its RIGHT marker,
write the guide's RIGHT marker. Rewind the guide to its origin.

Induction on records proves that after j outer iterations the complete
first j records have the required values and the output head is at their
successor cell. The inner unary loop proves the two width counts. No old
guide symbol controls production. Every old cell in the granted guide
window has been overwritten before its rewind begins. The only LEFT in
the resulting guide is its origin, so the rewind returns correctly even
when the old guide had false markers or interior blanks.

Erase both unary bodies, their RIGHT markers and their installed LEFT
markers. Erase the remaining binary-work LEFT marker. All three work
tapes are blank in every visited cell and their heads return to zero.
The descriptors keep their complete bytes and heads. The target is
untouched. The produced guide remains at head zero for its consumer.

## Actual source consumption and retirement

The finite INIT and CLEAR tables branch only on the produced guide. Their
outward pass writes exactly the L target payload cells. INIT writes the
scientific zero template, including both separators and represented blanks.
CLEAR writes physical blank. Both graphs return guide and target heads to
zero. The guide, target guards and exterior are unchanged. The source's
position induction applies to arbitrary old target payloads.

After consumers return the immutable guide at its origin, retirement
scans its body to RIGHT and blanks every cell it crosses. It erases RIGHT,
rewinds through the now-blank body to LEFT, and erases LEFT last. Thus the
entire granted guide window is blank and its head is zero. The left marker
is retained only until the return finishes. No backward scan tries to use
a marker that was already erased. Descriptors, target and other tapes
remain unchanged during guide retirement.

The composition is production, literal INIT, literal CLEAR and retirement.
Numerical work between the reset consumers is a separately charged service.
It must preserve the immutable guide and return its required heads. It is
not supplied by this theorem.

## Exact instruction ledger

Count every emitted instruction, including branches and fixed gotos. The
retained converter has exact cost

```text
c(x) = 24x - 7 popcount(x) + 15 bitlength(x) + 12 <= 44x.
```

Its proof uses sum from k=1 to x of v2(k)=x-popcount(x), so binary borrow
scans are charged. A retained rewind from head h costs exactly 3h.

One width pass emits W cells in 5W+1 instructions, then rewinds in 3W+3.
The two passes, three separator/blank writes and the outer advance cost
16W+17 per record. There is one final outer branch. Guide termination and
return cost 3L+5. Unary N cleanup costs 10N+11, including its initial
rewind; unary W cleanup costs 7W+8. Marker setup costs six, guide opening
costs two, binary-work cleanup costs two and the final halt costs one.
Consequently

```text
T_produce = c(N)+c(W)+22NW+36N+7W+36.
T_INIT = T_CLEAR = 9L+11.
T_retire = 7L+10.
T_lifecycle = c(N)+c(W)+72NW+111N+7W+68.
```

For a reset, the outward cell costs five instructions and a return cell
costs four. Start, turn, final boundary and halt add eleven. For retirement,
each forward erased cell costs four; the rewind costs 3L+3, and entry,
delimiter erase, origin erase, final goto and halt add seven.

The producer satisfies T_produce<=40L. After applying c(x)<=44x, the
difference is at least W(58N-51)+40N-36, which is positive for N,W>=1.
Retirement is at most 9L because L>=5. The two resets cost 18L+22.
Thus the complete lifecycle is at most 72L instructions. This is an
all-size count from the emitted paths, not an extrapolated timing result.
The smallest case takes 346 instructions for L=5. The complete N=512,W=1
view takes 106258 instructions for L=2560.

## Retained capacity

Include every cell between an origin and the furthest visited position,
even after the cell is blank. Write ell_N=bitlength(N), ell_W=bitlength(W).
The exact total over the seven tapes is

```text
2L + N + W + ell_N + ell_W + max(ell_N,ell_W) + 14 <= 7L.
```

The two full windows contribute 2L+4. The unary tapes contribute N+W+4.
Binary work contributes max(ell_N,ell_W)+2. Preserved descriptors contribute
ell_N+ell_W+4. Heads visit no negative position on valid inputs. Since
ell_x<=x, 2(N+W)<=L and L>=5, the displayed upper bound follows.

This is the visited capacity of one invocation on the stated windows.
If tapes already have reserved historical spans H_i, charge
sum_i max(H_i,s_i), where s_i are the seven current spans. Prior empty
storage is not released by this proof. Changing an owned guide or target
window requires a separate complete old-extent contract. Borrowed exterior
cells in the fixtures do not become free private storage.

## Evidence and limits

The complete tables are saved in TABLES.json and regenerated exactly.
Forty-two shapes exercise binary shrink boundaries, both components,
width 17 and complete current views. A separate dense interpreter executes
every phase and agrees on all cells, heads and instruction counts. The
source guide producer supplies an independent expected-format oracle.
The checker inspects full visited spans and all borrowed exterior cells.

Five actual instruction faults detect a wrong zero value, a skipped
represented-blank write, a premature RIGHT, a missing origin return and
an unerased guide LEFT. The retained binary converter also rejects a
redundant high zero. Rejection need not be atomic or restore dirty work;
the positive theorem assumes canonical descriptors and blank conversion
workspace. These controls are not a global malformed-input recognizer.

Root descriptor production, arbitrary historical-window reuse, numerical
children, native adapter movement, the actual recursive owner map, complete
compiler workspace and the whole physical tariff remain open here. The
delayed-cover root producer in PR6719 has a different consumer; this work
reuses its retained machine/counter and does not repeat that root theorem.
No framework assumption or multiplication theorem is discharged. There
is no new kappa or selected-frontier change.
128 changes: 128 additions & 0 deletions research/current-flat-guide-lifecycle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Produce, consume and retire the current flat guide

This package emits the current native flat guide from physical binary
record count N and signed component width W. The actual emitted guide
drives the retained INIT and CLEAR graphs, then is completely retired.
All seven heads return. No host-decoded dimension controls execution.
There is no new kappa or complete recursive allocator.

The source format and reset graph are from
[PR #7663](https://github.com/CrocSwap/integer-mult-bounds/pull/7663), exact
head `b81f40997de646de30749d367484d89e59fc3013`. The local selector in
[PR #7666](https://github.com/CrocSwap/integer-mult-bounds/pull/7666) starts
with a correct immutable guide. This result supplies that distinct local
producer/consumer connection. No code from PR7666 is imported.

[PROOF.md](PROOF.md) gives the all-size loop and cost arguments.
[TABLES.json](TABLES.json) contains every emitted instruction, and
[RESULT.json](RESULT.json) records the exact executions and controls.
[program.py](program.py) builds tables before runtime descriptors exist.
[verify.py](verify.py) checks them with two different interpreters.

## Exact contract and result

The preserved inputs are positive canonical binary N and W. The output
has N complete records of W real bits, a separator, W imaginary bits,
a separator and one represented blank. Put L=N(2W+3). For the current
native view N=R*2^(9f), including all spectators; this package does not
produce that root descriptor or derive the root width.

Three conversion work tapes start blank. The owned guide and target
windows may contain arbitrary old symbols. Every cell of the guide's
exact L+2-cell window is overwritten and later erased. INIT writes a
complete scientific-zero target, and CLEAR blanks its L payload cells
while preserving both guards. Borrowed exterior cells stay unchanged.

The producer has 210 literal instructions, INIT and CLEAR each have 40,
and guide retirement has 16. All use seven fixed tapes and the retained
seven-symbol alphabet. With
`c(x)=24x-7 popcount(x)+15 bitlength(x)+12`, the exact counts are:

| Phase | Instructions executed |
| --- | --- |
| Production | c(N)+c(W)+22NW+36N+7W+36 |
| Each reset | 9L+11 |
| Guide retirement | 7L+10 |
| Complete lifecycle | c(N)+c(W)+72NW+111N+7W+68 |

The complete lifecycle costs at most 72L instructions. Its exact visited
capacity, including cells that were erased, is
`2L+N+W+bitlength(N)+bitlength(W)+max(bitlength(N),bitlength(W))+14`,
which is at most 7L for the stated fresh windows. On reused tapes, each
prior reserved span remains charged through `max(old_span,current_span)`.
No erased backing is released for free.

## Evidence

Forty-two shapes cover binary shrink boundaries, widths 1,2,3,17 and
complete native views. Every phase agrees with a separate dense opcode
interpreter on all cells, heads and instruction counts. The complete
N=512,W=1 lifecycle takes exactly 106258 instructions and retains 5668
visited cells. The N=1024,W=3 case checks a second complete view.

Five literal instruction faults detect wrong zero output, skipped blank
writes on a dirty guide, a premature boundary, a missing head return and
incomplete guide retirement. A sixth control rejects a redundant high
zero in a binary input. Failure atomicity and full recognition of every
malformed global state are not claimed.

The unchanged source guide producer supplies the expected-format oracle.
The unchanged machine, assembler and binary-to-unary emitter come from
[PR #6719](https://github.com/CrocSwap/integer-mult-bounds/pull/6719)'s
retained source closure. The emitted program performs all loop control,
counter work, writes, head movement and cleanup on physical tapes.

## Reproduce

Use Python 3.12 and the standard library:

```sh
python3.12 -B scripts/research_package.py --package research/current-flat-guide-lifecycle
```

Normal and optimized isolated replay must print
`PASS_CURRENT_FLAT_GUIDE_LIFECYCLE` and
`PASS_REGISTERED_RESEARCH_PACKAGE`. No Git, network or solver is used by
scientific replay. Normal replay writes no files. The explicit `--write`
option creates initial receipts and refuses to replace existing ones.

## Limits

This result assumes distinct tapes, canonical binary descriptors, blank
conversion workspace and exact granted guide/target windows. A larger old
private tail needs its own complete-extent treatment. Numerical work
between reset calls is a separate service that must preserve the guide
and return the required heads.

Root descriptor production, adapter permutations, the actual compiled
owner map, numerical children, cross-depth workspace and common physical
pricing remain open. The source's full conditional application and the
selected multiplier were not replayed. All five framework assumptions
remain; the selected frontier is unchanged.

## Open next questions

Connect the output to one actual compiled owner map and charge guide
provisioning, storage and retirement at each occurrence. Use the earlier
root producer only after its different delayed-cover geometry has an
explicit consumer map. [TASK.json](TASK.json) records these boundaries.

## Source and credit

David Arias supplied the unchanged machine, assembler and counter, with
its exact counter proof. The [retained notice](../../research/delayed-cover-physical-batch-routing/NOTICE)
and file headers preserve that credit. thu-nmrc supplied the delayed-cover
physical/root package that retains those sources. This work does not
repeat its root or recursive shape theorem.

Ali Romman supplied the PR7663 guide/reset construction with substantial
OpenAI Codex assistance. CubeJerry supplied its selected primitive and
prior typed reset. [source/NOTICE](source/NOTICE) and the copied notices
preserve the native lineage. The copied word module supplies only helper
imports here; no native word is loaded or numerically executed.
[SOURCES.json](SOURCES.json) and [VENDORED.json](VENDORED.json) bind every
consumed source. Original files are unchanged.

Ali Romman directed this new emitted lifecycle, proof and verification
with substantial OpenAI Codex assistance. New work is Apache-2.0. The
canonical base is `e54523517d0f03e58352e647c403a5af3e525a57`.
Loading
Loading