godel
Class Godel3

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by godel.Godel3
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CaretListener

public class Godel3
extends java.applet.Applet
implements java.awt.event.ActionListener, javax.swing.event.CaretListener

This applet implements the conversion of a function (expressed as a computer program) into an arithmetical formula. This is the program which carries out the most important part of this Gödel's incompleteness theorem project. It works very much like a compiler, you input a program written in a programming language, and it tranforms this program into another form. In this case, rather than producing executable output, it expresses the program in terms of the Gödel number of an arithmetical formula.

Author:
Stephen Lee
See Also:
Serialized Form

Nested Class Summary
(package private)  class Godel3.Funinfo
          Holds information about Haskell function
(package private)  class Godel3.IdList
          List of identifiers
(package private)  class Godel3.TExpr
          Holds an encoded representation of an expression
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  javax.swing.JButton but3
          Press to encode statement of the form y=f(x) for a function f
(package private)  javax.swing.JButton but4
          Press to encode statement of the form σ1
(package private)  javax.swing.JButton but5
          Press to encode statement of the form σ2
(package private)  java.math.BigInteger c0
          Coded form of zero
(package private)  int Csp
          Stack pointer for CStore
(package private)  java.math.BigInteger[] Cstore
          Store for coded conditions
(package private)  char curch
          current character
(package private)  java.math.BigInteger curnum
          current item if it is an integer
(package private)  int curtok
          current item if it is a token
(package private)  java.lang.String curword
          current item if it is an identifier
(package private)  java.util.BitSet dep1
          Set of function nos.
(package private)  java.util.BitSet dep2
          Set of function nos.
(package private)  int[] deplist
          list of numbers of functions used in code
(package private)  int Esp
          Stack pointer for EStore
(package private)  int[] Estore
          Store for variables which need ∃ condition before current piece of code
(package private)  int fdct
          Counter for deplist
(package private)  javax.swing.JTextField fedit
          Edit area for name of function for y=f(x) encoding
(package private)  Godel3.Funinfo finf
          info for function currently being compiled
(package private)  Godel3.Funinfo[] finfo
          Store for information about functions
(package private)  java.math.BigInteger FOUR
           
(package private)  java.math.BigInteger[] Fstore
          Store for code of functions
(package private)  Godel3.IdList FunList
          Function names
(package private)  java.lang.Error InvInp
          General compilation error
(package private)  int itype
          Type of current item
(package private)  java.lang.String lfile
          Haskell file loaded automatically
(package private)  int locv
           
(package private)  int nonf
          number of functions without a name 2 i.e.
(package private)  java.math.BigInteger[] numc
          Bitstream forms of 0-3 (0,0',0'',0''')
(package private)  javax.swing.JTextArea plines
          Text area for input of Haskell code
(package private)  int pos
          Current position in strin
(package private)  java.math.BigInteger predefs
          Encoded form of predefined functions
(package private)  javax.swing.JTextArea prnum
          Text area for output of Gödel number of Gödel statement
(package private)  java.util.List ResList
          Reserved words in List form
(package private)  java.lang.String[] reswords
          Reserved words
private static long serialVersionUID
           
(package private)  java.lang.String strin
          Holds the Haskell code
(package private)  java.math.BigInteger THREE
           
(package private)  char[][] tokens
          2 character tokens
(package private)  java.lang.Error TypeErr
          More specific type Error
(package private)  Godel3.IdList VarList
          Haskell variable names
(package private)  int[] Varstore
          Store for info about Haskell variables Match position in VarList.
(package private)  int vbase
          counter for int form of variables
(package private)  java.math.BigInteger Vloc
          coded form of variable x1 (locv)
(package private)  int z0
          int form of first variable (x)
(package private)  java.math.BigInteger Z0
          coded form of first variable (x)
(package private)  java.math.BigInteger ZERO
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Godel3()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          responds to button press
(package private)  void addcond(java.math.BigInteger A)
          Add a condition to the list
(package private)  java.math.BigInteger binop(java.math.BigInteger x1, int op, java.math.BigInteger x2)
          Encodes the result of a binary operator
(package private)  void calcdep(int f)
          Recursively calculates which functions a function depends upon f may be recursively defined, but mutual recursion is not allowed
