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.
( 141, 0, 24 ), ( 141, 47, 16 ), ( 141, 94, 8 ),
( 188, 0, 32 ), ( 188, 47, 24 ), ( 188, 94, 16 ), ( 188, 141, 8 ),
( 235, 0, 40 ), ( 235, 47, 32 ), ( 235, 94, 24 ), ( 235, 141, 16 ), ( 235, 188, 8 ),
( 282, 0, 48 ), ( 282, 47, 40 ), ( 282, 94, 32 ), ( 282, 141, 24 ), ( 282, 188, 16 ), ( 282, 235, 8 ),
( 329, 0, 56 ), ( 329, 47, 48 ), ( 329, 94, 40 ), ( 329, 141, 32 ), ( 329, 188, 24 ), ( 329, 235, 16 ), ( 329, 282, 8 ),
( 376, 0, 64 ), ( 376, 47, 56 ), ( 376, 94, 48 ), ( 376, 141, 40 ), ( 376, 188, 32 ), ( 376, 235, 24 ), ( 376, 282, 16 ), ( 376, 329, 8 ),
( 423, 0, 72 ), ( 423, 47, 64 ), ( 423, 94, 56 ), ( 423, 141, 48 ), ( 423, 188, 40 ), ( 423, 235, 32 ), ( 423, 282, 24 ), ( 423, 329, 16 ), ( 423, 376, 8 ),
( 470, 0, 80 ), ( 470, 47, 72 ), ( 470, 94, 64 ), ( 470, 141, 56 ), ( 470, 188, 48 ), ( 470, 235, 40 ), ( 470, 282, 32 ), ( 470, 329, 24 ), ( 470, 376, 16 ), ( 470, 423, 8 ),
( 517, 0, 88 ), ( 517, 47, 80 ), ( 517, 94, 72 ), ( 517, 141, 64 ), ( 517, 188, 56 ), ( 517, 235, 48 ), ( 517, 282, 40 ), ( 517, 329, 32 ), ( 517, 376, 24 ), ( 517, 423, 16 ), ( 517, 470, 8 ),
( 564, 0, 96 ), ( 564, 47, 88 ), ( 564, 94, 80 ), ( 564, 141, 72 ), ( 564, 188, 64 ), ( 564, 235, 56 ), ( 564, 282, 48 ), ( 564, 329, 40 ), ( 564, 376, 32 ), ( 564, 423, 24 ), ( 564, 470, 16 ), ( 564, 517, 8 ),
( 611, 0, 104 ), ( 611, 47, 96 ), ( 611, 94, 88 ), ( 611, 141, 80 ), ( 611, 188, 72 ), ( 611, 235, 64 ), ( 611, 282, 56 ), ( 611, 329, 48 ), ( 611, 376, 40 ), ( 611, 423, 32 ), ( 611, 470, 24 ), ( 611, 517, 16 ), ( 611, 564, 8 ),
( 658, 0, 112 ), ( 658, 47, 104 ), ( 658, 94, 96 ), ( 658, 141, 88 ), ( 658, 188, 80 ), ( 658, 235, 72 ), ( 658, 282, 64 ), ( 658, 329, 56 ), ( 658, 376, 48 ), ( 658, 423, 40 ), ( 658, 470, 32 ), ( 658, 517, 24 ), ( 658, 564, 16 ), ( 658, 611, 8 ),
...
}
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 "}"