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, 27 ), ( 96, 32, 18 ), ( 96, 64, 9 ),
( 128, 0, 36 ), ( 128, 32, 27 ), ( 128, 64, 18 ), ( 128, 96, 9 ),
( 160, 0, 45 ), ( 160, 32, 36 ), ( 160, 64, 27 ), ( 160, 96, 18 ), ( 160, 128, 9 ),
( 192, 0, 54 ), ( 192, 32, 45 ), ( 192, 64, 36 ), ( 192, 96, 27 ), ( 192, 128, 18 ), ( 192, 160, 9 ),
( 224, 0, 63 ), ( 224, 32, 54 ), ( 224, 64, 45 ), ( 224, 96, 36 ), ( 224, 128, 27 ), ( 224, 160, 18 ), ( 224, 192, 9 ),
( 256, 0, 72 ), ( 256, 32, 63 ), ( 256, 64, 54 ), ( 256, 96, 45 ), ( 256, 128, 36 ), ( 256, 160, 27 ), ( 256, 192, 18 ), ( 256, 224, 9 ),
( 288, 0, 81 ), ( 288, 32, 72 ), ( 288, 64, 63 ), ( 288, 96, 54 ), ( 288, 128, 45 ), ( 288, 160, 36 ), ( 288, 192, 27 ), ( 288, 224, 18 ), ( 288, 256, 9 ),
( 320, 0, 90 ), ( 320, 32, 81 ), ( 320, 64, 72 ), ( 320, 96, 63 ), ( 320, 128, 54 ), ( 320, 160, 45 ), ( 320, 192, 36 ), ( 320, 224, 27 ), ( 320, 256, 18 ), ( 320, 288, 9 ),
( 352, 0, 99 ), ( 352, 32, 90 ), ( 352, 64, 81 ), ( 352, 96, 72 ), ( 352, 128, 63 ), ( 352, 160, 54 ), ( 352, 192, 45 ), ( 352, 224, 36 ), ( 352, 256, 27 ), ( 352, 288, 18 ), ( 352, 320, 9 ),
( 384, 0, 108 ), ( 384, 32, 99 ), ( 384, 64, 90 ), ( 384, 96, 81 ), ( 384, 128, 72 ), ( 384, 160, 63 ), ( 384, 192, 54 ), ( 384, 224, 45 ), ( 384, 256, 36 ), ( 384, 288, 27 ), ( 384, 320, 18 ), ( 384, 352, 9 ),
( 416, 0, 117 ), ( 416, 32, 108 ), ( 416, 64, 99 ), ( 416, 96, 90 ), ( 416, 128, 81 ), ( 416, 160, 72 ), ( 416, 192, 63 ), ( 416, 224, 54 ), ( 416, 256, 45 ), ( 416, 288, 36 ), ( 416, 320, 27 ), ( 416, 352, 18 ), ( 416, 384, 9 ),
( 448, 0, 126 ), ( 448, 32, 117 ), ( 448, 64, 108 ), ( 448, 96, 99 ), ( 448, 128, 90 ), ( 448, 160, 81 ), ( 448, 192, 72 ), ( 448, 224, 63 ), ( 448, 256, 54 ), ( 448, 288, 45 ), ( 448, 320, 36 ), ( 448, 352, 27 ), ( 448, 384, 18 ), ( 448, 416, 9 ),
...
}
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 "}"