Skip to content
Draft
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
413 changes: 413 additions & 0 deletions research/lean-paid-positioned-acquisition/ACCEPTANCE.json

Large diffs are not rendered by default.

463 changes: 463 additions & 0 deletions research/lean-paid-positioned-acquisition/PUBLIC_SOURCE_MANIFEST.json

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions research/lean-paid-positioned-acquisition/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Paid positioned track acquisition and return

Seven unchanged accepted Lean modules compose an actual three-tape read of one selected paired track from a supplied finite packed store, returning its data and control heads to home. The chosen bits are copied to a separately supplied empty tape. The complete store and both original paired tracks survive.

## Author-checked context

κ = 836330098538459/500000000000000000 = 0.001672660197076918 is the unchanged selected PR1094 context, author-checked by James Chang with OpenAI assistance. The original source context is 0b1cccf86e2f5132ed286a26ef0a681a495740ea; the five selected critical source blobs remain identical at observed main 0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2. These finite supplied-store results do not improve κ or establish the full selected multiplication theorem.

## Checked endpoint

Let `pre`, `selected`, `post` describe the ordered store, `p = pre.length`, and `w = selected.rows.length`. The actual controller performs positional access, one charged handoff, source-preserving track extraction, one charged handoff, and physical return to global home. Its first halt is exactly

`2 * capacity(pre) + 4*p + 6*w + 26` transitions.

The original represented entrance volume is `V = capacity(pre ++ selected :: post) + p + 2`, including every packed delimiter and the marked unary control. The output is initially empty. `entrance_resources` derives actual endpoint and first halt with time at most `7*V` and, for every run prefix including terminal stuttering, at most `2*V` represented tape cells. The copied output includes its paid left/right markers. Zero-width blocks and position zero are covered.

The complete data store, both selected source tracks, all other blocks, the unary control tape and the carried Boolean scratch are preserved. The seven extraction registers finish clear; arbitrary old register values are not restored. The track selector is a fixed Boolean program parameter. Tape-cell volume counts represented zipper cells; finite control and register fields remain separate fixed fields.

## Module roles

- `PairedTrackExtraction` specializes the accepted marked-difference extraction phase to a chosen Boolean track of the existing paired alphabet. It derives `6*w+16` transitions, first halt, exact output and `2*w+4` prefix cells from actual steps.
- `PairedTrackExtractionFraming` derives confinement and step/run compatibility with arbitrary surrounding source lists, then exact framed output and full-context storage. The left list is stored in reverse zipper order. Output remains a distinct empty-at-entry tape.
- `PackedMetadataSlots` supplies ordered structural lookup with explicit before/selected/after focus, missing-key failure, unique-key ownership, complete packing/capacity, and the existing metadata XOR/update refinement. Keys are logical labels, absent from the physical alphabet. Semantic first-match update and unique physical ownership are distinct facts.
- `PositionalMetadataAccess` traverses actual L/data/R symbols using one supplied unary tick per preceding block. Exact first halt is `capacity(pre)+2*p+4`; the control head rewinds while the data head reaches the selected left marker. All symbols and arbitrary carried scratch survive.
- `PositionalMetadataReturn` traverses those blocks in reverse physical order, returning data and unary heads home at the same exact cost. It reads finite symbols without a numeric seek or hidden boundary sensor.
- `PaidPairedTrackAcquisition` composes the three actual machines with two charged transitions, and binds executable `locate` success to the reached focus and copied word.
- `PaidPairedAcquisitionResources` derives the complete prefix bound and original-entrance `7V` time / `2V` space invoice without adding an execution premise.

`ACCEPTANCE.json` binds 43 complete axiom probes and 12 full printed types to exact source hashes. All use only standard Lean axioms. Two harmless `unnecessarySeqFocus` style warnings in `PackedMetadataSlots` are retained verbatim; the other six roots have no diagnostics. The historical “Uncompiled candidate” label in `PositionalMetadataReturn` is preserved. Its exact source subsequently passed and has an independent accepted terminal, as the source-bound summary records.

## Explicit caller obligations

