FAILURE MAP
← Case archive

FA-5511 / Number theory / Open access

Carmichael number predicate · case 01

A base-two Fermat congruence admits primes as Carmichael numbers.

Verified by executionVariant 1 · 5 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

A base-two Fermat congruence admits primes as Carmichael numbers.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return n>2 and any(n%d==0 for d in range(2,math.isqrt(n)+1)) and all(pow(a,n-1,n)==1 for a in range(2,n) if math.gcd(a,n)==1)

Unsuccessful approach: Requiring compositeness still accepts pseudoprimes that fail other coprime bases.

Case contract

Integer inputs; n is positive unless a zero or negative fixture explicitly extends that operation. A modulus is greater than one; p is prime; exponent k may be signed when an inverse exists. n is a nonnegative integer; return true precisely for composite n satisfying a**(n-1)=1 modulo n for every a coprime to n. Exact operational definition: n>2 and any(n%d==0 for d in range(2,math.isqrt(n)+1)) and all(pow(a,n-1,n)==1 for a in range(2,n) if math.gcd(a,n)==1)

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Number theory results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return n>1 and pow(2,n-1,n)==1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (561,)', solve(*(561,)), True)
check('fixture 2: (1105,)', solve(*(1105,)), True)
check('fixture 3: (341,)', solve(*(341,)), False)
check('fixture 4: (13,)', solve(*(13,)), False)
check('fixture 5: (1,)', solve(*(1,)), False)
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)
Boundary fixtureActualExpectedOutcome
fixture 1: (561,)TrueTruePassed
fixture 2: (1105,)TrueTruePassed
fixture 3: (341,)TrueFalseFailed
fixture 4: (13,)TrueFalseFailed
fixture 5: (1,)FalseFalsePassed

SHA-256 / 07a3892c720bbe09b1a0b0ac763b5b9eb237878b8843e54515a88b62ae62e33b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return n>2 and any(n%d==0 for d in range(2,math.isqrt(n)+1)) and pow(2,n-1,n)==1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (561,)', solve(*(561,)), True)
check('fixture 2: (1105,)', solve(*(1105,)), True)
check('fixture 3: (341,)', solve(*(341,)), False)
check('fixture 4: (13,)', solve(*(13,)), False)
check('fixture 5: (1,)', solve(*(1,)), False)
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)
Boundary fixtureActualExpectedOutcome
fixture 1: (561,)TrueTruePassed
fixture 2: (1105,)TrueTruePassed
fixture 3: (341,)TrueFalseFailed
fixture 4: (13,)FalseFalsePassed
fixture 5: (1,)FalseFalsePassed

SHA-256 / a4ead187758294440d6813ee03dee681c850be6c1925632a8deadcf00115172e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return n>2 and any(n%d==0 for d in range(2,math.isqrt(n)+1)) and all(pow(a,n-1,n)==1 for a in range(2,n) if math.gcd(a,n)==1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (561,)', solve(*(561,)), True)
check('fixture 2: (1105,)', solve(*(1105,)), True)
check('fixture 3: (341,)', solve(*(341,)), False)
check('fixture 4: (13,)', solve(*(13,)), False)
check('fixture 5: (1,)', solve(*(1,)), False)
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)
Boundary fixtureActualExpectedOutcome
fixture 1: (561,)TrueTruePassed
fixture 2: (1105,)TrueTruePassed
fixture 3: (341,)FalseFalsePassed
fixture 4: (13,)FalseFalsePassed
fixture 5: (1,)FalseFalsePassed

SHA-256 / 8fef38c938a1047342f3b604f53654384fc27262e99877f25f3dd05b804239cd

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:50.209965+00:00.

Case digest / 8e09514a24a75ddf4da0c6b7a20cbd6616a0d0f3c20ea6eb6203ba68908e3247