diff --git a/research/kind-b-frame-swap-removal/PROOF.md b/research/kind-b-frame-swap-removal/PROOF.md new file mode 100644 index 0000000000..e6fbf2b564 --- /dev/null +++ b/research/kind-b-frame-swap-removal/PROOF.md @@ -0,0 +1,208 @@ +# Exact kind B removal by an admissible call + +Work in the formal group algebra Q[G], where `G=Sp(2m,2)`, `m>=3`. +Let L be the raw Lagrangian and `P=Stab_G(L)`. Free combinations act +on the left and lie in Q[P]. The frame of g is `g^-1 L`; its level is +`ell(g)=m-dim(L intersection g^-1 L)`. Products act right to left. +Paid calls are transvections with normals outside L. They are involutions +of level one. Two terms g,h have the same frame exactly when `g h^-1` +is in P. Thus a frame is a left coset Pg. + +Use Jacob Sussman's removal definition from PR #7629. Let D be the +first call and W the shared call, with `ell(WD)=2`. For gamma in P +and nonzero rational c, a kind B part is + +```text +M = WD, E = W gamma, y = M+cE. +``` + +Assume `E not in PD`. This excludes the source's plain-in-disguise +case, where E is a free image of the first-call term. The levels of +M and E are two and one, so their frames are different. +Let T be a paid call with `ell(TW)=2`. Define + +```text +U = span_Q {p, pD, py : p in P}, +U_without = span_Q {p, pD : p in P} + + span_Q {py : p in P, p != 1}. +``` + +Removal means `Ty in U + T U_without`. The identity preparation is +excluded from `U_without`; otherwise every part would be removable. + +**Theorem.** At every such width, removal by T holds if and only if + +```text +TM in PE, TE in PM, c in {+1,-1}. +``` + +The first two conditions say that T exchanges the two frames. This +proves both directions of the kind B rule left open in PR #7629, +including its requested sufficiency statement. The theorem is about +one part and one removing call. It does not settle finishing, joint +decoding, post-call free processing, Pauli phases or a two-in-five unit. + +## Why both exchange directions are necessary + +Multiply the removal inclusion on the left by T. Because T is its +own inverse, the equivalent condition is + +```text +y in T U + U_without. +``` + +The available columns are the singletons in `P, PD, TP, TPD`, the +binomials `py` with `p in P, p!=1`, and the binomials `Tpy` with p in P. +Neither target endpoint M nor E can occur in a singleton: + +- M has level two, so it is outside P and PD. +- E has level one and is outside PD by the nonplain assumption. +- If TM were free, then `TW=(TM)D` would have level one, contrary + to `ell(TW)=2`. Also `TMD=TW` is not free. +- `TE=TW gamma` has level two, so it is not free. If TED were free, + then TE would be a free left multiple of D and have level one. + +These statements exclude M and E from TP and TPD as well. The level +is invariant under left or right multiplication by P. The displayed +uses require only this invariance and the level of a call. + +An old binomial py with p nonidentity cannot contain either endpoint: +matching its corresponding endpoint forces p=1, and matching the other +endpoint would put M and E on the same frame. In a paid binomial Tpy, +M cannot be its first endpoint and E cannot be its second endpoint, +because either equality would force `p=T`, which is not free. +The only remaining ways to cover the target endpoints are + +```text +M = TpE iff TM E^-1 is in P, +E = TpM iff TE M^-1 is in P. +``` + +If either is absent, the corresponding target coefficient, one or c, +is nonzero while every available column has coefficient zero there. +This is an explicit linear obstruction. It proves both exchange +conditions are necessary, without any enumeration or assumption about +other columns. + +## Exchange gives one even alternating cycle + +Assume both exchange conditions. Put `a=E M^-1` and let n be its order. +The two conditions say `T a^-1` and Ta are in P. Therefore + +```text +a^2 = (T a^-1)^-1 (T a) is in P. +``` + +But a is not in P because M and E have different frames. It follows +that n is even, and `a^j in P` exactly for even j. Also `T a^j in P` +exactly for odd j: for odd powers use Ta and powers of a squared; +for even powers membership would force T into P. + +Let `delta=M^-1 E` and define `g_j=a^j M=M delta^j`, with indices +modulo n. These are distinct group elements. Every binomial column +has endpoints g and `g delta`, so no column with an endpoint outside +this right-delta orbit can meet it. Let `e_j=[g_j]` be its formal +coordinate vectors. The target is `b_0=e_0+c e_1`. + +The available binomial columns on the cycle are precisely + +```text +b_j = e_j+c e_(j+1), 1 <= j < n. +``` + +For even j, b_j is `p_j y` with `p_j=a^j in P`. Its j=0 occurrence +is the excluded identity preparation; all other even occurrences are +allowed. For odd j, b_j is `T p_j y` with `p_j=T a^j in P`, which +is an allowed column of TU. + +There are no singleton columns anywhere on this cycle. For even j, +g_j is in PM; for odd j it is in PE. Both cosets miss P and PD by +level and the nonplain assumption. Moreover T sends these particular +cycle points to PE and PM respectively, because `T a^j` has the +opposite parity membership just proved. Hence they also miss TP and +TPD. This excludes every other way to repair the omitted column. + +## The coefficient test and explicit removal + +The exact cyclic identity is + +```text +sum_(j=0)^(n-1) (-c)^j b_j = (1-(-c)^n) e_0. +``` + +If `(-c)^n!=1`, the full cyclic binomial matrix is invertible: the +geometric sum inverts `1+cz` modulo `z^n-1`. Its columns are independent, +so b_0 is not spanned by the other n-1 columns. Removal is impossible. +For nonzero rational c and even n, equality `(-c)^n=1` holds exactly +at c=+1 or c=-1. + +At either of those coefficients, the identity expresses b_0 as minus +the weighted sum of the other columns. This is an identity in the full +group algebra, not only in the projection. The actual preparations are + +```text +p_j = a^j for even j, 0> j) & 1) << i for i, row in enumerate(a)) for j in range(len(a))) + + +def inv(a): + n = len(a) + rows = [row | (1 << (n+i)) for i, row in enumerate(a)] + for i in range(n): + j = next(j for j in range(i, n) if rows[j] & (1 << i)) + rows[i], rows[j] = rows[j], rows[i] + for j in range(n): + if j != i and rows[j] & (1 << i): + rows[j] ^= rows[i] + return tuple(row >> n for row in rows) + + +def rank2(rows): + pivots = {} + for row in rows: + while row: + i = row.bit_length()-1 + if i not in pivots: + pivots[i] = row + break + row ^= pivots[i] + return len(pivots) + + +def is_free(g): + m = len(g)//2 + return all(row >> m == 0 for row in g[:m]) + + +def level(g): + m = len(g)//2 + return rank2(row >> m for row in g[:m]) + + +def call(m, normal): + paired = ((normal & ((1 << m)-1)) << m) | (normal >> m) + return tuple((1 << i) ^ (paired if normal & (1 << i) else 0) for i in range(2*m)) + + +def all_free(m): + def bases(rows): + if len(rows) == m: + yield tuple(rows) + else: + for x in range(1, 1 << m): + if rank2([*rows, x]) > len(rows): + yield from bases([*rows, x]) + places = [(i, j) for i in range(m) for j in range(i, m)] + form = tuple(1 << ((i+m) % (2*m)) for i in range(2*m)) + result = [] + for a in bases([]): + b = transpose(inv(a)) + for mask in range(1 << len(places)): + s = [0]*m + for bit, (i, j) in enumerate(places): + if mask & (1 << bit): + s[i] |= 1 << j + s[j] |= 1 << i + lower = mul(b, s) + g = a + tuple(lower[i] | (b[i] << m) for i in range(m)) + need(is_free(g) and mul(mul(g, form), transpose(g)) == form, 'free symplectic matrix') + result.append(g) + need(len(result) == len(set(result)) == 10752, 'three-bit free group') + return result + + +def orbit(start, step): + points = [start] + point = mul(start, step) + while point != start: + need(point not in points, 'orbit closure') + points.append(point) + point = mul(point, step) + return points + + +def in_span(columns, target): + pivots = {} + for v in columns: + row = list(map(Fraction, v)) + for i in range(len(row)): + coefficient = row[i] + if coefficient == 0: + continue + if i in pivots: + row = [x-coefficient*y for x, y in zip(row, pivots[i], strict=True)] + else: + pivots[i] = [x/coefficient for x in row] + break + row = list(map(Fraction, target)) + for i, pivot in sorted(pivots.items()): + coefficient = row[i] + row = [x-coefficient*y for x, y in zip(row, pivot, strict=True)] + return all(x == 0 for x in row) + + +def flags(points, first, middle, last, keep_identity=False): + middle_inverse = inv(middle) + singles, starts = [], [] + for g in points: + tg = mul(last, g) + singles.append(any(is_free(h) for h in (g, mul(g, first), tg, mul(tg, first)))) + old = is_free(mul(g, middle_inverse)) and (keep_identity or g != middle) + paid = is_free(mul(tg, middle_inverse)) + starts.append(old or paid) + return singles, starts + + +def span_check(points, c, first, middle, last, keep_identity=False, remove_start=None): + singles, starts = flags(points, first, middle, last, keep_identity) + n = len(points) + columns = [] + for j in range(n): + if singles[j]: + row = [Fraction(0)]*n + row[j] = 1 + columns.append(row) + if starts[j] and j != remove_start: + row = [Fraction(0)]*n + row[j] = 1 + row[(j+1) % n] += c + columns.append(row) + target = [Fraction(0)]*n + target[0] = 1 + target[1] = c + return in_span(columns, target) + + +def endpoint_certificate(first, middle, extra, last, a, ai): + # A nonzero target coefficient absent from every available column proves failure. + out = [] + for g, relative, previous in ((middle, unit(len(middle)), ai), (extra, a, unit(len(middle)))): + tg = mul(last, g) + single = any(is_free(h) for h in (g, mul(g, first), tg, mul(tg, first))) + old_start = g != middle and is_free(relative) + old_previous = previous != unit(len(middle)) and is_free(previous) + paid_start = is_free(mul(last, relative)) + paid_previous = is_free(mul(last, previous)) + out.append(not (single or old_start or old_previous or paid_start or paid_previous)) + return out + + +def census(): + first, shared = call(3, 1), call(3, 2) + middle = mul(shared, first) + mi = inv(middle) + group = all_free(3) + removing = [(normal, call(3, normal)) for normal in range(1, 64) + if normal & 7 and level(mul(call(3, normal), shared)) == 2] + need(len(removing) == 48 and level(middle) == 2, 'admissible calls') + element_counts = {str(c): 0 for c in COEFFICIENTS} + pair_counts = {str(c): 0 for c in COEFFICIENTS} + plain = 0 + orphan_pairs = 0 + cycle_pairs = 0 + order_counts = Counter() + representatives = {} + for gamma in group: + extra = mul(shared, gamma) + if is_free(mul(extra, first)): + plain += 1 + continue + a = mul(extra, mi) + ai = inv(a) + step = mul(mi, extra) + reached = {str(c): False for c in COEFFICIENTS} + for normal, last in removing: + exchange = (is_free(mul(last, ai)), is_free(mul(last, a))) + orphan = endpoint_certificate(first, middle, extra, last, a, ai) + if any(orphan): + need(not all(exchange), 'swap cannot have an orphan endpoint') + orphan_pairs += 1 + if sum(exchange) == 1: + representatives.setdefault('one_direction_only', (gamma, normal)) + else: + representatives.setdefault('neither_direction', (gamma, normal)) + continue + need(all(exchange), 'uncovered endpoint configuration') + points = orbit(middle, step) + n = len(points) + need(n % 2 == 0, 'exchange cycle must be even') + singles, starts = flags(points, first, middle, last) + need(not any(singles) and starts == [False]+[True]*(n-1), 'complete missing-column cycle') + cycle_pairs += 1 + order_counts[n] += 1 + representatives.setdefault('cycle_'+str(n), (gamma, normal)) + for c in COEFFICIENTS: + got = span_check(points, c, first, middle, last) + need(got == (c in (1, -1)), 'exact cycle span') + if got: + relation = [Fraction(0)]*n + for j in range(n): + relation[j] += (-c)**j + relation[(j+1) % n] += c*(-c)**j + need(not any(relation), 'explicit alternating relation') + pair_counts[str(c)] += 1 + reached[str(c)] = True + for c in COEFFICIENTS: + element_counts[str(c)] += reached[str(c)] + need(plain == 768 and element_counts['1'] == element_counts['-1'] == 128, 'source nonplain domain') + need(orphan_pairs+cycle_pairs == (10752-plain)*48, 'complete pair domain') + return {'free_elements': 10752, 'plain_elements_excluded': plain, 'nonplain_elements': 10752-plain, + 'admissible_calls': len(removing), 'element_call_pairs': orphan_pairs+cycle_pairs, + 'coefficient_contracts': (orphan_pairs+cycle_pairs)*len(COEFFICIENTS), + 'orphan_endpoint_pairs': orphan_pairs, 'complete_cycle_pairs': cycle_pairs, + 'cycle_order_counts': {str(k): v for k, v in sorted(order_counts.items())}, + 'removable_parts_by_coefficient': element_counts, 'removable_pairs_by_coefficient': pair_counts}, representatives + + +def embed(g, m): + positions = [0, 1, 2, m, m+1, m+2] + out = list(unit(2*m)) + for old, new in enumerate(positions): + out[new] = sum(((g[old] >> j) & 1) << positions[j] for j in range(6)) + return tuple(out) + + +def wider(representatives): + total, positives = 0, 0 + for m in (4, 5, 6): + for gamma3, normal3 in representatives.values(): + d0, w0, t0 = (embed(g, m) for g in (call(3, 1), call(3, 2), call(3, normal3))) + gamma0 = embed(gamma3, m) + for h in (unit(2*m), call(m, (1 << m) | (1 << (2*m-1)))): + first, shared, last, gamma = (mul(mul(h, g), h) for g in (d0, w0, t0, gamma0)) + middle, extra = mul(shared, first), mul(shared, gamma) + need(level(middle) == level(mul(last, shared)) == 2 and is_free(gamma), 'wider premises') + a = mul(extra, inv(middle)) + exchange = is_free(mul(last, a)) and is_free(mul(last, inv(a))) + points = orbit(middle, mul(inv(middle), extra)) + for c in COEFFICIENTS: + got = span_check(points, c, first, middle, last) + need(got == (exchange and c in (1, -1)), 'wider full span') + total += 1 + positives += got + return {'contracts': total, 'removable': positives, 'nontrivial_spare_conjugations': True} + + +def controls(representatives): + first, shared = call(3, 1), call(3, 2) + middle = mul(shared, first) + gamma, normal = representatives['one_direction_only'] + last, extra = call(3, normal), mul(shared, gamma) + points = orbit(middle, mul(inv(middle), extra)) + need(not span_check(points, Fraction(1), first, middle, last), 'one exchange direction is insufficient') + need(span_check(points, Fraction(1), first, middle, last, True), 'identity preparation control') + cycle_key = max((key for key in representatives if key.startswith('cycle_')), key=lambda key: int(key[6:])) + gamma, normal = representatives[cycle_key] + last, extra = call(3, normal), mul(shared, gamma) + points = orbit(middle, mul(inv(middle), extra)) + need(span_check(points, Fraction(1), first, middle, last), 'positive control') + need(not span_check(points, Fraction(2), first, middle, last), 'coefficient control') + need(not span_check(points, Fraction(1), first, middle, last, remove_start=1), 'missing cyclic column control') + need(not span_check(points, Fraction(0), first, middle, last), 'zero coefficient boundary') + return {'controls': 5, 'positive_cycle_length': len(points)} + + +def verify(): + need(in_span([[1, 1], [1, 2]], [0, 1]), 'row-reduction positive control') + need(not in_span([[1, 1]], [1, 2]), 'row-reduction negative control') + data, reps = census() + result = {'status': 'PASS_KIND_B_FRAME_SWAP_REMOVAL', 'census': data, 'linear_solver_controls': 2, + 'wider_checks': wider(reps), 'boundary_controls': controls(reps), + 'representatives': {key: {'gamma_rows': list(g), 'removing_normal': n} + for key, (g, n) in sorted(reps.items())}} + need(json.loads((ROOT/'RESULT.json').read_text()) == result, 'retained receipt') + return result + + +if __name__ == '__main__': + print(json.dumps(verify(), indent=2, sort_keys=True))