Math::Goedel - Fundamental Goedel number calculator
use Math::Goedel qw/goedel/; goedel(9); # 512 (2**9) goedel(81); # 768 (2**8 * 3**1) goedel(230);# 108 (2**2 * 3**3 * 5**0) Math::Goedel::enc(9); # same as goedel(9) goedel(9, offset => 1); # 1024 (2**(9+1)) goedel(81, reverse => 1); # 13112 (2**1 * 3**8) goedel(4999, bigint => 1); # 24821251455656250000 as BigInt (2**1 * 3**9 * 5**9 * 7**9)
Goedel number is calculated by following Goedel's encoding theorem
enc(X0X1X2...Xn) = P0**X0 * P1**X1 * P2**X2 * ..... * Pn**Xn
Xk is a k th digit (from left hand) of input number.
Pk is a k th prime number.
@EXPORT_OK => qw/goedel/
calculate goedel number for n
According to fundamental theorem, goedel numbers are not unique.
goedel(23) == goedel(230); # 2**2 * 3**3 ( * 5**0 ) == 108
To make it unique, you can specify offset for Xk
enc(X0X1X2...Xn) = P0**(X0 +i) * P1**(X1 +i) * P2**(X2 +i) * ..... * Pn**(Xn +i)
so,
goedel(23, offset => 1); # 2**(2+1) * 3**(3+1) == 648 goedel(230, offset => 1); # 2**(2+1) * 3**(3+1) * 5**(0+1) == 3240
This option is for same purpose as offset option.
If reverse is set to 1, apply Xk in reverse order,
enc(X0X1X2...Xn) = P0**Xn * P1**Xn-1 * P2**Xn-2 * ..... * Pn**X0
goedel(23, reverse => 1); # 2**3 * 3**2 == 72 goedel(230, reverse => 1); # 2**0 * 3**3 * 5**2 == 675
This option is used to force result goedel numbers to be Math::BigInt.
synonym for goedel($n). but it won't be exported.
Goedel number: http://en.wikipedia.org/wiki/G%C3%B6del_number
Discussion of "how to make goedel number unique" (in Japanese): http://ja.doukaku.org/comment/4657/, http://ja.doukaku.org/comment/4661/
KATOU Akira (turugina), <turugina at cpan.org>
<turugina at cpan.org>
DANAJ
Please report any bugs or feature requests to bug-math-goedel at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-Goedel. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-math-goedel at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Math::Goedel
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Goedel
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Math-Goedel
CPAN Ratings
http://cpanratings.perl.org/d/Math-Goedel
Search CPAN
http://search.cpan.org/dist/Math-Goedel
Copyright 2008 KATOU Akira (turugina), all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Math::Goedel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Goedel
CPAN shell
perl -MCPAN -e shell install Math::Goedel
For more information on module installation, please visit the detailed CPAN module installation guide.