The initial marked packed store, unary positional tape, distinct empty output tape, fixed track choice and valid ordered layout are supplied. Structural key lookup is not a paid runtime key search. Key-to-position binding, unary preparation, physical field encoding, initial store construction/allocation, source refresh and subsequent output writeback remain separate obligations. A malformed entrance gets no success theorem merely because transitions are total. No uniform recursive bit-cost, selected precision, arbitrary dirty-register recovery or full multiplier theorem is claimed.

## Reuse and attribution

James Chang with OpenAI assistance, Apache-2.0; preserve all source headers and prerequisite attribution. The actual extractor reuses public PR1947 marked-difference extraction and PR1840/1869/1899 marked tape and arithmetic foundations. Packed metadata reuses PR2403 ambient exponent metadata, PR1921 XOR framing, and the exact reference arithmetic/store/routing chain. Import-renamed public LemmaG/LemmaA and PrefixNorm retain DreamingOfClouds and Gareth Davidson (@bitplane) credits and unchanged proof bodies.

PR2235 provides substantial generic finite-head machine, framing, charged-caller and serializer infrastructure. Its inspected serializer consumes a compiler-stack input into a blank-origin output. This package's endpoint is a source-preserving selected track of an occupied paired store, with actual positional access and return. The model/ABI distinction is explicit; no priority or generic framing novelty claim is made.


