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, 6 ), ( 141, 47, 4 ), ( 141, 94, 2 ),
( 188, 0, 8 ), ( 188, 47, 6 ), ( 188, 94, 4 ), ( 188, 141, 2 ),
( 235, 0, 10 ), ( 235, 47, 8 ), ( 235, 94, 6 ), ( 235, 141, 4 ), ( 235, 188, 2 ),
( 282, 0, 12 ), ( 282, 47, 10 ), ( 282, 94, 8 ), ( 282, 141, 6 ), ( 282, 188, 4 ), ( 282, 235, 2 ),
( 329, 0, 14 ), ( 329, 47, 12 ), ( 329, 94, 10 ), ( 329, 141, 8 ), ( 329, 188, 6 ), ( 329, 235, 4 ), ( 329, 282, 2 ),
( 376, 0, 16 ), ( 376, 47, 14 ), ( 376, 94, 12 ), ( 376, 141, 10 ), ( 376, 188, 8 ), ( 376, 235, 6 ), ( 376, 282, 4 ), ( 376, 329, 2 ),
( 423, 0, 18 ), ( 423, 47, 16 ), ( 423, 94, 14 ), ( 423, 141, 12 ), ( 423, 188, 10 ), ( 423, 235, 8 ), ( 423, 282, 6 ), ( 423, 329, 4 ), ( 423, 376, 2 ),
( 470, 0, 20 ), ( 470, 47, 18 ), ( 470, 94, 16 ), ( 470, 141, 14 ), ( 470, 188, 12 ), ( 470, 235, 10 ), ( 470, 282, 8 ), ( 470, 329, 6 ), ( 470, 376, 4 ), ( 470, 423, 2 ),
( 517, 0, 22 ), ( 517, 47, 20 ), ( 517, 94, 18 ), ( 517, 141, 16 ), ( 517, 188, 14 ), ( 517, 235, 12 ), ( 517, 282, 10 ), ( 517, 329, 8 ), ( 517, 376, 6 ), ( 517, 423, 4 ), ( 517, 470, 2 ),
( 564, 0, 24 ), ( 564, 47, 22 ), ( 564, 94, 20 ), ( 564, 141, 18 ), ( 564, 188, 16 ), ( 564, 235, 14 ), ( 564, 282, 12 ), ( 564, 329, 10 ), ( 564, 376, 8 ), ( 564, 423, 6 ), ( 564, 470, 4 ), ( 564, 517, 2 ),
( 611, 0, 26 ), ( 611, 47, 24 ), ( 611, 94, 22 ), ( 611, 141, 20 ), ( 611, 188, 18 ), ( 611, 235, 16 ), ( 611, 282, 14 ), ( 611, 329, 12 ), ( 611, 376, 10 ), ( 611, 423, 8 ), ( 611, 470, 6 ), ( 611, 517, 4 ), ( 611, 564, 2 ),
( 658, 0, 28 ), ( 658, 47, 26 ), ( 658, 94, 24 ), ( 658, 141, 22 ), ( 658, 188, 20 ), ( 658, 235, 18 ), ( 658, 282, 16 ), ( 658, 329, 14 ), ( 658, 376, 12 ), ( 658, 423, 10 ), ( 658, 470, 8 ), ( 658, 517, 6 ), ( 658, 564, 4 ), ( 658, 611, 2 ),
...
}
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 "}"