Hands-on experiments
Correct a candidate rank. At rank 100 the 30-wheel proposes 367. I recover 541 after 47 rejections among 147 candidates. Raising the wheel to 210 leaves 27 rejections. AT.EX18.03 · Simulate
Choose a robust offset. For periods 24 and 8 with two ticks of jitter, nominal offset 0 may fall to one slot. Offset 6 guarantees two. I checked 882 counts by scanning timestamps. AT.EX18.04 · Simulate
What passes through a wheel?
With wheels 2, 3 and 5, I keep 1, 7, 11, 13, 17, 19, 23 and 29 in each period of 30. These integers are coprime to 30. In the next period, 49 still passes. Adding the wheel for 7 removes it.
If the current address is s modulo D, a new prime p offers extensions s+Dd, 0 ≤ d < p. Exactly one digit, d ≡ −sD⁻¹ modulo p, makes this divisible by p. For unit status all surviving branches have the same capacity. I can therefore address survivors with radices p−1. For numerical order I need a strict-prefix count C(X). The k-th survivor is the first x with C(x+1)>k. I compare the costs of these two readings on the same constraints. Cover · Deléglise, Dusart and Roblot
The original factoradic digit
Write the rank as r=s+aₚ(p−1)!+t p!. Wilson’s theorem gives r ≡ s−aₚ modulo p. For p=5 and s=7 the local addresses are 7, 31, 55, 79 and 103. Digit 2 gives the multiple of five. My wheels make the forbidden digit visible.
Where the count gives primes
Let p be the last sieving prime and q the next. For p ≤ X < q² every survivor above one is prime: a surviving composite has at least two prime factors ≥ q. Thus π(X) = π(p)+C(X+1)−1. At p=5 and X=48 this gives 15. At 49 the surviving square ends that guarantee. I want to measure the cost of growing the sieve with X, including preparation. Reference prime counter · Try the sieve
Counting prefixes with a common conductor
Counting a residue class a modulo d below X combines a shared quotient and a remainder test. I reuse the division across classes with the same conductor. XI keeps O(N) reads on N classes but uses O(G) divisions for G conductors. The calendar extension groups compatible phases by gcd. Grouped prefixes · Noncoprime calendars
From a wheel to a changing calendar
I count admissible ticks in a window when two masks may have periods with a common factor. Repeated reads can recover the cost of indexing. For the same 64 long windows and two sparse masks of periods 251 and 257, the bitmap leads when the masks stay fixed. With seven updates, each followed by a rebuild, the gcd index regains the lead. I supply the three implementations and all repetitions. Calculations and assumptions
Changing a calendar or sharing a factor
For a left-phase toggle I can update just the affected words of a bitmap with a Fenwick tree. Including setup and reads, this beats full rebuilding on the sixteen workloads with flips. XII treats a different structure. If the periods have the form g·pᵢ with pairwise coprime pᵢ, I split into fibres modulo g before counting. The three-period control checks 541 prefixes. Measurements · XII fibres · Fenwick
What does the wheel read beyond the next square?
On wheel 30, 19 and 49 occupy the same position on consecutive revolutions. The first is prime and the second is 7². Supplying the surviving prime pairs corrects every threshold from 5 through 342. At 343 the counter returns 69 against 68 primes. I report which primes the correction had to obtain. Proof, code and costs
Counting primes with the quotients of 30
I can ask how many primes are at most X without supplying a prime list. I open one cell S(v)=v−1 for each distinct v=⌊X/i⌋. For X=30 the labels are 30, 15, 10, 7, 6, 5, 4, 3, 2 and 1. At step p, the difference S(p)−S(p−1) is one if p survived earlier divisions. For each such p I visit cells v≥p² in descending order and subtract S(⌊v/p⌋)−S(p−1), the number of surviving cofactors starting at p. Descending order lets me read the previous stage. Cell 30 goes from 29 to 15, then 11 and finally 10 as I process 2, 3 and 5.
I recover a combinatorial sieving mechanism. My contribution here is a controlled comparison of the starting information used by two machines. At one million I infer the 168 small primes up to 1,000 and count 78,498 primes with 1,999 cells, 1,000 domain divisions and 24,641 update divisions. My semiprime correction explicitly builds its factor list and overcounts by one at 343 for the 30-wheel. I can now test a proposed wheel operation against these cases once its inputs and prediction are specified. Code and measurements · Record AT.P2 · Lagarias, Miller and Odlyzko
I identify the exact scalar recurrence with the Lucy_Hedgehog prime-counting algorithm as explained and implemented by Griffin Macris. I use its basic quotient version in this comparison. Griffin Macris, Lucy’s Algorithm + Fenwick Trees (2023)
Which work can I share across several thresholds?
For threshold X let D(X) contain all positive quotients ⌊X/i⌋. If v=⌊X/i⌋ then ⌊v/p⌋=⌊X/(ip)⌋. Each domain is closed under the required divisions, as is a union U of domains. The largest threshold B supplies all keys from 1 to ⌊√B⌋, including p and p−1. After sieving through p, the count S(v,p) depends only on v and the sieve stage. I can compute each shared cell once by visiting v in descending order at each new prime. Whenever a threshold is already a key, its entire domain is present.
Update order matters even at X=8. When removing multiples of 2 I must read S(4,1)=3, leaving 7−3=4 survivors. Reading the final π(4)=2 too early gives 5. The scalar recurrence is Lucy_Hedgehog’s. My contribution concerns matched-stage sharing and its evaluation on multiple queries. Reference implementation · Code and inputs
On the 64 integers from 999,937 to one million I reduce the update count from 1,576,270 to 55,498. I keep 2,477 cells simultaneously, versus a peak of 1,999 for separate runs. On a spread-out grid, updates fall from 928,660 to 215,583 and I need 9,177 cells. I also test a seeded batch with duplicates. A direct sieve checks every final cell in the union, and primecount independently checks all 183 distinct thresholds in the three batches. Controls and measurements
Does a short interval need just one anchor?
If I request every threshold from A to B, the quotients for divisor i form the entire band [⌊A/i⌋,⌊B/i⌋]. Above s=⌊√B⌋ only i≤s can contribute. I clip the bands at s+1, merge touching bands in descending order and append s,…,1. This builds exactly U in O(√B+|U|) word operations. I checked every key and answer on the 8,385 intervals contained in [0,128].
For the 64 integers ending at one million I obtain the same 2,477 keys using at most 2,000 setup divisions, versus 63,937 for the generic union on this batch. In a second comparison on this interval I measure 16.96 ms for the generic union and 12.72 ms for the bands. A classical method is faster here. I compute π(999,936)=78,493 once, then use a short segmented sieve to detect the next five primes in the window. This takes 5.59 ms including setup. These are medians of five local Python runs. Next I will choose windows when the requests form multiple clusters. Identity and timings · Kim Walisch on segmented sieving
Counting primes at multiple thresholds
I sort the distinct requests and charge a window [a,b] the cost A(a−1)+c(b−a+1). A accounts for computing π(a−1), after which I sieve the window. Consecutive thresholds x<y can share a window. Cutting between them saves a scan of y−x−1 integers and costs an anchor A(y−1). This difference is independent of the other cuts, so one pass over gaps minimises the model exactly. For a general cost K(i,j) on the ith through jth thresholds I can still minimise D(j)=minᵢ[D(i−1)+K(i,j)], with D(0)=0 and indices starting at 1. Every partition ends in one such interval. Sharing quotient tables across windows would introduce another dependency. Bellman on dynamic programming · Segmented sieve
I freeze the coefficients on three training batches and compare four strategies on fifteen batches of 64 requests. A single window has the best median in all twelve new clustered batches. On the older spread batch, the quotient union takes 52.69 ms, one window takes 60.35 ms and the nine windows selected by dynamic programming take 61.01 ms. On the batch with duplicates, the partition uses 622,288 traced bytes against 1,957,187 for one segment. In a follow-up run the linear decision recovers every partition in 27 to 44 µs on these fifteen batches. I supply individual timing samples and separately traced memory.
I enumerate all 128 partitions of eight requests and 2,048 partitions of twelve. At eight, the model selects four windows. The sum of individually measured window times favours three at 1.5363 ms versus 1.5747 ms. At twelve both choose the same six windows. The timings depend on the machine and Python kernel. I check the ranks and anchors against a direct sieve, shuffle requests with duplicates, and check 108 distinct values with primecount. Data and method · Failure and next test · Independent counter
Sieving by byte ranges
I mark composites in a window [a,b] and count bytes equal to one from the end of the preceding range through each next threshold. The ranges are disjoint and cover exactly b−a+1 bytes. I add π(a−1) and restore every answer to its input position, including duplicates. I check endpoints on 1,176 intervals, every result against a direct sieve and 213 values against primecount 9.1. Python byte counting · primecount
I keep fifteen older batches, calibrate on seven batches with seed 8201 and evaluate seventeen with seed 8202. I compare a single window, the additive model's best partition with at least two windows when feasible, a quotient union, and automatic selection. I include the cost of estimating quotient keys and deciding. On held-out batches one window has the best median sixteen times, the union once, and the model selects all seventeen winning backends. Decision overhead can erase a small gain. On the older spread batch one window now takes 4.475 ms versus 64.129 ms for the union, at 2,005,943 traced Python bytes versus 919,068. The earlier integer-by-integer Python scan had reversed the timing ranking. I provide five samples, lengths, scans on prepared marks and separately traced memory. Protocol and material
I then specified a targeted challenge without changing any coefficients. For 450,000 and 900,000 the first quotient domain is contained in the second. The model selects a window. Its measured median is 5.160 ms against 4.648 ms for the union. I retain this miss and the large segment's peak memory as inputs for the next criterion. First targeted miss
Integer division guarantees nested quotient sets
For x=floor(y/m) I have floor(x/j)=floor(y/(mj)), so the quotient domain of x is contained in that of y. I check 2,739 parameter pairs. With y=900,000, shifting 450,000 down by one leaves 42 keys outside the larger domain, shifting it up leaves one. This asymmetry matters when estimating union cost.
I timed the seven offsets using the frozen previous model, five repeats per method. Union wins by median at 0, +1 and +2. One window wins at −64, −2, −1 and +64. The selector always chooses one window. At −1 I measure 4.303 ms for the window and 4.388 ms for union. At +1 I get 4.338 and 4.152 ms. These small local differences warrant isolated-process timing. python inclusion09.py --measure reproduces timings and allocation peaks.
My next test is to time both sides of the offset under the same memory cap. AT.P10 · Walisch, primecount
A state collision for primality
The integers 19 and 49 share a state modulo 30. One is prime and the other is 7 squared. Adding wheel 7 eliminates 49, then 121 is the first surviving composite above 7. I verify survivors up to 1,000 by trial division. No rule depending only on this state can separate 19 and 49.
The collision generalizes. For any fixed modulus M≥2 and prime q not dividing M, q and q(1+M) have the same residue. The latter is composite. Choosing q above any specified threshold gives a collision beyond that threshold. This elementary argument identifies what a proposed new algebra must add.
My next test is to specify another state variable and commit to an out-of-sample prediction. AT.P11 · Walisch, primesieve
A ranking reversal across three new batches
I freeze the earlier selector for three threshold pairs around 405,000 and 810,000. It chooses the single window three times. With five fresh processes per method and batch, observed median winners are single, single and union. Under a 300,000-byte Python allocation budget, union and separate windows fit on all three. I check all four distinct π queries against a sieve and primecount 9.1.
I plan to predict memory feasibility first and declare an uncertainty region when timings overlap. AT.P12 · Walisch, primecount
An enriched state that still loses addition
I augment the residue modulo 30 with divisibility flags for 7 and 11. On [150,400] the first surviving composite is the predicted 169 = 13². Prime 151 has the same state as 361 = 19². States of 2 and 32 agree, while those of 3 and 33 differ. I therefore cannot define a successor on this state alone. The full residue modulo 2,310 preserves addition but is periodic.
I plan to specify an operation carrying the state without the original integer and search a fresh interval for its first counterexample. AT.P13 · Walisch, primesieve
One successor bit and a counting budget
The flag “11 divides x+1” separates 2 from 32. States for 402 and 552 agree while their successors differ. The sieve admits 403=13×31 on [401,700]. For three new batches with a 300,000-byte Python allocation budget, union has the fastest feasible median on this machine. I verify π with primecount.
Test an operation with evolving information and account for its update. AT.P14 · Walisch, primesieve
Querying two periodic calendars
I provide a command accepting two integer masks, query windows and ranks in a JSON file. For periods 12 and 18 I obtain seven slots per 36 ticks and tick 13 at zero-based rank three. I check answers by a separate scan.
Time the full cost on an independent periodic workload. AT.T4 · Bettini, Mascetti & Wang, Supporting Temporal Reasoning by Mapping Calendar Expressions to Minimal Periodic Sets
I extract the Calendars kit and run python creneaux11.py --agenda agenda11.json. I replace the periods, open lists, half-open windows and zero-based ranks in the JSON.
The cost of building and querying a calendar
I fix two pairs of integer periods, masks and three profiles of 256 paired queries. Both methods give the same 1,536 count/rank pairs. On cycles of 420 and 5,063 ticks, materialisation wins on end-to-end time for all six loads. On the second cycle it uses 32,224 Python bytes to build against 3,932 for the implicit counter.
I seek a crossover at long periods and few queries, followed by a domain workload. AT.T5 · Bettini, Mascetti & Wang, Supporting Temporal Reasoning by Mapping Calendar Expressions to Minimal Periodic Sets
How many states advance the wheel?
I ask an autonomous deterministic machine to emit the cyclic sieve survival bit at each step for period 2,310. All 2,310 shifts have distinct future sequences, and windows of length 66 separate all shifts. In [701,1100], 701 and 881 share the enriched summary but have different successors, and composite 703 survives. I check π(700)=125 and π(1100)=184 with primecount.
I will identify and charge the additional information required by a proposed primitive. AT.P15 · Walisch, primesieve
For the state lower bound I take W(x)=1 when x is coprime to a square-free product R. For any shift d nonzero modulo R, some prime divisor p of R does not divide d. The Chinese remainder theorem gives x congruent to −d modulo p and to 1 modulo every other factor. Then W(x)=1 and W(x+d)=0. The R rotations of the periodic word therefore have distinct futures. For R=2,310 the shortest window separating all rotations has length 66. As for primality, any summary retaining only the residue modulo m assigns the same state to a prime p and the composite p(1+m), for m≥1. A new rule must describe the additional information it updates.
How many queries pay for building a calendar?
I measure five alternating repetitions on 60 workloads, two periods, two densities and three profiles. Each query checks prefix and selection. For cycle 420 the table wins at one query in all six profiles. For 5,063 the first tested winning count is four at low density and two at high density for all three localities. I publish medians with and without construction and peak Python memory.
Compare these thresholds with a dated calendar trace and cold-access costs. AT.T6 · Bettini, Mascetti & Wang, Supporting Temporal Reasoning by Mapping Calendar Expressions to Minimal Periodic Sets
How many outputs identify a wheel position?
I observe the unit indicator under translation by one and compare every shift. The first horizons separating all positions are 14, 38 and 66 for periods 30, 210 and 2,310. I supply indistinguishable shifts at horizons 1, 2, 4 and 8. The primitive outputs wheel admissibility. Composite 703 remains a witness separating it from primality.
Test any new primitive specifying state, update and output on a reserved interval. AT.P16 · Berstel et al., Minimization of automata
When two switches suffice
Can I rearrange the seven active slots so that a third switch lowers the guarantee? For each nominal offset I count slots at which one of three deviations can suppress a meeting. Each slot is accessible at three of six offsets, so the minimum is at most three. With two switches I can target any three accessible slots in order. I keep a one-slot minimum dwell.
I prove equality of the two- and three-switch guarantees for all 346,104 seven-slot masks. I check the first 500 by recurrence and count all masks by their residue class sizes. I will test the first cardinal at which the saturation bound allows a useful third switch. Try it · AT.EX23.04
Keith Conrad · The Chinese remainder theorem
Reproduce the experiment
In I, run python src/cli.py candidat 11 20 --primoriel. Compare with candidat-croissant to see the same survivors in numerical order.
Download research files ↓