The later [PR2411 framework](https://github.com/CrocSwap/integer-mult-bounds/pull/2411), at immutable provider commit `7415d773d14212c68b523979aaac6db9dc0ba542`, also supplies general components that overlap this work: [GuardedMapCopy.copy_hoare](https://github.com/platypii/integer-mult-bounds-lean/blob/7415d773d14212c68b523979aaac6db9dc0ba542/IntegerMultBounds/Machine/GuardedMapCopy.lean#L52) preserves an occupied source and the destination outside the written interval while applying a fixed symbol map in exactly the word length; [CountedSeek](https://github.com/platypii/integer-mult-bounds-lean/blob/7415d773d14212c68b523979aaac6db9dc0ba542/IntegerMultBounds/Machine/CountedSeek.lean#L212) supplies payload-preserving forward/backward movement with an immutable binary descriptor and clean local clock, bounded by `5*distance + 7*descriptor.length + 16`; [MarkedReturn.return_hoare](https://github.com/platypii/integer-mult-bounds-lean/blob/7415d773d14212c68b523979aaac6db9dc0ba542/IntegerMultBounds/Machine/MarkedReturn.lean#L104) restores a marked word's origin in `length+2` transitions. Those are reusable generic suppliers, not missing primitives. The present accepted endpoint remains specific to the existing paired-symbol/zipper model, a unary count of variable-width blocks, its two charged handoffs, exact home/output states and original represented-volume `7V/2V` theorem. The bounded comparison found no exact combined endpoint substitution; reuse in the other finite-alphabet absolute-tape model still needs an explicit representation/position/interface bridge. No generic copy/seek/return novelty or global absence claim is made.

Seven shipped sources total 85,710 bytes. Twenty-seven immutable public or deterministic import-derived prerequisites give a complete 34-module research closure of 355,239 bytes. No public prerequisite is recopied. `PUBLIC_SOURCE_MANIFEST.json` records exact identities and topological order. Use `REPRODUCTION.md` with an already prepared Lean 4.21.0 / Mathlib installation, and avoid loading conflicting original and alias namespaces together.
67 changes: 67 additions & 0 deletions research/lean-paid-positioned-acquisition/REPRODUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Reproduce the exact paid acquisition source closure

Use an already prepared official Lean 4.21.0 installation and Mathlib checkout/caches at the manifest commit, with its eight pinned package checkouts. Set LEAN_HOME, MATHLIB_HOME and a shared LEAN_REPLAY_LOCK. Git, Python3, timeout and flock are required. The recipe never invokes elan or installs/rebuilds dependencies. Run from this package directory.

```sh
set -eu
: "$LEAN_HOME" "$MATHLIB_HOME" "$LEAN_REPLAY_LOCK"
test -x "$LEAN_HOME/bin/lean"
unset LEAN_OPTS LEAN_PATH
"$LEAN_HOME/bin/lean" --version | grep -Eq '^Lean \(version 4\.21\.0([,)]| )'
[ "$(git -C "$MATHLIB_HOME" rev-parse HEAD)" = 308445d7985027f538e281e18df29ca16ede2ba3 ]
[ -z "$(git -C "$MATHLIB_HOME" status --porcelain --untracked-files=no)" ]
export MATHLIB_HOME
python3 - <<'PY_CHECK'
import json,os,pathlib,subprocess
m=json.load(open('PUBLIC_SOURCE_MANIFEST.json'));root=pathlib.Path(os.environ['MATHLIB_HOME'])
for x in m['runtime']['official_package_commits']:
p=root/'.lake/packages'/x['name']
assert subprocess.check_output(['git','-C',str(p),'rev-parse','HEAD'],text=True).strip()==x['commit']
assert not subprocess.check_output(['git','-C',str(p),'status','--porcelain','--untracked-files=no'],text=True).strip()
PY_CHECK
exec 9>"$LEAN_REPLAY_LOCK"
flock 9
work=$(mktemp -d)
export work
python3 - <<'PY_SOURCES'
import pathlib,hashlib,json,os,subprocess
w=pathlib.Path(os.environ['work']);m=json.load(open('PUBLIC_SOURCE_MANIFEST.json'))
for d in ['sources','objects','logs','upstream']:(w/d).mkdir()
def run(*a):return subprocess.check_output(list(a))
run('git','init','-q',str(w/'upstream'));fetched=set()
for x in m['public_prerequisites']:
key=(x['repository'],x['commit'])
if key not in fetched:
run('git','-C',str(w/'upstream'),'fetch','--no-tags','--depth=1','https://github.com/'+x['repository']+'.git',x['commit']);fetched.add(key)
b=run('git','-C',str(w/'upstream'),'show',x['commit']+':'+x['path'])
if 'replacement' in x:
assert len(b)==x['upstream_bytes'] and hashlib.sha256(b).hexdigest()==x['upstream_sha256']
r=x['replacement'];a=r['before'].encode();c=r['after'].encode();assert b.count(a)==r['count']==1
b=b.replace(a,c,1)
size=x.get('derived_bytes',x.get('bytes'));sha=x.get('derived_sha256',x.get('sha256'))
assert len(b)==size and hashlib.sha256(b).hexdigest()==sha
(w/'sources'/(x['module']+'.lean')).write_bytes(b)
for x in m['shipped_modules']:
b=pathlib.Path(x['path']).read_bytes()
assert len(b)==x['bytes'] and hashlib.sha256(b).hexdigest()==x['sha256']
(w/'sources'/(x['module']+'.lean')).write_bytes(b)
(w/'order').write_text('\n'.join(m['compile_order'])+'\n')
PY_SOURCES
libpath="$work/objects:$MATHLIB_HOME/.lake/build/lib/lean"
for p in plausible LeanSearchClient importGraph proofwidgets aesop Qq batteries Cli; do
libpath="$libpath:$MATHLIB_HOME/.lake/packages/$p/.lake/build/lib/lean"
done
while IFS= read -r module; do
available_kib=$(df -Pk "$work" | awk 'NR==2 {print $4}')
[ "$available_kib" -ge 8388608 ] || { echo 'Need at least 8 GiB free'; exit 1; }
set +e
(ulimit -v 4194304; LEAN_PATH="$libpath" timeout --signal=KILL 60s "$LEAN_HOME/bin/lean" -j1 -o "$work/objects/$module.olean" "$work/sources/$module.lean") >"$work/logs/$module.stdout" 2>"$work/logs/$module.stderr"
result=$?
set -e
printf '%s\n' "$result" >"$work/logs/$module.exit-code"
[ "$result" -eq 0 ] || { echo "Stopped; complete logs retained in $work/logs"; exit "$result"; }
done < "$work/order"
printf 'Sources, objects and logs retained in %s\n' "$work"
```

This is a reproduction recipe, not a claim of another publication-candidate replay. Stop if the prepared prerequisites are unavailable. The seven shipped modules retain two PackedMetadataSlots style warnings; all other shipped diagnostics were empty. Preserve every warning from reused prerequisites as well.
Loading
Loading