diff --git a/research/fractional-source-width/README.md b/research/fractional-source-width/README.md new file mode 100644 index 0000000000..9d0fd7e947 --- /dev/null +++ b/research/fractional-source-width/README.md @@ -0,0 +1,176 @@ +# A fractional-moment bound for selected nested widths + +This package was produced by Nick Petalas. Apache-2.0. + +**Scoped mathematical proof, with exact finite corroboration.** For the unchanged +selected #4470 invoice, product power 1024, completion floor and paid split rule, +the #4436 nested compiler satisfies `K/N < 3.0694`. + +This improves JoyboyBrian's [#5067](https://github.com/CrocSwap/integer-mult-bounds/pull/5067) +bound `K/N < 3.070`. More precisely, its uniform source logarithm bound +`197115103572543` decreases to `197100824008381`, a reduction of +`14279564162`. The new step is a fractional source-rank moment, including +completion and splitting. The selected kappa remains `60403/20000000`. +This is a mathematical width bound under the retained compiler assumptions; +physical stock, routing, native realization and supplier admission remain open. + +## Premise and new uniform inequality + +Use the source-labelled root/nonroot census and strict source-rank interval +proved in #5067 as cited premises. They are not independently audited here. +Write `M` for ambient rank, `L>=2` for the completed productive floor, +`x=n/M`, and `G=max{g:M L^g<=n}`. Let `T_k` and `P_r` be the fully completed +and split productive and paid inventories. The cited census includes every +nonroot absent-parent demand, with distinct chronological labels, and each +source rank `s` obeys `x0`, define `T_p=sum T_k k^p` and `P_p=sum P_r r^p`. +Each source contributes `1<(s/x)^p`. Sum this weight over the cited exact +census, then enlarge the eligible sets to full ordered words. Multiplicativity +of `(ab)^p` gives root weight `T_p^(G+1)` and depth-d weight +`P_p^d T_p^(G-d+1)`. Thus the new inequality is + +```text +S_n < x^(-p) T_p sum_(d=0..G) P_p^d T_p^(G-d). (1) +``` + +If a common `U` bounds both `T_p` and `P_p`, then + +```text +S_n < (G+1) U^(G+1)/x^p + <= (G+1) U (U/L^p)^G. (2) +``` + +This does not assume `P_p<=T_p`. Rank-mass ordering at p=1 alone does not +imply that ordering at a fractional p. + +## Charging the actual completion and splitting + +Let `t_p=sum T0_k k^p` and `q_p=sum P0_r r^p` be moments of the pinned raw +invoice, `W0=sum T0_k`, and `q_1=sum P0_r r`. The chronological product power +is `v=1024`, the completion floor is `L=21^v`, and split cutoff is `J=20^v`. +The product has `W0^v` productive slots. Completion adds at most `L` to +each slot on disjoint coordinates, so + +```text +T_p <= t_p^v + W0^v L^p. +``` + +For a paid rank `a`, write `a=bJ+c`, `0<=c 1. +``` + +Taking logarithms in (2) and bounding by integer bit lengths yields + +```text +log2 S_n < bit_length(h+1) + 18291 + h*(18291-4488) + = X = 197100824008381. +``` + +Therefore `log2 B_N 0 for c in (*targets.values(), *paid.values())), + 'positive multiplicities') + bounds = {r: power_interval(r) for r in targets.keys() | paid.keys()} + t_upper = sum(c * bounds[r][1] for r, c in targets.items()) + p_upper = sum(c * bounds[r][1] for r, c in paid.items()) + v, w = 1024, sum(targets.values()) + paid_mass = sum(r * c for r, c in paid.items()) + floor_power, floor_rank = 21 ** 1022, 21 ** v + completion = w ** v * floor_power + target_upper = t_upper ** v + completion + paid_upper = (p_upper ** v + Fraction(paid_mass ** v, 400) + + completion + Fraction(w ** v * floor_rank, 400)) + uniform = 1 << 18291 + need(target_upper < uniform, 'productive fractional moment ceiling') + need(paid_upper < uniform, 'fully charged paid fractional moment ceiling') + need(uniform > floor_power, 'height monotonicity') + h_bits = invoice['compiler']['H'] + need(h_bits == 64215200000000, 'selected height') + height = (h_bits - ((145 ** v).bit_length() - 1)) // (floor_rank.bit_length() - 1) + x_bound = ((height + 1).bit_length() + 18291 + + height * (18291 - (floor_power.bit_length() - 1))) + need(10000 * x_bound < 30694 * h_bits, 'K/N < 3.0694') + need(x_bound < 197115103572543, 'strict predecessor-envelope improvement') + return {'exponent': '511/512', 'moment_ceiling': '2^18291', + 'height_upper': height, 'floor_power_log2_floor': floor_power.bit_length() - 1, + 'log_source_upper': x_bound, 'width_coefficient_upper': '15347/5000', + 'previous_log_source_upper': 197115103572543, + 'log_source_bound_reduction': 197115103572543 - x_bound, + 'root_intervals': {str(r): [str(a), str(b)] for r, (a, b) in sorted(bounds.items())}} + + +def half_moment_ceiling(inventory): + """Independent coarse square-root enclosure for small word controls.""" + total = 0 + for rank, count in inventory.items(): + root = next(j for j in range(1, 11) if j * j >= rank) + total += count * root + return total + + +def source_count(targets, paid, rank): + """Literal ordered paths, only for new tiny fractional-bound fixtures.""" + ambient, floor = max(targets), min(targets) + height = 0 + for g in range(1, 5): + if ambient * floor ** g <= rank: + height = g + need(ambient * floor ** (height + 1) > rank, 'fixture depth cap') + count = 0 + for d in range(height + 1): + for path in product(paid, repeat=d): + rho = 1 + for r in path: + rho *= r + for word in product(targets, repeat=height - d): + column = 1 + for k in word: + column *= k + for k in targets: + eligible = ambient * rho * column <= rank + absent = d == 0 or ambient * (rho // path[-1]) * column * k > rank + if eligible and absent: + source_rank = rho * column * k + need(ambient * source_rank > rank, 'strict source threshold') + count += 1 + return count, height + + +def finite_controls(): + cases = 0 + for targets in ((2, 3), (2, 4), (3, 4)): + for paid in ((1,), (1, 2), (1, 2, 3)): + if max(paid) >= max(targets): + continue + upper = max(half_moment_ceiling(dict.fromkeys(targets, 1)), + half_moment_ceiling(dict.fromkeys(paid, 1))) + for rank in range(max(targets), 61): + count, height = source_count(targets, paid, rank) + rhs_squared = Fraction(max(targets), rank) * (height + 1) ** 2 * upper ** (2 * height + 2) + need(count ** 2 < rhs_squared, 'fractional source-count inequality') + cases += 1 + split_cases = 0 + for root in range(1, 9): + rank = root * root + for cut_root in range(1, 5): + cutoff = cut_root * cut_root + q, rem = divmod(rank, cutoff) + remainder_upper = Fraction(isqrt(rem * 256 ** 2) + 1, 256) + lhs_upper = q * cut_root + remainder_upper + rhs = Fraction(rank, cut_root) + root + need(lhs_upper <= rhs, 'actual split square-root moment bound') + split_cases += 1 + need(16 * 2 > 8, 'rank 64 split at 4 exceeds its unsplit square-root moment') + need(half_moment_ceiling({1: 10}) > half_moment_ceiling({4: 1}), + 'paid/productive moment ordering is not assumed') + lower, upper = power_interval(2) + need(lower > 1 and upper ** 512 >= 2 ** 511, + 'rounding 2^(511/512) down to 1 is invalid') + return {'fractional_source_fixtures': cases, 'split_fixtures': split_cases, + 'semantic_controls': 3} + + +def main(): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_text()) + live = {} + for row in manifest['files']: + if row['usage'] == 'input': + live[row['path']] = read_input(row['path'], row['sha256']) + invoice = json.loads(live['research/selected-truncated-source-envelope/vendor/selected.json']) + result = selected_certificate(invoice) | finite_controls() + files = sorted(p for p in PACKAGE.iterdir() if p.is_file()) + need(len(files) <= 10, 'package file capacity') + receipt = {} + for path in files: + raw = path.read_bytes() + need(len(raw) <= 65536, 'package size') + receipt[path.name] = sha256(raw).hexdigest() + print(json.dumps({'result': result, 'file_sha256': receipt, + 'python': sys.version.split()[0]}, sort_keys=True, indent=2)) + print('PASS_FRACTIONAL_SOURCE_WIDTH K/N<3.0694 no_new_kappa') + + +if __name__ == '__main__': + main()