"""Extended function library v5 — Auto-generated utility functions."""

from .expr import Expr, Symbol
from .rules import RuleDelayed
from .pattern import Blank
import math


def build_extended5_rules():
    rules = []
    
    def rule1(head, fn):
        rules.append(RuleDelayed(Expr(head, Blank("a")), lambda b: fn(b["a"])))
    
    def rule2(head, fn):
        rules.append(RuleDelayed(Expr(head, Blank("a"), Blank("b")), lambda b: fn(b["a"], b["b"])))
    
    def _fib(n):
        a, b = 0, 1
        for _ in range(n):
            a, b = b, a + b
        return a

    def _is_prime_check(n):
        if n < 2:
            return False
        for i in range(2, int(n**0.5) + 1):
            if n % i == 0:
                return False
        return True

    rule1("Power1", lambda a: float(a)**1)
    rule1("Root1", lambda a: float(a)**(1/1))
    rule1("Reciprocal1", lambda a: 1/(float(a)**1))
    rule1("Double1", lambda a: float(a)*2)
    rule1("Half1", lambda a: float(a)/2)
    rule1("Negate1", lambda a: -float(a)**1)
    rule1("Increment1", lambda a: float(a)+1)
    rule1("Decrement1", lambda a: float(a)-1)
    rule1("ScaleBy1", lambda a: float(a)*1)
    rule1("DivideBy1", lambda a: float(a)/1)
    rule1("Power2", lambda a: float(a)**2)
    rule1("Root2", lambda a: float(a)**(1/2))
    rule1("Reciprocal2", lambda a: 1/(float(a)**2))
    rule1("Double2", lambda a: float(a)*4)
    rule1("Half2", lambda a: float(a)/4)
    rule1("Negate2", lambda a: -float(a)**2)
    rule1("Increment2", lambda a: float(a)+2)
    rule1("Decrement2", lambda a: float(a)-2)
    rule1("ScaleBy2", lambda a: float(a)*2)
    rule1("DivideBy2", lambda a: float(a)/2)
    rule1("Power3", lambda a: float(a)**3)
    rule1("Root3", lambda a: float(a)**(1/3))
    rule1("Reciprocal3", lambda a: 1/(float(a)**3))
    rule1("Double3", lambda a: float(a)*8)
    rule1("Half3", lambda a: float(a)/8)
    rule1("Negate3", lambda a: -float(a)**3)
    rule1("Increment3", lambda a: float(a)+3)
    rule1("Decrement3", lambda a: float(a)-3)
    rule1("ScaleBy3", lambda a: float(a)*3)
    rule1("DivideBy3", lambda a: float(a)/3)
    rule1("Power4", lambda a: float(a)**4)
    rule1("Root4", lambda a: float(a)**(1/4))
    rule1("Reciprocal4", lambda a: 1/(float(a)**4))
    rule1("Double4", lambda a: float(a)*16)
    rule1("Half4", lambda a: float(a)/16)
    rule1("Negate4", lambda a: -float(a)**4)
    rule1("Increment4", lambda a: float(a)+4)
    rule1("Decrement4", lambda a: float(a)-4)
    rule1("ScaleBy4", lambda a: float(a)*4)
    rule1("DivideBy4", lambda a: float(a)/4)
    rule1("Power5", lambda a: float(a)**5)
    rule1("Root5", lambda a: float(a)**(1/5))
    rule1("Reciprocal5", lambda a: 1/(float(a)**5))
    rule1("Double5", lambda a: float(a)*32)
    rule1("Half5", lambda a: float(a)/32)
    rule1("Negate5", lambda a: -float(a)**5)
    rule1("Increment5", lambda a: float(a)+5)
    rule1("Decrement5", lambda a: float(a)-5)
    rule1("ScaleBy5", lambda a: float(a)*5)
    rule1("DivideBy5", lambda a: float(a)/5)
    rule1("Power6", lambda a: float(a)**6)
    rule1("Root6", lambda a: float(a)**(1/6))
    rule1("Reciprocal6", lambda a: 1/(float(a)**6))
    rule1("Double6", lambda a: float(a)*64)
    rule1("Half6", lambda a: float(a)/64)
    rule1("Negate6", lambda a: -float(a)**6)
    rule1("Increment6", lambda a: float(a)+6)
    rule1("Decrement6", lambda a: float(a)-6)
    rule1("ScaleBy6", lambda a: float(a)*6)
    rule1("DivideBy6", lambda a: float(a)/6)
    rule1("Power7", lambda a: float(a)**7)
    rule1("Root7", lambda a: float(a)**(1/7))
    rule1("Reciprocal7", lambda a: 1/(float(a)**7))
    rule1("Double7", lambda a: float(a)*128)
    rule1("Half7", lambda a: float(a)/128)
    rule1("Negate7", lambda a: -float(a)**7)
    rule1("Increment7", lambda a: float(a)+7)
    rule1("Decrement7", lambda a: float(a)-7)
    rule1("ScaleBy7", lambda a: float(a)*7)
    rule1("DivideBy7", lambda a: float(a)/7)
    rule1("Power8", lambda a: float(a)**8)
    rule1("Root8", lambda a: float(a)**(1/8))
    rule1("Reciprocal8", lambda a: 1/(float(a)**8))
    rule1("Double8", lambda a: float(a)*256)
    rule1("Half8", lambda a: float(a)/256)
    rule1("Negate8", lambda a: -float(a)**8)
    rule1("Increment8", lambda a: float(a)+8)
    rule1("Decrement8", lambda a: float(a)-8)
    rule1("ScaleBy8", lambda a: float(a)*8)
    rule1("DivideBy8", lambda a: float(a)/8)
    rule1("Power9", lambda a: float(a)**9)
    rule1("Root9", lambda a: float(a)**(1/9))
    rule1("Reciprocal9", lambda a: 1/(float(a)**9))
    rule1("Double9", lambda a: float(a)*512)
    rule1("Half9", lambda a: float(a)/512)
    rule1("Negate9", lambda a: -float(a)**9)
    rule1("Increment9", lambda a: float(a)+9)
    rule1("Decrement9", lambda a: float(a)-9)
    rule1("ScaleBy9", lambda a: float(a)*9)
    rule1("DivideBy9", lambda a: float(a)/9)
    rule1("Power10", lambda a: float(a)**10)
    rule1("Root10", lambda a: float(a)**(1/10))
    rule1("Reciprocal10", lambda a: 1/(float(a)**10))
    rule1("Double10", lambda a: float(a)*1024)
    rule1("Half10", lambda a: float(a)/1024)
    rule1("Negate10", lambda a: -float(a)**10)
    rule1("Increment10", lambda a: float(a)+10)
    rule1("Decrement10", lambda a: float(a)-10)
    rule1("ScaleBy10", lambda a: float(a)*10)
    rule1("DivideBy10", lambda a: float(a)/10)
    rule1("Take1", lambda a: Expr("List", *list(a.args[:1] if hasattr(a, "args") else [])))
    rule1("Drop1", lambda a: Expr("List", *list(a.args[1:] if hasattr(a, "args") else [])))
    rule1("Reverse1Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*1)))
    rule1("Repeat1Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*1)))
    rule1("EveryNth1", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::1])))
    rule1("Skip1", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[1::])))
    rule1("PadLeft1", lambda a: Expr("List", *([0]*1 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight1", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*1)))
    rule1("ChunkSize1", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+1]) for j in range(0, len(a.args if hasattr(a, "args") else []), 1)]))
    rule2("AppendN1", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*1)))
    rule1("Take2", lambda a: Expr("List", *list(a.args[:2] if hasattr(a, "args") else [])))
    rule1("Drop2", lambda a: Expr("List", *list(a.args[2:] if hasattr(a, "args") else [])))
    rule1("Reverse2Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*2)))
    rule1("Repeat2Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*2)))
    rule1("EveryNth2", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::2])))
    rule1("Skip2", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[2::])))
    rule1("PadLeft2", lambda a: Expr("List", *([0]*2 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight2", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*2)))
    rule1("ChunkSize2", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+2]) for j in range(0, len(a.args if hasattr(a, "args") else []), 2)]))
    rule2("AppendN2", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*2)))
    rule1("Take3", lambda a: Expr("List", *list(a.args[:3] if hasattr(a, "args") else [])))
    rule1("Drop3", lambda a: Expr("List", *list(a.args[3:] if hasattr(a, "args") else [])))
    rule1("Reverse3Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*3)))
    rule1("Repeat3Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*3)))
    rule1("EveryNth3", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::3])))
    rule1("Skip3", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[3::])))
    rule1("PadLeft3", lambda a: Expr("List", *([0]*3 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight3", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*3)))
    rule1("ChunkSize3", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+3]) for j in range(0, len(a.args if hasattr(a, "args") else []), 3)]))
    rule2("AppendN3", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*3)))
    rule1("Take4", lambda a: Expr("List", *list(a.args[:4] if hasattr(a, "args") else [])))
    rule1("Drop4", lambda a: Expr("List", *list(a.args[4:] if hasattr(a, "args") else [])))
    rule1("Reverse4Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*4)))
    rule1("Repeat4Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*4)))
    rule1("EveryNth4", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::4])))
    rule1("Skip4", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[4::])))
    rule1("PadLeft4", lambda a: Expr("List", *([0]*4 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight4", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*4)))
    rule1("ChunkSize4", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+4]) for j in range(0, len(a.args if hasattr(a, "args") else []), 4)]))
    rule2("AppendN4", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*4)))
    rule1("Take5", lambda a: Expr("List", *list(a.args[:5] if hasattr(a, "args") else [])))
    rule1("Drop5", lambda a: Expr("List", *list(a.args[5:] if hasattr(a, "args") else [])))
    rule1("Reverse5Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*5)))
    rule1("Repeat5Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*5)))
    rule1("EveryNth5", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::5])))
    rule1("Skip5", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[5::])))
    rule1("PadLeft5", lambda a: Expr("List", *([0]*5 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight5", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*5)))
    rule1("ChunkSize5", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+5]) for j in range(0, len(a.args if hasattr(a, "args") else []), 5)]))
    rule2("AppendN5", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*5)))
    rule1("Take6", lambda a: Expr("List", *list(a.args[:6] if hasattr(a, "args") else [])))
    rule1("Drop6", lambda a: Expr("List", *list(a.args[6:] if hasattr(a, "args") else [])))
    rule1("Reverse6Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*6)))
    rule1("Repeat6Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*6)))
    rule1("EveryNth6", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::6])))
    rule1("Skip6", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[6::])))
    rule1("PadLeft6", lambda a: Expr("List", *([0]*6 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight6", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*6)))
    rule1("ChunkSize6", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+6]) for j in range(0, len(a.args if hasattr(a, "args") else []), 6)]))
    rule2("AppendN6", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*6)))
    rule1("Take7", lambda a: Expr("List", *list(a.args[:7] if hasattr(a, "args") else [])))
    rule1("Drop7", lambda a: Expr("List", *list(a.args[7:] if hasattr(a, "args") else [])))
    rule1("Reverse7Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*7)))
    rule1("Repeat7Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*7)))
    rule1("EveryNth7", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::7])))
    rule1("Skip7", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[7::])))
    rule1("PadLeft7", lambda a: Expr("List", *([0]*7 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight7", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*7)))
    rule1("ChunkSize7", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+7]) for j in range(0, len(a.args if hasattr(a, "args") else []), 7)]))
    rule2("AppendN7", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*7)))
    rule1("Take8", lambda a: Expr("List", *list(a.args[:8] if hasattr(a, "args") else [])))
    rule1("Drop8", lambda a: Expr("List", *list(a.args[8:] if hasattr(a, "args") else [])))
    rule1("Reverse8Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*8)))
    rule1("Repeat8Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*8)))
    rule1("EveryNth8", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::8])))
    rule1("Skip8", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[8::])))
    rule1("PadLeft8", lambda a: Expr("List", *([0]*8 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight8", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*8)))
    rule1("ChunkSize8", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+8]) for j in range(0, len(a.args if hasattr(a, "args") else []), 8)]))
    rule2("AppendN8", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*8)))
    rule1("Take9", lambda a: Expr("List", *list(a.args[:9] if hasattr(a, "args") else [])))
    rule1("Drop9", lambda a: Expr("List", *list(a.args[9:] if hasattr(a, "args") else [])))
    rule1("Reverse9Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*9)))
    rule1("Repeat9Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*9)))
    rule1("EveryNth9", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::9])))
    rule1("Skip9", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[9::])))
    rule1("PadLeft9", lambda a: Expr("List", *([0]*9 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight9", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*9)))
    rule1("ChunkSize9", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+9]) for j in range(0, len(a.args if hasattr(a, "args") else []), 9)]))
    rule2("AppendN9", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*9)))
    rule1("Take10", lambda a: Expr("List", *list(a.args[:10] if hasattr(a, "args") else [])))
    rule1("Drop10", lambda a: Expr("List", *list(a.args[10:] if hasattr(a, "args") else [])))
    rule1("Reverse10Times", lambda a: Expr("List", *([x for x in (a.args if hasattr(a, "args") else [])][::-1]*10)))
    rule1("Repeat10Times", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else [])*10)))
    rule1("EveryNth10", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[::10])))
    rule1("Skip10", lambda a: Expr("List", *list((a.args if hasattr(a, "args") else [])[10::])))
    rule1("PadLeft10", lambda a: Expr("List", *([0]*10 + list(a.args if hasattr(a, "args") else []))))
    rule1("PadRight10", lambda a: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [0]*10)))
    rule1("ChunkSize10", lambda a: Expr("List", *[Expr("List", *list((a.args if hasattr(a, "args") else []))[j:j+10]) for j in range(0, len(a.args if hasattr(a, "args") else []), 10)]))
    rule2("AppendN10", lambda a, b: Expr("List", *(list(a.args if hasattr(a, "args") else []) + [b]*10)))
    rule1("Factorial1Plus", lambda a: math.factorial(int(a)+1))
    rule1("Binomial1Choose", lambda a: math.comb(int(a), 1) if int(a) >= 1 else 0)
    rule1("Fibonacci1Plus", lambda a, _i=1: _fib(int(a)+_i))
    rule1("IsPrime1Plus", lambda a, _i=1: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf1", lambda a: ((int(a) // 1) + 1) * 1)
    rule1("PrevMultipleOf1", lambda a: (int(a) // 1) * 1)
    rule1("Mod1", lambda a: int(a) % 1)
    rule1("Quotient1", lambda a: int(a) // 1)
    rule1("PowerMod1By1000", lambda a: pow(int(a), 1, 1000))
    rule1("DigitSum1Base", lambda a: sum(int(d) for d in str(int(a), 1)) if 1 <= 36 else 0)
    rule1("Factorial2Plus", lambda a: math.factorial(int(a)+2))
    rule1("Binomial2Choose", lambda a: math.comb(int(a), 2) if int(a) >= 2 else 0)
    rule1("Fibonacci2Plus", lambda a, _i=2: _fib(int(a)+_i))
    rule1("IsPrime2Plus", lambda a, _i=2: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf2", lambda a: ((int(a) // 2) + 1) * 2)
    rule1("PrevMultipleOf2", lambda a: (int(a) // 2) * 2)
    rule1("Mod2", lambda a: int(a) % 2)
    rule1("Quotient2", lambda a: int(a) // 2)
    rule1("PowerMod2By1000", lambda a: pow(int(a), 2, 1000))
    rule1("DigitSum2Base", lambda a: sum(int(d) for d in str(int(a), 2)) if 2 <= 36 else 0)
    rule1("Factorial3Plus", lambda a: math.factorial(int(a)+3))
    rule1("Binomial3Choose", lambda a: math.comb(int(a), 3) if int(a) >= 3 else 0)
    rule1("Fibonacci3Plus", lambda a, _i=3: _fib(int(a)+_i))
    rule1("IsPrime3Plus", lambda a, _i=3: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf3", lambda a: ((int(a) // 3) + 1) * 3)
    rule1("PrevMultipleOf3", lambda a: (int(a) // 3) * 3)
    rule1("Mod3", lambda a: int(a) % 3)
    rule1("Quotient3", lambda a: int(a) // 3)
    rule1("PowerMod3By1000", lambda a: pow(int(a), 3, 1000))
    rule1("DigitSum3Base", lambda a: sum(int(d) for d in str(int(a), 3)) if 3 <= 36 else 0)
    rule1("Factorial4Plus", lambda a: math.factorial(int(a)+4))
    rule1("Binomial4Choose", lambda a: math.comb(int(a), 4) if int(a) >= 4 else 0)
    rule1("Fibonacci4Plus", lambda a, _i=4: _fib(int(a)+_i))
    rule1("IsPrime4Plus", lambda a, _i=4: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf4", lambda a: ((int(a) // 4) + 1) * 4)
    rule1("PrevMultipleOf4", lambda a: (int(a) // 4) * 4)
    rule1("Mod4", lambda a: int(a) % 4)
    rule1("Quotient4", lambda a: int(a) // 4)
    rule1("PowerMod4By1000", lambda a: pow(int(a), 4, 1000))
    rule1("DigitSum4Base", lambda a: sum(int(d) for d in str(int(a), 4)) if 4 <= 36 else 0)
    rule1("Factorial5Plus", lambda a: math.factorial(int(a)+5))
    rule1("Binomial5Choose", lambda a: math.comb(int(a), 5) if int(a) >= 5 else 0)
    rule1("Fibonacci5Plus", lambda a, _i=5: _fib(int(a)+_i))
    rule1("IsPrime5Plus", lambda a, _i=5: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf5", lambda a: ((int(a) // 5) + 1) * 5)
    rule1("PrevMultipleOf5", lambda a: (int(a) // 5) * 5)
    rule1("Mod5", lambda a: int(a) % 5)
    rule1("Quotient5", lambda a: int(a) // 5)
    rule1("PowerMod5By1000", lambda a: pow(int(a), 5, 1000))
    rule1("DigitSum5Base", lambda a: sum(int(d) for d in str(int(a), 5)) if 5 <= 36 else 0)
    rule1("Factorial6Plus", lambda a: math.factorial(int(a)+6))
    rule1("Binomial6Choose", lambda a: math.comb(int(a), 6) if int(a) >= 6 else 0)
    rule1("Fibonacci6Plus", lambda a, _i=6: _fib(int(a)+_i))
    rule1("IsPrime6Plus", lambda a, _i=6: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf6", lambda a: ((int(a) // 6) + 1) * 6)
    rule1("PrevMultipleOf6", lambda a: (int(a) // 6) * 6)
    rule1("Mod6", lambda a: int(a) % 6)
    rule1("Quotient6", lambda a: int(a) // 6)
    rule1("PowerMod6By1000", lambda a: pow(int(a), 6, 1000))
    rule1("DigitSum6Base", lambda a: sum(int(d) for d in str(int(a), 6)) if 6 <= 36 else 0)
    rule1("Factorial7Plus", lambda a: math.factorial(int(a)+7))
    rule1("Binomial7Choose", lambda a: math.comb(int(a), 7) if int(a) >= 7 else 0)
    rule1("Fibonacci7Plus", lambda a, _i=7: _fib(int(a)+_i))
    rule1("IsPrime7Plus", lambda a, _i=7: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf7", lambda a: ((int(a) // 7) + 1) * 7)
    rule1("PrevMultipleOf7", lambda a: (int(a) // 7) * 7)
    rule1("Mod7", lambda a: int(a) % 7)
    rule1("Quotient7", lambda a: int(a) // 7)
    rule1("PowerMod7By1000", lambda a: pow(int(a), 7, 1000))
    rule1("DigitSum7Base", lambda a: sum(int(d) for d in str(int(a), 7)) if 7 <= 36 else 0)
    rule1("Factorial8Plus", lambda a: math.factorial(int(a)+8))
    rule1("Binomial8Choose", lambda a: math.comb(int(a), 8) if int(a) >= 8 else 0)
    rule1("Fibonacci8Plus", lambda a, _i=8: _fib(int(a)+_i))
    rule1("IsPrime8Plus", lambda a, _i=8: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf8", lambda a: ((int(a) // 8) + 1) * 8)
    rule1("PrevMultipleOf8", lambda a: (int(a) // 8) * 8)
    rule1("Mod8", lambda a: int(a) % 8)
    rule1("Quotient8", lambda a: int(a) // 8)
    rule1("PowerMod8By1000", lambda a: pow(int(a), 8, 1000))
    rule1("DigitSum8Base", lambda a: sum(int(d) for d in str(int(a), 8)) if 8 <= 36 else 0)
    rule1("Factorial9Plus", lambda a: math.factorial(int(a)+9))
    rule1("Binomial9Choose", lambda a: math.comb(int(a), 9) if int(a) >= 9 else 0)
    rule1("Fibonacci9Plus", lambda a, _i=9: _fib(int(a)+_i))
    rule1("IsPrime9Plus", lambda a, _i=9: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf9", lambda a: ((int(a) // 9) + 1) * 9)
    rule1("PrevMultipleOf9", lambda a: (int(a) // 9) * 9)
    rule1("Mod9", lambda a: int(a) % 9)
    rule1("Quotient9", lambda a: int(a) // 9)
    rule1("PowerMod9By1000", lambda a: pow(int(a), 9, 1000))
    rule1("DigitSum9Base", lambda a: sum(int(d) for d in str(int(a), 9)) if 9 <= 36 else 0)
    rule1("Factorial10Plus", lambda a: math.factorial(int(a)+10))
    rule1("Binomial10Choose", lambda a: math.comb(int(a), 10) if int(a) >= 10 else 0)
    rule1("Fibonacci10Plus", lambda a, _i=10: _fib(int(a)+_i))
    rule1("IsPrime10Plus", lambda a, _i=10: _is_prime_check(int(a)+_i))
    rule1("NextMultipleOf10", lambda a: ((int(a) // 10) + 1) * 10)
    rule1("PrevMultipleOf10", lambda a: (int(a) // 10) * 10)
    rule1("Mod10", lambda a: int(a) % 10)
    rule1("Quotient10", lambda a: int(a) // 10)
    rule1("PowerMod10By1000", lambda a: pow(int(a), 10, 1000))
    rule1("DigitSum10Base", lambda a: sum(int(d) for d in str(int(a), 10)) if 10 <= 36 else 0)
    rule1("Sin1Pi", lambda a: math.sin(float(a) * 1 * math.pi))
    rule1("Cos1Pi", lambda a: math.cos(float(a) * 1 * math.pi))
    rule1("Tan1Pi", lambda a: math.tan(float(a) * 1 * math.pi))
    rule1("Sinh1X", lambda a: math.sinh(float(a) * 1))
    rule1("Cosh1X", lambda a: math.cosh(float(a) * 1))
    rule1("Tanh1X", lambda a: math.tanh(float(a) * 1))
    rule1("Exp1X", lambda a: math.exp(float(a) * 1))
    rule1("Log1X", lambda a: math.log(float(a) * 1) if float(a) > 0 else float("nan"))
    rule1("Sqrt1X", lambda a: math.sqrt(float(a) * 1) if float(a) >= 0 else float("nan"))
    rule1("Cbrt1X", lambda a: (float(a) * 1)**(1/3))
    rule1("Sin2Pi", lambda a: math.sin(float(a) * 2 * math.pi))
    rule1("Cos2Pi", lambda a: math.cos(float(a) * 2 * math.pi))
    rule1("Tan2Pi", lambda a: math.tan(float(a) * 2 * math.pi))
    rule1("Sinh2X", lambda a: math.sinh(float(a) * 2))
    rule1("Cosh2X", lambda a: math.cosh(float(a) * 2))
    rule1("Tanh2X", lambda a: math.tanh(float(a) * 2))
    rule1("Exp2X", lambda a: math.exp(float(a) * 2))
    rule1("Log2X", lambda a: math.log(float(a) * 2) if float(a) > 0 else float("nan"))
    rule1("Sqrt2X", lambda a: math.sqrt(float(a) * 2) if float(a) >= 0 else float("nan"))
    rule1("Cbrt2X", lambda a: (float(a) * 2)**(1/3))
    rule1("Sin3Pi", lambda a: math.sin(float(a) * 3 * math.pi))
    rule1("Cos3Pi", lambda a: math.cos(float(a) * 3 * math.pi))
    rule1("Tan3Pi", lambda a: math.tan(float(a) * 3 * math.pi))
    rule1("Sinh3X", lambda a: math.sinh(float(a) * 3))
    rule1("Cosh3X", lambda a: math.cosh(float(a) * 3))
    rule1("Tanh3X", lambda a: math.tanh(float(a) * 3))
    rule1("Exp3X", lambda a: math.exp(float(a) * 3))
    rule1("Log3X", lambda a: math.log(float(a) * 3) if float(a) > 0 else float("nan"))
    rule1("Sqrt3X", lambda a: math.sqrt(float(a) * 3) if float(a) >= 0 else float("nan"))
    rule1("Cbrt3X", lambda a: (float(a) * 3)**(1/3))
    rule1("Sin4Pi", lambda a: math.sin(float(a) * 4 * math.pi))
    rule1("Cos4Pi", lambda a: math.cos(float(a) * 4 * math.pi))
    rule1("Tan4Pi", lambda a: math.tan(float(a) * 4 * math.pi))
    rule1("Sinh4X", lambda a: math.sinh(float(a) * 4))
    rule1("Cosh4X", lambda a: math.cosh(float(a) * 4))
    rule1("Tanh4X", lambda a: math.tanh(float(a) * 4))
    rule1("Exp4X", lambda a: math.exp(float(a) * 4))
    rule1("Log4X", lambda a: math.log(float(a) * 4) if float(a) > 0 else float("nan"))
    rule1("Sqrt4X", lambda a: math.sqrt(float(a) * 4) if float(a) >= 0 else float("nan"))
    rule1("Cbrt4X", lambda a: (float(a) * 4)**(1/3))
    rule1("Sin5Pi", lambda a: math.sin(float(a) * 5 * math.pi))
    rule1("Cos5Pi", lambda a: math.cos(float(a) * 5 * math.pi))
    rule1("Tan5Pi", lambda a: math.tan(float(a) * 5 * math.pi))
    rule1("Sinh5X", lambda a: math.sinh(float(a) * 5))
    rule1("Cosh5X", lambda a: math.cosh(float(a) * 5))
    rule1("Tanh5X", lambda a: math.tanh(float(a) * 5))
    rule1("Exp5X", lambda a: math.exp(float(a) * 5))
    rule1("Log5X", lambda a: math.log(float(a) * 5) if float(a) > 0 else float("nan"))
    rule1("Sqrt5X", lambda a: math.sqrt(float(a) * 5) if float(a) >= 0 else float("nan"))
    rule1("Cbrt5X", lambda a: (float(a) * 5)**(1/3))
    rule1("Sin6Pi", lambda a: math.sin(float(a) * 6 * math.pi))
    rule1("Cos6Pi", lambda a: math.cos(float(a) * 6 * math.pi))
    rule1("Tan6Pi", lambda a: math.tan(float(a) * 6 * math.pi))
    rule1("Sinh6X", lambda a: math.sinh(float(a) * 6))
    rule1("Cosh6X", lambda a: math.cosh(float(a) * 6))
    rule1("Tanh6X", lambda a: math.tanh(float(a) * 6))
    rule1("Exp6X", lambda a: math.exp(float(a) * 6))
    rule1("Log6X", lambda a: math.log(float(a) * 6) if float(a) > 0 else float("nan"))
    rule1("Sqrt6X", lambda a: math.sqrt(float(a) * 6) if float(a) >= 0 else float("nan"))
    rule1("Cbrt6X", lambda a: (float(a) * 6)**(1/3))
    rule1("Sin7Pi", lambda a: math.sin(float(a) * 7 * math.pi))
    rule1("Cos7Pi", lambda a: math.cos(float(a) * 7 * math.pi))
    rule1("Tan7Pi", lambda a: math.tan(float(a) * 7 * math.pi))
    rule1("Sinh7X", lambda a: math.sinh(float(a) * 7))
    rule1("Cosh7X", lambda a: math.cosh(float(a) * 7))
    rule1("Tanh7X", lambda a: math.tanh(float(a) * 7))
    rule1("Exp7X", lambda a: math.exp(float(a) * 7))
    rule1("Log7X", lambda a: math.log(float(a) * 7) if float(a) > 0 else float("nan"))
    rule1("Sqrt7X", lambda a: math.sqrt(float(a) * 7) if float(a) >= 0 else float("nan"))
    rule1("Cbrt7X", lambda a: (float(a) * 7)**(1/3))
    rule1("Sin8Pi", lambda a: math.sin(float(a) * 8 * math.pi))
    rule1("Cos8Pi", lambda a: math.cos(float(a) * 8 * math.pi))
    rule1("Tan8Pi", lambda a: math.tan(float(a) * 8 * math.pi))
    rule1("Sinh8X", lambda a: math.sinh(float(a) * 8))
    rule1("Cosh8X", lambda a: math.cosh(float(a) * 8))
    rule1("Tanh8X", lambda a: math.tanh(float(a) * 8))
    rule1("Exp8X", lambda a: math.exp(float(a) * 8))
    rule1("Log8X", lambda a: math.log(float(a) * 8) if float(a) > 0 else float("nan"))
    rule1("Sqrt8X", lambda a: math.sqrt(float(a) * 8) if float(a) >= 0 else float("nan"))
    rule1("Cbrt8X", lambda a: (float(a) * 8)**(1/3))
    rule1("Sin9Pi", lambda a: math.sin(float(a) * 9 * math.pi))
    rule1("Cos9Pi", lambda a: math.cos(float(a) * 9 * math.pi))
    rule1("Tan9Pi", lambda a: math.tan(float(a) * 9 * math.pi))
    rule1("Sinh9X", lambda a: math.sinh(float(a) * 9))
    rule1("Cosh9X", lambda a: math.cosh(float(a) * 9))
    rule1("Tanh9X", lambda a: math.tanh(float(a) * 9))
    rule1("Exp9X", lambda a: math.exp(float(a) * 9))
    rule1("Log9X", lambda a: math.log(float(a) * 9) if float(a) > 0 else float("nan"))
    rule1("Sqrt9X", lambda a: math.sqrt(float(a) * 9) if float(a) >= 0 else float("nan"))
    rule1("Cbrt9X", lambda a: (float(a) * 9)**(1/3))
    rule1("Sin10Pi", lambda a: math.sin(float(a) * 10 * math.pi))
    rule1("Cos10Pi", lambda a: math.cos(float(a) * 10 * math.pi))
    rule1("Tan10Pi", lambda a: math.tan(float(a) * 10 * math.pi))
    rule1("Sinh10X", lambda a: math.sinh(float(a) * 10))
    rule1("Cosh10X", lambda a: math.cosh(float(a) * 10))
    rule1("Tanh10X", lambda a: math.tanh(float(a) * 10))
    rule1("Exp10X", lambda a: math.exp(float(a) * 10))
    rule1("Log10X", lambda a: math.log(float(a) * 10) if float(a) > 0 else float("nan"))
    rule1("Sqrt10X", lambda a: math.sqrt(float(a) * 10) if float(a) >= 0 else float("nan"))
    rule1("Cbrt10X", lambda a: (float(a) * 10)**(1/3))

    return rules

EXTENDED5_RULES = build_extended5_rules()
