"""test_639 -- MB open problem 7 as a Codazzi condition: a closed form for DF_gamma(df (x) df). On the unit round S^3 put L_f = nabla^2 f + f gamma (round Hessian) and, as an endomorphism with gamma, sigma_2(L_f) and adj_gamma L_f = gamma . adj(gamma^{-1} L_f). F(g) = Cod_g(K~) is MA's realizability operator (K~ = sqrt(det M) M^{-1}, M = -g^{-1} G), Cod(T)_ajk = nabla_a T_jk - nabla_j T_ak. Claims registered before the run: P1 [exact] DF_gamma(H) = Cod_gamma(Ric' - (1/4) R' gamma - 2H) for general polynomial H (primes: first variation along gamma + eps H), at two rational points: the first variation of the Cotton tensor about P = gamma/2. test_625 built this tensor but did not gate it. P2 [exact] On the conformal ray c(t) = e^{2tf} gamma, K~(c) = P_c + c/2 + t^2 (adj_gamma L_f - (1/2) sigma_2(L_f) gamma) + O(t^3) (P_c the Schouten tensor of c), at two rational points, for f = x0 x1 and a generic cubic. P3 [exact] Hence DF_gamma(df (x) df) = Cod_gamma(S_f), S_f = -adj_gamma L_f + (1/2) sigma_2(L_f) gamma: both sides computed independently at two rational points for x0 x1, x0^2, x0^2 + x1, x0^2/(1 + x1/3) and a generic cubic; nonzero for x0 x1 and the cubic, zero for the three solutions of MB Proposition 5.12. P4 [symbolic] tr S_f = sigma_2(L_f)/2, so S_f = 0 iff rank L_f <= 1. The solutions of Prop 5.12 are not of that kind: for f = x0^2/v, v = 1 + x1/3, S_f != 0, and L_f + (x0/v)^2 gamma has rank one (it is D^2F on the tangent space; F - x.DF = dF/dv = -(x0/v)^2 adds the multiple of gamma). [Re-posed; see History.] P5 [symbolic, identically on S^3] In the left-invariant quaternion frame everything is polynomial (or rational) in x, reduced modulo |x|^2 - 1: Cod S_f = 0 identically for x0^2 + x1 and x0^2/(1 + x1/3), not for x0 x1; and for the zonal x0^2, S_f = nabla^2 phi + phi gamma with phi = -x0^4/6, of the form Ferus (1981) proves every Codazzi tensor on a space of constant curvature takes, locally. So (df (x) df)^TT = 0 iff S_f is a Codazzi tensor, iff S_f = nabla^2 phi + phi gamma for some phi (and then sigma_2(L_f) = 2 (Delta + 3) phi): a quadratic third-order equation for f, local, in place of the projection. History: proposed by Gemini (17 November 2026, its independent-route draft, Theorem 2.1 and (2.5)); Fable checked the expansion P2 (x18 I.3, working docs/current/rh_nov26). This script is independent of both: exact rational jets in stereographic coordinates, gamma = 4|dy|^2/(1 + |y|^2)^2, x = (1 - |y|^2, 2y)/(1 + |y|^2). P1-P3 passed on the first run. P4 as first registered (this script's own addition, not Gemini's) claimed S_f = 0 identically for x0^2/(1 + x1/3), reading L_f as the Hessian of a rank-one function; it is not: F = v psi(x0/v) is homogeneous in (x0, v), not in x, so L_f = D^2F|_T + (dF/dv) gamma, and S_f != 0 at both points. The claim was re-posed as above before P4 and P5 were run; the first P4/P5, in stereographic sympy, were also too slow (stopped after 10 minutes) and were moved to the frame. The frame P5's first run failed on a coding error (f added to every entry of L_f, not only the diagonal); fixed, claim unchanged. """ import sys import itertools import random from fractions import Fraction as Fr import sympy as sp FAIL = [] def check(name, ok, detail=""): ok = bool(ok) if not ok: FAIL.append(name) print(f"[{'PASS' if ok else 'FAIL'}] {name}" + (f" ({detail})" if detail else ""), flush=True) # ---------------------------------------------------------------- exact jets in (dy0, dy1, dy2; t) D = 4 # y-degree kept; the inputs (x(y), gamma, H) are exact to this degree NT = 3 # t-orders kept (t^0, t^1, t^2) MONS = [m for m in itertools.product(range(D + 1), repeat=3) if sum(m) <= D] class J: __slots__ = ("c",) def __init__(self, c=None): self.c = c if c is not None else {} @staticmethod def const(v, k=0): return J({(0, 0, 0, k): Fr(v)} if v != 0 else {}) def __add__(s, o): o = o if isinstance(o, J) else J.const(o) c = dict(s.c) for k, v in o.c.items(): c[k] = c.get(k, 0) + v return J({k: v for k, v in c.items() if v != 0}) __radd__ = __add__ def __neg__(s): return J({k: -v for k, v in s.c.items()}) def __sub__(s, o): return s + (-(o if isinstance(o, J) else J.const(o))) def __rsub__(s, o): return J.const(o) - s def __mul__(s, o): if not isinstance(o, J): o = Fr(o) return J({k: v*o for k, v in s.c.items() if v*o != 0}) c = {} for (a0, a1, a2, ka), va in s.c.items(): for (b0, b1, b2, kb), vb in o.c.items(): if a0 + a1 + a2 + b0 + b1 + b2 > D or ka + kb >= NT: continue key = (a0 + b0, a1 + b1, a2 + b2, ka + kb) c[key] = c.get(key, 0) + va*vb return J({k: v for k, v in c.items() if v != 0}) __rmul__ = __mul__ def c0(s): return s.c.get((0, 0, 0, 0), Fr(0)) def inv(s): a = s.c0() assert a != 0 u = (s - a)*Fr(1, 1)*(1/a) out, p = J.const(1), J.const(1) for _ in range(D + NT): p = p*(-u) out = out + p return out*(1/a) def __truediv__(s, o): return s*(o.inv() if isinstance(o, J) else 1/Fr(o)) def sqrt(s): a = s.c0() r = sp.sqrt(sp.Rational(a.numerator, a.denominator)) assert r.is_Rational, "sqrt: constant term not a rational square" r = Fr(int(r.p), int(r.q)) u = (s - a)*(1/a) out, p, coef = J.const(1), J.const(1), Fr(1) for k in range(1, D + NT + 1): coef = coef*(Fr(1, 2) - (k - 1))/k p = p*u out = out + p*coef return out*r def d(s, i): c = {} for (a0, a1, a2, k), v in s.c.items(): a = [a0, a1, a2] if a[i] == 0: continue m = a[i] a[i] -= 1 c[(a[0], a[1], a[2], k)] = v*m return J(c) def tpart(s, k): """coefficient of t^k, as a jet with t^0.""" return J({(a0, a1, a2, 0): v for (a0, a1, a2, kk), v in s.c.items() if kk == k}) def at(s, k=0): return s.c.get((0, 0, 0, k), Fr(0)) def tvar(): return J({(0, 0, 0, 1): Fr(1)}) def coords(pt): """jets of y_i = pt_i + dy_i.""" return [J({(0, 0, 0, 0): Fr(pt[i]), tuple(1 if j == i else 0 for j in range(3)) + (0,): Fr(1)}) for i in range(3)] def embed(y): s = 1 + y[0]*y[0] + y[1]*y[1] + y[2]*y[2] si = s.inv() x0 = (2 - s)*si # (1 - |y|^2)/(1 + |y|^2) return [x0] + [y[i]*2*si for i in range(3)], si def round_metric(si): c = si*si*4 return [[c if i == j else J() for j in range(3)] for i in range(3)] # ---------------------------------------------------------------- 3x3 algebra on jets def det3(A): return (A[0][0]*(A[1][1]*A[2][2] - A[1][2]*A[2][1]) - A[0][1]*(A[1][0]*A[2][2] - A[1][2]*A[2][0]) + A[0][2]*(A[1][0]*A[2][1] - A[1][1]*A[2][0])) def adj3(A): cof = [[None]*3 for _ in range(3)] for i in range(3): for j in range(3): m = [[A[r][c] for c in range(3) if c != j] for r in range(3) if r != i] cof[i][j] = (m[0][0]*m[1][1] - m[0][1]*m[1][0])*(1 if (i + j) % 2 == 0 else -1) return [[cof[j][i] for j in range(3)] for i in range(3)] def matmul(A, B): return [[sum((A[i][k]*B[k][j] for k in range(3)), J()) for j in range(3)] for i in range(3)] def inv3(A): di = det3(A).inv() ad = adj3(A) return [[ad[i][j]*di for j in range(3)] for i in range(3)] def christoffel(g, gi): dg = [[[g[i][j].d(k) for k in range(3)] for j in range(3)] for i in range(3)] return [[[sum((gi[l][m]*(dg[m][i][j] + dg[m][j][i] - dg[i][j][m]) for m in range(3)), J())*Fr(1, 2) for j in range(3)] for i in range(3)] for l in range(3)] # Gam[l][i][j] = Gamma^l_ij def ricci(Gm): return [[sum((Gm[i][j][k].d(i) - Gm[i][j][i].d(k) + sum((Gm[i][i][l]*Gm[l][j][k] - Gm[i][k][l]*Gm[l][j][i] for l in range(3)), J()) for i in range(3)), J()) for k in range(3)] for j in range(3)] def cod(T, Gm): """Cod(T)_ajk = nabla_a T_jk - nabla_j T_ak, a < j.""" out = {} for a in range(3): for j in range(a + 1, 3): for k in range(3): t = T[j][k].d(a) - T[a][k].d(j) for m in range(3): t = t - Gm[m][a][k]*T[j][m] + Gm[m][j][k]*T[a][m] out[(a, j, k)] = t return out def geometry(g): gi = inv3(g) Gm = christoffel(g, gi) Rc = ricci(Gm) Rs = sum((gi[j][k]*Rc[j][k] for j in range(3) for k in range(3)), J()) return gi, Gm, Rc, Rs def ktilde(g, gi, Rc, Rs): Gl = [[Rc[i][j] - Rs*g[i][j]*Fr(1, 2) for j in range(3)] for i in range(3)] M = [[-sum((gi[a][c]*Gl[c][b] for c in range(3)), J()) for b in range(3)] for a in range(3)] dM = det3(M) Kmix = [[e*dM.sqrt()/dM for e in row] for row in adj3(M)] # sqrt(det M) M^{-1} return matmul(g, Kmix) def schouten(g, Rc, Rs): return [[Rc[i][j] - Rs*g[i][j]*Fr(1, 4) for j in range(3)] for i in range(3)] def L_and_S(f, gam, Gm0): """L_f = nabla^2 f + f gamma and S_f = -adj_gamma L_f + sigma_2 gamma / 2, round connection.""" df = [f.d(i) for i in range(3)] L = [[f.d(i).d(j) - sum((Gm0[k][i][j]*df[k] for k in range(3)), J()) + f*gam[i][j] for j in range(3)] for i in range(3)] A = matmul(inv3(gam), L) trA = A[0][0] + A[1][1] + A[2][2] A2 = matmul(A, A) s2 = (trA*trA - (A2[0][0] + A2[1][1] + A2[2][2]))*Fr(1, 2) adjL = matmul(gam, adj3(A)) S = [[-adjL[i][j] + s2*gam[i][j]*Fr(1, 2) for j in range(3)] for i in range(3)] return L, S, adjL, s2 def DF_of(H, gam): """eps-coefficient, at the point, of F(gamma + eps H) and of Cod_gamma(Ric' - R' gamma/4 - 2H).""" eps = tvar() g = [[gam[i][j] + eps*H[i][j] for j in range(3)] for i in range(3)] gi, Gm, Rc, Rs = geometry(g) F = cod(ktilde(g, gi, Rc, Rs), Gm) Gm0 = [[[Gm[l][i][j].tpart(0) for j in range(3)] for i in range(3)] for l in range(3)] T1 = [[Rc[i][j].tpart(1) - gam[i][j]*Rs.tpart(1)*Fr(1, 4) - H[i][j]*2 for j in range(3)] for i in range(3)] G1 = cod(T1, Gm0) return {k: v.at(1) for k, v in F.items()}, {k: v.at(0) for k, v in G1.items()}, {k: v.at(0) for k, v in F.items()}, Gm0 # ---------------------------------------------------------------- the functions def funcs(x): x0, x1, x2, x3 = x return { "x0 x1": x0*x1, "x0^2": x0*x0, "x0^2 + x1": x0*x0 + x1, "x0^2/(1 + x1/3)": x0*x0*(1 + x1*Fr(1, 3)).inv(), "cubic": x0*x0*x1*2 - x1*x2*x3*3 + x0*x2*x2 + x3*x3*x3 - x0*x1*5 + x2, } PTS = [(Fr(1, 2), Fr(1, 3), Fr(1, 5)), (Fr(-2, 3), Fr(1, 4), Fr(3, 7))] random.seed(639) def rand_poly(y, deg=3): terms = [J.const(1)] + list(y) + [y[i]*y[j] for i in range(3) for j in range(i, 3)] \ + [y[i]*y[j]*y[k] for i in range(3) for j in range(i, 3) for k in range(j, 3)] return sum((t*random.randint(-3, 3) for t in terms), J()) # P1 ----------------------------------------------------------------------------------------------- ok1, nz1 = True, False for pt in PTS: y = coords(pt) x, si = embed(y) gam = round_metric(si) H = [[None]*3 for _ in range(3)] for i in range(3): for j in range(i, 3): H[i][j] = H[j][i] = rand_poly(y) Fe, Ge, F0, _ = DF_of(H, gam) ok1 &= all(v == 0 for v in F0.values()) and all(Fe[k] == Ge[k] for k in Fe) nz1 |= any(v != 0 for v in Fe.values()) check("P1 DF_gamma(H) = Cod_gamma(Ric' - R' gamma/4 - 2H) for general H at two rational points", ok1 and nz1) # P2 ----------------------------------------------------------------------------------------------- ok2 = True for pt in PTS: y = coords(pt) x, si = embed(y) gam = round_metric(si) Gm0 = christoffel(gam, inv3(gam)) for name in ("x0 x1", "cubic"): f = funcs(x)[name] t = tvar() conf = 1 + t*f*2 + t*t*f*f*2 # e^{2tf} to t^2 c = [[gam[i][j]*conf for j in range(3)] for i in range(3)] gi, Gm, Rc, Rs = geometry(c) K = ktilde(c, gi, Rc, Rs) P = schouten(c, Rc, Rs) _, _, adjL, s2 = L_and_S(f, gam, Gm0) for i in range(3): for j in range(3): diff = K[i][j] - P[i][j] - c[i][j]*Fr(1, 2) want2 = (adjL[i][j] - s2*gam[i][j]*Fr(1, 2)).at(0) ok2 &= diff.at(0) == 0 and diff.at(1) == 0 and diff.at(2) == want2 check("P2 on e^{2tf} gamma: K~ = P + g/2 + t^2 (adj_gamma L_f - sigma_2 gamma/2) + O(t^3), two points, two f", ok2) # P3 ----------------------------------------------------------------------------------------------- ok3, rows = True, [] for name in ("x0 x1", "x0^2", "x0^2 + x1", "x0^2/(1 + x1/3)", "cubic"): allzero = True for pt in PTS: y = coords(pt) x, si = embed(y) gam = round_metric(si) f = funcs(x)[name] df = [f.d(i) for i in range(3)] H = [[df[i]*df[j] for j in range(3)] for i in range(3)] Fe, _, _, Gm0 = DF_of(H, gam) _, S, _, _ = L_and_S(f, gam, Gm0) CS = {k: v.at(0) for k, v in cod(S, Gm0).items()} ok3 &= all(Fe[k] == CS[k] for k in Fe) allzero &= all(v == 0 for v in Fe.values()) rows.append((name, allzero)) want = {"x0 x1": False, "x0^2": True, "x0^2 + x1": True, "x0^2/(1 + x1/3)": True, "cubic": False} ok3 &= all(want[n] == z for n, z in rows) check("P3 DF_gamma(df (x) df) = Cod_gamma(-adj_gamma L_f + sigma_2(L_f) gamma/2); zero exactly for the Prop 5.12 solutions", ok3, ", ".join(f"{n}: {'0' if z else 'nonzero'}" for n, z in rows)) # P4 ---------------------------------------------------------------------------------------------- Lg = sp.Matrix(3, 3, lambda i, j: sp.Symbol(f"l{min(i, j)}{max(i, j)}")) s2g = ((Lg.trace())**2 - (Lg*Lg).trace())/2 Sg = -Lg.adjugate() + s2g*sp.eye(3)/2 alg = sp.expand(Sg.trace() - s2g/2) == 0 ok4 = alg for pt in PTS: y = coords(pt) x, si = embed(y) gam = round_metric(si) Gm0 = christoffel(gam, inv3(gam)) f = funcs(x)["x0^2/(1 + x1/3)"] L, S, _, _ = L_and_S(f, gam, Gm0) w = x[0]*(1 + x[1]*Fr(1, 3)).inv() A = matmul(inv3(gam), [[L[i][j] + w*w*gam[i][j] for j in range(3)] for i in range(3)]) trA = A[0][0] + A[1][1] + A[2][2] A2 = matmul(A, A) ok4 &= any(S[i][j].at(0) != 0 for i in range(3) for j in range(3)) ok4 &= ((trA*trA - (A2[0][0] + A2[1][1] + A2[2][2]))*Fr(1, 2)).at(0) == 0 and det3(A).at(0) == 0 check("P4 tr S_f = sigma_2/2 (S_f = 0 iff rank L_f <= 1); for x0^2/v, S_f != 0 and L_f + (x0/v)^2 gamma has rank one", ok4) # P5: the quaternion frame ------------------------------------------------------------------------ xs = sp.symbols('x0:4', real=True) FR = [(-xs[1], xs[0], xs[3], -xs[2]), (-xs[2], -xs[3], xs[0], xs[1]), (-xs[3], xs[2], -xs[1], xs[0])] # x i, x j, x k Xop = lambda a, p: sum(FR[a][m]*sp.diff(p, xs[m]) for m in range(4)) br = [[[sp.expand(sum(FR[a][n]*sp.diff(FR[b][m], xs[n]) - FR[b][n]*sp.diff(FR[a][m], xs[n]) for n in range(4))) for m in range(4)] for b in range(3)] for a in range(3)] frame_ok = all(br[a][b] == [sp.expand(2*sum(sp.LeviCivita(a, b, c)*FR[c][m] for c in range(3))) for m in range(4)] for a in range(3) for b in range(3)) sphere = sum(v**2 for v in xs) - 1 def on_sphere_zero(e): num = sp.numer(sp.together(sp.expand(e))) return sp.rem(sp.expand(num), sphere, xs[0]) == 0 def hessL(f): return sp.Matrix(3, 3, lambda a, b: Xop(a, Xop(b, f)) - sum(sp.LeviCivita(a, b, c)*Xop(c, f) for c in range(3)) + (f if a == b else 0)) def S_frame(f): L = hessL(f) s2 = ((L.trace())**2 - (L*L).trace())/2 return -L.adjugate() + s2*sp.eye(3)/2 def cod_frame(S): nab = lambda a, b, c: (Xop(a, S[b, c]) - sum(sp.LeviCivita(a, b, d)*S[d, c] + sp.LeviCivita(a, c, d)*S[b, d] for d in range(3))) return [nab(a, b, c) - nab(b, a, c) for a in range(3) for b in range(a + 1, 3) for c in range(3)] codazzi_zero = {} for name, f in (("x0^2 + x1", xs[0]**2 + xs[1]), ("x0^2/(1 + x1/3)", xs[0]**2/(1 + xs[1]/3)), ("x0 x1", xs[0]*xs[1])): codazzi_zero[name] = all(on_sphere_zero(e) for e in cod_frame(S_frame(f))) Sz = S_frame(xs[0]**2) Lphi = hessL(-xs[0]**4/6) zonal = (not all(on_sphere_zero(e) for e in Sz)) and all(on_sphere_zero(Sz[a, b] - Lphi[a, b]) for a in range(3) for b in range(3)) check("P5 identically on S^3: Cod S_f = 0 for x0^2 + x1 and x0^2/(1 + x1/3), not for x0 x1; S_{x0^2} = L_phi, phi = -x0^4/6", frame_ok and codazzi_zero == {"x0^2 + x1": True, "x0^2/(1 + x1/3)": True, "x0 x1": False} and zonal, f"frame brackets 2 eps: {frame_ok}; {codazzi_zero}; zonal: {zonal}") print("\nALL PASS" if not FAIL else f"\nFAILURES: {FAIL}") sys.exit(1 if FAIL else 0)