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
211 changes: 211 additions & 0 deletions research/rational-box-fraction-free/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# Fraction-free solves in the complete rational parameter optimizer

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

An opt-in integer elimination kernel removes **15.49% of measured complete
solve-and-check wall time** on the declared six-parameter workload. The
median falls from 0.079004 to 0.066770 seconds across seven alternating runs
per arm. Every certificate byte agrees, including the first chosen optimal
basis, its 757 examined bases, exact point, dual and objective 24.

Claim type: scoped implementation proof, finite correctness evidence and a
local performance measurement. This improves execution of Ali Romman's
[PR5792](https://github.com/CrocSwap/integer-mult-bounds/pull/5792) parameter
tool. It does not prove a new LP theorem or improve kappa. The elementary
fraction-free algorithm and LP duality are classical. The new contribution
is their bounded implementation in this complete caller and its evidence.

## Use and reproduce

From the repository root, using CPython 3.12 and the standard library:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B -W error research/rational-box-fraction-free/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -O -B -W error research/rational-box-fraction-free/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/rational-box-fraction-free
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/rational-box-fraction-free --check-source-history
```

The direct marker is `PASS_RATIONAL_BOX_FRACTION_FREE`. Each direct command
prints a generated JSON receipt bound to hashes of the package files. Replay
writes only temporary files outside the checkout. Set `IMB_RUN_DIR` to an
existing scratch directory to place all temporary files there. Another
CPython 3.12 interpreter can replace the displayed local path.

Use the unchanged input and output schemas with the new opt-in runner:

```sh
python3.12 -B research/rational-box-fraction-free/run.py problem.json > certificate.json
python3.12 -B research/rational-box-fraction-free/run.py problem.json --check certificate.json
```

The runner authenticates all three declared source inputs before importing
the original engine. It replaces only that process's `solve` binding and
restores it on return. Input parsing, incumbent validation, basis order,
feasibility tests, dual tests, JSON output and certificate checking are the
original code. No default or shared source file changes.

## Why the replacement solves the same systems

The source optimizer permits one to six parameters, at most 24 total rows,
at most 50,000 active bases, and rational numerators and denominators bounded
by 10^9. Both primal and dual solves use square matrices within this domain.
The new kernel checks that domain and requires exact `Fraction` entries.

First multiply each augmented equation by the positive least common
multiple of its own denominators. This preserves its rational solution set
and produces an integer augmented matrix. Perform ordinary row pivoting,
then use the fraction-free update

```text
next[i,j] = (pivot * current[i,j] - current[i,k] * current[k,j]) / previous_pivot
previous_pivot = 1 before the first column
```

The classical Sylvester determinant identity expresses the numerator as
`previous_pivot` times an integer minor. It applies to the augmented column
as well as coefficient columns. Row interchanges permute equations and the
corresponding minors. Thus every division is exact; the implementation also
checks its remainder explicitly. Over the rationals each update is a
nonzero scaled elimination step, preserving the solution set. A missing
pivot, or zero final diagonal, means a singular coefficient matrix. The
return is `None`, including inconsistent singular systems, as in the source.
Otherwise exact rational back substitution gives the unique solution.
Inputs are never mutated.

Therefore each square solve has the same answer. The unchanged caller takes
the same branches in the same basis enumeration and returns the same full
certificate. Its unchanged final primal-dual checker still runs. This proof
is scoped to this bounded solver interface; the finite tests corroborate it.

The complete workload maximizes
`x0-2x1+3x2-4x3+5x4-6x5`, with `-1<=xi<=2` and
`xi+x(i+1 mod 6)<=1/3`. Its exact optimum is independently visible: each
positive-price coordinate is at most 4/3 because its negative-price neighbor
is at least -1. Hence the objective is at most
`(1+3+5)*4/3+(2+4+6)=24`. Alternating 4/3 and -1 attains it.
This is a parameter-tool workload, not an authenticated supplier invoice.

## Correctness evidence

The verifier checks all 5,625 augmented two-dimensional systems whose four
matrix entries lie in `{-2,-1,0,1,2}` and whose right-hand entries lie in
`{-1,0,1}`. A separate literal determinant classifies their 1,161 singular
cases. Every nonsingular answer has zero exact residual and unchanged input.
Another 360 seeded rational systems cover every dimension one through six,
with forced singular rows in part of that domain. All 5,985 answers agree
with the source kernel. No timing result uses those differential loops.

Eight kernel controls cover shape, exact types, numerator and denominator
limits, a late row pivot and the maximum accepted rational boundary. All six
inherited regression groups run with the replacement in-process kernel,
including 100 independent geometric LP oracles, a fractional optimum,
degenerate boxes, zero objectives, invalid incumbents and forged duals.
The inherited portable subprocess test still exercises the original CLI;
a separate exported, Git-free candidate CLI test compares complete output
bytes and checks its certificate. Each of the three actual declared input
files is then changed separately and must reject before engine import.
Normal and optimized checks retain explicit exceptions throughout.

## Complete-path measurement

The opt-in benchmark is:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B -W error research/rational-box-fraction-free/benchmark.py
```

It times two fresh processes per observation: generate the complete optimum,
write its certificate, then run the separate CLI certificate check. Startup,
imports, parsing, the complete optimization, source gates on the candidate,
serialization and checking are inside the timed region. Fixture creation and
result comparison are outside it. Every output must be byte-identical and
must report objective 24 and 757 examined bases. All 14 complete pairs pass;
there are zero errors. The generated stdout receipt records the fixture,
output and source hashes, checks source stability before and after the run,
and includes every raw wall and child-CPU sample. Timing is not a CI gate.

Measured on macOS 27.0.1, arm64, CPython 3.12.15, using the interpreter above.
The host has 18 logical CPUs; the entry load averages were 2.11, 2.02, 1.49.
Another Python process was active, and the machine was unreserved. The run
order is baseline, candidate, repeated seven times. The complete wall-time
samples, in seconds, are:

| Round | Baseline | Candidate |
| ---: | ---: | ---: |
| 1 | 0.079575208 | 0.066769792 |
| 2 | 0.079004042 | 0.066722000 |
| 3 | 0.078111000 | 0.068358500 |
| 4 | 0.080634459 | 0.066205500 |
| 5 | 0.078052458 | 0.066579042 |
| 6 | 0.077945250 | 0.068450875 |
| 7 | 0.080182458 | 0.069031500 |

Baseline range is 0.077945..0.080634 seconds; candidate range is
0.066205..0.069032 seconds. Median child CPU time falls from 0.075766 to
0.063610 seconds. The wall-time ranges are disjoint. This is one bounded
workload on one host; no uniform speedup across all legal LPs is claimed.

A separate diagnostic profile of the unchanged complete in-process optimizer
records 814 square solves using 0.099 of 0.123 profiled seconds. Those times
are excluded from the benchmark. Fraction arithmetic is the measured
computation bottleneck. Feasibility arithmetic and two interpreter startups
remain, so the complete improvement is smaller than a solve-only comparison.
The observed saving fits within that work; no cached optimum is used.

## Scope, sources and review limits

Scientific base is canonical main
`2485805a6d47f36ea83ddde6327d453ac82d44dc`, priority revision 8. The selected
conditional kappa remains 781451/250000000, with its five framework assumptions.
The current selected-binding first example passed as metadata orientation.
No selected scientific replay, Lean, Docker, supplier admission or complete
multiplication theorem is claimed. Source-to-constraint correctness, strict
physical margins, native implementation, ownership, restoration, precision,
tape costs and outer use remain separate obligations.

The original `replay-runtime` card is refined to this independently posed
implementation question. The advance
[CLAIM](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19294680)
preceded the new implementation. The first passing improvement is packaged;
there is no second optimization round. The fresh overlap snapshot covered
333 open PRs and 6,046 Discussion records with complete remote pagination.
Only 98 of 8,722 main note paths were materialized in its local scan. Separate
main-tree searches covered the exact tool name, rational-box model, active
bases and fraction-free parameter optimization, including general dimension
wording. Merged-title searches and the source PR body were read. PR5792 and
its released Discussion5776 supply the predecessor, not a competing active
claim. Empty matches and sparse coverage are not novelty guarantees.

The new code is nonrecursive. The kernel stores at most six augmented rows
of seven integer entries, performs at most five elimination stages and six
back-substitution stages, and uses functions below 60 physical lines. With
input bounds, cleared entries are at most 10^72 in magnitude; determinant
bounds control intermediate minors and their products. Python allocates
integers, Fractions and JSON dynamically within these finite capacities.
This is a managed-runtime deviation from allocation-free execution.
The scoped engine-binding replacement and inherited test loader have one
authenticated target and restore their mutable bindings. Each child has a
30-second timeout; registered checks have 120 seconds. Warning-strict normal
and optimized execution, in-memory compilation and whitespace checks provide
the local diagnostics. External Python linters were unavailable. The optional
benchmark uses POSIX `resource`; Windows
benchmarking is unclaimed. Independent human and formal proof-kernel review
are unclaimed.

## Open next questions

1. Can the unchanged complete feasibility checks be accelerated while preserving
the first optimal basis and output bytes? Start with a separate profile after
this kernel. A second correctness and complete-path measurement is required.
2. Which authenticated supplier parameter problem benefits from this complete
solver? Derive every row from one pinned full bill and include a positive
margin variable. An LP optimum does not establish physical legality.

## Credit

Credit Ali Romman and PR5792 for the retained bounded optimizer, exact
certificate checker, original tests and parameter guide. Credit zxv for the inherited invoice-parser boundary helpers, and classical
LP, denominator-clearing, Sylvester and Bareiss methods. All predecessor bytes and their credit remain unchanged.
The new kernel, opt-in integration, controls and measurements were produced
by Nick Petalas.
36 changes: 36 additions & 0 deletions research/rational-box-fraction-free/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": "scripts/compare_recursive_invoices.py",
"usage": "input",
"git_blob": "fda2a852e9937e42fe40df0707694465ca7c1b48",
"sha256": "3930c22c11da7bc6042cfeb6e459ecb06e4478430037bee3469d034353855fc6"
},
{
"path": "scripts/optimize_rational_box.py",
"usage": "input",
"git_blob": "95c79882bcd5dced19be66faaf54829599dad72c",
"sha256": "2b466207d9f0c6aa14f37f7be4e9a9feb78ef74e90ca5fabb71e1004783c5059"
},
{
"path": "tests/test_research_rational_box.py",
"usage": "input",
"git_blob": "63c9ef81dc308d9763d746e98da2b10fedef2f83",
"sha256": "38472b11f48cbbc2d176abc51372e51dbfab07c3a670e1282a5061c83556583f"
}
]
}
67 changes: 67 additions & 0 deletions research/rational-box-fraction-free/TASK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"schema_version": 1,
"task_id": "replay-runtime",
"priority_revision": 8,
"base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc",
"original_card": {
"id": "replay-runtime",
"question": "Can one measured replay bottleneck be sped up without dropping coverage?",
"starting_points": [
"scripts/run_isolated_tests.py",
"scripts/verify_replay_coverage.py",
"certificates/selected-result.json"
],
"methods": [
"Profile one isolated replay and optimize the measured bottleneck.",
"Design source-bound reuse with explicit dependency invalidation and negative controls."
],
"acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.",
"first_step": {
"command": [
"python3",
"-B",
"scripts/research_selected_baseline.py"
],
"expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY",
"inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.",
"scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse."
},
"first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.",
"bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.",
"allowed_variations": [
"Profile one stage or design one source-bound cache boundary."
],
"scope_change_triggers": [
"Skipping coverage or comparing different fixtures to claim speedup."
],
"overlap_terms": [
"replay runtime",
"cache invalidation",
"isolated tests"
]
},
"scope_status": "refined",
"actual_scope": "An opt-in fraction-free integer solve kernel in the unchanged complete rational-box optimizer, with byte-identical certificates and complete-process timing.",
"scope_change_reason": "Refine replay-runtime to an originally posed exact parameter-tool improvement. No predecessor audit or source-specific mathematical extension is the deliverable.",
"bottleneck_link": "Cheaper complete exact parameter optimization can reduce the cost of finding and certifying bounded supplier parameter choices. Source-to-constraint correctness remains separate.",
"budget_minutes": 60,
"stop_rule": "Ship the first exact candidate with a measured complete-path improvement; do not expand the search or claim a new kappa.",
"outcome": "completed",
"evidence": "5,985 exact systems; eight kernel controls; six unchanged inherited test groups; complete CLI byte equality; all three source mutations reject; seven alternating complete CLI pairs per arm. See README and generated stdout receipts.",
"author": "Nick Petalas",
"ai_assistance": "Independent human and formal proof-kernel review are unclaimed.",
"open_questions": [
{
"question": "Can the unchanged complete feasibility checks be accelerated without changing the first optimal basis or output bytes?",
"why_it_matters": "They and interpreter startup remain after the integer solve improvement.",
"first_step": "Profile a complete authenticated caller after installing the present kernel, separately from reported timing.",
"blocked_by": "A new bounded correctness and performance comparison is required; no second optimization is supplied here."
},
{
"question": "Which authenticated supplier parameter problem benefits from this complete solver?",
"why_it_matters": "The present six-cycle fixture is a tool workload, not a supplier invoice.",
"first_step": "Derive every closed linear constraint from one pinned complete bill and include a positive margin variable.",
"blocked_by": "Native, ownership, restoration, compiler and outer conditions are not established by an LP optimum."
}
]
}
36 changes: 36 additions & 0 deletions research/rational-box-fraction-free/VERIFY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"schema_version": 1,
"status": "ready",
"python": "3.12",
"requirements": [],
"inputs": [
"scripts/compare_recursive_invoices.py",
"scripts/optimize_rational_box.py",
"tests/test_research_rational_box.py"
],
"commands": [
{
"argv": [
"{python}",
"-B",
"-W",
"error",
"{package}/verify.py"
],
"timeout_seconds": 120,
"checks": "5,985 exact systems, kernel boundaries, six inherited test groups, complete CLI byte equality and three actual source corruptions."
},
{
"argv": [
"{python}",
"-O",
"-B",
"-W",
"error",
"{package}/verify.py"
],
"timeout_seconds": 120,
"checks": "The same checks with assertions disabled; all new checks use explicit exceptions."
}
]
}
Loading