"""lists.py -- the dial's lists: at a cell that obeys the pure law, is every polynomial of height at most k and degree d_k(J) flattened to J a pure product? QUESTION. The lattice decides d_k(J) at most cells of J <= 16 and exhibits one vector; a width is listed whole only down the column k = 1, at the seven cells of suffixwalk.py's DIAL that obey the pure law, at (2, 16) of walkc.py's record, and at the three breaks. walkc.py's cell at (11, 18) lists two polynomials at the least pure degree 73, one of them no pure product: a cell that obeys the pure law whose list is not all pure products. Asked, at the 165 cells J = 2..16, k = 2..12: how many lists hold a polynomial that is no pure product, at which heights, and what is left of each once its cyclotomic factors are divided out. The instrument is walkc.py's cell, which lists its last width whole, and members.py's split; (2, 16), fourteen minutes, is read off walkc.py's record and not run. PREDICTIONS, before this file's first run. LP1 The breaks are the three known, (9, 10), (8, 15) and (11, 15), each with one polynomial, no pure product; every other cell has d the least pure degree (the lattice's verdicts, flatten.py's dial and members.py's hunt). LP2 At k <= 7 no list holds a polynomial that is no pure product: a TRANSPLANT from the column k = 1 to depth 18 and the seven cells of k <= 7 listed. LP3 At k = 8..12, of the 72 cells that obey the pure law, 2 to 8 hold one: a guess from one cell, (11, 18). LP4 Every irreducible factor left of such a polynomial is a palindrome with positive coefficients, as members.py's nine are and (11, 18)'s is. KILLS, as prints. LK1 (a bug: a break missed or made) "breaks: N, the three known M", N != 3 or M != 3. LK2 (a finding against the front's range) "lists off the pure products at k <= 7: N of M cells", N >= 1. LK3 "lists off the pure products at k = 8..12: N of M cells", N = 0 ((11, 18) stands alone) or N >= 10 (the lists, not the degrees, are where the pure products lose first). LK4 "factors left: N of M palindromes with positive coefficients", N < M. CONTROLS, read before the sweep's lines. LC1 the known instance through this file's classifier: walkc.py's vector at (11, 18) is no pure product, its split rebuilds it, and its pure neighbour is one. LC2 the lists already read: at the seven cells of suffixwalk.py's DIAL run here that obey the pure law the parts are DIAL's. LC3 LK1's three breaks, each with its one polynomial of no pure product. CHANGED AFTER THE FIRST RUN. No frozen line moved, and LK2 and LK3 as frozen read a confound: a constant multiple c (x - 1)^J of a lower height's polynomial is no pure product, and at J <= 4 it fills the lists (17 of the 21 cells the two lines count hold nothing else). The statistic's algebra was not derived before the freeze: content was never named. stage_primitive is the read added, its lines printed under the frozen ones: a cell counts only for a polynomial of content 1, and each such cell's list is read by height, the pure products' apart. FINDINGS, each figure from the print of the form that reads by height, which holds the first form's lines quoted here but (3)'s wording. (1) The controls. LC1: "heights 11 and 10, width 74"; the split of (11, 18)'s second polynomial rebuilds it, cyclotomic part Phi_1^18 Phi_2^5 Phi_3^3 Phi_4^2 Phi_5^2 Phi_7 Phi_8 Phi_11, one factor left, T = 1 + 2x + 3x^2 + 5x^3 + 7x^4 + 8x^5 + 9x^6 + 8x^7 + 7x^8 + 5x^9 + 3x^10 + 2x^11 + x^12; the pure product's is Phi_1^18 Phi_2^5 Phi_3^5 Phi_4^2 Phi_5^3 Phi_6 Phi_7 Phi_9 Phi_11. LC2: "7 of 7 cells". LK1 silent, LP1 holds: "breaks: 3, the three known 3". (2) The frozen lines, confounded as named above: "lists off the pure products at k = 2..7: 8 of 90 cells" and "at k = 8..12: 13 of 72 cells". Read on content 1: "of them with a polynomial of content 1, k = 2..7: 2 of 90 cells [(7, 6), (7, 14)]" and "k = 8..12: 2 of 72 cells [(8, 6), (9, 15)]". LK2 fires on both reads and LP2 fails, at (7, 6) and (7, 14); LK3 fires as frozen by the confound alone and is silent on content 1, where LP3's count, 2 at J <= 16, sits at its low end. (3) Two of the four are ties, the other two a polynomial above a pure product's height, as the form that reads by height prints them: "(7, 14), degree 49: heights of the pure products [7], of the others of content 1 [7, 7]: tie"; "(9, 15), degree 53: heights of the pure products [9], of the others of content 1 [9]: tie"; "(7, 6), degree 9: heights of the pure products [5], of the others of content 1 [7]: above" and "(8, 6), degree 9: heights of the pure products [5, 8], of the others of content 1 [7]: above". Off walkc.py's record, "(11, 18), degree 73: heights of the pure products [10], of the others of content 1 [11]: above", and "the cells of walkc.py's record: 19, with a polynomial of content 1 that is no pure product: [(11, 18)]". LC4: "5 of 5". LP5 holds and LK5 is silent: the first form's lines are this form's. (4) What is left. (7, 6) and (8, 6): (x - 1)^6 (x + 1) B, B = 2 + 3x + 2x^2, the vector [2, -7, 5, 7, -7, -7, 7, 5, -7, 2]. (7, 14), its two: cyclotomic Phi_1^14 Phi_2^3 Phi_3^3 Phi_4 Phi_5^2 Phi_7 with U = 1 + x + 2x^2 + 3x^3 + 3x^4 + 3x^5 + 3x^6 + 3x^7 + 2x^8 + x^9 + x^10 left, and Phi_1^14 Phi_2^3 Phi_3^3 Phi_4 Phi_5 Phi_7 Phi_9 with V = 2 + 5x + 8x^2 + 10x^3 + 11x^4 + 10x^5 + 8x^6 + 5x^7 + 2x^8 left. (9, 15): Phi_1^15 Phi_2^4 Phi_3^2 Phi_4^2 Phi_5^2 Phi_7 Phi_8 with members.py's N left, the factor of the break d_11(15). (5) LK4 silent, LP4 holds: "factors left: 10 of 10 palindromes with positive coefficients", five of them the constants 2 to 6, the others B, N, T, U and V. members.py's describe: U has degree 10, leading coefficient 1, value 23 at 1, 3 of 5 trace roots in [-2, 2]; V degree 8, leading coefficient 2, value 61 at 1, 4 of 4; T degree 12, leading coefficient 1, value 61 at 1, 2 of 6; each takes 1 at -1. T, U and V are in none of members.py's nine. (6) "cells by the size of their list: {1: 129, 2: 23, 3: 7, 4: 3, 5: 2, 6: 1}", constant multiples counted. What the record does not read: the lists past J = 16 but at the eighteen cells of walkc.py's CELLS there; whether U, V or T is traded in at a failing cell; any list at k > 12. THE READ BY HEIGHT, asked after the record above and before this form's first run. The first form read content 1 in a stage of its own that ran each such cell's last width a second time, and its "at the list's least height" was coded as the least height of the polynomials of content 1 being at most the pure products' least: equality only where the printed heights say so. This form reads each list once, as it is listed, through `standing`, which sets the constant multiples aside and says how the polynomials of content 1 that are no pure product stand to the pure products: "none" (there is none), "below" (one is under every pure product's height: a break's shape), "tie" (their least height is the pure products' least, and the whole list's) or "above". The cells past depth 16 that walkc.py's record holds are read the same way off that record, not run. LP5 The rerun's lines are the first form's: the frozen lines as printed above; content 1 at (7, 6), (7, 14), (8, 6) and (9, 15); a tie at (7, 14) and (9, 15), above at (7, 6) and (8, 6); past depth 16, (11, 18) alone, above; the factors left B, N, T, U, V and the constants 2 to 6. LK5 (a bug, in this form or the first) any of those lines other than LP5 has it: the record check FAILS. LC4 `standing` on five lists written by hand, one of each word and a constant multiple set aside: (x - 1)^2 alone, "none"; with 2 (x - 1)^2 beside it, "none"; (x - 1)^2 Phi_4, of height 2, beside (x^2 - 1)^2, of height 2, "tie"; beside (x - 1)^4, of height 6, "below", which the first form's test called a tie; beside x^4 - 1, of height 1, "above". RUN RECORD. python lists.py, four processes at a width: "3 of 3 checks, 165 cells, 150 s", twice, the second with stage_primitive. The form that reads by height: "4 of 5 checks, 165 cells, 151 s" before its record was entered, LK5 alone failing on the empty record, then "5 of 5 checks, 165 cells, 149 s", every other line the same but three clock fields. """ import sys import time from math import gcd import flatten as F import members as M import suffixwalk as SW import walkc as WC KNOWN = {(9, 10): 22, (8, 15): 55, (11, 15): 48} SKIP = (2, 16) # the factors left that members.py does not name, as the first form # printed them HERE = {"T": (1, 2, 3, 5, 7, 8, 9, 8, 7, 5, 3, 2, 1), "U": (1, 1, 2, 3, 3, 3, 3, 3, 2, 1, 1), "V": (2, 5, 8, 10, 11, 10, 8, 5, 2)} NAMES = dict(list(M.NAMES.items()) + [(f, n) for n, f in HERE.items()]) RECORD = { (7, 14): ((7,), (7, 7), 'tie'), (7, 6): ((5,), (7,), 'above'), (8, 6): ((5, 8), (7,), 'above'), (9, 15): ((9,), (9,), 'tie'), 'breaks': (((8, 15), 55), ((9, 10), 22), ((11, 15), 48)), 'cells by the size of their list': ( (1, 129), (2, 23), (3, 7), (4, 3), (5, 2), (6, 1)), 'factors left: palindromes with positive coefficients, of how many, ' 'the constants': (10, 10, (2, 3, 4, 5, 6)), 'factors: name, degree, leading coefficient, value at 1, value at -1': ( ('B', 2, 2, 7, 1), ('N', 8, 1, 17, 1), ('T', 12, 1, 61, 1), ('U', 10, 1, 23, 1), ('V', 8, 2, 61, 1)), "in members.py's nine": ('B', 'N'), 'k = 2..7: cells of the law, lists off the pure products, of them on ' 'content 1': (90, 8, ((7, 6), (7, 14))), 'k = 8..12: cells of the law, lists off the pure products, of them on ' 'content 1': (72, 13, ((8, 6), (9, 15))), 'not every root read on the circle: name, trace roots in [-2, 2], of ' 'how many': (('N', 2, 4), ('T', 2, 6), ('U', 3, 5)), 'palindromes, with positive coefficients, of how many': (5, 5, 5), 'value at -1 other than 1; monic; monic with every root on the ' 'circle': ((), ('N', 'T', 'U'), ()), "walkc.py's record: cells, those on content 1": ( 19, (((11, 18), ((10,), (11,), 'above')),)), } CHECKS = [] def check(name, ok, detail=""): CHECKS.append(bool(ok)) print(" [%s] %s%s" % ("PASS" if ok else "FAIL", name, " " + detail if detail else ""), flush=True) def left(v): """(the cyclotomic multiplicities, the irreducible factors left, whether they rebuild v) of a vector.""" mult, _, fs, back = M.split(v) return dict(sorted(mult.items())), fs, back def fair(f): """A palindrome with positive coefficients.""" return list(f) == list(f)[::-1] and min(f) > 0 def content(v): g = 0 for c in v: g = gcd(g, c) return g def read(vecs): """A list as (vector, its parts or None, its height, its content), in the order listed.""" return [(list(v), SW.pure_parts(v), F.height(v), content(v)) for v in vecs] def standing(rows): """(the pure products' heights, the heights of the polynomials of content 1 that are no pure product, how those stand): "none", "below" every pure product, a "tie" at the least height of the pure products and of the whole list, or "above".""" pure = tuple(sorted(h for _, q, h, _ in rows if q)) odd = tuple(sorted(h for _, q, h, c in rows if q is None and c == 1)) least = min(h for _, _, h, _ in rows) if not odd: how = "none" elif not pure or odd[0] < pure[0]: how = "below" elif odd[0] == pure[0] == least: how = "tie" else: how = "above" return pure, odd, how def stage_standing(): """LC4: one hand list a word, and a constant multiple set aside.""" sq = [1, -2, 1] # (x - 1)^2 odd = [1, -2, 2, -2, 1] # (x - 1)^2 Phi_4, height 2 hand = (("(x - 1)^2 alone", [sq], ((2,), (), "none")), ("with 2 (x - 1)^2", [sq, [2, -4, 2]], ((2,), (), "none")), ("(x - 1)^2 Phi_4 beside (x^2 - 1)^2", [odd, [1, 0, -2, 0, 1]], ((2,), (2,), "tie")), ("beside (x - 1)^4", [odd, [1, -4, 6, -4, 1]], ((6,), (2,), "below")), ("beside x^4 - 1", [odd, [-1, 0, 0, 0, 1]], ((1,), (2,), "above"))) got = [standing(read(vecs)) for _, vecs, _ in hand] for (name, _, want), g in zip(hand, got): print(" %s: %s%s" % (name, g, "" if g == want else " DIFFERS")) check("LC4 standing on five hand lists, one of each word", got == [want for _, _, want in hand] and SW.pure_parts(odd) is None and F.clears(odd, 2), "%d of %d" % (sum(g == w for g, (_, _, w) in zip(got, hand)), len(hand))) def stage_known(): k, J = 11, 18 v = list(WC.NOT_PURE[(k, J)][0]) p = WC.product(WC.CELLS[(k, J)][4][0]) mult, fs, back = left(v) check("LC1 (11, 18)'s second polynomial: no pure product, its split " "rebuilds it, its neighbour pure", SW.pure_parts(v) is None and back and SW.pure_parts(p) is not None and F.height(v) == k and F.clears(v, J) and len(v) == len(p), "heights %d and %d, width %d" % (F.height(v), F.height(p), len(v))) print(" cyclotomic %s" % (mult,)) for f in fs: print(" left: %s %s" % (list(f), M.describe(f))) mp, fp, _ = left(p) print(" the pure product's cyclotomic %s, left %s" % (mp, fp)) def say_standing(k, J, d, rows): pure, odd, how = standing(rows) print(" (%d, %d), degree %d: heights of the pure products %s, of the " "others of content 1 %s: %s" % (k, J, d, list(pure), list(odd), how), flush=True) return pure, odd, how def stage_sweep(jmax=16, kmax=12): """The 165 lists, each read once. Returns the record's fields, every factor left of a polynomial that is no pure product, and the count of cells.""" cells = {} for J in range(2, jmax + 1): for k in range(2, kmax + 1): dp = F.least_pure_degree(J, k, 400)[0] if (k, J) == SKIP: d, _, _, _, parts, odd = WC.CELLS[(k, J)] assert odd == 0 cells[(k, J)] = (d, dp, read(WC.product(q) for q in parts)) continue status, W, vecs, counts, _, _, secs = WC.cell(k, J, dp=dp) assert status == "found", (k, J, status) rows = read(vecs) cells[(k, J)] = (W - 1, dp, rows) n = sum(q is None for _, q, _, _ in rows) if n or secs > 20: print(" (%d, %d): d = %d%s, %d listed, %d no pure product, " "%d children, %.1f s" % (k, J, W - 1, ", a break" if W - 1 < dp else "", len(rows), n, sum(counts), secs), flush=True) listed = [c for c in cells if c in SW.DIAL and c != SKIP and cells[c][0] == cells[c][1]] same = [tuple(sorted(q for _, q, _, _ in cells[c][2] if q)) == SW.DIAL[c][3] and all(q for _, q, _, _ in cells[c][2]) for c in listed] check("LC2 the lists already read, at suffixwalk.py's DIAL", listed and all(same), "%d of %d cells" % (sum(same), len(listed))) breaks = {c: r[0] for c, r in cells.items() if r[0] < r[1]} met = sum(breaks.get(c) == d and len(cells[c][2]) == 1 and standing(cells[c][2])[2] == "below" for c, d in KNOWN.items()) check("LK1, LC3 the breaks", len(breaks) == 3 and met == 3, "breaks: %d, the three known %d" % (len(breaks), met)) factors, got = [], {} for lo, hi in ((2, 7), (8, kmax)): law = [c for c in cells if lo <= c[0] <= hi and c not in breaks] off = sorted(c for c in law if any(q is None for _, q, _, _ in cells[c][2])) prim = [c for c in off if standing(cells[c][2])[1]] print("lists off the pure products at k = %d..%d: %d of %d cells%s" % (lo, hi, len(off), len(law), " %s" % (off,) if off else "")) print("of them with a polynomial of content 1, k = %d..%d: %d of " "%d cells %s" % (lo, hi, len(prim), len(law), prim)) got["k = %d..%d: cells of the law, lists off the pure products, " "of them on content 1" % (lo, hi)] = (len(law), len(off), tuple(prim)) for c in off: for v, q, h, cont in cells[c][2]: if q is None: mult, fs, back = left(v) assert back factors.extend(fs) if cont == 1: print(" (%d, %d): d = %d, of %d listed; height %d, " "cyclotomic %s, left %s" % (c[0], c[1], cells[c][0], len(cells[c][2]), h, mult, [list(f) for f in fs])) print(" %s" % (v,), flush=True) for c in prim: got[c] = say_standing(c[0], c[1], cells[c][0], cells[c][2]) sizes = {} for d, dp, rows in cells.values(): sizes[len(rows)] = sizes.get(len(rows), 0) + 1 print("cells by the size of their list: %s" % (dict(sorted(sizes.items())),)) got["cells by the size of their list"] = tuple(sorted(sizes.items())) got["breaks"] = tuple(sorted(breaks.items())) return got, factors, len(cells) def stage_past(): """The cells walkc.py's record holds, read off it and not run.""" got = {} for (k, J), want in sorted(WC.CELLS.items()): rows = read([WC.product(q) for q in want[4]] + [list(v) for v in WC.NOT_PURE.get((k, J), ())]) assert all(len(v) == want[0] + 1 and h <= k and F.clears(v, J) for v, _, h, _ in rows) if standing(rows)[1]: got[(k, J)] = say_standing(k, J, want[0], rows) print("the cells of walkc.py's record: %d, with a polynomial of content " "1 that is no pure product: %s" % (len(WC.CELLS), sorted(got))) return {"walkc.py's record: cells, those on content 1": (len(WC.CELLS), tuple(sorted(got.items())))} def stage_factors(factors): """LK4's line as frozen, the constants among the factors, then members.py's class tests on the others.""" kinds = sorted(set(factors)) good = sum(fair(f) for f in kinds) print("factors left: %d of %d palindromes with positive coefficients" % (good, len(kinds))) found = {NAMES.get(tuple(f), str(list(f))): f for f in kinds if len(f) > 1} for n in sorted(found): print(" %s %s %s" % (n, list(found[n]), M.describe(found[n]))) got = dict(M.class_record(found)) got["factors left: palindromes with positive coefficients, of how " "many, the constants"] = (good, len(kinds), tuple(f[0] for f in kinds if len(f) == 1)) got["in members.py's nine"] = tuple( n for n in sorted(found) if tuple(found[n]) in M.NAMES) return got def main(): t0 = time.time() WC.build() print("THE CONTROLS") stage_standing() stage_known() print("\nTHE SWEEP: J = 2..16, k = 2..12") got, factors, n = stage_sweep() print("\nTHE CELLS OF WALKC.PY'S RECORD") got.update(stage_past()) v = list(WC.NOT_PURE[(11, 18)][0]) print("\nTHE FACTORS LEFT") got.update(stage_factors(factors + list(left(v)[1]))) print("\nTHE RECORD") bad = sorted(str(key) for key in set(got) | set(RECORD) if got.get(key) != RECORD.get(key)) for key in sorted(got, key=str): print(" %r: %r," % (key, got[key])) check("LK5 the record: every line above at its recorded value", not bad, "%d of %d lines%s" % (len(got) - len(bad), len(got), "; off: %s" % (bad,) if bad else "")) print("\n%d of %d checks, %d cells, %.0f s" % (sum(CHECKS), len(CHECKS), n, time.time() - t0)) sys.exit(0 if all(CHECKS) else 1) if __name__ == "__main__": main()