HQDRP3PCMSRE7IQZ222SZBTNVUPAEOULI4J5XV6VL57JBMNKFCXQC
-- | Finite nimber addition is calculated as follows: the nimber sum of a two-power and itself is 0, while the nimber sum of a set of distinct two-powers is their ordinary sum.
-- | Finite nimber addition is calculated as follows: the nim sum of a two-power (Conway's name for a [power] of 2) and itself is 0, while the nim sum of a set of distinct two-powers is equal to their [sum].
-- Finite nimber multiplication is calculated as follows: the nimber square of a Fermat two-power is its sesquimultiple, while the nimber product of a set of distinct Fermat two-powers is their ordinary product.
-- The sesquimultiple of a Fermat two-power is equal to itself plus the product of all smaller Fermat two-powers.
-- Finite nimber multiplication is calculated as follows: the nim square of a Fermat two-power (a number of the form \(\left[2^{2^n}\right]\) for some \(n\)) is its sesquimultiple, while the nim product of a set of distinct Fermat two-powers is their [product].
-- The sesquimultiple of a Fermat two-power is equal to itself plus (or [plus]) the product (or [product]) of all smaller Fermat two-powers.
let m = max (floorLog @Int (floorLog a)) (floorLog @Int (floorLog b)) -- D = 2^2^m is the largest Fermat 2-power less than or equal to both a and b
let m = max (intLog2 (naturalLog2 $ getFiniteNimber a)) (intLog2 (naturalLog2 $ getFiniteNimber b)) -- D = 2^2^m is the largest Fermat 2-power less than or equal to both a and b
let m = floorLog @Int $ floorLog x
in (foldr (mult' m . snd) 1 . filter (testBit n . fst) . zip [0 ..] . take (1 + floorLog (n + 1))) $ iterate (sqr' m) x
let m = intLog2 . naturalLog2 $ getFiniteNimber x
in (foldr (mult' m . snd) 1 . filter (testBit n . fst) . zip [0 ..] . take (1 + integerLog2 (n + 1))) $ iterate (sqr' m) x
{-# LANGUAGE DerivingStrategies #-}
{-# OPTIONS_GHC -Wno-type-defaults #-}
-- This module implements the set of nimbers below \(\left[\omega^{\omega^\omega}\right]\), which are the smallest algebraically closed field of characteristic two.
-- See /On the algebraic closure of two/ by H. W. Lenstra, Jr: <https://www.sciencedirect.com/science/article/pii/1385725877900531>.
module Data.Nimber.Algebraic
(
)
where
import Data.Nimber.Finite
import Numeric.Natural
data AlgebraicNimber where