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
180 changes: 180 additions & 0 deletions research/modular-phase-cache/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Exact persistent memory for a modular phase cache

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

## Contract and theorem

Fix integers t>=0 and b>=1. A source x has one coefficient x_a in
Z/(2^b) for each a in F2^t. After loading x, a cache has no further access
to it. An external command i replaces the logical source coefficient x_a
by (-1)^(a_i) x_a. A read returns the sum of the current logical source,
modulo 2^b. Commands and reads can occur in any finite order, including
repetitions. Every source and every such history must be handled exactly.
The original source need not be recoverable from the cache.

Count only the cache states that can depend on x. Program constants and
externally supplied commands are not charged as source memory. Every
source-dependent header, retained output, random seed or control state is
part of that cache. There is no uncharged source-dependent transcript.
The construction below needs no history cursor. Its read leaves the state
unchanged. Temporary arithmetic and source preparation are separate costs.

Define

```text
B(t,b) = sum_{j=0}^t binom(t,j) max(b-j,0).
```

The minimum number of persistent states is exactly 2^B(t,b). Thus the
minimum fixed binary packet width is B(t,b), even for arbitrary nonlinear
encoding and state transitions. Zero-error randomized encoding or updates
cannot reduce this state count. Here zero error means correctness with
probability one for every source and every finite history, with random
coins independent of the source before loading.

This is a finite-ring observation theorem. It does not assert a smaller
cache for exact complex or unbounded integer outputs.

## A complete family of observations

Starting at x, apply exactly the commands indicated by a bit vector s
and then read. The response is

```text
f_x(s) = sum_a (-1)^(a dot s) x_a mod 2^b.
```

After every later history, the logical source is again an updated x of
this form. Two sources are observationally equivalent exactly when their
complete tables f_x agree. An exact cache may merge equivalent sources;
it cannot merge sources with different tables, since one fixed command
sequence and read separates them.

For each subset S of {0,...,t-1}, put

```text
z_S(x) = sum_{a: S subset supp(a)} x_a.
```

For Boolean s, ordinary integer expansion gives

```text
(-1)^(a dot s) = product_i (1-2 a_i s_i),
f_x(s) = sum_{S subset supp(s)} (-2)^|S| z_S(x) mod 2^b.
```

Evaluation of a multilinear polynomial on the Boolean cube is the
subset-zeta transform. Its matrix is triangular with diagonal one when
subsets are ordered by inclusion. Integer Mobius inversion gives its
inverse, so it remains invertible over Z/(2^b). Consequently two tables
agree if and only if every coefficient (-2)^|S| z_S agrees modulo 2^b.
For |S|<b this is equivalent to agreement of

```text
c_S = z_S mod 2^(b-|S|).
```

For |S|>=b the coefficient vanishes identically. Thus the vector of c_S
is exactly the observational equivalence class, not merely a sufficient
list of cached statistics.

## Every packed state is attainable

The full map x -> (z_S)_S is another subset-zeta transform: it sums over
supersets instead of subsets. It too is unimodular over the integers and
invertible modulo 2^b.

Prescribe each c_S independently in Z/(2^(b-|S|)) for |S|<b. Choose a
lift z_S modulo 2^b for each prescribed value and set the unused z_S to
zero. Invert the full zeta transform to obtain a source x. This source
attains all the prescribed residues simultaneously. Therefore the number
of distinct tables is exactly

```text
product_{|S|<b} 2^(b-|S|) = 2^B(t,b).
```

The nonlinearity-independent lower bound now follows by counting
distinguishable classes. This is the standard finite-state distinguishability
argument applied to the complete phase table. No rank claim over a field
is substituted for cardinality over this ring.

For randomized caches, concatenate a fixed finite distinguishing experiment:
visit each s, read f_x(s), and undo its commands before the next visit.
Conditional on any state immediately after loading, the future output law
depends only on that state and fresh source-independent coins. If the same
state had positive probability for two sources with different phase tables,
this common output law would have to equal two different deterministic
transcripts with probability one. That is impossible. The loading-state
supports for distinct tables are therefore disjoint. Each is nonempty,
so the same state-count lower bound follows. Any retained private randomness
or source-dependent random-tape position is included in the state, as the
contract requires. The upper construction is deterministic. Positive-error
randomized compression is not covered.

## Explicit updates, with no cursor

Pack c_S into disjoint fields of width b-|S| for |S|<b. The first field
c_empty has b bits and is the current readout. A command i has the
following simultaneous action, with each expression reduced at its own
destination modulus:

