A scan and analysis tool based on the m4/m6 pair predicate decomposition of the Collatz-type map \(T(n) = (xn+1)/2^d\). This is an implementation of Algorithm 7.1 from the paper "Pair Predicate Decomposition of the Collatz-type Map \((xn+1)/2^d\) and Structural Closure of \(3n+1\)," providing the following features.
| Parameter \(x\) | \(s = \log_2(x-1)\) | Reference pattern | Status |
|---|---|---|---|
| 3 | 1 (odd) | ref_R=(a[i-1], b[i]), ref_L=(b[i], a[i]) | Dedicated optimization available |
| 5 | 2 (even) | ref_R=(b[i-1], b[i]), ref_L=(a[i-1], a[i]) | Dedicated optimization available |
| 9 | 3 (odd) | Generic pattern | Generic routine |
| 17 | 4 (even) | Generic pattern | Generic routine |
| 33, 65, 129, … | 5, 6, 7, … | Generic pattern | Generic routine |
Constraint: \(x \geq 3\) and \(x-1\) must be a power of 2.
src/ ├── lib.rs # Crate root (public API definitions) ├── main.rs # CLI entry point ├── gui.rs # GUI entry point (egui) ├── pair_number.rs # PairNumber type (m4/m6 bit-pair representation) ├── reference.rs # Reference patterns (implementation of Table 3.1) ├── scan.rs # Single-step scan (including GPK classification) ├── postprocess.rs # Postprocessing (MSB trimming, trailing zero removal, re-pairing) ├── trajectory.rs # Trajectory tracking / stopping time calculation └── verify.rs # Range parallel verification (rayon)
Input n (BigUint)
│
├─ [Trajectory tracking path] ─── PairNumber conversion → scan::collatz_step → postprocess → record
│ (retains m4/m6, GPK sequence, d for each step)
│
└─ [Stopping time path] ─── u128 direct arithmetic → BigUint fallback
(fast arithmetic without going through PairNumber; GPK computed via bit extraction)
| Trajectory tracking path | Stopping time path | |
|---|---|---|
| Purpose | Single analysis (GUI single tab) | Range verification (GUI range tab) |
| Internal representation | PairNumber (Vec<u8> per bit) | u128 / BigUint direct arithmetic |
| GPK acquisition | By-product of scan function (GPK sequence per pair) | Computed directly from bit sequence (statistics only) |
| Output | n', d, GPK sequence for all steps | Stopping time + GPK aggregate statistics |
| Speed | Slow (detailed data for research) | Fast (for bulk verification) |
stopping_time_u64_fastOptimized path for u64 input.
current * x + 1 in u128trailing_zeros(), then right-shift(u128::MAX - 1) / xBigUint::*=, +=, >>=to_bytes_le()stopping_time_with_gpkGeneric path for BigUint input. Same logic as Phase 2.
| Limit | Value | Purpose |
|---|---|---|
| MAX_PAIR_COUNT | 10,000 pairs | Memory limit for trajectory tracking path |
| MAX_BIT_LENGTH | 20,000 bits | Bit-length limit for stopping time path |
| max_steps | Configurable in GUI | Truncation for divergent series |
For each pair position \(i\), from the 4 bits \((p_r, q_r, p_l, q_l)\) based on the reference pattern:
m6 stage: g_mid = p_r & q_r, p_mid = p_r ^ q_r
m4 stage: g_out = p_l & q_l, p_out = p_l ^ q_l
Serial composition: G_i = g_out | (p_out & g_mid)
P_i = p_out & p_mid
K_i = otherwise
Records the maximum length of chains starting from the initial carry \(c=1\) and chains after regeneration by G. Aggregated as a histogram (distance 0–127).
| \(3n+1\) | \(5n+1\) | \(17n+1\) | |
|---|---|---|---|
| G% | 38.41 | 36.91 | 37.26 |
| P% | 28.32 | 25.45 | 25.09 |
| K% | 33.26 | 37.64 | 37.65 |
| G/K ratio | 1.15 | 0.98 | 0.99 |
| Element | Description |
|---|---|
x = | Parameter for \(xn+1\). Only values where \(x-1\) is a power of 2 are accepted |
max_steps: | Maximum number of iteration steps. Default 10000 |
| Tab switching | Single analysis / Range analysis / Analysis |
output/ directoryThe output/ folder in the same directory as the exe (created automatically).
gui_trace_{x}n1_{n}[_stopped]_{timestamp}.txt # Trajectory tracking summary
gui_trace_{x}n1_{n}.csv # Trajectory tracking CSV
gui_verify_{x}n1_{start}-{end}[_stopped]_{timestamp}.txt # Range verification summary
# collatz-m4m6 verify range = [3, 9999999] x = 5 total_checked = 4999999 all_converged = false max_stopping_time = 490 max_stopping_time_n = 4580349 # GPK G = 17746659852 P = 12236187544 K = 18094218711 total_pairs = 48077066107 total_steps = 897149444 G% = 36.9129 P% = 25.4512 K% = 37.6359 # Carry chain histogram 0: 720342 1: 1400349 ... elapsed = 79.0672604s
step,n,d,digits,gpk,G,P,K,max_carry_chain 0,27,0,2,,0,0,0,0 1,41,1,2,PGP,1,2,0,2 ...
# Use build_gui.ps1 $env:PATH = "C:\msys64\mingw64\bin;C:\Users\ykihi\.cargo\bin;" + $env:PATH cargo build --release --features gui --bin collatz-gui
target\release\collatz-gui.exe
| \(x\) | Time | nums/s | Avg steps/number |
|---|---|---|---|
| 3 | 0.49s | 10,200,000 | 3.5 |
| 5 | 79s | 63,300 | 179 |
| 17 | 1654s | 3,020 | 456 |
| Version | Method | 5n+1 (\(n \leq 10^6\)) speed |
|---|---|---|
| v0.1 | PairNumber + BigUint conversion/step | 46ms/number (92 numbers/5.65s) |
| v0.2 | BigUint direct arithmetic + u128 fast path | 8μs/number (499,999/4s) |
| Improvement factor | Approx. 5,750x |
.txt files in output/. Direct viewing of CSV files is not yet implemented