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.
( 96, 0, 3 ), ( 96, 32, 2 ), ( 96, 64, 1 ),
( 128, 0, 4 ), ( 128, 32, 3 ), ( 128, 64, 2 ), ( 128, 96, 1 ),
( 160, 0, 5 ), ( 160, 32, 4 ), ( 160, 64, 3 ), ( 160, 96, 2 ), ( 160, 128, 1 ),
( 192, 0, 6 ), ( 192, 32, 5 ), ( 192, 64, 4 ), ( 192, 96, 3 ), ( 192, 128, 2 ), ( 192, 160, 1 ),
( 224, 0, 7 ), ( 224, 32, 6 ), ( 224, 64, 5 ), ( 224, 96, 4 ), ( 224, 128, 3 ), ( 224, 160, 2 ), ( 224, 192, 1 ),
( 256, 0, 8 ), ( 256, 32, 7 ), ( 256, 64, 6 ), ( 256, 96, 5 ), ( 256, 128, 4 ), ( 256, 160, 3 ), ( 256, 192, 2 ), ( 256, 224, 1 ),
( 288, 0, 9 ), ( 288, 32, 8 ), ( 288, 64, 7 ), ( 288, 96, 6 ), ( 288, 128, 5 ), ( 288, 160, 4 ), ( 288, 192, 3 ), ( 288, 224, 2 ), ( 288, 256, 1 ),
( 320, 0, 10 ), ( 320, 32, 9 ), ( 320, 64, 8 ), ( 320, 96, 7 ), ( 320, 128, 6 ), ( 320, 160, 5 ), ( 320, 192, 4 ), ( 320, 224, 3 ), ( 320, 256, 2 ), ( 320, 288, 1 ),
( 352, 0, 11 ), ( 352, 32, 10 ), ( 352, 64, 9 ), ( 352, 96, 8 ), ( 352, 128, 7 ), ( 352, 160, 6 ), ( 352, 192, 5 ), ( 352, 224, 4 ), ( 352, 256, 3 ), ( 352, 288, 2 ), ( 352, 320, 1 ),
( 384, 0, 12 ), ( 384, 32, 11 ), ( 384, 64, 10 ), ( 384, 96, 9 ), ( 384, 128, 8 ), ( 384, 160, 7 ), ( 384, 192, 6 ), ( 384, 224, 5 ), ( 384, 256, 4 ), ( 384, 288, 3 ), ( 384, 320, 2 ), ( 384, 352, 1 ),
( 416, 0, 13 ), ( 416, 32, 12 ), ( 416, 64, 11 ), ( 416, 96, 10 ), ( 416, 128, 9 ), ( 416, 160, 8 ), ( 416, 192, 7 ), ( 416, 224, 6 ), ( 416, 256, 5 ), ( 416, 288, 4 ), ( 416, 320, 3 ), ( 416, 352, 2 ), ( 416, 384, 1 ),
( 448, 0, 14 ), ( 448, 32, 13 ), ( 448, 64, 12 ), ( 448, 96, 11 ), ( 448, 128, 10 ), ( 448, 160, 9 ), ( 448, 192, 8 ), ( 448, 224, 7 ), ( 448, 256, 6 ), ( 448, 288, 5 ), ( 448, 320, 4 ), ( 448, 352, 3 ), ( 448, 384, 2 ), ( 448, 416, 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 "}"