"""Interval estimates for the independent-union kernel in the rank certificates.""" from check_rank import TAU, Q, diagonal_input, entropy, entropy_range from flint import arb def verify_interior(edge, comparison): # The endpoint strips are treated analytically in the respective proofs. pending = [(edge, 1 - edge)] count = 0 while pending: a, b = pending.pop() x = a.union(b) if b < arb(1) / 2: diag = (1 - x) * (x * (x.log1p() - (-x).log1p()) + (-x * x).log1p()) else: diag = (1 - x) * ((1 + x) * (1 + x).log() + (1 - x) * (1 - x).log()) h0 = entropy_range(diagonal_input(a), diagonal_input(b)) # The positive kernel expansion also gives D(x,x) <= x^2. if comparison(diag.min(x * x).nonnegative_part(), x, entropy_range(a, b), h0): count += 1 else: mid = (a + b) / 2 pending.extend([(a, mid), (mid, b)]) return count CLIPPED_MU = arb(37) / 10 CLIPPED_LAMBDA = arb(14) / 5 def verify_clipped_tail(): denominator = (arb(167) / 200).sqrt() def comparison(diag, x, h, h0): clipped = (x * h).nonnegative_part().sqrt().min(3 * h / 2) rhs = clipped / (2 * denominator) + (3 * CLIPPED_MU * Q * h0 / 4).sqrt() return rhs >= ((CLIPPED_LAMBDA + CLIPPED_MU) * diag).sqrt() return verify_interior(arb(1) / 65536, comparison) def diagonal_residual(a, b, x, phi): """Enclose [Q h(I0(x,x)) - D(x,x)]/phi using its numerator derivative.""" mid = (a + b) / 2 left, right = 1 - mid, 1 + mid value = Q * entropy(diagonal_input(mid)) - left * ( right * right.log() + left * left.log() ) u = diagonal_input(a).union(diagonal_input(b)) du = 2 * x * (1 + TAU * (1 - x) * (1 - 2 * x)) left, right = 1 - x, 1 + x deriv = ( Q * (1 / u - 1).log() * du + right * right.log() + left * left.log() - left * (right / left).log() ) return (value + (x - mid) * deriv) / phi