Skip to content
Merged
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
24 changes: 24 additions & 0 deletions research/cached-hamming-tail/PROFILE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
493367 function calls (486018 primitive calls) in 0.079 seconds

Ordered by: cumulative time
List reduced from 22 to 18 due to restriction <18>

ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.079 0.079 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:130(search)
7350/1 0.006 0.000 0.079 0.079 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:136(visit)
7350 0.004 0.000 0.070 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:114(reject)
4434 0.009 0.000 0.035 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:42(tail_envelope)
4896 0.010 0.000 0.029 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:75(union_reject)
19817 0.011 0.000 0.017 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:47(<genexpr>)
15054 0.016 0.000 0.016 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:18(pair_support)
62363 0.008 0.000 0.012 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:77(<genexpr>)
307110 0.011 0.000 0.011 0.000 {method 'bit_count' of 'int' objects}
7350 0.001 0.000 0.002 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:71(remaining_reject)
28519 0.001 0.000 0.001 0.000 {built-in method builtins.len}
7349 0.001 0.000 0.001 0.000 {built-in method builtins.max}
9792 0.001 0.000 0.001 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:25(choose2)
7350 0.000 0.000 0.000 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:13(require)
2141 0.000 0.000 0.000 0.000 {built-in method builtins.min}
1656 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
828 0.000 0.000 0.000 0.000 {method 'bit_length' of 'int' objects}
2 0.000 0.000 0.000 0.000 {built-in method builtins.sorted}
89 changes: 89 additions & 0 deletions research/cached-hamming-tail/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Exact cached Hamming envelopes

This is an implementation-equivalence proof for the shared-tail predicate of
SHIN09-git's PR6046. The predecessor's completion theorem and canonical caller
remain cited premises. No predecessor mathematical claim is audited here.
The new contribution was produced by Nick Petalas. Apache-2.0.

Let P be the distinct visited vertices, with last vertex q in P. Let r be the
remaining edge budget. Write D(P) for the nonzero pair differences and define

```
H(q,r) = {x : weight(q XOR x) + weight(x) <= r}
U = H(q,r) minus P.
```

The source's already simplified exact envelope is

```
E = D(P) union {p XOR x : p in P, x in U}.
```

The following identity removes the prefix-dependent exclusion from the support
calculation, while retaining it in the future-vertex count:

```
E = (D(P) union union_(p in P) (p XOR H(q,r))) minus {0}.
```

To prove inclusion from left to right, use U subset H. For the reverse inclusion,
consider an added x in H intersect P. For every p in P, p XOR x belongs to D(P)
unless p=x, in which case it is zero and is removed. Thus the larger cached set
adds no nonzero difference. This identity holds for arbitrary distinct vertices;
it does not require the path condition used by the source's completion theorem.

`tables` enumerates H for all 32 endpoints and all budgets 0 through 12. For each
distinct mask it computes all 32 XOR translations. A bitset stores membership
of vertex x at bit x. At coordinate i, XOR by 2^i exchanges the two halves of
each consecutive block of 2^(i+1) bit positions. `translate` performs that
exchange by two masks and shifts. The five coordinate exchanges commute, and
their product is exactly x maps to x XOR p. All masks have at most 32 bits.

For a validated source prefix, `envelope` forms U by `reach & (ALL XOR seen)`.
It ORs the precomputed translations for every old vertex into the literal
source pair support, then removes zero. Consequently both U and E equal the
source outputs exactly. The necessary conditions `|U| >= 12-|P|` and
`E = all nonzero masks` therefore return the same decision at every prefix.

The adapter retains the source's remaining-label and parity-union checks in
their original order. It changes only the subsequent shared-tail test in
`two_without_cap`. The source traversal, child order, simple-prefix gate,
closing-edge test and final word checks are unchanged. Induction along that
same traversal gives identical entered nodes, prunes, closed words and
universal words. The original predicate is restored on successful return and
on exceptions by a `finally` block. Each invocation has its own authenticated
source module; no shared file or maintained engine is mutated.

There are 416 reach entries and 13,312 logical translated entries. Identical
reach masks share translation tuples. Storage is bounded by those fixed counts;
it is not a prefix cache that grows with search history. Setup is paid once in
every candidate call and is included in both caller and full-process timing.
The remaining per-prefix support loop visits at most twelve old vertices.
The source's repeated scan over all 32 candidate vertices and nested old/new
pair loop disappear from this stage. The unchanged cheap checks and DFS still
cost time, so this is not a claim of the same speedup for a complete research
package, another census, another dimension or another Python implementation.

