Automata

## Class NumberSystem

- java.lang.Object
- - Automata.NumberSystem

-     public class NumberSystem
      extends java.lang.Object

  The class NumberSystem represents a number system.
  A number system consists of the following four:
  - a rule to represent non-negative numbers, and hence an alphabet
  - a rule for addition
  - a rule for comparison, and by comparison we mean equality and less than testing.
  - a flag that determines whether numbers are represented in most significant digit order or least significant digit.
  For example msd_3 is a number system. It is the number system in which
  - numbers are represented in base 3 in most significant digit first. Hence the alphabet is {0,1,2}.
  - the rule for addition, is a simple two states automaton, that gets 3-tuples (a,b,c) in base three and accepts iff c=a+b.
  - the rule for comparison is a simple two state automaton, that gets 2-tuples (a,b) in base three and accepts iff a < b.
  - we already mentioned that numbers are in most significant digit first (msd) in this number system.
  We mandate that 0 and 1 belong to the alphabet of every number systems. In addition, we require that 0* represent the additive identity in all number systems. We also mandate that either 0*1 or 10* (depending on msd/lsd) represent multiplicative identity in all number systems.
  From here on by rule we mean a finite automaton. If the users want to create a new number system, they, at least, have to provide the rule for addition (in the Custom Bases directory). They can further provide the rule for less than. If less than rule is not provided, we use the lexicographic ordering on integers to create an automaton for less than testing. So for example if the alphabet is {-2,0,7} then in lexicographic order, we have -270 < 0-270-2.
  Rule for equality is always the rule for word equalities, i.e., two numbers are equal if the words representing them are equal.
  Rules for base n already exist in the system for every n>1. However the user can override them.
  VERY IMPORTANT: ALL PRIVATE METHODS WHICH RETURN AUTOMATON MUST BE USED WITH CAUTION. THEIR RETURNED AUTOMATON SHOULD NOT BE ALTERED. IF YOU WANT TO ALTER THEIR RETURNED VALUE, THEN YOU HAVE GOT TO MAKE A CLONE AND DO THE MODIFICATION ON THE CLONE.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `Automaton` | `addition` Automata for addition, lessThan, and equal -addition has three inputs, and it accepts iff the third is the sum of the first two.
    `Automaton` | `allRepresentations` Automata for addition, lessThan, and equal -addition has three inputs, and it accepts iff the third is the sum of the first two.
    `Automaton` | `equality` Automata for addition, lessThan, and equal -addition has three inputs, and it accepts iff the third is the sum of the first two.
    `Automaton` | `lessThan` Automata for addition, lessThan, and equal -addition has three inputs, and it accepts iff the third is the sum of the first two.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NumberSystem(java.lang.String name)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Automaton` | `arithmetic(int a, java.lang.String b, java.lang.String c, java.lang.String arithmeticOperator)`
    `Automaton` | `arithmetic(java.lang.String a, int b, java.lang.String c, java.lang.String arithmeticOperator)`
    `Automaton` | `arithmetic(java.lang.String a, java.lang.String b, java.lang.String c, java.lang.String arithmeticOperator)`
    `Automaton` | `comparison(int a, java.lang.String b, java.lang.String comparisonOperator)`
    `Automaton` | `comparison(java.lang.String a, int b, java.lang.String comparisonOperator)`
    `Automaton` | `comparison(java.lang.String a, java.lang.String b, java.lang.String comparisonOperator)`
    `Automaton` | `get(int n)`
    `Automaton` | `getAllRepresentations()`
    `java.util.List<java.lang.Integer>` | `getAlphabet()`
    `Automaton` | `getDivision(int n)`
    `Automaton` | `getMultiplication(int n)`
    `boolean` | `isMsd()`
    `boolean` | `should_we_use_allRepresentations()`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### addition

          public Automaton addition

      Automata for addition, lessThan, and equal
      -addition has three inputs, and it accepts iff the third is the sum of the first two. So the input is ordered!
      -lessThan has two inputs, and it accepts iff the first one is less than the second one. So the input is ordered!
      -equal has two inputs, and it accepts iff they are equal.

    - #### lessThan

          public Automaton lessThan

      Automata for addition, lessThan, and equal
      -addition has three inputs, and it accepts iff the third is the sum of the first two. So the input is ordered!
      -lessThan has two inputs, and it accepts iff the first one is less than the second one. So the input is ordered!
      -equal has two inputs, and it accepts iff they are equal.

    - #### equality

          public Automaton equality

      Automata for addition, lessThan, and equal
      -addition has three inputs, and it accepts iff the third is the sum of the first two. So the input is ordered!
      -lessThan has two inputs, and it accepts iff the first one is less than the second one. So the input is ordered!
      -equal has two inputs, and it accepts iff they are equal.

    - #### allRepresentations

          public Automaton allRepresentations

      Automata for addition, lessThan, and equal
      -addition has three inputs, and it accepts iff the third is the sum of the first two. So the input is ordered!
      -lessThan has two inputs, and it accepts iff the first one is less than the second one. So the input is ordered!
      -equal has two inputs, and it accepts iff they are equal.

  - ### Constructor Detail

    - #### NumberSystem

          public NumberSystem(java.lang.String name)
                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

  - ### Method Detail

    - #### isMsd

          public boolean isMsd()

    - #### should_we_use_allRepresentations

          public boolean should_we_use_allRepresentations()

    - #### getAlphabet

          public java.util.List<java.lang.Integer> getAlphabet()

    - #### getAllRepresentations

          public Automaton getAllRepresentations()

    - #### get

          public Automaton get(int n)
                        throws java.lang.Exception

      Parameters:
        `n` -
      Returns:
        an automaton that accepts only n.
      Throws:
        `java.lang.Exception`

    - #### getDivision

          public Automaton getDivision(int n)
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getMultiplication

          public Automaton getMultiplication(int n)
                                      throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### comparison

          public Automaton comparison(java.lang.String a,
                             java.lang.String b,
                             java.lang.String comparisonOperator)
                               throws java.lang.Exception

      Parameters:
        `a` -
        `b` -
        `comparisonOperator` - can be any of "<",">","<=",">=","=","!="
      Returns:
        an Automaton with two inputs, with labels a and b. It accepts iff a comparisonOperator b. Note that the order of inputs, in the resulting automaton, is not guaranteed to be either (a,b) or (b,a). So the input is not ordered!
      Throws:
        `java.lang.Exception`

    - #### comparison

          public Automaton comparison(java.lang.String a,
                             int b,
                             java.lang.String comparisonOperator)
                               throws java.lang.Exception

      Parameters:
        `a` -
        `b` - a non negative integer
        `comparisonOperator` - can be any of "<",">","<=",">=","=","!="
      Returns:
        an Automaton with single input, with label = [a]. It accepts iff a comparisonOperator b.
      Throws:
        `java.lang.Exception`

    - #### comparison

          public Automaton comparison(int a,
                             java.lang.String b,
                             java.lang.String comparisonOperator)
                               throws java.lang.Exception

      Parameters:
        `a` - a non negative integer
        `b` -
        `comparisonOperator` - can be any of "<",">","<=",">=","=","!="
      Returns:
        an Automaton with single input, with label = [b]. It accepts iff a comparisonOperator b.
      Throws:
        `java.lang.Exception`

    - #### arithmetic

          public Automaton arithmetic(java.lang.String a,
                             java.lang.String b,
                             java.lang.String c,
                             java.lang.String arithmeticOperator)
                               throws java.lang.Exception

      Parameters:
        `a` -
        `b` -
        `c` -
        `arithmeticOperator` - can be any of "+", "-","*","/"
      Returns:
        an Automaton with three inputs with labels a,b,c. It accepts iff c = a arithmeticOperator b. Note that the order of inputs, in the resulting automaton, is not guaranteed to be in any fixed order like (a,b,c) or (c,b,a) ... So the input is not ordered!
      Throws:
        `java.lang.Exception`

    - #### arithmetic

          public Automaton arithmetic(java.lang.String a,
                             int b,
                             java.lang.String c,
                             java.lang.String arithmeticOperator)
                               throws java.lang.Exception

      Parameters:
        `a` -
        `b` - a non-negative integer
        `c` -
        `arithmeticOperator` - can be any of "+","-","*","/"
      Returns:
        an Automaton with two inputs, with labels a and c. It accepts iff c = a arithmeticOperator b. Note that the order of inputs, in the resulting automaton, is not guaranteed to be in any fixed order like [a,c] or [c,a]. So the input is not ordered!
      Throws:
        `java.lang.Exception`

    - #### arithmetic

          public Automaton arithmetic(int a,
                             java.lang.String b,
                             java.lang.String c,
                             java.lang.String arithmeticOperator)
                               throws java.lang.Exception

      Parameters:
        `a` - a non-negative integer
        `b` -
        `c` -
        `arithmeticOperator` - can be any of "+","-","*","/"
      Returns:
        an Automaton with two inputs, with labels b and c. It accepts iff c = a arithmeticOperator b. Note that the order of inputs, in the resulting automaton, is not guaranteed to be in any fixed order like [b,c] or [c,b]. So the input is not ordered!
      Throws:
        `java.lang.Exception`