(package private)  void calcdeps(int f)
          Calculates which functions a function depends upon, using calcdep
 void caretUpdate(javax.swing.event.CaretEvent e)
          Reset caret colour after it's turned red to show an error
(package private)  boolean chkch(char c)
          Checks whether the current item is a single character matching c
(package private)  int chkchS(java.lang.String S)
          Checks whether the current item is a single character in S.
(package private)  void chkchv(char c)
          requires the current item to be a single character matching c
(package private)  void chkIntv()
          Requires current item to be 'Integer' reserved word
(package private)  void chkResv(int i)
          Ensures that current word is a given reserved word
(package private)  void chktokv(int t)
          Checks whether the current item is a 2 character token number t
(package private)  void DefFn(java.lang.String name)
          Deals with the definition part of a function (which must be present)
(package private)  java.math.BigInteger diag(java.math.BigInteger n)
          ¬(∀z (z=num(n)⇒¬#n)
(package private)  java.math.BigInteger DoFun(int id)
          Processes body of a function
(package private)  java.math.BigInteger exists(int v, java.math.BigInteger T)
          ∃ #v #T
(package private)  Godel3.TExpr expr10()
          Function calls, variables, numbers,[], (expr),duples
(package private)  Godel3.TExpr expr2(int vareq)
          if, case and let and || operator
(package private)  Godel3.TExpr expr3()
          && operator
(package private)  Godel3.TExpr expr4()
          relational operators
(package private)  Godel3.TExpr expr5()
           
(package private)  Godel3.TExpr expr6()
          + and -
(package private)  Godel3.TExpr expr7()
          , `div`, `mod`
(package private)  Godel3.TExpr expr9()
          !! operator
(package private)  java.math.BigInteger falll(int v, java.math.BigInteger t1)
          ∀ #v #t1
(package private)  void fcompile()
          compiles the functions defined in the plines edit,
(package private)  java.math.BigInteger funcround(java.math.BigInteger fcode)
           
(package private)  void getitem()
          Gets item from input text.
(package private)  int getType()
          Gets type descriptor.
(package private)  void getword()
          Requires a word, that is an identifier or reserved word
(package private)  java.math.BigInteger impp(java.math.BigInteger A, java.math.BigInteger B)
          #A ⇒ #B
 void init()
          Initalise applet
(package private)  java.math.BigInteger iseq(java.math.BigInteger t1, java.math.BigInteger t2)
          Code for #t1=#t2
(package private)  java.math.BigInteger J(java.math.BigInteger t1, java.math.BigInteger t2)
          J is a 1 to 1 functio combining two integers into one
(package private)  java.math.BigInteger Jn(int[] vs, int n)
          Combines n integer variables into one integer
(package private)  java.math.BigInteger lessthan(java.math.BigInteger t1, java.math.BigInteger t2)
          #t1<#t2
(package private)  int makesym(int type)
          Defines the current identifier to be a variable of a given type
(package private)  int mulop()
          #0, `div` #1, `mod` #2
(package private)  int newV()
          new arithmetic variable
(package private)  java.math.BigInteger nott(java.math.BigInteger A)
          Encode ¬#A
(package private)  java.math.BigInteger num(java.math.BigInteger x)
          Encodes a number as an arithmetic expression
(package private)  void paramcond(int v, int fno)
          #v<Nf
(package private)  void parse1()
          Parses program in strin
(package private)  void predefines()
          produces the code for predefined list operators (:),(!!) and functions length and tail
(package private)  java.math.BigInteger resconds(int csb, int esb, int vsb)
          ∃ variables (∧ Conditions)
(package private)  java.math.BigInteger sigma(java.math.BigInteger phi)
          σφ
(package private)  void skipsps()
          moves pos to the first non-whitespace character
(package private)  java.math.BigInteger unop(int op, java.math.BigInteger x1)
          Encodes the result of the unary operator
(package private)  java.math.BigInteger varb(int n)
           
(package private)  java.math.BigInteger varb0(int n)
           
(package private)  java.math.BigInteger vform(java.math.BigInteger Term)
          Creates (if needed) a variable equal to a given term
(package private)  java.math.BigInteger yisfx(java.lang.String fname)
           
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

lfile

java.lang.String lfile
Haskell file loaded automatically


vbase

int vbase
counter for int form of variables


finfo

Godel3.Funinfo[] finfo
Store for information about functions


nonf

int nonf
number of functions without a name 2 i.e. !! and (:)


locv

final int locv
See Also:
Constant Field Values

deplist

int[] deplist
list of numbers of functions used in code


reswords

java.lang.String[] reswords
Reserved words


tokens

char[][] tokens
2 character tokens


FunList

Godel3.IdList FunList
Function names


VarList

Godel3.IdList VarList
Haskell variable names


ResList

java.util.List ResList
Reserved words in List form


Fstore

java.math.BigInteger[] Fstore
Store for code of functions


Cstore

java.math.BigInteger[] Cstore
Store for coded conditions


Estore

int[] Estore
Store for variables which need ∃ condition before current piece of code


Varstore

int[] Varstore
Store for info about Haskell variables Match position in VarList. Stores (int form)*8)+type


but3

javax.swing.JButton but3
Press to encode statement of the form y=f(x) for a function f


but4

javax.swing.JButton but4
Press to encode statement of the form σ1


but5

javax.swing.JButton but5
Press to encode statement of the form σ2


fedit

javax.swing.JTextField fedit
Edit area for name of function for y=f(x) encoding


prnum

javax.swing.JTextArea prnum
Text area for output of Gödel number of Gödel statement


plines

javax.swing.JTextArea plines
Text area for input of Haskell code


strin

java.lang.String strin
Holds the Haskell code


pos

int pos
Current position in strin


fdct

int fdct
Counter for deplist


Csp

int Csp
Stack pointer for CStore


Esp

int Esp
Stack pointer for EStore


InvInp

java.lang.Error InvInp
General compilation error


TypeErr

java.lang.Error TypeErr
More specific type Error


THREE

final java.math.BigInteger THREE

FOUR

final java.math.BigInteger FOUR

ZERO

final java.math.BigInteger ZERO

predefs

java.math.BigInteger predefs
Encoded form of predefined functions


c0

final java.math.BigInteger c0
Coded form of zero


Vloc

final java.math.BigInteger Vloc
coded form of variable x1 (locv)


Z0

final java.math.BigInteger Z0
coded form of first variable (x)


z0

final int z0
int form of first variable (x)

See Also:
Constant Field Values

finf

Godel3.Funinfo finf
info for function currently being compiled


dep1

java.util.BitSet dep1
Set of function nos. for which dependency calculation has started


dep2

java.util.BitSet dep2
Set of function nos. for which dependency calculation has finished


numc

java.math.BigInteger[] numc
Bitstream forms of 0-3 (0,0',0'',0''')


itype

int itype
Type of current item


curch

char curch
current character


curnum

java.math.BigInteger curnum
current item if it is an integer


curword

java.lang.String curword
current item if it is an identifier


curtok

int curtok
current item if it is a token

Constructor Detail

Godel3

public Godel3()
Method Detail

newV

int newV()
new arithmetic variable

Returns:
int form of new variable

init

public void init()
Initalise applet

Overrides:
init in class java.applet.Applet

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent e)
Reset caret colour after it's turned red to show an error

