README.md
4.1 kB · markdown
two-base-gasket
- Computes
C(N) = card(A cap B cap [0, N)^2)exactly, whereAis the base-2 gasket{(x, y) : x AND y = 0}andBis the base-3 gasket, the pairs whose base-3 digit pairs all lie in{(0,0), (0,1), (1,0)}. - Exact integer arithmetic throughout; no sampling, no fit.
- The fast count walks the base-3 exponents from the top down, choosing for each whether
3^ijoinsx, joinsyor neither, and prunes a branch when the high halves ofxandycannot be made disjoint: withB_kthe bit length of3^kandkexponents still unread, the remaining addition to each coordinate is below3^k, so each final high partx >> B_kis its current value or one more, and a branch dies when all four combinations of the two high parts share a bit. - Also prints the naive planar budget
dim A + dim B - 2and the axis lower bound2^(m+1) - 1, with the bound truncated down and the budget rounded up. - The recurrence test is exact over
Q: Bareiss integer Hankel determinants, and one rational Gauss-Jordan per order on every equation the terms supply, so a reported absence is a proof that no such recurrence fits the terms given, and nothing else.
VERBS
budgetprintsdim A = log_2 3,dim B = log_3 3, the budgetdim A + dim B - 2rounded up, the axis exponentlog_3 2truncated down, and the excess. Runtime under0.05s.control MrecomputesC(3^m)form = 0..Mtwice: once by the pruned walk and once by testing every pair(x, y)in[0, 3^m)^2against both digit rules with one shared routine, and prints whether the two agree and whether the axis bound holds. Runtime0.2s atM = 6.terms LO HIprintsC(3^m), the axis bound2^(m+1) - 1, the ratio to the level below andlog_3 C(3^m) / m, asserting the axis bound at every level. Runtime3min13s forLO HIequal to0 24on one core, the cost per level rising by a factor near2.1;m = 25costs about3.5min more and is not run.hankel HI [RMAX]recomputesC(3^m)form = 0..HIand prints them, prints the Hankel determinantsdet H_kof the matrix with entriesa[i+j]fork = 1..RMAX+1, and for each orderr = 1..RMAXsolves the systema(n) = c_1 a(n-1) + ... + c_r a(n-r)over everynwithr <= n <= HI, printing the number of equations, the equations spare after therunknowns, and eithernonefor an inconsistent system or the coefficients. A consistent order also gets its characteristic polynomial and the modulus of its dominant root fromgp -q.RMAXdefaults to12, which is the largest orderHI = 24leaves a spare equation for, orderrwanting2r+1terms and so order13wantingHI = 26. Runtime3min15s atHI = 24, the census being the whole cost and the algebra under0.01s.selftestruns the algebra ofhankelagainst answers known in advance:bareisson five determinants computed by hand, reading3,-2,-6,0and4, the third needing a pivot swap and the fourth singular; the Fibonacci numbers, first fitted at order2with characteristic polynomialx^2 - x - 1;2^n + 3^n + 1, first fitted at order3with dominant root3.0000000fromgp -q; andn^3 + 2^n, fitted at no order below5and at5with(x - 1)^4 (x - 2). Eleven checks, each printing its expected value beside what it got. A solver that answerednoneto everything would fail the three positive fits, and one that fitted anything would failn^3 + 2^nbelow order5. Runtime0.05s.
RUN
- From the repo root.
uv run python research/lab/py/two-base-gasket/census.py budget
uv run python research/lab/py/two-base-gasket/census.py control 6
uv run python research/lab/py/two-base-gasket/census.py terms 0 24
uv run python research/lab/py/two-base-gasket/census.py hankel 24 12
uv run python research/lab/py/two-base-gasket/census.py selftest
WITNESSES
cobham.md:76the budget0.584963cobham.md:77the twenty-five termsC(3^m)atm = 0..24and the control that rebuilds them tom = 6cobham.md:78the axis lower boundC(3^m) >= 2^(m+1) - 1cobham.md:79the excesslog_3 2 >= 0.630929over0.584963cobham.md:81the falling readingslog_3 C(3^m) / matm = 14..24