The verifier compares all 13,312 translations against literal set translation,
then all 21,640 canonical simple prefixes against the original kernel. It
compares the full returned word tuples from both complete callers. These finite
checks corroborate the identity and adapter proof; they do not establish new
word-census exclusions, a seven-label result, or the predecessor theorem.

## Implementation constraints

The new kernel has no recursion. Its fixed loops have bounds 5, 32, 13 and 12.
The finite verifier's iterative DFS has a 21,641-iteration guard and at most 56
pending entries. Benchmarking admits at most thirty pairs with thirty-second
child timeouts. The retained caller has unchanged recursive depth at most
eleven; that source-control deviation is bounded and not expanded here.

CPython allocates managed objects during execution. The live cache and prefix
state have the fixed bounds above; no allocation-free claim is made. The
source adapter compiles exactly one SHA-256-authenticated, declared Python file
to avoid stale bytecode. This bounded source loading and the private predicate
replacement are explicit metaprogramming and indirect-call deviations. No
untrusted code path or arbitrary callback is accepted. Warning-strict normal
and optimized verification exercise success, unsupported mode, adapter failure
and actual source-corruption paths. Runtime checks use exceptions so they
remain enabled under optimized Python.
147 changes: 147 additions & 0 deletions research/cached-hamming-tail/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Cached Hamming envelopes in the complete prefix-completion caller

This contribution was produced by Nick Petalas. Apache-2.0.

**Implementation-equivalence proof with exact finite conformance and a measured
local runtime improvement.** A fixed bitset cache replaces the repeated
future-vertex and old/new difference loops in SHIN09-git's PR6046 shared-tail
predicate. The complete five-label, length-twelve no-cap caller retains exactly
the same rejection decisions, traversal and returned word tuples.

Across all thirty alternating fresh-process pairs, the candidate has a **10.96%
lower median paired wall time**, with 28/30 paired wins and zero errors. This is
a local performance observation, not a portable timing guarantee. The cache is
built inside each timed caller. The complete process includes interpreter
startup, imports, source authentication, cache setup, traversal and JSON output.

| Complete process | Median | Minimum | Maximum |
| --- | ---: | ---: | ---: |
| Unchanged source caller | 63.815 ms | 62.508 ms | 72.149 ms |
| Same caller with cached tail predicate | 56.849 ms | 55.466 ms | 167.177 ms |

The slow candidate outlier is retained. An initial nine-pair experiment had
overlapping ranges and inconclusive rank-sum evidence. Before any further
measurement, the decision was to run one additional twenty-one-pair experiment
without changing the timed code and retain all thirty pairs. Both complete raw
receipts are committed. Their combined descriptive two-sided rank-sum
probability is `11226165959/59132290782430712`, about `1.90e-7`. Host contention
and sequential sampling limit its interpretation; it is not a portable speed
certificate. No samples from those two fixed experiments were removed and no
timing threshold runs in CI. An earlier in-process development probe and the
untimed profile were used to choose the implementation, not as published
performance samples.

## The new step

For visited vertices P, endpoint q and remaining budget r, let
`H={x: weight(q XOR x)+weight(x)<=r}`. The predecessor uses `U=H minus P` and
the support `D(P) union (P XOR U)`. The exact identity

```
D(P) union (P XOR U) = (D(P) union (P XOR H)) minus {0}
```

lets the implementation cache H and its XOR translations independently of the
prefix. Differences involving an already visited x are already in D(P), except
zero. The future cardinality still excludes every visited point. This is an
exact implementation of the same predicate, not a new pruning theorem.
[PROOF.md](PROOF.md) gives the equivalence, adapter and resource arguments.

An untimed profile of the original complete caller attributes 0.035 of 0.079
instrumented seconds to `tail_envelope`, including 4,434 calls. Its vertex scan
and nested difference loop are the replaced work. The unchanged parity-union
checks consume 0.029 instrumented seconds and constrain the attainable gain.
[PROFILE.txt](PROFILE.txt) retains the full profile; profiler times are not the
reported wall-time measurement. The measured wall-time reduction is smaller
than the replaced stage's profile share.

The cache has 416 reach entries and 13,312 logical translated entries, with
identical masks sharing tuples. It has a fixed bound and is discarded after
the caller. The three source files are authenticated before loading. The
adapter changes one function on its private source module and restores it on
both success and failure. No predecessor file or maintained engine is edited.

## Evidence and reproduction

