broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c,d):
    try:
        if c==0 and d==0: return 'zero-denominator'
        if abs(c)<abs(d):
            r=d/c
            den=c+d*r
            real=(a+b*r)/den
            imag=(b-a*r)/den
        else:
            r=c/d
            den=d+c*r
            real=(a*r+b)/den
            imag=(b*r-a)/den
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('asymmetric numerator', solve(3.0,2.0,4.0,1.0), [render(14/17),render(5/17)])
check('asymmetric imaginary', solve(3.0,2.0,1.0,4.0), [render(11/17),render(-10/17)])
check('negative imaginary ratio', solve(3.0,2.0,-1.0,4.0), [render(5/17),render(-14/17)])
check('negative extreme ratio', solve(float(N),2.0,-1e200,1e-200), [render(-N/1e200),render(-2e-200)])
check('large real denominator', solve(float(N),2.0,1e200,1e199), [render((N+0.2)/1.01e200),render((2-N*0.1)/1.01e200)])
check('tiny imaginary denominator', solve(float(N),2.0,1e-201,1e-200), [render((N*0.1+2)/1.01e-200),render((0.2-N)/1.01e-200)])
check('normal real branch', solve(float(N),2.0,4.0,1.0), [render((4*N+2)/17),render((8-N)/17)])
check('normal imaginary branch', solve(float(N),2.0,1.0,4.0), [render((N+8)/17),render((2-4*N)/17)])
check('negative denominator', solve(float(N),2.0,-4.0,1.0), [render((-4*N+2)/17),render((-8-N)/17)])
check('pure real', solve(float(N),2.0,2.0,0.0), [render(N/2),"1"])
check('pure imaginary', solve(float(N),2.0,0.0,2.0), ["1",render(-N/2)])
check('zero denominator', solve(float(N),2.0,0.0,0.0), "zero-denominator")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c,d):
    try:
        if c==0 and d==0: return 'zero-denominator'
        if c>=d:
            r=d/c
            den=c+d*r
            real=(a+b*r)/den
            imag=(b-a*r)/den
        else:
            r=c/d
            den=d+c*r
            real=(a*r+b)/den
            imag=(b*r-a)/den
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('asymmetric numerator', solve(3.0,2.0,4.0,1.0), [render(14/17),render(5/17)])
check('asymmetric imaginary', solve(3.0,2.0,1.0,4.0), [render(11/17),render(-10/17)])
check('negative imaginary ratio', solve(3.0,2.0,-1.0,4.0), [render(5/17),render(-14/17)])
check('negative extreme ratio', solve(float(N),2.0,-1e200,1e-200), [render(-N/1e200),render(-2e-200)])
check('large real denominator', solve(float(N),2.0,1e200,1e199), [render((N+0.2)/1.01e200),render((2-N*0.1)/1.01e200)])
check('tiny imaginary denominator', solve(float(N),2.0,1e-201,1e-200), [render((N*0.1+2)/1.01e-200),render((0.2-N)/1.01e-200)])
check('normal real branch', solve(float(N),2.0,4.0,1.0), [render((4*N+2)/17),render((8-N)/17)])
check('normal imaginary branch', solve(float(N),2.0,1.0,4.0), [render((N+8)/17),render((2-4*N)/17)])
check('negative denominator', solve(float(N),2.0,-4.0,1.0), [render((-4*N+2)/17),render((-8-N)/17)])
check('pure real', solve(float(N),2.0,2.0,0.0), [render(N/2),"1"])
check('pure imaginary', solve(float(N),2.0,0.0,2.0), ["1",render(-N/2)])
check('zero denominator', solve(float(N),2.0,0.0,0.0), "zero-denominator")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex division selects the smaller denominator component.

