I have four ranks beyond rank 4,000 and a 128-byte marking buffer. Where does sharing save the most?
I compare one traversal to the last request against four independent traversals using the same buffer. I check the values by direct sieve and external counts at each endpoint. For offsets 61, 62, 63 and 64 I mark 6 windows instead of 24. For 1, 8, 32 and 64 the largest request is the same and I go from 11 to 6. The 128 bytes count only the marking buffer.
I will compare batching queries arriving in a prescribed order. AT.EX21.03 · Try the experiment
Sharing a sieve segment
I request four prime ranks beyond the same anchor. How many marking operations can I save?
I mark up to the largest requested rank and read offsets 1, 8, 32 and 64. I compare separate queries and check the prime counts at each answer and its predecessor. Beyond rank 4,000 I count 3,982 shared marks versus 6,543 separate marks and 173 visits versus 285. The saving concerns sieve work from a known anchor.
I will measure the effect of rank dispersion at a fixed memory budget. AT.EX20.03 · Change the inputs.
Selecting an actual prime
Correct a candidate rank
Where does the wheel put the requested rank, and how many composite candidates must disappear?
I retain the base primes and integers ≥2 coprime to their product. Each remaining composite has a unique least prime factor. Charging each rejection to that factor partitions them into disjoint classes. Up to the requested prime p, candidate count minus all rejections gives its exact rank. The program constructs a least-factor sieve and checks prime values by trial division.
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.
I provide a counting certificate and a counterexample for prediction by the wheel alone. Building the sieve is part of the cost.
In the field ZIP, I run python experience/rang18.py. The matching JSON file contains the reference output.
Change the parameters · AT.EX18.03
APP016 · Limit or unmet objective (XI)
Prior work and my contribution
I study a proposed address corrected by an exact counter. The square of the next prime gives an explicit limit of a fixed wheel.
Limit and next check
Compare with primecount on the same true prime ranks and account for the full correction.
Prior work
Deléglise, Dusart & Roblot, Counting Primes in Residue Classes · Kim Walisch, primecount
Related results
I link this field to the following results. An address certificate for a gap of thirty
I connect this field to True prime rank up to the first omitted cube.
A05 infers primes p≤√X when S(p)−S(p−1)=1. At one million I find 78,498 primes with 1,999 quotients and 24,641 update divisions. Traces agree with the historical implementation at four scales. Primecount independently checks 153 counts and three selections. I distinguish inferred information from AT.P1’s explicitly constructed factor list. Detecting small primes inside quotient counts
Further checks
Subproblems agree at matched stages. For 64 consecutive thresholds I reduce updates from 1,576,270 to 55,498. I check all counts and independently compare 183 distinct thresholds with primecount across three batches. At X=8, reading a final cofactor value too early gives 5 instead of 4. Sharing a sieve cell across several thresholds
I construct union keys by merging descending bands in O(√B+|U|). I check keys and outputs on 8,385 intervals. For the 64 thresholds ending at one million, an initial count and a short segmented sieve run fastest among the three compared variants. Building all quotient keys for an interval from bands
Compare a prespecified grouping rule against the best measured partition and both uniform strategies on separate batches. When should a new sieve window be opened?
Results and questions
I cut before x if c(x−x_previous−1)>A(x−1). After sorting, decisions are independent. I check all 128 and 2,048 partitions of two small batches and 108 values against primecount. The model selects one window for all twelve clustered batches. When one pass suffices to choose windows
A single direct window has the best median in the first benchmark on all twelve new clustered batches. The global quotient union is faster on both older scattered batches in that comparison. Choosing between a segment and a quotient union
Further checks
I recover all ranks and check 213 values with primecount. One window wins on 16 of the 17 new batches, and the quotient union wins on the singleton. A pair of nested thresholds then defeats the selector. When byte counting changes the winning backend
The model prefers one window for 450,000 and 900,000. The union wins in this challenge by reusing the largest domain. When do nested domains favour a quotient union?
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 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
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
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
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
Share corrections across adjacent prime ranks
I start from a certified anchor pₖ, mark multiples in the next segment, scan candidates coprime to 210 and retain each rejection’s least factor. A witness sieves independently from 2. I count visits and report segment preparation separately. For the 32 ranks following rank 4000 I visit 88 candidates. Restarting at the same anchor for each query takes 1,473 visits. This measures the scan after segment preparation.
Change the inputs · AT.EX19.03 · Walisch · primesieve
I reproduce · python rang19.py
Waiting to batch rank requests
How many sieve windows can I save by delaying replies? I fix eight out-of-order arrivals after rank 4,000, a 128-byte marking buffer and instantaneous service at the end of each FIFO batch. I compare an offline optimum with greedy maximal batches. I enumerate all 128 partitions to check the optimum.
I go from 25 windows for immediate replies to 12 with four ticks of delay and 6 with nine. Greedy batching matches the optimum at all seven tested deadlines. I will seek an arrival sequence on which greedy batching loses. Change parameters · AT.EX22.03
A counterexample to maximal batching
When does waiting as long as possible make me sieve a window again? I assume one arrival per tick and instantaneous FIFO service. A query costs 1, 2 or 6 windows. A batch costs the maximum. I compare every segmentation with a dynamic program and check the primes returned by the sieve.
At deadline 1, costs (1,2,2) require 4 windows with maximal batches and 3 when the first arrival is served separately. At deadline 2 the first loss occurs on (1,1,2,2). I will seek an online rule with a bound against the segmentation that knows future arrivals. Try it · AT.EX23.03
The cost of unseen arrivals
How many extra windows must I allow before future requests are known? I take five consecutive ordered arrivals with costs 1, 2 or 6. At the oldest deadline I know the arrived prefix and can serve any pending prefix. Batch cost is its maximum. I solve the finite game recursively, with the adversary maximizing regret against offline segmentation.
Over 243 streams per deadline, minimum deterministic worst-case regret is one window at delay 1 and two at delay 2. Stopping before the first larger cost loses up to three and two windows. I will test the recurrence without announcing the last arrival. Change parameters · AT.EX24.03
I know the horizon is five. I can postpone service to the oldest pending deadline, remember any earlier decisions and reproduce them then. Service is instantaneous. At each visible prefix I minimize over admissible batch ends, and at each new arrival I maximize over costs 1, 2 and 6. At the terminal state I subtract the best offline segmentation cost for the full stream. This gives minimum worst-case regret for deterministic rules. A longer deadline also helps the offline comparator, so regret can grow.
Batching without knowing the last arrival
What regret remains unavoidable if I only know there will be two to five requests? I reveal one request per tick until the first empty tick. At a deadline I choose a prefix to serve and pay its maximum. I solve the deterministic game against an adversary who can also stop arrivals.
I find minimax worst-case regret of two windows at either deadline. Announcing the length at the outset gives (0,1,2,1) and (0,0,1,2), respectively, over lengths 2 to 5. The maximum over the same lengths stays two in both models. I will seek indistinguishable prefixes that force the bound without exploring the whole tree. Change parameters · AT.EX25.03
Two streams forcing a loss of two
At the first delivery deadline, how much can I be forced to lose even if I know the final length? Both streams begin with 2,6. I compare delivering one or two items, then grant the best offline continuation.
The equal-length streams (2,6,1,1) and (2,6,6,1) force at least two units of regret. The finite-game strategy attains that ceiling at delay one. I will measure the cost of a randomized first decision against these two streams. Change parameters · AT.EX26.03
Randomizing the first delivery
What regret can I guarantee on two streams fixed before my draw? I enumerate schedules that respond identically to a shared prefix. The two undominated regret vectors are (2,0) and (0,3). I mix these strategies with probability p of delivering one item.
The worst expected regret is max(2p,3(1−p)). Its exact minimum is 6/5 at p=3/5 for these two streams and their compatible continuations. I will seek the randomized game value over all length-four streams. Change parameters · AT.EX27.03
I assume that the adversary fixes the stream before the strategy draws its action. If it selects A with probability 3/5, each deterministic strategy has mean regret at least 6/5. This yields the lower bound for the mixed game. I check compatible continuations so the guarantee is attainable on the two streams. The minimax principle of placing a distribution on the inputs is classical. Yao
Exact regret over 81 streams
What does the first decision cost when I must serve every length-four stream? I use sizes 1, 2 and 6, delay one, and an adversary who fixes the stream before the random draw. For each prefix I compare nine policies with nine suffixes and verify matching rational strategies for both players.
I find minimax regret 6/5, attained after (2,6). Prefix (1,6) has value 4/5. Each of the seven other prefixes permits zero regret. I will look for the first horizon where this guarantee ceases to suffice. Change parameters · AT.EX28.03
Guaranteed regret over five items
I know the stream length. What regret can I guarantee before seeing its end? I fix delay at one item and sizes at 1, 2 or 6. I construct a best response to a distribution of streams on the observation tree and verify mixed strategies in fractions.
Across the 243 length-five streams I certify worst expected regret of 4/5. Prefix (1,6) has value zero and each other prefix has value 4/5. At known length four the maximum was 6/5. I will test whether the drop depends on the parity of the known horizon. Change parameters · AT.EX29.03
Walisch · primesieve · Yao · von Stengel · Behavior strategies
On each prefix I can deliver one or two items, seeing the first waiting item and its successor. I know there will be exactly five items. Given an adversarial suffix distribution I minimize expected cost recursively over observable prefixes. I add this policy to the game while it improves the lower bound, then check every probability, the mixed strategy’s worst cost and the best response to the adversarial distribution using fractions. horizon29.json contains the actual decision rules for every support strategy. An adversary adapting the stream after each draw defines a different game.
Delivering six items with two values visible
I know the stream length and its first two values. What randomized regret can I guarantee on values 1, 2 and 6? I minimize excess cost over the offline partition into batches of one or two. I publish an adversarial distribution, a mixed policy and the loss for every stream.
I find 22/15 at the worst prefix (2,6) for six items. The five-item worst regret was 4/5. The announced length changes the information in the game. I will seek a recurrence or seven-item witness to separate parity from horizon effects. Change parameters · AT.EX30.03
Walisch · primesieve · Yao · von Stengel · Behavior strategies
Measuring regret over seven arrivals
What regret can I guarantee against an adversary when seven items arrive in sequence? I compute unconditional action probabilities at each prefix. I check regret on each stream and the best response to the adversarial strategy in rational arithmetic.
I certify the value 19/10 at the worst prefix (2,6), after 4/5 at five arrivals and 22/15 at six. These consecutive increases rule out strict alternation over these horizons. I will seek an eight-arrival bound using the support of the adversarial strategy. Change parameters · AT.EX31.03
Walisch · primesieve · Yao · von Stengel · Behavior strategies
The eight-arrival delivery game
What guarantee can I transfer from a horizon of seven arrivals to eight? I extend the seven-arrival adversarial strategy, then compute a new policy and adversarial strategy per prefix. I check their costs in rational arithmetic on 729 suffixes per prefix.
I certify 29/15 at the worst prefix (2,6). The four reserved extensions of the seven-arrival witness only gave 13/10 at this prefix. The full certificate covers 6,561 streams. I will seek a lower bound that transfers to arbitrary horizons without solving the full game. Change parameters · AT.EX32.03
Walisch · primesieve · Yao · von Stengel · Behavior strategies
Unavoidable regret at long horizons
I keep the same observable prefix (2,6) and must choose to serve one or two items before seeing the third. I compare streams (2,6,1,1,…) and (2,6,6,1,…). After the first choice the third cost is revealed. A tail of k ones costs exactly ⌈k/2⌉, giving all four regrets for any horizon.
For every n≥4, the exact value of this two-stream game is 6/5 at even horizons and 4/5 at odd ones. These values lower-bound the full game. At n=8 the full game reaches 29/15. I will look for separated ambiguous blocks whose regrets add after accounting for boundary decisions. Change parameters · AT.EX33.03
Walisch · primesieve · Yao · von Stengel · Behavior strategies
Historical results — A02 · Limits of sieve candidates, A03 · Prefixes and selection, A05 · Quotient sieve, A06 · Multiplicative primitives, A16 · Hybrid selection, A24 · An address certificate for a gap of thirty, N04 · Open bounds and resource claims