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, 27 ), ( 141, 47, 18 ), ( 141, 94, 9 ),
( 188, 0, 36 ), ( 188, 47, 27 ), ( 188, 94, 18 ), ( 188, 141, 9 ),
( 235, 0, 45 ), ( 235, 47, 36 ), ( 235, 94, 27 ), ( 235, 141, 18 ), ( 235, 188, 9 ),
( 282, 0, 54 ), ( 282, 47, 45 ), ( 282, 94, 36 ), ( 282, 141, 27 ), ( 282, 188, 18 ), ( 282, 235, 9 ),
( 329, 0, 63 ), ( 329, 47, 54 ), ( 329, 94, 45 ), ( 329, 141, 36 ), ( 329, 188, 27 ), ( 329, 235, 18 ), ( 329, 282, 9 ),
( 376, 0, 72 ), ( 376, 47, 63 ), ( 376, 94, 54 ), ( 376, 141, 45 ), ( 376, 188, 36 ), ( 376, 235, 27 ), ( 376, 282, 18 ), ( 376, 329, 9 ),
( 423, 0, 81 ), ( 423, 47, 72 ), ( 423, 94, 63 ), ( 423, 141, 54 ), ( 423, 188, 45 ), ( 423, 235, 36 ), ( 423, 282, 27 ), ( 423, 329, 18 ), ( 423, 376, 9 ),
( 470, 0, 90 ), ( 470, 47, 81 ), ( 470, 94, 72 ), ( 470, 141, 63 ), ( 470, 188, 54 ), ( 470, 235, 45 ), ( 470, 282, 36 ), ( 470, 329, 27 ), ( 470, 376, 18 ), ( 470, 423, 9 ),
( 517, 0, 99 ), ( 517, 47, 90 ), ( 517, 94, 81 ), ( 517, 141, 72 ), ( 517, 188, 63 ), ( 517, 235, 54 ), ( 517, 282, 45 ), ( 517, 329, 36 ), ( 517, 376, 27 ), ( 517, 423, 18 ), ( 517, 470, 9 ),
( 564, 0, 108 ), ( 564, 47, 99 ), ( 564, 94, 90 ), ( 564, 141, 81 ), ( 564, 188, 72 ), ( 564, 235, 63 ), ( 564, 282, 54 ), ( 564, 329, 45 ), ( 564, 376, 36 ), ( 564, 423, 27 ), ( 564, 470, 18 ), ( 564, 517, 9 ),
( 611, 0, 117 ), ( 611, 47, 108 ), ( 611, 94, 99 ), ( 611, 141, 90 ), ( 611, 188, 81 ), ( 611, 235, 72 ), ( 611, 282, 63 ), ( 611, 329, 54 ), ( 611, 376, 45 ), ( 611, 423, 36 ), ( 611, 470, 27 ), ( 611, 517, 18 ), ( 611, 564, 9 ),
( 658, 0, 126 ), ( 658, 47, 117 ), ( 658, 94, 108 ), ( 658, 141, 99 ), ( 658, 188, 90 ), ( 658, 235, 81 ), ( 658, 282, 72 ), ( 658, 329, 63 ), ( 658, 376, 54 ), ( 658, 423, 45 ), ( 658, 470, 36 ), ( 658, 517, 27 ), ( 658, 564, 18 ), ( 658, 611, 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 "}"