我知道为了让这个函数工作 crtHasSolution 首先必须是真的我很难证明 n 可能是一个解决方案关于如何在haskell中编写或检查它的任何想法或提示?
我知道 N 的条件是它必须大于或等于 0 并且小于 m,这是所有 mod 基数的乘积。
crtHasSolution :: [Integer] -> [Integer] -> Bool
crtHasSolution as ms = length as > 0 &&
length ms > 0 &&
length as == length ms &&
all (>=0) as &&
all (>=2) ms &&
pairwise_coprime ms
-- Is a given number a solution to a CRT problem?
-- usage: crtIsSolution n as ms = ans
-- assures: ans == True, if crtHasSolution as ms == True and n is a solution
-- ans == False, otherwise
crtIsSolution :: Integer -> [Integer] -> [Integer] -> Bool
crtIsSolution n as ms = crtHasSolution as ms &&
n >= 0 &&
n < m
where m =