```text
i in S: c'_S = -c_S,
i not in S: c'_S = c_S - 2 c_(S union {i}).
```

An absent c_(S union {i}) contributes zero. If |S|=b-1, its unretained
integer value is multiplied by two at a one-bit destination and vanishes.
Otherwise the source field has one fewer bit than the destination, so
twice that residue is well-defined at the destination modulus.

The formulas follow by splitting the supersets of S according to a_i.
They can be executed in place. First update all fields with i not in S,
reading only fields with i in S. Those source fields remain untouched
throughout this pass. Then negate all fields with i in S. No copy of a
cache coefficient or stored phase cursor is required. Each command is
an involution, and different commands commute, because they realize the
literal source sign changes. Reads leave the cache unchanged.

This constructs an exact machine with all 2^B states. It is a logical
modular-arithmetic construction, without a native or fixed-tape tariff.
The Python implementation is functional and returns a packed integer;
it does not claim that Python's runtime allocates only B physical bits.

## Examples and limits

For b=1, B=1. For b=2, B=t+2. For t>=1 and b>=t,

```text
B(t,b) = b*2^t - t*2^(t-1).
```

This follows from the binomial sum and its first moment. At t=2,b=3,
the exact cache width is eight bits, versus twelve bits for the literal
four-coefficient source. At t=3,b=2 it is five bits, versus sixteen.
These comparisons price only persistent modular source information.

The modular quotient is essential. At t=1,b=2 the distinct sources
(0,0) and (2,2) have the same complete modular phase table, while their
unbounded integer sums differ. If a later caller needs source recovery,
discarded carries, exact Gaussian values or a changed query family, the
discarded information must be supplied and charged. This theorem does
not establish a saving under that stronger boundary.

## Predecessor boundary

Ali Romman's PR #4958 proves that the least invariant linear cache over
the complex numbers is the sum of the query ranks on joint diagonal
fibers. Its historical 56- and 112-row values are not recalculated here
and are not asserted over Z/(2^b). Its source and native lineage retain
their credit. The new step is a changed finite-ring contract, exact
observational class count allowing nonlinear states, and an attaining
variable-width cache with reversible generator updates.

Boolean zeta/Mobius transforms, Walsh interpolation, Smith normal forms
and finite-state distinguishability are classical. The same state count
can be read from the classical Walsh Smith diagonal, whose 2^j entries
have multiplicity binom(t,j). No new classical normal-form theorem or
literature-wide priority is claimed. The elementary proof above needs no
predecessor executable or spectral certificate.
127 changes: 127 additions & 0 deletions research/modular-phase-cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Exact bit memory for modular phase caches

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

Claim type: scoped written proof with exact finite corroboration. For a source
indexed by F2^t with coefficients modulo 2^b, the least persistent cache that
answers its sum after every sequence of coordinate sign changes has exactly

```text
2^B(t,b) states, where B(t,b) = sum_j binom(t,j) max(b-j,0).
```

The lower bound permits arbitrary nonlinear states and zero-error randomized
encodings and updates. An explicit packed subset-sum cache attains it, with
reversible in-place modular updates and no separate phase cursor. For t=2,
b=3 it needs eight logical persistent bits rather than the source's twelve.
For b=2, its width is exactly t+2. The source is not required to be recoverable.
[PROOF.md](PROOF.md) defines the complete contract and proves the formula.

