gold 4/5/2026. Advisor requests similar to previous snippets, but on topic of Collatz variants and better organizing snippets into modular snippets inside modular structured programs.
I do not have all the answers. The Ideas Seemed to work, but maybe drawbacks? When measured by the Tcl timing statements, completion times and solutions of parameters will differ on different computer set-ups. Assume a future maintainer, either AI Model or human programmer, would have to maintain code with info content and explanatory variable name in program, ref "Snippets Concepts Effects". The Nassi Shneiderman Diagrams NSD or Flowcharts pertain to the Tool Control Language TCL computer language as well as other computer languages like Python 3, pseudocode, word logic problems, and technical reports.
For each logic condition selecting a path or calculation task, we might have one, two, or multiple deterministic branches. Attempting to adapt format to multiple probabilistic branches used in Artificial Intelligence AI Models.
Particularly, the Collatz Conjecture offers a variety of situations where the NDS diagrams are useful in studying the low level logic of sequence calculations. Examines the iterative sequence for the question of how many steps, or iterations, each number requires before reaching 1 remains central. Since the Collatz Sequences are infinite, we will be modeling core concepts as flowcharts, but will simplify to ideal behavior in models/code and probably truncate after the interesting portions.
The TCL Snippets illustrate ideal mathematical behavior only and do not perform full simulation, actual measurements, or state vector evolution. The tool only visualizes ideal math structure, whereas no state vector simulation, probabilities, or actual measurement outcomes are derived. This tool for visualization does not simulate actual measurement outcomes or state vector evolution during operations. These are idealized protocols for tutorial purposes. Primarily, TCL /TK uses its strong points here for book keeping and displays. The example tool is not a full emulator. Meaning, limited scope for tutorial purposes.
Disclaimer. None of the computer programs, numerical experiments, power-law fits, or physical analogies described here give a strict, formal proof of the Collatz Conjecture, either individually or in combination. The tools and analogies are heuristic models and visualization tools that follow engineering “rules of thumb.” Whereas, pure mathematics has its own shop rules for what counts as a rigorous proof. Any opinions on the difficulty or plausibility reflect current understanding here and programming of the Collatz Conjecture as a very hard open problem, not a completed exact math proof, and are offered with full respect for the standards of professional mathematicians.
In debugging the calculations, some of the printout values reflect roughly 17-digit precision output from a typical double-precision computation. It's not "true exact" beyond 5 significant figures. Extra significant figures are used to check the calculations from other computer set-ups, not necessarily to infer accuracy of data measurements here. Typically, the slight differences in decimal places on far right of decimal point are normal floating-point behavior in Tcl's expr.
The classic Collatz conjecture applies deterministic rules based on parity. Probabilistic variants relax this determinism by modeling steps as random choices with assigned weights.
1) One widely studied heuristic treats the sequence as a random walk on the logarithms of the numbers.
2) A second key variant appears in stochastic Collatz maps analyzed in papers by Kontorovich and others. Here the process no longer checks parity strictly. Instead each iteration independently selects the divide-by-two branch with probability two thirds or the multiply-by-three-plus-one branch with probability one third. These probabilities arise from the long-run parity statistics observed in Collatz sequences. The resulting Markov chain converges almost surely to the trivial cycle at one because the negative drift dominates. This model directly supports probabilistic documentation because each branch now carries explicit probability weights rather than fixed true-false outcomes.
3) A third adaptation treats Collatz as a multi-outcome decision node suitable for artificial intelligence AI decision trees.
These probabilistic variants do not prove the original conjecture. The probabilistic variants do supply strong heuristic evidence that divergence or non-trivial cycles have probability zero.
The Collatz algorithm was redesigned for options on a probabilistic algorithm . The original code applied 3n+1 with probability at 1/3, when the number was odd. The expected growth ratio per step under that gamed design is (2/3 * 1/2) + (1/3 * 3) = 4/3. Meaning sequences at ratio = 4/3 grow on average and rarely converge. The revised runProbCollatz first checks parity with $currentValue % 2 == 0, then applies either the standard Collatz rule (with probability 2/3) or the swapped rule (with probability 1/3). With the probability at 2/3, the sequence follows the proven convergent path. With the probability at 1/3, the deviation can still cause divergence for some seeds. The 1000-step cap correctly catches the divergent seeds, and reports any endless loops, we hope. The divergent cases are the scientifically interesting output. The divergent cases show which seeds are most sensitive to rule deviations.
A more AI-like version of the Collatz row logic would be:
1. Encode current state.
- `n := n / 2` for even-state compression.
- `n := 3n + 1` for odd-state expansion.
- `return to parity test` for loop recurrence.
- `halt successfully` for the terminal state.
- `abort iteration` for safety cutoff or overflow.
- State token instead of just branch number.
- Transition rule instead of only probability.
- Confidence / risk as a proxy for activation strength or path reliability.
- Audit note for explanation trace.
- Next Logic Step for the immediate state update.
2. Score candidate transitions.
3. Choose the strongest branch.
4. Apply the next state update.
5. Re-score at the new state.
6. Stop on terminal condition or safety limit.That is closer to AI probabilistic inference than a plain deterministic loop, while still preserving the Collatz structure. The current Mockup program can be adapted more closely to AI-style probabilistic logic. Treat each branch as a scored transition rather than a simple arithmetic step. Instead of only even/odd, the program could model state → test → weighted transition → next state, which is closer to how large LLM models move through many internal branch probabilities.
gold 4/6/2026. This TCL program was written to simulate an Artificial Intelligence AI style Algorithm of the Collatz Conjecture. Program deck contains multiple estimation procs. First, a separate state machine that computes some samples of the Collatz sequences by standard deterministic iteration. As a second proc set for comparison, a separate AI-style Algorithm was computed as probabilistic random walk choices. The program implements 6 Artificial Intelligence (AI) weighting signals — parity, trend pressure, bit pressure, budget pressure, repeat Risk, and entropy Pressure. There is a diagnostic printout with the "hooks" or variable diagnostics to address AI-like simulation parameters. This program gets gritty pretty fast. These probabilistic variants do not prove the original conjecture.
At inference time, the typical LLL model does not explore thousands of independent token branches in a brute-force way. Instead, the AI diagnostic parameters constrain the probability distribution over the next token to a narrow, coherent set of likely choices. Obviously, thousands of token values would cost computer time, beyond the scope here. Maybe 4-12 weighted branch "tokens" would give the human reader the flavor of AI handling the Collatz numbers, bound by the architected modular AI weighting system. Using typical transformer architecture parameters as a problem constraint as opposed to thousands of weighted token branches. in other words, the program does not model the sheer volume of LLM token branches.
In the TCL program, the six signals in computeAiWeights act as lightweight constraints. The signals are Parity, trendPressure, bitPressure, and budgetPressure., repeat Risk, and entropy Pressure. The six signals together bias the choice between standard and swapped actions. This approach avoids simulating the full explosion of token-level branches that an LLM would face with a vocabulary of 50,000 or more token entries. The artificial intelligence (AI) weighting module computes a simple two-way decision (standard versus swapped) under those constraints.
The temperature measurement in large language models serves as a diagnostic tool for controlling randomness during sampling. Classic AI temperature does not exist as a direct setting in the current Probabilistic Collatz Variant program. For here, AI-like Temperature is estimated more as a follow-up diagnostic concept that measures how closely the probabilistic choices stay to the standard deterministic Collatz behavior. The current program used with the default settings, and without explicit temperature, already leans conservative. Current code favors contraction and avoids excessive divergence as default. Adding temperature as a tunable diagnostic would let users experiment with hotter or cooler runs.
The temperature control now behaves somewhat like in transformer-based large language models while keeping the program lightweight and fully auditable. The output file clearly shows how temperature affects closeness to the deterministic reference. Once the console is opened, successive commands with the various seed and temperature options will preserve your "scorecards" on the Collatz Sequences.
How Each Signal Contributes in Practice from preliminary testcases. The program uses signals as AI-like constraints on the Collatz variant in probabilistic random walk choices. These results are from random walk choices, so your results may not be identical numbers.
Parity (p) is the base layer. Even numbers give 80 % standard weight, odd numbers 75 %. In every run, Parity sets the floor. Without Parity, the walk would be pure noise.
TrendPressure (t) is the “brake pedal.” TrendPressure only activates when the last three values are strictly increasing. In seed 27 (the famous long hailstone), t = 0.10 appeared repeatedly in the middle of the run, helping to cut the expected 111 deterministic steps down to 80. It directly fights expansion.
BitPressure (b) is the "size watchdog." For seed 97 (long run of 423 steps) b stayed at 0.10 for most of the second half. This signal alone explains why the AI version avoided blow-up while pure random would have exploded earlier.
BudgetPressure (bu) is the “time-is-running-out” signal. BudgetPressure ramps linearly from 0 to 0.15. In seed 97, BudgetPressure reached 0.13 by step 422 and helped lock w_std near 0.87. This is exactly how AI search algorithms shift to exploitation near a deadline.
RepeatRisk (r) is the "repetition penalty." RepeatRisk is almost always 0.08 when active. In seed 5 RepeatRisk triggered the loop_det after only 3 steps; in seed 100 after 44 steps. It is the cheapest and most effective cycle-breaker.
EntropyPressure (e) measures "calm-down from chaos." EntropyPressure spikes to 0.05 when variance is high. In seed 2, EntropyPressure stayed at maximum for the last 10 steps, yet could not prevent blow-up. In seed 27, EntropyPressure helped calm the trajectory after the peak. Entropy is the “calm-down” signal.
AI-Like Model Temperature is the final master dial. At 1.0 it gives the balanced behavior we see above. Lower values (e.g. 0.8) would have made every run look more like the deterministic column; higher values (1.5) would have produced more loop_det and blowup_cap exits.
Recommended Expanded Test Set (20–25 cases). Many short numbers (2, 3, 5, 7, 9, 15, 25, 100) finish in under 30 steps. Meaning, signals like budgetPressure and bitPressure barely have time to activate. Only a few long ones (27 and 97) show the full dynamics. Get very few data points for repeatRisk and entropyPressure in action across many different regimes.
Short / Easy (baseline behavior): 2, 3, 5, 7, 9, 15, 21, 25, 31, 63 Medium (good signal activity): 27, 41, 57, 73, 85, 97, 111, 129 Long / Challenging (rich signal data): 637, 703, 871, 1132, 1234, 6171, 9663, 18127, 270271 Very Large (tests safety signals): 1000000, 9999999
The Collatz conjecture is an ideal playground for teaching AI concepts. The problem is simple enough to run in Tcl, yet rich enough to expose parity bias, expansion risk, repetition penalties, entropy, and budget pressure. These are exactly the same ideas that appear in transformer attention and sampling.
The program proves that “AI-like” behavior can be achieved with only 6 floating-point calculations per step. This is valuable for collegiate labs: students can see the signals change in real time, modify the coefficients, and immediately observe the effect on convergence rate and loop frequency.
Temperature control is the single most powerful pedagogical tool in the system. Students can run the suite at 0.7 (very deterministic) versus 1.5 (highly exploratory) and watch the average P-D difference swing from negative to positive. This directly illustrates how LLMs trade creativity for coherence. The dual-output design (console + collatz_results.txt) and automatic wiki tables make the program self-documenting.
Exploring ways to make the program's logic flow more closely resemble how artificial intelligence (AI) models process iterative mathematical problems. The Collatz conjecture provides an ideal test case. The structure of the Collatz Conjecture mirrors the kind of probabilistic, branch-weighted decision-making that large language models (LLMs) use internally. The parity node is the correct intervention point adapt the program closer to AI probabilistic logic flow.
The parity decision is the correct place to insert AI-style divergence. Every Collatz step branches at exactly one point: the parity check that decides whether to divide by 2 or apply the 3n plus 1 rule. That single node is where the standard deterministic algorithm and a probabilistic AI-style algorithm differ.
Note. These Snippets on Theoretical Physics are a set, not stand alones. Recommend read all of the set.
Log2 vs Log2 plot is closest to a lion tamer that I know. Points would follow straight line if linear data. Some points or "binary probabilistic bins in computer lingo" are reused and overlaid, making a cleaner look to a non-linear function.
Classic NSD graphs drawn here, rest of page is based on Wiki table format.
---- ***Figure. TEMPERATURE EFFECT ON AI BEHAVIOR *** ---- figure. TEMPERATURE EFFECT ON AI BEHAVIOR +----------------------------------------------------------------------------------+ | TEMPERATURE EFFECT - AI Randomness Control | | | | Temperature Value Behavior Randomness Level | | ────────────────── ───────────────────── ───────────────────── | | < 0.8 Very Conservative Low (Close to Deterministic) | | 0.8 – 1.2 Balanced / Neutral Medium (Recommended) | | > 1.3 Aggressive / Chaotic High (More Swapped Actions) | | | | Lower Temperature → Stronger bias toward standard Collatz rule | | Higher Temperature → More exploration, higher chance of loops & caps | | | | Default: Temperature = 1.0 (Neutral) | +----------------------------------------------------------------------------------+ ---- ***Figure. 6 AI SIGNALS USED IN WEIGHT CALCULATION *** ---- figure. 6 AI SIGNALS USED IN WEIGHT CALCULATION +----------------------------------------------------------------------------------+ | 6 AI SIGNALS - Probabilistic Decision Engine | | | | Signal Purpose Effect | | ───────────────── ──────────────────────────────── ─────────────────── | | 1. Parity Even / Odd status Base probability | | 2. TrendPressure Rising values in last 3 steps Encourages expansion | | 3. BitPressure Bit length of current number Blowup risk warning | | 4. BudgetPressure Steps used vs total limit Urgency to finish | | 5. RepeatRisk Number seen recently Loop prevention | | 6. EntropyPressure Variance in recent values Chaos / randomness | | | | These 6 signals dynamically adjust weights between "Standard" and "Swapped" | | rules at every step. | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. TEMPERATURE vs RANDOMNESS SPECTRUM +----------------------------------------------------------------------------------+ | TEMPERATURE vs RANDOMNESS SPECTRUM | | | | Cold ←──────────────────── Neutral ─────────────────────→ Hot | | 0.6 0.8 1.0 1.2 1.5 | | │ │ │ │ │ | | Mostly Slight Balanced More Highly | | Deterministic Randomness Exploration Swaps Chaotic | | | | • Closer to classic Collatz • Higher chance of long paths & caps | | • More predictable results • Greater variation between runs | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. PROBABILISTIC COLLATZ VARIANT OVERVIEW +----------------------------------------------------------------------------------+ | PROBABILISTIC COLLATZ VARIANT - Tcl Implementation | | | | ┌─────────────────────┐ | | │ seedTheRandom │ | | └──────────┬──────────┘ | | ▼ | | ┌─────────────────────┐ ┌─────────────────────┐ | | │ runDetStateMachine │ │ runAiProbCollatz │ | | │ (Deterministic) │ │ (AI Probabilistic) │ | | └──────────┬──────────┘ └──────────┬──────────┘ | | │ │ | | └──────────────┬──────────┘ | | ▼ | | printAllResults + Wiki Tables | | | | Compares classic Collatz with AI-weighted probabilistic choices | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. COLLATZ DECISION ENGINE +----------------------------------------------------------------------------------+ | COLLATZ DECISION ENGINE | | | | Current Number (n) | | │ | | ▼ | | assessState() | | (parity, magnitude, risk, trend) | | │ | | ┌────────────┼────────────┐ | | │ │ │ | | ▼ ▼ ▼ | | Deterministic Probabilistic Swapped Rule | | (Standard) (Weighted) (Opposite) | | │ │ │ | | └────────────┼────────────┘ | | ▼ | | applyAction() | | | | AI uses 6 signals: parity, trend, bitPressure, budget, repeatRisk, entropy | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. AI PROBABILISTIC CHOICE +----------------------------------------------------------------------------------+ | AI PROBABILISTIC CHOICE (Temperature Controlled) | | | | Temperature = 1.0 → Neutral (balanced randomness) | | Temperature < 1.0 → Cooler (more deterministic) | | Temperature > 1.0 → Hotter (more chaotic) | | | | Base Weights: | | Even n → 80% Standard / 20% Swapped | | Odd n → 75% Standard / 25% Swapped | | | | Adjusted by: trendPressure, bitPressure, budgetPressure, | | repeatRisk, entropyPressure | | | | Final choice made by drawFromWeights() | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. SAFETY CAPS & DEFENSIVE DESIGN +----------------------------------------------------------------------------------+ | SAFETY CAPS & DEFENSIVE PROGRAMMING | | | | CAP 1 : Step Limit (maxStepLimit = 500) | | CAP 2 : Blowup Limit (n > 1,000,000,000) | | CAP 3 : Loop Detection (visited values check) | | | | When any cap fires → logCapDiagnosis() writes to collatz_cap_log.txt | | | | Pure Integer Discipline + History Tracking | | Prevents infinite loops and floating-point drift | +----------------------------------------------------------------------------------+ ---- ***Figure. *** ---- figure. PROGRAM FLOW & OUTPUT +----------------------------------------------------------------------------------+ | PROGRAM FLOW | | | | seedTheRandom() | | │ | | ▼ | | ┌───────────────────────┐ | | │ Test Suite Runner │ | | └──────────┬────────────┘ | | │ | | ┌──────┴──────┐ | | │ │ | | Deterministic Probabilistic | | State Machine AI Model | | │ │ | | └──────┬──────┘ | | ▼ | | printAllResults() | | │ | | ▼ | | Two Wiki Tables + Summary Statistics + Log File | +----------------------------------------------------------------------------------+
table, printed in TCL format, Partial Collatz Sequences up to 30, omitting long/infinite tails for brevity.
| Index No. # | number | steps shown | partial sequence | note |
|---|---|---|---|---|
| 1 | 1 | 0 | 1 | (already at end) |
| 2 | 2 | 1 | 2 1 | |
| 3 | 3 | 7 | 3 10 5 16 8 4 2 1 | |
| 4 | 4 | 3 | 4 2 1 | |
| 5 | 5 | 5 | 5 16 8 4 2 1 | |
| 6 | 6 | 8 | 6 3 10 5 16 8 4 2 1 | |
| 7 | 7 | 16 | 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 8 | 8 | 3 | 8 4 2 1 | |
| 9 | 9 | 19 | 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 10 | 10 | 6 | 10 5 16 8 4 2 1 | |
| 11 | 11 | 14 | 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 12 | 12 | 9 | 12 6 3 10 5 16 8 4 2 1 | |
| 13 | 13 | 9 | 13 40 20 10 5 16 8 4 2 1 | |
| 14 | 14 | 17 | 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 15 | 15 | 17 | 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 | |
| 16 | 16 | 4 | 16 8 4 2 1 | |
| 17 | 17 | 12 | 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 18 | 18 | 20 | 18 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 19 | 19 | 20 | 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 20 | 20 | 7 | 20 10 5 16 8 4 2 1 | |
| 21 | 21 | 7 | 21 64 32 16 8 4 2 1 | |
| 22 | 22 | 15 | 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 23 | 23 | 15 | 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 | |
| 24 | 24 | 10 | 24 12 6 3 10 5 16 8 4 2 1 | |
| 25 | 25 | 23 | 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 26 | 26 | 10 | 26 13 40 20 10 5 16 8 4 2 1 | |
| 27 | 27 | 111 | 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 ... | very long, abbreviated here |
| 28 | 28 | 18 | 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 29 | 29 | 18 | 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
| 30 | 30 | 18 | 30 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 |
Notes:
“Steps shown” counts transitions before hitting 1 (where and if it does).
Integer Sequences such as for 27 grow extremely long — only a partial chain is included.
All integers up to 30 that reduce to 1 have been fully shown to that endpoint; longer or nonterminating cases would be truncated.
Collatz sequences below 2 are not defined fully, at least in terms of >> my << computing algorithms. Listing Integers 1 and 2 for completeness of table, but questions on definition remains here.
Cutoff date is 2/14/2026.
| Index No. # | n | log2(n) | Legendre_Primes_Est | Calibrated Actual(known) | est bits for N | Sequence (up to 20 terms) | quibble note |
|---|---|---|---|---|---|---|---|
| 1 | 2 | 1.0 | 1 | 1 | 2 | 2→1 | Smallest even; trivial cycle 2→1 |
| 2 | 3 | 1.58 | 2 | 2 | 2 | 3→10→5→16→8→4→2→1 | Classic odd starter: 3→10→5→16→8→4→2→1 (7 steps) |
| 3 | 4 | 2.0 | 2 | 2 | 3 | 4→2→1 | Power of 2; quick to 1 |
| 4 | 5 | 2.32 | 3 | 3 | 3 | 5→16→8→4→2→1 | 5→16→... (5 steps) |
| 5 | 6 | 2.58 | 3 | 3 | 3 | 6→3→10→5→16→8→4→2→1 | Even; merges quickly |
| 6 | 7 | 2.81 | 4 | 4 | 3 | 7→22→11→34→17→52→26→13→40→20→10→5→16→... | 7→22→11→34→17→52→26→13→40→20→10→5→16→... (16 steps) |
| 7 | 8 | 3.0 | 4 | 4 | 4 | 8→4→2→1 | Power of 2 |
| 8 | 9 | 3.17 | 4 | 4 | 4 | 9→28→14→7→... | 9→28→14→7→... (19 steps) |
| 9 | 20 | 4.32 | 8 | 8 | 5 | 20→10→5→16→8→4→2→1 | Merges early |
| 10 | 27 | 4.75 | 9 | 9 | 5 | 27→82→41→124→62→31→94→47→142→71→214→107→322→... | Famous: longest sequence under 100 (111 steps, reaches 9232) |
| 11 | 30 | 4.91 | 10 | 10 | 5 | 30→15→46→23→70→35→106→53→160→80→40→20→10→5→16→... | Even; moderate |
| 12 | 40 | 5.32 | 12 | 12 | 6 | 40→20→10→5→16→8→4→2→1 | Power-of-2 like path |
| 13 | 50 | 5.64 | 15 | 15 | 6 | 50→25→76→38→19→58→29→88→44→22→11→34→17→52→26→13→40→20→10→5→... | |
| 14 | 60 | 5.91 | 17 | 17 | 6 | 60→30→15→46→23→70→35→106→53→160→80→40→20→10→5→16→8→4→2→1 | |
| 15 | 70 | 6.13 | 19 | 19 | 7 | 70→35→106→53→160→80→40→20→10→5→16→8→4→2→1 | |
| 16 | 90 | 6.49 | 24 | 24 | 7 | 90→45→136→68→34→17→52→26→13→40→20→10→5→16→8→4→2→1 | |
| 17 | 200 | 7.64 | 46 | 46 | 8 | 200→100→50→25→76→38→19→58→29→88→44→22→11→34→17→52→26→13→40→... | Power of ten region |
| 18 | 300 | 8.23 | 62 | 62 | 9 | 300→150→75→226→113→340→170→85→256→128→64→32→16→8→4→2→1 | |
| 19 | 400 | 8.64 | 78 | 78 | 9 | 400→200→100→50→25→76→38→19→58→29→88→44→22→11→34→17→52→26→... | |
| 20 | 500 | 8.97 | 95 | 95 | 9 | 500→250→125→376→188→94→47→142→71→214→107→322→161→484→242→... | |
| 21 | 600 | 9.23 | 114 | 114 | 10 | 600→300→150→75→226→113→340→170→85→256→128→64→32→16→8→4→2→1 | |
| 22 | 700 | 9.45 | 127 | 127 | 10 | 700→350→175→526→263→790→395→1186→593→1780→890→445→1336→668→... | |
| 23 | 800 | 9.64 | 143 | 144 | 10 | 800→400→200→100→50→25→76→38→19→58→29→88→44→22→11→34→17→52→... | π(800)=144 exact |
| 24 | 900 | 9.81 | 154 | 154 | 10 | 900→450→225→676→338→169→508→254→127→382→191→574→287→862→431→... | |
| 25 | 1000 | 9.96 | 177516 | 176000 | 10 | 1000→500→250→125→376→188→94→47→142→71→214→107→322→161→484→... | Known exact π(1000)=168 |
| 26 | 1000000 | 19.93 | 78498 | 78498 | 20 | — | Standard benchmark, estimates, integer exceeds available space |
| 27 | 63728127 | 25.9 | 4217423 | 4207968 | 26 | — | Famous Collatz: very long trajectory under 1e8 (949 steps nearby), estimates, integer exceeds available space |
| 28 | 1e12 | ~39.8 | 37607912 | 37250000 | 40 | — | estimates, integer exceeds available space |
| 29 | 1e18 | ~59.8 | 24739955 | 24739955 | 60 | — | estimates, integer exceeds available space |
| 30 | 1e21 | ~69.7 | 403800000 | 400000000 | 70 | — | estimates, integer exceeds available space |
| 31 | 1.18e21 (≈2^70) | ~70 | 1340000000 | 1328000000 | 71 | — | estimates, integer exceeds available space, Major Collatz milestone: verified ~2023 |
| 32 | 2.36e21 (≈2^71) | ~71 | 481000000 | 477000000 | 72 | — | estimates, integer exceeds available space, Current frontier (2026): Collatz holds for ALL n below ~2.36e21 (Barina et al.; no counterexamples) |
Notes on Primes. Quick estimates for Collatz-scale numbers. Cutoff date is 2/14/2026.
For small n:
pi(63728127) ≈ 4207968 primes (2590 bits) pi(2.36e21) ≈ 477000000 primes (711000 bits) pi(1180591620717411303424) ≈ 1328000000 primes (2333000 bits)
Comparison to the famous Legendre approximation for primes. Legendre conjectured (around 1798–1808) that:π(x) ≈ x / (log x − 1.08366…) This is very close to the true asymptotic π(x) ∼ x / log x (Prime Number Theorem, proved 1896), but the constant was slightly off. The real bias term is closer to 1 in the long run.
Collatz scale on iterations. Collatz Numbers under 100 million produce 949 steps maximum. The starting number 63,728,127 achieves this record. Numbers under 1 billion reach 986 steps with 670,617,279 as champion.
| Index | Variant | Decision Rule | Predictability | Convergence | Exploration | Quibble Notes |
|---|---|---|---|---|---|---|
| 1 | Standard Collatz (Classic) | Always fixed (n/2 even, 3n+1 odd) | Completely deterministic | Always reaches 1 (observed) | None | The original famous conjecture. Most predictable. |
| 2 | Deterministic State Machine | Same fixed rules via state machine | Completely deterministic | Always reaches 1 | None | Clean modular implementation used as reference column. |
| 3 | Pure Probabilistic (Random) | Random choice between standard and swapped | Highly random, different each run | Often fails, hits loops/caps | Very high | Too chaotic. Many early terminations. |
| 4 | AI-Weighted Probabilistic (V10) | 6 signals + temperature control | Controllable randomness | Some qualified convergence thanks to signals | Balanced | Current version for educational uses. Mimics LLM-style reasoning. |
| Index | Aspect | Standard Collatz (Classic) | Deterministic State Machine | Probabilistic Random | AI-Weighted Probabilistic (V10) | Quibble Notes |
|---|---|---|---|---|---|---|
| 1 | Decision Rule | Always fixed (even: n/2, odd: 3n+1) | Same as classic, via state machine | Random choice between standard and swapped | Dynamic probability based on 6 AI signals + temperature | Current version — adapts like an LLM. |
| 2 | Predictability | Completely deterministic | Completely deterministic | Highly random (differs every run) | Controllable randomness (via temperature and signals) | Most tunable and educational. |
| 3 | Convergence Behavior | Always reaches 1 (observed) | Same as classic | Often converges but can loop or hit caps | Much better convergence thanks to smart signals | Clear winner for reliability. |
| 4 | Loop Prevention | None needed | None needed | Basic loop detector | Advanced: RepeatRisk + visited window + entropy control | Excellent safety features. |
| 5 | Exploration vs Safety | No exploration | No exploration | High exploration, frequent blowups/loops | Balanced: explores while using signals for safety | Best balance of creativity and control. |
| 6 | Steps Taken (typical) | Fixed for each seed | Same as classic | Highly variable | Moderately variable, tunable with temperature | Controllable variation is very useful. |
| 7 | Educational Value | Basic number theory | Good for state machines | Shows randomness effect | Demonstrates LLM-style reasoning | Highest educational value. |
| 8 | Computational Cost | Very low | Very low | Low | Still low (6 lightweight signals) | Efficient even with AI logic. |
| 9 | Main Strength | Simplicity & famous conjecture | Clean modular code | Shows sensitivity to rules | AI-like adaptive decision making | Demonstrates LLM-style reasoning and insightful on AI processes. |
| 10 | Main Weakness | No variation | No variation | Too chaotic, many early terminations | Slightly more complex but still readable | Very minor drawbacks. |
| Index | Signal | Description | Effect on Decision | Quibble Notes |
|---|---|---|---|---|
| 0 | Parity (Base) | Even or odd status of current number | Even: 80% standard / Odd: 75% standard | Foundation signal. The original Collatz bias lives here. |
| 1 | TrendPressure | Checks if last 3 values are strictly rising | +0.10 to standard (contract) when expanding | Acts as an automatic brake when the sequence is growing too fast. |
| 2 | BitPressure | Bit-length of current number (proxy for size) | Up to +0.10 boost to standard on very large numbers | Bigger numbers get gently pushed toward safety (divide). |
| 3 | BudgetPressure | How close we are to the step limit (0 to 500) | Gradually increases preference for standard rule | Near the end, the AI becomes more conservative — like a student rushing to finish the exam. |
| 4 | RepeatRisk | Detects if current number appeared recently | +0.08 to swapped action | Repetition penalty. Helps escape short loops before the hard detector fires. |
| 5 | EntropyPressure | Variance/chaos in recent values | Boosts standard rule when sequence is irregular | High chaos = "calm down and contract" signal. |
| - | Combined + Temperature | All signals summed then scaled by temperature | Final probability between standard and swapped | The AI "thinks" using these 6 signals before every step. |
Note. Using multiple safety caps or clamps. Collatz Sequence is infinite, means danger of endless loops in computer program.
Note. Signals are organized as elements inside TCL program lists as { Signal_0, Signal_1, Signal_2 .... }.
| Index | Signal Name | Description | Weight Effect | Quibble Notes |
|---|---|---|---|---|
| 1 | Parity | Base decision signal. Even numbers favor standard (/2). Odd numbers slightly favor swapped to avoid 3n+1 expansion. | even: 0.80/0.20, odd: 0.75/0.25 | core,always active |
| 2 | TrendPressure | Last 3 values strictly increasing (expansion phase). Adds brake to prevent blow-ups. | +0.10 → standard | expansion brake |
| 3 | BitPressure | Bit-length of current number (log₂n). Larger numbers = higher explosion risk. | bitLen×0.005, max +0.10 → standard | size safety |
| 4 | BudgetPressure | Step count ÷ 500 limit. Ramps contraction bias as time runs out. | (step/500)×0.15 → standard | time→exploit |
| 5 | RepeatRisk | Current value appears in recent 4 values window. Breaks local cycles early. | +0.08 → swapped | LLM rep penalty |
| 6 | EntropyPressure | Variance of recent values (chaos measure). High disorder → restore order. | variance×0.000001, max +0.05 → standard | chaos→order |
| 7 | Temperature | Final scaling factor applied to all weights. Controls exploration vs exploitation. | weights÷temp (1.0=neutral) | master control |
| Audit | - | Six signals + temperature create constrained 2-way decision (standard/swapped). Avoids simulating 50K+ LLM token branches. | Modular AI weights | transformer flavor |
Note. Signals are organized as elements inside TCL program lists as { Signal_0, Signal_1, Signal_2 .... }.
n=27 and n=63728127 , table shows ranges from multiple runs (10).
| Index | Seed | Deterministic Steps | Pure Prob. Avg Steps (10 runs) | Pure Prob. Range | AI Weighted Steps (est.) | Notes |
|---|---|---|---|---|---|---|
| 1 | 27 | 111 | 703 | 8–1000 (30% converge) | 80–110 | Pure prob explodes wildly. AI signals stabilize near deterministic. |
| 2 | 63728127 | 949 | 1000 (5/5 cap out) | 1000 (0% converge) | 600–900 | Pure prob always hits cap. AI bitPressure + budgetPressure save run. |
| Index | Collatz Variant | Steps Predictability ref Classic Collatz | Loop Risk | Educational Value | Quibble Notes |
|---|---|---|---|---|---|
| 1 | Standard / Deterministic | Fixed for each seed | Very Low | Basic | Reliable reference. Always clean. |
| 2 | Pure Probabilistic | Highly variable | High | Medium | Shows sensitivity but too random. |
| 3 | AI-Weighted Probabilistic | Moderately variable, tunable | Low to Medium | High | Best balance. Demonstrates adaptive choices. |
# tcl
# Probabilistic Collatz Variant -- Modular Test Runner V10
# Compares deterministic Collatz reference steps with
# AI-style probabilistic random walk choices.
# Compares deterministic STATE MACHINE steps with
# AI-style probabilistic random walk choices.
# Probabilistic means random simulations -- output differs each run
# unless a fixed seed is supplied to seedTheRandom.
# Using multiple safety caps or clamps, Collatz Sequence is infinite,
# danger of endless loops in program.
# ----
console show
# ============================================================
# RANDOM SEED SETUP
# ============================================================
proc seedTheRandom {fixedSeed} {
if {$fixedSeed == 0} {
set chosenSeed [clock seconds]
} else {
set chosenSeed $fixedSeed
}
expr {srand($chosenSeed)}
puts "Random seed used: $chosenSeed"
return $chosenSeed
}
# ============================================================
# CAP DIAGNOSTIC LOGGER
# ============================================================
proc logCapDiagnosis {startingSeed stepCounter currentValue exitReason stepHistory} {
set diagFile "collatz_cap_log.txt"
set header "CAP FIRED: seed=$startingSeed steps=$stepCounter finalVal=$currentValue reason=$exitReason"
puts " $header"
puts " Last [llength $stepHistory] steps before cap:"
set fileFd ""
catch { set fileFd [open $diagFile a] }
if {$fileFd ne ""} {
puts $fileFd $header
puts $fileFd " Last [llength $stepHistory] steps:"
}
foreach histItem $stepHistory {
lassign $histItem histStep histValue
set diagLine [format " step %-4d value = %d" $histStep $histValue]
puts $diagLine
if {$fileFd ne ""} { puts $fileFd $diagLine }
}
if {$fileFd ne ""} {
puts $fileFd ""
catch { close $fileFd }
}
}
# ============================================================
# STATE MACHINE & AI MODULES (unchanged)
# ============================================================
proc assessState {n} {
set parity [expr {$n % 2 == 0 ? "even" : "odd"}]
set magnitude [expr {$n < 1000 ? "low" : $n < 1e6 ? "medium" : "high"}]
set risk [expr {$n > 1e8 ? "high" : $n > 1e6 ? "medium" : "low"}]
set trend [expr {$parity eq "even" ? "contract" : "expand"}]
return [dict create parity $parity magnitude $magnitude risk $risk trend $trend]
}
proc scoreBranches {state deterministicMode} {
dict with state {}
if {$deterministicMode} {
return {standard 1.0 swapped 0.0}
}
if {$parity eq "even"} {
return {standard 0.80 swapped 0.20}
} else {
return {standard 0.75 swapped 0.25}
}
}
proc chooseAction {branchScores} {
set bestWeight -1
set bestAction ""
dict for {action weight} $branchScores {
if {$weight > $bestWeight} {
set bestWeight $weight
set bestAction $action
}
}
return $bestAction
}
proc applyAction {n action} {
if {$action eq "standard"} {
if {$n % 2 == 0} { return [expr {int($n / 2)}] } else { return [expr {int(3 * $n + 1)}] }
} else {
if {$n % 2 == 0} { return [expr {int(3 * $n + 1)}] } else { return [expr {int(($n + 1) / 2)}] }
}
}
proc computeAiWeights {state n stepCounter maxStepLimit recentVals temperature} {
dict with state {}
if {$parity eq "even"} {
set wStandard 0.80; set wSwapped 0.20
} else {
set wStandard 0.75; set wSwapped 0.25
}
set trendPressure 0.00
if {[llength $recentVals] >= 3} {
set v1 [lindex $recentVals end-2]
set v2 [lindex $recentVals end-1]
set v3 [lindex $recentVals end]
if {$v3 > $v2 && $v2 > $v1} { set trendPressure 0.10 }
}
set bitPressure 0.00
if {$n > 0} {
set bitLen [expr {int(log(double($n)) / log(2.0)) + 1}]
set bitPressure [expr {min($bitLen * 0.005, 0.10)}]
}
set budgetPressure [expr {double($stepCounter) / double($maxStepLimit) * 0.15}]
set repeatRisk 0.0
if {[llength $recentVals] > 0 && [lsearch -exact $recentVals $n] >= 0} {
set repeatRisk 0.08
}
set entropyPressure 0.0
if {[llength $recentVals] >= 2} {
set valCount [llength $recentVals]
set valSum 0.0
foreach v $recentVals { set valSum [expr {$valSum + $v}] }
set mean [expr {$valSum / double($valCount)}]
set variance 0.0
foreach v $recentVals {
set diff [expr {double($v) - $mean}]
set variance [expr {$variance + $diff * $diff}]
}
set variance [expr {$variance / double($valCount)}]
set entropyPressure [expr {min($variance * 0.000001, 0.05)}]
}
set wStandard [expr {$wStandard + $trendPressure + $bitPressure + $budgetPressure + $entropyPressure}]
set wSwapped [expr {$wSwapped - $trendPressure - $bitPressure - $budgetPressure - $entropyPressure + $repeatRisk}]
if {$wSwapped < 0.02} { set wSwapped 0.02 }
set wStandard [expr {$wStandard / $temperature}]
set wSwapped [expr {$wSwapped / $temperature}]
set total [expr {$wStandard + $wSwapped}]
set wStandard [expr {$wStandard / $total}]
set wSwapped [expr {$wSwapped / $total}]
return [dict create standard $wStandard swapped $wSwapped entropyPressure $entropyPressure]
}
proc drawFromWeights {weightDict} {
set wStandard [dict get $weightDict standard]
if {[expr {rand()}] < $wStandard} { return "standard" } else { return "swapped" }
}
# ============================================================
# RUNNERS
# ============================================================
proc runDetStateMachine {startingSeed} {
set n [expr {int($startingSeed)}]
set stepCounter 0
set maxStepLimit 500
set blowupLimit 1000000000
set exitReason "converged"
while {$n != 1 && $stepCounter < $maxStepLimit} {
if {$n > $blowupLimit} { set exitReason "blowup_cap"; break }
set state [assessState $n]
set branchScores [scoreBranches $state 1]
set chosenAction [chooseAction $branchScores]
set n [applyAction $n $chosenAction]
set n [expr {int($n)}]
incr stepCounter
}
if {$stepCounter >= $maxStepLimit && $exitReason eq "converged"} {
set exitReason "step_cap"
}
return [list $stepCounter $exitReason]
}
proc runAiProbCollatz {startingSeed temperature} {
set n [expr {int($startingSeed)}]
set maxStepLimit 500
set blowupLimit 1000000000
set stepCounter 0
set exitReason "converged"
set lastEntropy 0.0
set stepHistory {}; set recentVals {}; set visitedVals {}
set historyMax 8; set recentMax 4; set visitedMax 10
while {$n != 1 && $stepCounter < $maxStepLimit} {
if {$n > $blowupLimit} { set exitReason "blowup_cap"; break }
if {[lsearch -exact $visitedVals $n] >= 0} { set exitReason "loop_det"; break }
lappend visitedVals $n
if {[llength $visitedVals] > $visitedMax} {
set visitedVals [lrange $visitedVals end-[expr {$visitedMax - 1}] end]
}
lappend stepHistory [list $stepCounter $n]
if {[llength $stepHistory] > $historyMax} {
set stepHistory [lrange $stepHistory end-[expr {$historyMax - 1}] end]
}
lappend recentVals $n
if {[llength $recentVals] > $recentMax} {
set recentVals [lrange $recentVals end-[expr {$recentMax - 1}] end]
}
set state [assessState $n]
set weightDict [computeAiWeights $state $n $stepCounter $maxStepLimit $recentVals $temperature]
set lastEntropy [dict get $weightDict entropyPressure]
set chosenAction [drawFromWeights $weightDict]
set n [applyAction $n $chosenAction]
set n [expr {int($n)}]
incr stepCounter
}
if {$stepCounter >= $maxStepLimit && $exitReason eq "converged"} {
set exitReason "step_cap"
}
if {$exitReason ne "converged"} {
set entropyTag [format "%.4f" $lastEntropy]
set exitReason "${exitReason}/ent=${entropyTag}"
}
if {[string match "*cap*" $exitReason] || [string match "*loop*" $exitReason]} {
logCapDiagnosis $startingSeed $stepCounter $n $exitReason $stepHistory
set energyLevel [expr {log(double($stepCounter) + 1.0) / log(2.0)}]
puts [format " Quantum-Level: %.3f for seed=%d" $energyLevel $startingSeed]
}
return [list $stepCounter $exitReason $lastEntropy]
}
# ============================================================
# TEST DATA
# ============================================================
proc getTestCases {} {
return {{2 1} {3 7} {5 5} {7 16} {9 19} {15 17} {25 23} {27 111} {97 118} {100 25}}
}
proc getWikiNotes {} {
return {
{2 "Reaches 1 almost certainly. Very short path."}
{3 "Negative drift from 0.80 divide bias aids convergence."}
{5 "Short paths dominate in stochastic model."}
{7 "Medium length typical. Moderate variation."}
{9 "19 det. steps confirmed by hand trace. Audit corrected V6."}
{15 "Moderate stochastic variation around reference."}
{25 "Longer but still terminates. Spread widens."}
{27 "Famous long hailstone seed. Prob. version often shorter."}
{97 "High variation possible. May hit step cap."}
{100 "Usually moderate length. Even start favors divide."}
}
}
# ============================================================
# CONSOLIDATED OUTPUT SUBROUTINE
# ============================================================
proc printAllResults {resultsList temperature} {
set outFile "collatz_results.txt"
set fd ""
catch {set fd [open $outFile w]}
proc putsDual {fd msg} {
puts $msg
if {$fd ne ""} { puts $fd $msg }
}
set divider [string repeat "-" 105]
putsDual $fd ""
putsDual $fd $divider
putsDual $fd [format "%-8s %-10s %-10s %-12s %-8s %-8s %-8s %-8s %-18s" \
"Seed" "ProbSteps" "DetSteps" "Exit" "Diff" "Temp" "A.Exit" "A.Vec" "Quibble"]
putsDual $fd [format "%-8s %-10s %-10s %-12s %-8s %-8s %-8s %-8s %-18s" \
"" "Steps" "Det" "Reason" "(P-D)" "AI.Temp" "AI.Exit" "AI.Vec" "Notes"]
putsDual $fd $divider
set noteData [getWikiNotes]
foreach res $resultsList {
lassign $res seed probSteps detSteps exitReason lastEntropy
set reasonTag [string range $exitReason 0 11]
set diff [expr {$probSteps - $detSteps}]
if {$temperature < 0.7} { set tempTag "cool"
} elseif {$temperature <= 1.3} { set tempTag "neutral"
} else { set tempTag "hot" }
if {[string match "*loop_det*" $exitReason]} { set aiExit "loop"
} elseif {[string match "*blowup_cap*" $exitReason]} { set aiExit "blow"
} elseif {[string match "*step_cap*" $exitReason]} { set aiExit "step"
} else { set aiExit "conv" }
set aiVec "p,t,b,bu,r,e"
set noteText [format "{%s, %.2f, %s}" $tempTag $temperature $aiExit]
putsDual $fd [format "%-8d %-10d %-10d %-12s %+8d %-8.2f %-8s %-8s %-18s" \
$seed $probSteps $detSteps $reasonTag $diff $temperature $aiExit $aiVec $noteText]
}
putsDual $fd $divider
# === FIRST WIKI TABLE: AI Algorithm Report ===
putsDual $fd ""
putsDual $fd "=== AI Algorithm Report ==="
putsDual $fd ""
putsDual $fd "%| Index | Seed | ProbSteps | DetSteps | Exit | Diff | Temp | A.Exit | A.Vec | Quibble |%"
set idx 1
foreach res $resultsList {
lassign $res seed probSteps detSteps exitReason lastEntropy
set reasonTag [string range $exitReason 0 11]
set diff [expr {$probSteps - $detSteps}]
set aiVec "p,t,b,bu,r,e"
set noteText [format "{%s t=%.2f %s}" $tempTag $temperature $aiExit]
set row "&| $idx | $seed | $probSteps | $detSteps | $reasonTag | $diff | $temperature | $aiExit | $aiVec | $noteText |&"
putsDual $fd $row
incr idx
}
putsDual $fd "&| Audit | - | - | - | - | - | - | - | - | All runs used temperature control and 6 signals. |&"
putsDual $fd ""
putsDual $fd "=== End AI Algorithm Report ==="
# === SECOND WIKI TABLE: General Comparison (unchanged) ===
putsDual $fd ""
putsDual $fd "=== General Comparison Wiki Table ==="
putsDual $fd ""
putsDual $fd "%| Index | Seed | StateMachine.Steps | Prob.Steps(this run) | Behavior Note |%"
set rowIndex 1
foreach res $resultsList {
lassign $res seed probSteps detSteps
set noteText "No note available."
foreach pair $noteData {
lassign $pair noteSeed noteStr
if {$noteSeed == $seed} { set noteText $noteStr; break }
}
set rowText "&| $rowIndex | $seed | $detSteps | $probSteps | $noteText |&"
putsDual $fd $rowText
incr rowIndex
}
putsDual $fd "&| Audit | - | - | - | All state machine seeds reach 1. AI prob. model converges almost surely. |&"
putsDual $fd ""
putsDual $fd "=== End Wiki Table ==="
# Summary (unchanged)
set totalDiff 0; set above 0; set below 0; set equal 0
set auditOK 0; set auditFail 0
set totalCases [llength $resultsList]
set auditList [getTestCases]
foreach res $resultsList {
lassign $res seed p d
set diff [expr {$p - $d}]
set totalDiff [expr {$totalDiff + $diff}]
if {$diff > 0} {incr above} elseif {$diff < 0} {incr below} else {incr equal}
set expected -1
foreach a $auditList {
lassign $a s e
if {$s == $seed} { set expected $e; break }
}
if {$expected >= 0 && $d == $expected} {incr auditOK} else {incr auditFail}
}
set avg [expr {$totalCases > 0 ? double($totalDiff) / $totalCases : 0.0}]
set summaryDivider [string repeat "-" 90]
putsDual $fd ""
putsDual $fd $summaryDivider
putsDual $fd [format "Total cases : %d" $totalCases]
putsDual $fd [format "Above state mach : %d (AI prob. took more steps)" $above]
putsDual $fd [format "Below state mach : %d (AI prob. took fewer steps)" $below]
putsDual $fd [format "Equal state mach : %d (matched state machine)" $equal]
putsDual $fd [format "Avg P-D diff : %+.2f steps" $avg]
putsDual $fd [format "Audit passed : %d / %d" $auditOK $totalCases]
putsDual $fd $summaryDivider
putsDual $fd ""
if {$fd ne ""} { close $fd }
puts "Results also saved to: $outFile"
}
# ============================================================
# MASTER TEST RUNNER
# ============================================================
proc runTestSuite {fixedSeed {temperature 1.0}} {
seedTheRandom $fixedSeed
puts "Running with temperature = $temperature"
set testCaseList [getTestCases]
set resultsList {}
foreach onePair $testCaseList {
lassign $onePair seedValue auditSteps
set detReturn [runDetStateMachine $seedValue]
set detStepCount [lindex $detReturn 0]
set probReturn [runAiProbCollatz $seedValue $temperature]
set probStepCount [lindex $probReturn 0]
set exitReason [lindex $probReturn 1]
set lastEntropy [lindex $probReturn 2]
lappend resultsList [list $seedValue $probStepCount $detStepCount $exitReason $lastEntropy]
}
printAllResults $resultsList $temperature
return $resultsList
}
# ============================================================
# MAIN
#
# ============================================================
runTestSuite 0
# end of file
Note. This V10 is the "Spartan Version" with few explanatory comments and headers.
# culled comments
# ----
# tcl
# Probabilistic Collatz Variant -- Modular Test Runner V10
# Compares deterministic Collatz reference steps with
# AI-style probabilistic random walk choices.
# Compares deterministic STATE MACHINE steps with
# AI-style probabilistic random walk choices.
# Probabilistic means random simulations -- output differs each run
# unless a fixed seed is supplied to seedTheRandom.
# Using multiple safety caps or clamps, Collatz Sequence is infinite,
# danger of endless loops in program.
# ----
# Educational version with visible probabilities (4 sig figs)
# Alternate results in wiki table format (header with %|, alternating rows &|)
# Probabilistic Collatz Variant -- Modular Test Runner V10
# Compares deterministic Collatz reference steps with
# AI-style probabilistic random walk choices using temperature control.
# Temperature = 1.0 is neutral. Lower values stay closer to standard Collatz.
# Probabilistic means random simulations -- output differs each run
# unless a fixed seed is supplied to seedTheRandom.
# Using multiple safety caps or clamps. Collatz Sequence is infinite,
# danger of endless loops in program.
# ----
# Educational version with visible probabilities and temperature diagnostic.
# Alternate results in wiki table format.
# ----
# Tcl/Tk 8.6+ 7-bit ASCII safe. NASA/JPL defensive programming style.
# Compatible with Tcl/Tk (Tool Control Language / Toolkit) 8.6+
# Written for Windows 11 on ActiveState Tcl.
# Pure ASCII code - no Unicode characters used anywhere.
# TCL Club 4/7/2026
# ----
# V10 changes from V9:
# CHANGE -- Added first Wiki Table: AI Algorithm Report (Index + Quibble last)
# CHANGE -- Second Wiki Table remains the general comparison table
# FIX -- Cleaned wiki formatting and braces
# ----
# Educational version with visible probabilities (4 sig figs)
# Alternate results in wiki table format (header with %|, alternating rows &|)
# ----
# Tcl/Tk 8.6+ 7-bit ASCII safe. NASA/JPL defensive programming style.
# NASA/JPL defensive programming style.
# Compatible with Tcl/Tk (Tool Control Language / Toolkit) 8.6+
# Written for Windows 11 on ActiveState Tcl.
# Working under strict 7-bit ASCII encoding.
# Optimized for collegiate information technology lab environments.
# Written to be very modular for transferable procs.
# Program deck may contain multiple estimation procs.
# May contain code dependencies on Active State and Windows 11
# Complex math calculations up to 8 units computer time
# Wait for complete calculations before saving files.
# This is a hacker's patch, not rigorously derived.
# appears correct solutions for autotests.
# pure ASCII code - no Unicode characters used anywhere.
# Approaching =>>> computer time limit on this TCL configuration setup.
# Program contains multiple estimation procs for comparison.
# Uses original 10 test numbers + hardcoded odd steps
# These probabilistic variants do not prove the original conjecture.
# ABOUT srand:
# Tcl seeds rand() via: expr {srand(integerValue)}
# fixedSeed = 0 --> clock seconds (differs each run)
# fixedSeed > 0 --> that integer (reproducible each run)
# ============================================================
# PROBABILISTIC COLLATZ CORE
# Returns a two-element list: {stepCount exitReason}
# exitReason: "converged" | "step_cap" | "blowup_cap"
#
# AI probabilistic choice at every step:
# probability 0.80 --> follow standard Collatz rule (FIX 3)
# probability 0.20 --> apply the opposite (swapped) rule
#
# SAFETY CAPS (all three active):
# CAP 1 -- maxStepLimit 500: hard iteration ceiling. (FIX 2)
# CAP 2 -- blowupLimit 1e9: value ceiling. (FIX 2)
# CAP 3 -- termination via int() nearest-rounding check.
#
# PURE INTEGER DISCIPLINE (FIX 1):
# Every arithmetic result is immediately truncated with int().
# An explicit "force integer" line follows each assignment.
# This eliminates all floating-point residue that previously
# caused the while-condition to miss the value 1.
#
# STEP HISTORY (FIX 4):
# stepHistory keeps the last 8 {stepNumber value} pairs.
# The list is passed to logCapDiagnosis when any cap fires.
# ============================================================
# ============================================================
# RANDOM SEED SETUP
# ============================================================
# ============================================================
# TEST CASE DATA PROVIDER
# Format: {seed deterministicReferenceSteps}
# deterministicReferenceSteps is the classical Collatz step count,
# always the same value, used as the comparison baseline.
# ============================================================
# ============================================================
# CAP DIAGNOSTIC LOGGER
# Called only when a safety cap fires.
# Prints the last 8 steps to console and appends them to
# collatz_cap_log.txt for offline inspection.
# Arguments:
# startingSeed -- original seed that triggered this run
# stepCounter -- number of steps taken before cap fired
# currentValue -- final integer value when cap fired
# exitReason -- "step_cap", "blowup_cap", or "loop_det"
# stepHistory -- list of {stepNum value} pairs, up to 8 entries
# ============================================================
# ----
# AI weighting signals used in computeAiWeights (6 total in V8):
# SIGNAL 0 -- parity (base weight, even or odd)
# SIGNAL 1 -- trendPressure (last 3 values all rising = expansion)
# SIGNAL 2 -- bitPressure (bit-length of n, proxy for blowup risk)
# SIGNAL 3 -- budgetPressure (step fraction of cap, ramp to exploit)
# SIGNAL 4 -- repeatRisk (n in recentVals window = cycle warning)
# SIGNAL 5 -- entropyPressure (variance of recentVals, chaos proxy)
# ----
# ----
# PROBABILISTIC COLLATZ CORE
# Returns a two-element list: {stepCount exitReason}
# exitReason: "converged" | "step_cap" | "blowup_cap"
#
# AI probabilistic choice at every step:
# probability 0.80 --> follow standard Collatz rule (FIX 3)
# probability 0.20 --> apply the opposite (swapped) rule
#
# SAFETY CAPS (all three active):
# CAP 1 -- maxStepLimit 500: hard iteration ceiling. (FIX 2)
# CAP 2 -- blowupLimit 1e9: value ceiling. (FIX 2)
# CAP 3 -- termination via int() nearest-rounding check.
#
# PURE INTEGER DISCIPLINE (FIX 1):
# Every arithmetic result is immediately truncated with int().
# An explicit "force integer" line follows each assignment.
# This eliminates all floating-point residue that previously
# caused the while-condition to miss the value 1.
#
# STEP HISTORY (FIX 4):
# stepHistory keeps the last 8 {stepNumber value} pairs.
# The list is passed to logCapDiagnosis when any cap fires.
# ============================================================
# ============================================================
# MAIN
# Examples:
# runTestSuite 0 → default random seed and default temperature 1.0 (recommended starting point)
# runTestSuite 0 1.0 → default random seed and default temperature 1.0 (recommended starting point)
# ( default temperature close to standard notation in AI models)
# runTestSuite 0 0.8 --> cooler, more deterministic
# runTestSuite 0 1.5 --> hotter, more random
# runTestSuite 0 0.7 → lower temperature choices < 1.0 , stay much closer to standard Collatz iterations
# runTestSuite 77777777 1.4 → different random seed integers !!!, higher temperature choices > 1.0 ,
# higher chance of swapped actions and loop detection, farther from standard Collatz
# runTestSuite 7777487989 1.4 → more exploration, different random seed integers !!!
# higher chance of swapped actions and loop detection
# ============================================================Comparison of Deterministic Steps and Probabilistic Choices in Collatz iterations # Probabilistic means random simulations -- output differs each run # unless a fixed seed is supplied to seedTheRandom. # Using multiple safety caps or clamps, Collatz Sequence is infinite, # danger of endless loops in program.
Random seed used: 1775397967
-----------------------------------------------------------------
Seed Probabilistic StateMachine Exit Diff
Steps(rand) Det.Steps Reason (P - D)
-----------------------------------------------------------------
2 1 1 converge +0
3 2 7 converge -5
CAP FIRED: seed=5 steps=41 finalVal=10 reason=loop_det
Last 8 steps before cap:
step 33 value = 319
step 34 value = 160
step 35 value = 80
step 36 value = 40
step 37 value = 20
step 38 value = 10
step 39 value = 5
step 40 value = 3
5 41 5 loop_det +36
7 3 16 converge -13
9 45 19 converge +26
15 12 17 converge -5
25 10 23 converge -13
27 10 111 converge -101
97 38 118 converge -80
100 12 25 converge -13
| Index | Seed | StateMachine.Steps | AI Prob.Steps(this run) | Behavior Note |
|---|---|---|---|---|
| 1 | 2 | 1 | 1 | Reaches 1 almost certainly. Very short path. |
| 2 | 3 | 7 | 2 | Negative drift from 0.80 divide bias aids convergence. |
| 3 | 5 | 5 | 41 | Short paths dominate in stochastic model. |
| 4 | 7 | 16 | 3 | Medium length typical. Moderate variation. |
| 5 | 9 | 19 | 45 | 19 det. steps confirmed by hand trace. Audit corrected V6. |
| 6 | 15 | 17 | 12 | Moderate stochastic variation around reference. |
| 7 | 25 | 23 | 10 | Longer but still terminates. Spread widens. |
| 8 | 27 | 111 | 10 | Famous long hailstone seed. Prob. version often shorter. |
| 9 | 97 | 118 | 38 | High variation possible. May hit step cap. |
| 10 | 100 | 25 | 12 | Usually moderate length. Even start favors divide. |
| Audit | - | - | - | All state machine seeds reach 1. AI prob. model converges almost surely. |
---- Total cases : 10 Above state mach : 2 (AI prob. took more steps) Below state mach : 7 (AI prob. took fewer steps) Equal state mach : 1 (matched state machine) Avg P-D diff : -16.80 steps Audit passed : 10 / 10 (state machine vs hand-verified)
| Index | Seed | ProbSteps | DetSteps | Exit | Diff | Temp | A.Exit | A.Vec | Quibble |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 196 | 1 | converged | 195 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 2 | 3 | 235 | 7 | converged | 228 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 3 | 5 | 3 | 5 | loop_det/ent | -2 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 4 | 7 | 108 | 16 | loop_det/ent | 92 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 5 | 9 | 73 | 19 | loop_det/ent | 54 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 6 | 15 | 335 | 17 | converged | 318 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 7 | 25 | 63 | 23 | loop_det/ent | 40 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 8 | 27 | 15 | 111 | loop_det/ent | -96 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 9 | 97 | 142 | 118 | blowup_cap/e | 24 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| 10 | 100 | 377 | 25 | converged | 352 | 1.0 | conv | p,t,b,bu,r,e | {neutral t=1.00 conv} |
| Audit | - | - | - | - | - | - | - | - | All runs used temperature control and 6 signals. |
| Index | Seed | Determ.Steps | Prob.Steps(this run) | Behavior Note |
|---|---|---|---|---|
| 1 | 2 | 1 | 1 | Reaches 1 almost certainly. Very short path. |
| 2 | 3 | 7 | 41 | Negative drift from 0.80 divide bias aids convergence. |
| 3 | 5 | 5 | 5 | Short paths dominate in stochastic model. |
| 4 | 7 | 16 | 48 | Medium length typical. Moderate variation. |
| 5 | 9 | 19 | 95 | Quick convergence likely with divide bias. |
| 6 | 15 | 17 | 17 | Moderate stochastic variation around reference. |
| 7 | 25 | 23 | 135 | Longer but still terminates. Spread widens. |
| 8 | 27 | 111 | 130 | Famous long hailstone seed. Prob. version often shorter. |
| 9 | 97 | 118 | 104 | High variation possible. May hit step cap. |
| 10 | 100 | 25 | 238 | Usually moderate length. Even start favors divide. |
| Audit | - | - | - | All deterministic seeds reach 1. Prob. model converges almost surely. |
Total cases : 10 Above ref : 6 (probabilistic took more steps) Below ref : 1 (probabilistic took fewer steps) Equal ref : 3 (matched deterministic exactly) Avg P-D diff: +48.50 steps
# Modular test runner for probabilistic Collatz variant
# prototype code V1
# Clean, wiki-friendly structure with separate procs
# Compares deterministic Collatz with AI-style probabilistic choices.
# probabilistic means using random simulations so
# printout not the same each run.
# Core probabilistic routine (AI choice point clearly marked)
proc run_probabilistic_collatz {seed} {
set n [expr {double($seed)}]
set max_steps 10000
set steps 0
while {$n != 1 && $steps < $max_steps} {
if {rand() < 0.666667} { ;# AI PROBABILISTIC CHOICE: ~2/3 divide-by-2
set n [expr {$n / 2.0}]
} else { ;# ~1/3 3n+1
set n [expr {3.0 * $n + 1}]
}
incr steps
}
return $steps
}
# Modular test data provider
proc get_collatz_test_data {} {
return {
{2 1}
{3 7}
{5 5}
{7 16}
{9 6}
{15 17}
{25 23}
{27 111}
{97 118}
{100 25}
}
}
# Modular test runner (main test procedure)
proc run_collatz_tests {} {
set test_data [get_collatz_test_data]
set results {}
foreach pair $test_data {
lassign $pair seed expected
set result [run_probabilistic_collatz $seed]
lappend results [list $seed $result $expected]
puts "Seed $seed -> $result steps (deterministic ref: $expected)"
}
return $results
}
# Example usage (call this to execute all tests)
# run_collatz_tests
run_collatz_testsmockup TABLE l 3 branches
| Index | Condition | Branch | Probability | Outcome Action | Normalized | Logic Check | Quibble / Notes |
|---|---|---|---|---|---|---|---|
| 1 | if (u < 0.2) | B1 (Small) | 0.20 | recordStep low weight | Yes | Non-negative | Small branch -- typical for rare quantum events |
| 2 | if (0.2 <= u < 0.7) | B2 (Medium) | 0.50 | standard lambda path | Yes | Non-negative | Most likely path in slide rule logic |
| 3 | else (u >= 0.7) | B3 (Large) | 0.30 | fallback / clamp | Yes | Non-negative | Safety default when probability is high |
| Sum / Audit | --- | 1.00 | --- | Yes | Complete + Normalized | Probability audit: nonnegative, exhaustive, sums to 1 |
# Table complete. Rows processed: 3. Audit: Complete + Normalized.
This is a draft. Adapted for NDS MockUp
| Index No. | Branch | Probability | Normalized prob. /Factored | NDS Elements Type | Probabilistic Logic Element | Risk / Confidence Level | Safety Margin | Quibbles and Notes |
|---|---|---|---|---|---|---|---|---|
| 1 | B2 | 1.000000 | yes | testing A1 | Testing extra e | Testing extra e Risk | Safety Margin A | testing comment A |
| 2 | B3 | 0.562500 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin A | testing comment A |
| 3 | B5 | 0.750000 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin A | testing comment A |
| 4 | B7 | 0.237305 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin A | testing comment A |
| 5 | B9 | 0.177979 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin B | testing comment A |
| 6 | B15 | 0.237305 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin A | testing comment A |
| 7 | B25 | 0.133484 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin B | testing comment A |
| 8 | B27 | 0.000008 | no | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin D | testing comment A |
| 9 | B97 | 0.000004 | no | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin D | testing comment A |
| 10 | B100 | 0.133484 | yes | testing A2 | Testing extra e | Testing extra e Risk | Safety Margin B | testing comment A |
| Sum /Audit | testing comment A |
This is a draft. Adapted for NDS MockUp
for the Collatz Conjecture, using the standard rule: if \(n\) is even, divide by 2; if odd, compute 3n+1
3n+1, repeating until n=1
# NSD-style pseudocode
# text
START
INPUT n
WHILE n != 1
IF n is even
n = n / 2
ELSE
n = 3 * n + 1
END IF
OUTPUT n
END WHILE
STOP
# Compact wiki-friendly version
# text
START
Read seed n
While n is not 1
Test parity
If even -> n := n / 2
If odd -> n := 3n + 1
Record n
End While
STOP
# If you want branch labels
# text
WHILE n != 1
IF even branch
Next state: n / 2
ELSE odd branch
Next state: 3n + 1
ENDgold 2/9/2026. Added categories, so can find message in Wiki.
gold 2/3/2025. Testing, encountered initial difficulty in saving work? Long code blocks with or unmatched wiki markup can sometimes confuse the Tcl Wiki formatting engine, especially if fences are not balanced or a line begins with markup it treats specially.
gold 2/14/2026. Added Automatic Dump of Examples, Using ActiveState.
gold 2/14/2026. convert to strict 7-bit ASCII for Playground V9. reporting error at bottom. program should run to completion with automatic test suite.
gold 2/14/2026.
gold 3/7/2026. convert to strict 7-bit ASCII for Playground V9. variables need to be human readable and very explanatory. avoid variables with single letter names. Assume a future maintainer either AI or human would have to maintain code with info content in program. the program is working the numbers correctly . so minimal changes.
gold 3/10/2026. Other than a clipping function or a number clamp { y =< limit } in tcl program, not sure how to separate lower solutions band from upper solutions band. Are you able to produce 2 sets of x,y columns for fitting upper and lower solutions, from the 500 points? Referee my weak eyes, but seems real possibility that quantized levels of solutions could be intermixing?
Matrix of Collatz solutions look like two swarms of bees rather a single linear solution or even look like multiple fuzzy levels of solution ranges, eg. non-linear solutions, observable in various pngs. You can tell me different. Based on long experience of fitting equations in engineering, possibly the probabilistic reasoning or pattern matching on quantum solutions plural is more adaptable.
Please place any comments here with your wiki MONIKER and date, Thanks.gold 3/4/2026
Note. Testing computer methods and computer programs, maybe wrong numbers.
| Category Numerical Analysis | Category Toys | Category Calculator | Category Mathematics | Category Example | Toys and Games | Category Games | Category Application | Category GUI |