Divide finite complex a+ib by nonzero c+id using a denominator-ratio branch. Fixtures bound products and exercise huge or tiny denominators whose naive squares overflow or underflow. Return rendered real and imaginary components. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c,d):
    try:
        if c==0 or d==0: return 'zero-denominator'
        if abs(c)>=abs(d):
            r=d/c
            den=c+d*r
            real=(a+b*r)/den
            imag=(b-a*r)/den
        else:
            r=c/d
            den=d+c*r
            real=(a*r+b)/den
            imag=(b*r-a)/den
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('asymmetric numerator', solve(3.0,2.0,4.0,1.0), [render(14/17),render(5/17)])
check('asymmetric imaginary', solve(3.0,2.0,1.0,4.0), [render(11/17),render(-10/17)])
check('negative imaginary ratio', solve(3.0,2.0,-1.0,4.0), [render(5/17),render(-14/17)])
check('negative extreme ratio', solve(float(N),2.0,-1e200,1e-200), [render(-N/1e200),render(-2e-200)])
check('large real denominator', solve(float(N),2.0,1e200,1e199), [render((N+0.2)/1.01e200),render((2-N*0.1)/1.01e200)])
check('tiny imaginary denominator', solve(float(N),2.0,1e-201,1e-200), [render((N*0.1+2)/1.01e-200),render((0.2-N)/1.01e-200)])
check('normal real branch', solve(float(N),2.0,4.0,1.0), [render((4*N+2)/17),render((8-N)/17)])
check('normal imaginary branch', solve(float(N),2.0,1.0,4.0), [render((N+8)/17),render((2-4*N)/17)])
check('negative denominator', solve(float(N),2.0,-4.0,1.0), [render((-4*N+2)/17),render((-8-N)/17)])
check('pure real', solve(float(N),2.0,2.0,0.0), [render(N/2),"1"])
check('pure imaginary', solve(float(N),2.0,0.0,2.0), ["1",render(-N/2)])
check('zero denominator', solve(float(N),2.0,0.0,0.0), "zero-denominator")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c,d):
    try:
        if c==0: return 'zero-denominator'
        if abs(c)>=abs(d):
            r=d/c
            den=c+d*r
            real=(a+b*r)/den
            imag=(b-a*r)/den
        else:
            r=c/d
            den=d+c*r
            real=(a*r+b)/den
            imag=(b*r-a)/den
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('asymmetric numerator', solve(3.0,2.0,4.0,1.0), [render(14/17),render(5/17)])
check('asymmetric imaginary', solve(3.0,2.0,1.0,4.0), [render(11/17),render(-10/17)])
check('negative imaginary ratio', solve(3.0,2.0,-1.0,4.0), [render(5/17),render(-14/17)])
check('negative extreme ratio', solve(float(N),2.0,-1e200,1e-200), [render(-N/1e200),render(-2e-200)])
check('large real denominator', solve(float(N),2.0,1e200,1e199), [render((N+0.2)/1.01e200),render((2-N*0.1)/1.01e200)])
check('tiny imaginary denominator', solve(float(N),2.0,1e-201,1e-200), [render((N*0.1+2)/1.01e-200),render((0.2-N)/1.01e-200)])
check('normal real branch', solve(float(N),2.0,4.0,1.0), [render((4*N+2)/17),render((8-N)/17)])
check('normal imaginary branch', solve(float(N),2.0,1.0,4.0), [render((N+8)/17),render((2-4*N)/17)])
check('negative denominator', solve(float(N),2.0,-4.0,1.0), [render((-4*N+2)/17),render((-8-N)/17)])
check('pure real', solve(float(N),2.0,2.0,0.0), [render(N/2),"1"])
check('pure imaginary', solve(float(N),2.0,0.0,2.0), ["1",render(-N/2)])
check('zero denominator', solve(float(N),2.0,0.0,0.0), "zero-denominator")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex division rejects a single zero denominator component.

Divide finite complex a+ib by nonzero c+id using a denominator-ratio branch. Fixtures bound products and exercise huge or tiny denominators whose naive squares overflow or underflow. Return rendered real and imaginary components. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.sqrt(x*x+y*y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.sqrt(min(x*x+y*y,1e308))
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex square root overflows while forming the radius.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt((r+abs(x))/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(min(r+abs(x),1e308)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex square root overflows before halving its radius sum.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+x/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(abs(r/2+x/2))
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex square root adds signed real part in its stable magnitude.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=math.copysign(math.sqrt((r-x)/2),y)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=math.copysign(math.sqrt(max(0,(r-x)/2)),y)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Positive-real square root subtracts nearly equal radii.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=t if y>=0 else -t
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=t
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex square root discards the side of its branch cut.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=y/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0',render(y)]
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=-abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative-real square root retains a negative imaginary sign in its real part.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0','0']
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return ['0','-0']
        r=math.hypot(x,y)
        t=math.sqrt(r/2+abs(x)/2)
        if x>=0:
            real=t
            imag=y/(2*t)
        else:
            imag=math.copysign(t,y)
            real=abs(y)/(2*t)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex square root canonicalizes the imaginary zero at the origin.

Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=0.5*math.log(x*x+y*y)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=0.5*math.log(max(x*x+y*y,1e-300))
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm squares components before scaling.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=min(a,b); lo=max(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=a; lo=b
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm normalizes by the smaller component.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+math.log1p(ratio*ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm forgets the square of the normalized component.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan(y/x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan(y/x) if x else math.pi/2
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm uses one-argument arctangent.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(x,y)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 and y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(abs(y),abs(x))
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm reverses the atan2 arguments.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0 or y==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x,y):
    try:
        if x==0: return 'pole'
        a=abs(x); b=abs(y)
        hi=max(a,b); lo=min(a,b)
        ratio=lo/hi
        real=math.log(hi)+0.5*math.log1p(ratio*ratio)
        imag=math.atan2(y,x)
        return [render(real),render(imag)]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complex logarithm mistakes axis points for the origin.

Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)|set(raised)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set()
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Floating exception save-state aliases mutable accrued flags.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.discard('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('underflow')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Overflow does not accrue its implied inexact flag.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.discard('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('overflow')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Underflow does not accrue its implied inexact flag.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior&new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Floating exception flags replace the accumulated history.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new | set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Disabled floating exception flags trigger traps.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=accrued & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Old sticky flags retrigger floating exception traps.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in reversed(priority) if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=sorted(pending)[-1] if pending else None
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["invalid"]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Floating exceptions select the lowest-priority simultaneous trap.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access