2Q7SZHYMAFCYLG5MROYQ4BJ7HDIASPLIZJP7SM7BNX4GESUCZXJQC
5CXVNGYMMIBKPFJFJK7T5HLMUAP2IE7UCFZBFZTY5DBJFRQHPP5QC
BKOAQCTL55P6HCIDOLA3WKRDJPPZTFDFROKMKRCLXT7ANA3JG4NQC
O6UAIBEXBNE2XMWQWU6YKGGRLDQFI364JMV6HCYCCI3LBQRD6RPQC
P63H7XZA5FGJP5RTASK5NOWQDV4BSKFFCN4AIS7RW44KUK3LK2JQC
VRPOSMITS7VRSIJU6YNEBELCUBTHPMPJD6F6F5PE35R2KECS42KAC
6U24OB4HZGUVZZTOEHQKTBOHGV5FKEE4EQDGJF6IP3QQ3HXNNWUQC
PMF36FUOINXVVNP5XW6ZOFPPWFBRK62O4VCX45NE4Y4GDPL2Z3BQC
KARMFRM7OJF6RDDAVRISRV223RS6AWE6BG33QMFJ4GYLQFZYL56QC
V7A5CRSQQY3WTZFNH73E6J4YOKE7YJMEW2XW7YJTM37UNTWRMZJQC
M373MXDAPWQZQZT4RWAXFLLUUP5266TW5RUKHB7QNUBUKYQDTOYQC
--prop_def_add :: Small Int -> Small Int -> Bool
--prop_def_add Small {getSmall = a} Small {getSmall = b} = abs a `nimberAdd` abs b == fromIntegral (getNimber $ fromIntegral a + fromIntegral b)
-- prop_def_add :: Small Int -> Small Int -> Bool
-- prop_def_add Small {getSmall = a} Small {getSmall = b} = abs a `nimberAdd` abs b == fromIntegral (getNimber $ fromIntegral a + fromIntegral b)
--prop_def_mul :: Small Int -> Small Int -> Bool
--prop_def_mul Small {getSmall = a} Small {getSmall = b} = abs a `nimberMul` abs b == fromIntegral (getNimber $ fromIntegral a * fromIntegral b)
-- prop_def_mul :: Small Int -> Small Int -> Bool
-- prop_def_mul Small {getSmall = a} Small {getSmall = b} = abs a `nimberMul` abs b == fromIntegral (getNimber $ fromIntegral a * fromIntegral b)
in (aD + a + b) / (semiD * a ^ 2 + b * (a + b))
in (aD + a + b) / (semiD * a * a + b * (a + b))
-- | Squaring function. Faster than multiplying @n@ by itself.
sqr :: Nimber -> Nimber
sqr 0 = 0
sqr 1 = 1
sqr n =
let m = floorLog @Int $ floorLog n -- D = 2^2^m is the largest Fermat 2-power less than or equal to n
a = n `shiftR` bit m -- n = aD+b
aD = a `shiftL` bit m
b = n .^. aD
semiD = bit (bit m - 1) -- semimultiple of D
sqra = sqr a
in sqra `shiftL` bit m + sqra * semiD + sqr b