Specified by:
caretUpdate in interface javax.swing.event.CaretListener

iseq

java.math.BigInteger iseq(java.math.BigInteger t1,
                          java.math.BigInteger t2)
Code for #t1=#t2


falll

java.math.BigInteger falll(int v,
                           java.math.BigInteger t1)
∀ #v #t1


paramcond

void paramcond(int v,
               int fno)
#v<Nf


lessthan

java.math.BigInteger lessthan(java.math.BigInteger t1,
                              java.math.BigInteger t2)
#t1<#t2


diag

java.math.BigInteger diag(java.math.BigInteger n)
¬(∀z (z=num(n)⇒¬#n)


exists

java.math.BigInteger exists(int v,
                            java.math.BigInteger T)
∃ #v #T


sigma

java.math.BigInteger sigma(java.math.BigInteger phi)
σφ


predefines

void predefines()
produces the code for predefined list operators (:),(!!) and functions length and tail


calcdep

void calcdep(int f)
Recursively calculates which functions a function depends upon f may be recursively defined, but mutual recursion is not allowed

Parameters:
f - index of function

calcdeps

void calcdeps(int f)
Calculates which functions a function depends upon, using calcdep

Parameters:
f - index of function

fcompile

void fcompile()
compiles the functions defined in the plines edit,


funcround

java.math.BigInteger funcround(java.math.BigInteger fcode)

yisfx

java.math.BigInteger yisfx(java.lang.String fname)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
responds to button press

Specified by:
actionPerformed in interface java.awt.event.ActionListener

num

java.math.BigInteger num(java.math.BigInteger x)
Encodes a number as an arithmetic expression


skipsps

void skipsps()
moves pos to the first non-whitespace character


getitem

void getitem()
Gets item from input text.


getword

void getword()
Requires a word, that is an identifier or reserved word


chkch

boolean chkch(char c)
Checks whether the current item is a single character matching c


chkchS

int chkchS(java.lang.String S)
Checks whether the current item is a single character in S.

Parameters:
S - characters considered
Returns:
The index of the character in S if found, otherwise -1

chkchv

void chkchv(char c)
requires the current item to be a single character matching c

Parameters:
c - the character to match

chktokv

void chktokv(int t)
Checks whether the current item is a 2 character token number t


unop

java.math.BigInteger unop(int op,
                          java.math.BigInteger x1)
Encodes the result of the unary operator


binop

java.math.BigInteger binop(java.math.BigInteger x1,
                           int op,
                           java.math.BigInteger x2)
Encodes the result of a binary operator


impp

java.math.BigInteger impp(java.math.BigInteger A,
                          java.math.BigInteger B)
#A ⇒ #B


expr10

Godel3.TExpr expr10()
Function calls, variables, numbers,[], (expr),duples


expr9

Godel3.TExpr expr9()
!! operator


mulop

int mulop()
#0, `div` #1, `mod` #2


expr7

Godel3.TExpr expr7()
, `div`, `mod`


expr6

Godel3.TExpr expr6()
+ and -


expr5

Godel3.TExpr expr5()

nott

java.math.BigInteger nott(java.math.BigInteger A)
Encode ¬#A


addcond

void addcond(java.math.BigInteger A)
Add a condition to the list


resconds

java.math.BigInteger resconds(int csb,
                              int esb,
                              int vsb)
∃ variables (∧ Conditions)


expr4

Godel3.TExpr expr4()
relational operators


expr3

Godel3.TExpr expr3()
&& operator


expr2

Godel3.TExpr expr2(int vareq)
if, case and let and || operator


chkIntv

void chkIntv()
Requires current item to be 'Integer' reserved word


getType

int getType()
Gets type descriptor. Type will be based on Integer


DefFn

void DefFn(java.lang.String name)
Deals with the definition part of a function (which must be present)


makesym

int makesym(int type)
Defines the current identifier to be a variable of a given type

Parameters:
type -
Returns:
int representation of variable

varb0

java.math.BigInteger varb0(int n)
Parameters:
n - - an int representation of an arithmetic variable
Returns:
the bitstream representation of the variable

varb

java.math.BigInteger varb(int n)
Parameters:
n - - an int representation of an arithmetic variable
Returns:
the bitstream representation of the variable with last bit 0 (signifying a variable)

J

java.math.BigInteger J(java.math.BigInteger t1,
                       java.math.BigInteger t2)
J is a 1 to 1 functio combining two integers into one

Parameters:
t1 - 1st term
t2 - 2nd term
Returns:
representation of (t1+t2)^2+t1+1

Jn

java.math.BigInteger Jn(int[] vs,
                        int n)
Combines n integer variables into one integer

Parameters:
vs - int representation of variables
n - number of variables
Returns:
values combined using J function

vform

java.math.BigInteger vform(java.math.BigInteger Term)
Creates (if needed) a variable equal to a given term

Parameters:
Term -
Returns:
int form of variable equal to Term

DoFun

java.math.BigInteger DoFun(int id)
Processes body of a function

Parameters:
id - function identifier
Returns:
code for function

chkResv

void chkResv(int i)
Ensures that current word is a given reserved word

Parameters:
i - Number of reserved word required

parse1

void parse1()
Parses program in strin