The rational number 4/1 as a set

One way to define a rational number (a-b)/c is to define it as the (infinite) set of all 3-tuples of natural numbers (a1, b1, c1) for which (a-b)/c = (a1-b1)/c1 (b is needed for negative numbers).

Klick on a 3-tuple to see how it may be defined as a set.

4/1 = (4-0)/1 = {

( 4, 0, 1 ),

( 8, 0, 2 ), ( 8, 4, 1 ),

( 12, 0, 3 ), ( 12, 4, 2 ), ( 12, 8, 1 ),

( 16, 0, 4 ), ( 16, 4, 3 ), ( 16, 8, 2 ), ( 16, 12, 1 ),

( 20, 0, 5 ), ( 20, 4, 4 ), ( 20, 8, 3 ), ( 20, 12, 2 ), ( 20, 16, 1 ),

( 24, 0, 6 ), ( 24, 4, 5 ), ( 24, 8, 4 ), ( 24, 12, 3 ), ( 24, 16, 2 ), ( 24, 20, 1 ),

( 28, 0, 7 ), ( 28, 4, 6 ), ( 28, 8, 5 ), ( 28, 12, 4 ), ( 28, 16, 3 ), ( 28, 20, 2 ), ( 28, 24, 1 ),

( 32, 0, 8 ), ( 32, 4, 7 ), ( 32, 8, 6 ), ( 32, 12, 5 ), ( 32, 16, 4 ), ( 32, 20, 3 ), ( 32, 24, 2 ), ( 32, 28, 1 ),

( 36, 0, 9 ), ( 36, 4, 8 ), ( 36, 8, 7 ), ( 36, 12, 6 ), ( 36, 16, 5 ), ( 36, 20, 4 ), ( 36, 24, 3 ), ( 36, 28, 2 ), ( 36, 32, 1 ),

( 40, 0, 10 ), ( 40, 4, 9 ), ( 40, 8, 8 ), ( 40, 12, 7 ), ( 40, 16, 6 ), ( 40, 20, 5 ), ( 40, 24, 4 ), ( 40, 28, 3 ), ( 40, 32, 2 ), ( 40, 36, 1 ),

( 44, 0, 11 ), ( 44, 4, 10 ), ( 44, 8, 9 ), ( 44, 12, 8 ), ( 44, 16, 7 ), ( 44, 20, 6 ), ( 44, 24, 5 ), ( 44, 28, 4 ), ( 44, 32, 3 ), ( 44, 36, 2 ), ( 44, 40, 1 ),

( 48, 0, 12 ), ( 48, 4, 11 ), ( 48, 8, 10 ), ( 48, 12, 9 ), ( 48, 16, 8 ), ( 48, 20, 7 ), ( 48, 24, 6 ), ( 48, 28, 5 ), ( 48, 32, 4 ), ( 48, 36, 3 ), ( 48, 40, 2 ), ( 48, 44, 1 ),

( 52, 0, 13 ), ( 52, 4, 12 ), ( 52, 8, 11 ), ( 52, 12, 10 ), ( 52, 16, 9 ), ( 52, 20, 8 ), ( 52, 24, 7 ), ( 52, 28, 6 ), ( 52, 32, 5 ), ( 52, 36, 4 ), ( 52, 40, 3 ), ( 52, 44, 2 ), ( 52, 48, 1 ),

( 56, 0, 14 ), ( 56, 4, 13 ), ( 56, 8, 12 ), ( 56, 12, 11 ), ( 56, 16, 10 ), ( 56, 20, 9 ), ( 56, 24, 8 ), ( 56, 28, 7 ), ( 56, 32, 6 ), ( 56, 36, 5 ), ( 56, 40, 4 ), ( 56, 44, 3 ), ( 56, 48, 2 ), ( 56, 52, 1 ),

...

}

The equation (a-b)/c = (a1-b1)/c1 is equivalent to a·c1 + b1·c = a1·c + b·c1 - so only addition and multiplication of natural numbers are needed to define the rational numbers.

For rational numbers Q, Q1 as defined above, Q < Q1 is defined as a·c1 + b1·c < a1·c + b·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.

Q + Q1 is defined as (a2-b2)/c2, where a2 = a·c1 + a1·c, b2 = b·c1 + b1·c, c2 = c·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.

Be aware that (a2-b2)/c2 is simply a notation for the set determined by a2, b2 and c2 here - not an expression using subtraction and division.

The definition for Q + Q1 above simply is a transformation of the expression (a-b)/c + (a1-b1)/c1.

Assuming that a,c is minimal for a positive rational number a/c or (a-0)/c, we can enumerate all members of the set by doing this:

Let n be 1
Repeat:
  For all n1 from 0 to n-1:
    Let a1 be n·a
    Let b1 be n1·a
    Let c1 be (n-n1)·c
    Enumerate (a1,b1,c1)
  Increase n by 1

The enumeration as Python function with a limiting parameter k which will cause the function to enumerate (k·(k+1))/2 elements of a/c:

def print_rational_number(a,c,k):
    print str(a)+'/'+str(c)+' = ('+str(a)+'-0)/'+str(c)+' = {'
    for n in range(1,k+1):
        for n1 in range(n):
            a1=n*a
            b1=n1*a
            c1=(n-n1)*c
            print '( '+str(a1)+', '+str(b1)+', '+str(c1)+' ),'
        print
    print "..."
    print "}"

(back to √2)