"""SC exact rational intervals for analytic Cox grain probabilities, not simulation. Only arithmetic on Fraction endpoints establishes signs. Decimal output below is for readable summaries. Positive-exponential Taylor remainder has a geometric bound; log-void uses the positive q power series remainder. """ from fractions import Fraction as F from decimal import Decimal,localcontext import json import sys sys.set_int_max_str_digits(200000) def outward(a,digits=80): """Exact rational outward quantization to a common denominator.""" Q=10**digits low=a[0]*Q;high=a[1]*Q return F(low.numerator//low.denominator,Q),F(-((-high.numerator)//high.denominator),Q) def add(a,b):return outward((a[0]+b[0],a[1]+b[1])) def neg(a):return (-a[1],-a[0]) def sub(a,b):return add(a,neg(b)) def mul(a,b): p=[x*y for x in a for y in b] return outward((min(p),max(p))) def scale(a,x):return mul(a,(x,x)) def exp_negative(x,terms=80): """Enclose exp(-x), x>=0; proof uses exact Taylor/geometric remainder.""" x=F(x) if x<0 or type(terms) is not int or terms<1 or x>=terms+2: raise ValueError('need nonnegative x and remainder ratio x/(terms+2)<1') if x<=1:terms=min(terms,16) term=F(1);partial=F(1) for k in range(1,terms+1): term=term*x/k;partial+=term next_term=term*x/(terms+1) remainder=next_term/(1-x/(terms+2)) return outward((F(1)/(partial+remainder),F(1)/partial)) def log_void(v,terms=18): """Enclose log(v) using q=1-v in [0,1); no floating point in enclosure.""" if type(terms) is not int or terms<1 or not 0F(1,10**9), 'compact_L0_above_1e_minus9':base_L[0]>F(1,10**9), 'heavy_D_positive':D[0]>0,'heavy_L_positive':L[0]>0, 'both_W_negative':all(r['W'][1]<0 for r in rows), 'all_hole_probabilities_below_0_002':all(v[0]>F(499,500) for r in rows for v in r['void']), 'uniform_anchor_D_above_9e_minus10':base_D[0]-D_error>F(9,10**10), 'uniform_anchor_L_above_9e_minus10':base_L[0]-L_error>F(9,10**10)} assert all(assertions.values()) return {'method':'exact Fraction endpoints, Taylor/geometric exponential and log power-series bounds', 'data_identity':'analytic comparator certificate; not Monte Carlo or original cooperative-field data', 'parameters':{'epsilon':'1/1000','eta':'1/10000000000','anchor':1,'life':12,'beta_low':'1/100000','beta_high':'2','H':[1,10],'T':1,'old_control':[1,2,3],'target_control':1}, 'assertions':assertions,'D0':enclose(base_D),'L0':enclose(base_L),'D':enclose(D),'L':enclose(L), 'W':[enclose(r['W']) for r in rows], 'q':[[enclose(sub((F(1),F(1)),v)) for v in r['void']] for r in rows], 'uniform_anchor_D_error_fraction':str(D_error),'uniform_anchor_L_error_fraction':str(L_error), 'proof_scope':'one fixed law for all times per anchor; anchor-dependent family removes uniform sign onset, not complete finite data-law indistinguishability'} if __name__=='__main__':print(json.dumps(certificate(),indent=2))