The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::Goedel - Fundamental Goedel number calculator

SYNOPSIS

  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)

DESCRIPTION

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

  @EXPORT_OK => qw/goedel/

FUNCTIONS

goedel($n, %opts)

calculate goedel number for n

%opts

offset => $i

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

reverse => 0|1

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

so,

  goedel(23,  reverse => 1); # 2**3 * 3**2 == 72
  goedel(230, reverse => 1); # 2**0 * 3**3 * 5**2 == 675

bigint => 0|1

This option is used to force result goedel numbers to be Math::BigInt.

enc($n)

synonym for goedel($n). but it won't be exported.

REFERENCES

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/

AUTHOR

KATOU Akira (turugina), <turugina at cpan.org>

CONTRIBUTERS

DANAJ

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Math::Goedel

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.