The new contribution changes Ali Romman's
[PR #4958](https://github.com/CrocSwap/integer-mult-bounds/pull/4958)
characteristic-zero linear-cache interface to a finite residue ring, where
integer rank alone does not count states. Its 56- and 112-row historical
values are cited background, not computations or claims of this package.
Boolean zeta/Mobius inversion, Walsh interpolation, the classical Walsh Smith
diagonal and finite-state distinguishability retain their classical credit.
No literature-wide priority claim is made for those ingredients.

## Reproduce

From the repository root with standard-library CPython 3.12:

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

Another CPython 3.12 executable may replace the absolute path. The verifier is
read-only and Git-free. It emits `PASS_MODULAR_PHASE_CACHE` in a generated JSON
receipt bound to all six package files. No receipt is handwritten. The
registered normal and optimized commands have 120-second limits.

The finite checks compare literal phase tables and subset sums with the packed
zeta encoder, enumerate every source in eleven small domains, and enumerate
every packed state in the declared small-state domain. They check image
cardinality, inverse-zeta representatives, every generator, involution,
commutation and longer histories. Larger fixtures reach t=10 and b=16.
Boundary controls reject malformed domains and states; semantic controls show
that one initial sum is insufficient and that the modular quotient cannot
recover exact integer sums. The universal result rests on the written proof.
No predecessor scientific program or certificate is replayed.

The local CPython 3.12.15 normal and optimized checks agree on all 135,798
enumerated sources, 337,268 source/generator transitions, 8,766 enumerated
cache states, 21,564 state/generator transitions and 17,156 commuting pairs.
They also check 220 larger fixtures, 2,200 history updates, 131 closed-form
parameter cases and eleven rejected inputs. The two direct registered
commands took 4.636 and 4.539 seconds locally. These are check durations,
not a performance comparison. The combined registered replay passed.
Three disposable implementation mutations, changing the ADD sign, omitting
negation and skipping a zeta axis, were rejected by the literal comparisons.
The longest function has 29 physical lines. No separate static-analyzer
or independent mathematical review is claimed.

## Scope and limitations

This is a modular observation cache, not lossless storage of the source.
Every source-dependent header or controller state counts toward the lower
bound. The upper construction has no source-dependent external transcript.
The B-bit claim counts persistent logical information. Python object sizes,
source loading, temporary arithmetic, output storage, physical movement and
instruction costs are not claimed to fit in B bits.

There is no asserted transfer to exact complex queries, unbounded integers,
source restoration, omitted carries or the selected word. A source-preserving
physical caller and its complete invoice remain missing. No native supplier,
selected assumption discharge, new kappa, complete multiplication theorem,
independent human review or formal proof-kernel acceptance is claimed. Lean,
Docker and the selected cold replay were not run. The selected frontier and
all five framework assumptions remain unchanged.

The historical source is pinned as provenance in [SOURCES.json](SOURCES.json).
It supplies motivation, not a live input. [TASK.json](TASK.json) records the
change from the centre-path-sharing card to this finite-ring side result.
The [advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19601590)
pins canonical base e54523517d0f03e58352e647c403a5af3e525a57, priority revision
8 and selected #7000. The first card control passed
`PASS_RESEARCH_BASELINE_BINDINGS_ONLY`; it is metadata orientation only.

Overlap checks included live open/account PRs, recent handoffs, active
Discussions, merged searches and all-main README searches for modular phase
caches, nonlinear caches and Walsh/Smith state counts. The overlap cache
reported 846 open PRs and 7,482 Discussion records, with complete remote
pagination. Its sparse local search covered 215 of 10,178 note paths;
the all-main searches cover omitted READMEs. Arbitrary code diffs, unindexed
prose and unpublished work remain limits, and no-match is not novelty proof.

## Open next questions

Can one source-bound caller use only these modular observations and safely
discard the quotient kernel? First specify the output modulus, every later
read and all carry/restoration obligations. Its physical boundary and full
paid invoice are missing. The present result alone does not justify a
construction campaign. The structured question is in TASK.json.

## Verification bounds

The single verifier has no recursion, subprocess, network access, dynamic code
or output files. Its public constructor accepts 0<=t<=10 and 1<=b<=16.
At most 1,024 source coefficients, cache fields or layout entries are live
per construction. The source census has at most 65,536 inputs per fixture;
its transcript dictionary retains at most 4,096 records. The state census
admits at most 4,096 states per fixture. Functions stay below 60 lines.
Explicit contracts remain active with assertions disabled. File reads for
receipts are bounded at 256 KiB each. Warning-strict normal/optimized runs,
in-memory compilation and AST inspection are the available diagnostics.

Power of Ten rule 3 deviation: CPython arithmetic and containers allocate
during evaluation. This terminating verifier bounds input dimensions,
retained dictionaries and integer widths, and claims no fixed-allocation
runtime. A fixed-storage port would need its own arithmetic and receipt
implementation before use in an allocation-prohibited environment.
Rule 9 deviation: eleven fixed no-argument rejection closures invoke the
same local validation functions. Their target set and lifetimes are bounded
by `controls`; each is executed once and its exact error is checked.
24 changes: 24 additions & 0 deletions research/modular-phase-cache/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"schema_version": 1,
"base_commit": "e54523517d0f03e58352e647c403a5af3e525a57",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8",
"sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/centre-polynomial-cache-limits/PROOF.md",
"usage": "provenance",
"git_blob": "98e070a4e309010d76d7885b39366f9a9ef71341",
"sha256": "ebcd0912e990c71f3b29b87674c1b5e3efa8f5ea37ed20f4fd06d80ce27f6382"
}
]
}
Loading
Loading