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, 9 ), ( 96, 32, 6 ), ( 96, 64, 3 ),
( 128, 0, 12 ), ( 128, 32, 9 ), ( 128, 64, 6 ), ( 128, 96, 3 ),
( 160, 0, 15 ), ( 160, 32, 12 ), ( 160, 64, 9 ), ( 160, 96, 6 ), ( 160, 128, 3 ),
( 192, 0, 18 ), ( 192, 32, 15 ), ( 192, 64, 12 ), ( 192, 96, 9 ), ( 192, 128, 6 ), ( 192, 160, 3 ),
( 224, 0, 21 ), ( 224, 32, 18 ), ( 224, 64, 15 ), ( 224, 96, 12 ), ( 224, 128, 9 ), ( 224, 160, 6 ), ( 224, 192, 3 ),
( 256, 0, 24 ), ( 256, 32, 21 ), ( 256, 64, 18 ), ( 256, 96, 15 ), ( 256, 128, 12 ), ( 256, 160, 9 ), ( 256, 192, 6 ), ( 256, 224, 3 ),
( 288, 0, 27 ), ( 288, 32, 24 ), ( 288, 64, 21 ), ( 288, 96, 18 ), ( 288, 128, 15 ), ( 288, 160, 12 ), ( 288, 192, 9 ), ( 288, 224, 6 ), ( 288, 256, 3 ),
( 320, 0, 30 ), ( 320, 32, 27 ), ( 320, 64, 24 ), ( 320, 96, 21 ), ( 320, 128, 18 ), ( 320, 160, 15 ), ( 320, 192, 12 ), ( 320, 224, 9 ), ( 320, 256, 6 ), ( 320, 288, 3 ),
( 352, 0, 33 ), ( 352, 32, 30 ), ( 352, 64, 27 ), ( 352, 96, 24 ), ( 352, 128, 21 ), ( 352, 160, 18 ), ( 352, 192, 15 ), ( 352, 224, 12 ), ( 352, 256, 9 ), ( 352, 288, 6 ), ( 352, 320, 3 ),
( 384, 0, 36 ), ( 384, 32, 33 ), ( 384, 64, 30 ), ( 384, 96, 27 ), ( 384, 128, 24 ), ( 384, 160, 21 ), ( 384, 192, 18 ), ( 384, 224, 15 ), ( 384, 256, 12 ), ( 384, 288, 9 ), ( 384, 320, 6 ), ( 384, 352, 3 ),
( 416, 0, 39 ), ( 416, 32, 36 ), ( 416, 64, 33 ), ( 416, 96, 30 ), ( 416, 128, 27 ), ( 416, 160, 24 ), ( 416, 192, 21 ), ( 416, 224, 18 ), ( 416, 256, 15 ), ( 416, 288, 12 ), ( 416, 320, 9 ), ( 416, 352, 6 ), ( 416, 384, 3 ),
( 448, 0, 42 ), ( 448, 32, 39 ), ( 448, 64, 36 ), ( 448, 96, 33 ), ( 448, 128, 30 ), ( 448, 160, 27 ), ( 448, 192, 24 ), ( 448, 224, 21 ), ( 448, 256, 18 ), ( 448, 288, 15 ), ( 448, 320, 12 ), ( 448, 352, 9 ), ( 448, 384, 6 ), ( 448, 416, 3 ),
...
}
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 "}"