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.
( 94, 0, 22 ), ( 94, 47, 11 ),
( 141, 0, 33 ), ( 141, 47, 22 ), ( 141, 94, 11 ),
( 188, 0, 44 ), ( 188, 47, 33 ), ( 188, 94, 22 ), ( 188, 141, 11 ),
( 235, 0, 55 ), ( 235, 47, 44 ), ( 235, 94, 33 ), ( 235, 141, 22 ), ( 235, 188, 11 ),
( 282, 0, 66 ), ( 282, 47, 55 ), ( 282, 94, 44 ), ( 282, 141, 33 ), ( 282, 188, 22 ), ( 282, 235, 11 ),
( 329, 0, 77 ), ( 329, 47, 66 ), ( 329, 94, 55 ), ( 329, 141, 44 ), ( 329, 188, 33 ), ( 329, 235, 22 ), ( 329, 282, 11 ),
( 376, 0, 88 ), ( 376, 47, 77 ), ( 376, 94, 66 ), ( 376, 141, 55 ), ( 376, 188, 44 ), ( 376, 235, 33 ), ( 376, 282, 22 ), ( 376, 329, 11 ),
( 423, 0, 99 ), ( 423, 47, 88 ), ( 423, 94, 77 ), ( 423, 141, 66 ), ( 423, 188, 55 ), ( 423, 235, 44 ), ( 423, 282, 33 ), ( 423, 329, 22 ), ( 423, 376, 11 ),
( 470, 0, 110 ), ( 470, 47, 99 ), ( 470, 94, 88 ), ( 470, 141, 77 ), ( 470, 188, 66 ), ( 470, 235, 55 ), ( 470, 282, 44 ), ( 470, 329, 33 ), ( 470, 376, 22 ), ( 470, 423, 11 ),
( 517, 0, 121 ), ( 517, 47, 110 ), ( 517, 94, 99 ), ( 517, 141, 88 ), ( 517, 188, 77 ), ( 517, 235, 66 ), ( 517, 282, 55 ), ( 517, 329, 44 ), ( 517, 376, 33 ), ( 517, 423, 22 ), ( 517, 470, 11 ),
( 564, 0, 132 ), ( 564, 47, 121 ), ( 564, 94, 110 ), ( 564, 141, 99 ), ( 564, 188, 88 ), ( 564, 235, 77 ), ( 564, 282, 66 ), ( 564, 329, 55 ), ( 564, 376, 44 ), ( 564, 423, 33 ), ( 564, 470, 22 ), ( 564, 517, 11 ),
( 611, 0, 143 ), ( 611, 47, 132 ), ( 611, 94, 121 ), ( 611, 141, 110 ), ( 611, 188, 99 ), ( 611, 235, 88 ), ( 611, 282, 77 ), ( 611, 329, 66 ), ( 611, 376, 55 ), ( 611, 423, 44 ), ( 611, 470, 33 ), ( 611, 517, 22 ), ( 611, 564, 11 ),
( 658, 0, 154 ), ( 658, 47, 143 ), ( 658, 94, 132 ), ( 658, 141, 121 ), ( 658, 188, 110 ), ( 658, 235, 99 ), ( 658, 282, 88 ), ( 658, 329, 77 ), ( 658, 376, 66 ), ( 658, 423, 55 ), ( 658, 470, 44 ), ( 658, 517, 33 ), ( 658, 564, 22 ), ( 658, 611, 11 ),
...
}
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 "}"