Copyright | (c) 2011 Daniel Fischer |
---|---|
License | MIT |
Maintainer | Daniel Fischer <daniel.is.fischer@googlemail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Certificates for primality or compositeness.
Synopsis
- data Certificate
- argueCertificate :: Certificate -> Either CompositenessArgument PrimalityArgument
- data CompositenessProof
- composite :: CompositenessProof -> Integer
- data PrimalityProof
- cprime :: PrimalityProof -> Integer
- data CompositenessArgument
- data PrimalityArgument
- = Pock {
- aprime :: Integer
- largeFactor, smallFactor :: Integer
- factorList :: [(Integer, Word, Integer, PrimalityArgument)]
- | Division { }
- | Obvious { }
- | Assumption { }
- = Pock {
- arguePrimality :: PrimalityProof -> PrimalityArgument
- argueCompositeness :: CompositenessProof -> CompositenessArgument
- verifyPrimalityArgument :: PrimalityArgument -> Maybe PrimalityProof
- verifyCompositenessArgument :: CompositenessArgument -> Maybe CompositenessProof
- certify :: Integer -> Certificate
- checkCertificate :: Certificate -> Bool
- checkCompositenessProof :: CompositenessProof -> Bool
- checkPrimalityProof :: PrimalityProof -> Bool
Certificates
data Certificate Source #
A certificate of either compositeness or primality of an
Integer
. Only numbers > 1
can be certified, trying to
create a certificate for other numbers raises an error.
Instances
Show Certificate Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal showsPrec :: Int -> Certificate -> ShowS # show :: Certificate -> String # showList :: [Certificate] -> ShowS # |
argueCertificate :: Certificate -> Either CompositenessArgument PrimalityArgument Source #
Eliminate Certificate
.
data CompositenessProof Source #
A proof of compositeness of a positive number. The type is abstract to ensure the validity of proofs.
Instances
Show CompositenessProof Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal showsPrec :: Int -> CompositenessProof -> ShowS # show :: CompositenessProof -> String # showList :: [CompositenessProof] -> ShowS # |
composite :: CompositenessProof -> Integer Source #
The number whose compositeness is proved.
data PrimalityProof Source #
A proof of primality of a positive number. The type is abstract to ensure the validity of proofs.
Instances
Show PrimalityProof Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal showsPrec :: Int -> PrimalityProof -> ShowS # show :: PrimalityProof -> String # showList :: [PrimalityProof] -> ShowS # |
cprime :: PrimalityProof -> Integer Source #
The number whose primality is proved.
Arguments
data CompositenessArgument Source #
An argument for compositeness of a number (which must be > 1
).
CompositenessProof
s translate directly to CompositenessArgument
s,
correct arguments can be transformed into proofs. This type allows the
manipulation of proofs while maintaining their correctness.
The only way to access components of a CompositenessProof
except
the composite is through this type.
Divisors |
|
Fermat |
|
| |
Lucas |
|
Belief | No particular reason given |
Instances
data PrimalityArgument Source #
An argument for primality of a number (which must be > 1
).
PrimalityProof
s translate directly to PrimalityArgument
s,
correct arguments can be transformed into proofs. This type allows the
manipulation of proofs while maintaining their correctness.
The only way to access components of a PrimalityProof
except
the prime is through this type.
Pock | A suggested Pocklington certificate |
| |
Division | Primality should be provable by trial division to |
Obvious |
|
Assumption | Primality assumed |
Instances
Eq PrimalityArgument Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal (==) :: PrimalityArgument -> PrimalityArgument -> Bool # (/=) :: PrimalityArgument -> PrimalityArgument -> Bool # | |
Ord PrimalityArgument Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal compare :: PrimalityArgument -> PrimalityArgument -> Ordering # (<) :: PrimalityArgument -> PrimalityArgument -> Bool # (<=) :: PrimalityArgument -> PrimalityArgument -> Bool # (>) :: PrimalityArgument -> PrimalityArgument -> Bool # (>=) :: PrimalityArgument -> PrimalityArgument -> Bool # max :: PrimalityArgument -> PrimalityArgument -> PrimalityArgument # min :: PrimalityArgument -> PrimalityArgument -> PrimalityArgument # | |
Read PrimalityArgument Source # | |
Show PrimalityArgument Source # | |
Defined in Math.NumberTheory.Primes.Testing.Certificates.Internal showsPrec :: Int -> PrimalityArgument -> ShowS # show :: PrimalityArgument -> String # showList :: [PrimalityArgument] -> ShowS # |
Weaken proofs to arguments
arguePrimality :: PrimalityProof -> PrimalityArgument Source #
transforms a proof of primality into an argument for primality.arguePrimality
argueCompositeness :: CompositenessProof -> CompositenessArgument Source #
transforms a proof of compositeness into an argument
for compositeness.argueCompositeness
Prove valid arguments
verifyPrimalityArgument :: PrimalityArgument -> Maybe PrimalityProof Source #
checks the given argument and constructs a proof from
it, if it is valid. For the explicit arguments, this is simple and resonably fast,
for an verifyPrimalityArgument
Assumption
, the verification uses certify
and hence may take a long time.
verifyCompositenessArgument :: CompositenessArgument -> Maybe CompositenessProof Source #
checks the given argument and constructs a proof from
it, if it is valid. For the explicit arguments, this is simple and resonably fast,
for a verifyCompositenessArgument
Belief
, the verification uses certify
and hence may take a long time.
Determine and prove whether a number is prime or composite
certify :: Integer -> Certificate Source #
constructs, for certify
nn > 1
, a proof of either
primality or compositeness of n
. This may take a very long
time if the number has no small(ish) prime divisors
Checks for the paranoid
checkCertificate :: Certificate -> Bool Source #
Check the validity of a Certificate
. Since it should be impossible
to construct invalid certificates by the public interface, this should
never return False
.
checkCompositenessProof :: CompositenessProof -> Bool Source #
Check the validity of a CompositenessProof
. Since it should be
impossible to create invalid proofs by the public interface, this
should never return False
.
checkPrimalityProof :: PrimalityProof -> Bool Source #
Check the validity of a PrimalityProof
. Since it should be
impossible to create invalid proofs by the public interface, this
should never return False
.