Skip to content

Program to convert a program encoding based on its Gödel number to 𝒮 Language (S Language) or convert an 𝒮 Language program to it's program number

License

Notifications You must be signed in to change notification settings

DenverCoder1/godel-program-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gödel Program Converter

Program to convert a program encoding based on its Gödel number to 𝒮 Language (S Language) or convert an 𝒮 Language program to its program number

Convert a program number to code

Running the code

Method 1: Command line input

Launch the program, providing the number as a command line argument:

py -m src.godel_to_code [program number]

For example: py -m src.godel_to_code 52

(The command for Python may be different on your system. See the Python documentation for details.)

Method 2: Interactive input

Launch the program with the following command:

py -m src.godel_to_code

Enter a program number when prompted.

Examples

Enter program number: 99
Y ← Y + 1
Y ← Y
Y ← Y + 1
Enter program number: 25724
Y ← Y
[A1] Y ← Y
Y ← Y + 1
[B1] Y ← Y
Enter program number: 2097151
[A1] X1 ← X1 + 1

Convert code to a program number

Running the code

Method 1: File input

Launch the program with the following command:

py -m src.code_to_godel test.s

Where test.s is the name of the file containing the program.

Method 2: Command line input

Launch the program with the code input as a command line argument:

Single line:

py -m src.code_to_godel "Y <- Y + 1"

Multiline:

py -m src.code_to_godel <<EOF
Y <- Y
Y <- Y + 1
EOF

Method 3: Interactive input

Launch the program with the following command:

py -m src.code_to_godel

Enter the code line by line when prompted. Enter a blank line to end the input.

How to input code

  • Assignment can be represented by <-, =, <= or .
  • Inequality can be represented by !=, =/=, or .
  • Labels must only contain indexed letters A-E, and variables must be either Y, or an indexed X or Z.
  • Labels without indices will be interpreted as index 1 (eg. [A] is equivalent to [A1]).
  • Variables without indices will be interpreted as index 1 (eg. X is equivalent to X1).
  • Valid instructions include: V ← V, V ← V + 1, V ← V - 1, and IF V≠0 GOTO L where in all cases, V represents a variable and L represents a label as specified above.
  • Instructions can be preceded by a label in square brackets (eg. [A]).

Examples

Enter program (press enter twice to submit):

Program number: 0
Enter program (press enter twice to submit):
Y <- Y                       
[A] Y <- Y
Y <- Y + 1
[B] Y <- Y

Program number: 25724
Enter program (press enter twice to submit):
IF X != 0 GOTO A 
Y <- Y + 1
[A1] Y <- Y - 1    

Program number: 773094113279999999999999

Development

Command to run tests:

tox

Command to lint with flake8:

py setup.py lint

See also

About

Program to convert a program encoding based on its Gödel number to 𝒮 Language (S Language) or convert an 𝒮 Language program to it's program number

Topics

Resources

License

Stars

Watchers

Forks