= fromIntegral @Word64 . getLarge <$> arbitrary
a - a == 0
a + 0 == a && 0 + a == a
a * 1 == a && 1 * a == a
a + b == b + a
a * b == b * a
a + (b + c) == (a + b) + c
a * (b * c) == (a * b) * c
a * (b + c) == a * b + a * c
a} = a / a == 1
a == 0 || recip (recip a) == a
sqr a == a * a
a} n = pow a n == a ^^ n
n} = 0 `pow` n == if n == 0 then 1 else 0
sqr (sqrt a) == a
let x = artinSchreierRoot a in sqr x + x == a && not (x `testBit` 0)
let (x, y) = solveQuadratic p q
in sqr x + p * x + q == 0
&& sqr y + p * y + q == 0
&& (r - x) * (r - y) == sqr r + p * r + q
&& x <= y
if 0 `notElem` s then 0 else 1 + mex (fmap (+ (-1)) s)
-- | Compute nimber sum directly from the definition. This is very slow.
(!!) . (nimberSumTable !!)
fmap add <$> [(i,) <$> [0 ..] | i <- [0 ..]]
where
add (a, b) = mex $ [nimberSumTable !! a' !! b | a' <- [0 .. a - 1]] ++ [nimberSumTable !! a !! b' | b' <- [0 .. b - 1]]
-- | Compute nimber product directly from the definition. This is very slow.
(!!) . (nimberProdTable !!)
[mult i <$> [0 ..] | i <- [0 ..]]
where
mult a b = mex $ [(nimberProdTable !! a' !! b) `nimberAdd` (nimberProdTable !! a !! b') `nimberAdd` (nimberProdTable !! a' !! b') | a' <- [0 .. a - 1], b' <- [0 .. b - 1]]
and $ do
i <- [0 .. 15]
j <- [0 .. 15]
pure $ fromIntegral @Int @FiniteNimber (nimberAdd i j) == fromIntegral i + fromIntegral j
and $ do
i <- [0 .. 15]
j <- [0 .. 15]
pure $ fromIntegral @Int @FiniteNimber (nimberMult i j) == fromIntegral i * fromIntegral j
pure []
$forAllProperties $ verboseCheckWithResult stdArgs {maxSuccess = 500}
do
success <- runTests
unless success exitFailure
arbitrary