Run from the repository root with the recorded CPython 3.12.15 interpreter:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/cached-hamming-tail/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/timing_check.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/cached-hamming-tail
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/cached-hamming-tail --check-source-history
```

An installed CPython 3.12 can replace that interpreter path. Only the standard
library is needed. Direct checks print generated receipts bound to package and
input SHA-256 hashes. They write no package files. Temporary source-corruption
fixtures use the operating system temporary directory and are removed.

The verifier compares all 13,312 translations against literal set translation,
all 21,640 canonical simple prefixes against the source's complete future set,
support mask and rejection decision, and both full returned word tuples. Each
complete caller enters 7,350 nodes, prunes 4,381 and returns 828 closed words,
all universal. Both tuple hashes are
`2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727`.
Six controls cover an overpermissive cache, omitted visited set, omitted XOR
translation, unsupported mode, caller-failure restoration and an actual changed
source file. These are checks of the new implementation's equivalence, not a
new scientific audit of the predecessor census or its completion theorem.

`timing_check.py` authenticates every timed source and recomputes all retained
measurement arithmetic. It does not rerun benchmarks or certify host speed.
To collect new measurements, choose an external output path that does not exist:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/benchmark.py --pairs 9 --output /absolute/external/path.json
```

Each child has a thirty-second timeout. All samples check the counts and both
complete tuple hashes before accepting an output. The recorded machine has
eighteen logical CPUs; load averages at orientation were 1.72, 2.73 and 2.63.
Another Python process was active. Measurements are sequential and alternate
which side runs first. OS caches were not flushed and other host work was not
controlled. The receipts retain the exact platform, interpreter and load data.

## Scope and credit

Scientific base is canonical main `2485805a6d47f36ea83ddde6327d453ac82d44dc`,
priority revision 8. The selected conditional result remains PR6030. The
[advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19292017)
takes PR6046's explicit cached-envelope runtime question. The `replay-runtime`
card is refined to this standalone caller. This does not alter the selected
frontier, supply a new kappa, or make a complete multiplication theorem claim.

Credit SHIN09-git for PR6046's shared-tail theorem, simplified predicate,
comparison traversal and open implementation question. Credit Ali Romman for
the distinct matching-capacity predicate and incremental matching engine;
Mihir Srivastava for the five-label handoff; Ross Richardson for the prefix-walk
model; Nicholas Stone for the parity correction; unpaidmoon, James Reed and
the retained word-census contributors for their cited work. The earlier
matching-balance, union-support and position-block work retains its attribution.
Classical bitsets, Hamming distance and XOR permutations are not claimed as new.

Live open PRs, active Discussions and recent account work were checked. The
overlap helper covered 316 open PRs with complete pagination at
2026-10-30T11:25:39Z, but only 95 of 8,722 local note records; its broader
Discussion refresh timed out. Separate live GraphQL reads covered start-here,
twelve active Discussions and the latest thirty handoff comments. Main README
and merged-PR searches included cached Hamming envelopes, prefix completion,
incremental pair support and tail bitsets. This bounded coverage is not a
novelty certificate; historical diffs and unpublished work remain limits.

No larger census, maintained-engine integration/default change, full historical
replay, selected cold replay, Lean or Docker run, native/dirty-restoration
construction, supplier admission or all-size theorem is supplied. All five
framework assumptions remain. Independent human and formal proof-kernel review
are unclaimed.

## Open next questions

Does this cache improve a named maintained-engine caller after its complete
setup and other predicates are paid? First select one exact small caller and
budget a full enabled-versus-disabled comparison with identical complete
outputs. A separate integration and resource budget are required; these local
results do not justify a larger census or a default change. No follow-up is
reserved. [TASK.json](TASK.json) records the same question and blockers.
36 changes: 36 additions & 0 deletions research/cached-hamming-tail/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"schema_version": 1,
"base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a",
"sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/five-label-prefix-completion/PROOF.md",
"usage": "input",
"git_blob": "1f504817b2f4281e0551ac9fc24dfed2d9a3585c",
"sha256": "54731461e8636b0048bb01ad6bde4b92ce718959923a5cb58e888a519d94ac9d"
},
{
"path": "research/five-label-prefix-completion/README.md",
"usage": "input",
"git_blob": "1f3be2eab0c9df69e9965f4f9afe2d486ef04049",
"sha256": "591816a89f4f733b69fe218a66efd9f396e3c260ee2f3c0f4a8cdcd893571c83"
},
{
"path": "research/five-label-prefix-completion/bounds.py",
"usage": "input",
"git_blob": "3022224471f1578d4d7f6e3d31c9c0c091029a55",
"sha256": "e9023abd49e92ae4c5d0bcbf265ad0883d9408a51bab5354e321102f2f20f522"
}
]
}
Loading