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, 58 ), ( 94, 47, 29 ),
( 141, 0, 87 ), ( 141, 47, 58 ), ( 141, 94, 29 ),
( 188, 0, 116 ), ( 188, 47, 87 ), ( 188, 94, 58 ), ( 188, 141, 29 ),
( 235, 0, 145 ), ( 235, 47, 116 ), ( 235, 94, 87 ), ( 235, 141, 58 ), ( 235, 188, 29 ),
( 282, 0, 174 ), ( 282, 47, 145 ), ( 282, 94, 116 ), ( 282, 141, 87 ), ( 282, 188, 58 ), ( 282, 235, 29 ),
( 329, 0, 203 ), ( 329, 47, 174 ), ( 329, 94, 145 ), ( 329, 141, 116 ), ( 329, 188, 87 ), ( 329, 235, 58 ), ( 329, 282, 29 ),
( 376, 0, 232 ), ( 376, 47, 203 ), ( 376, 94, 174 ), ( 376, 141, 145 ), ( 376, 188, 116 ), ( 376, 235, 87 ), ( 376, 282, 58 ), ( 376, 329, 29 ),
( 423, 0, 261 ), ( 423, 47, 232 ), ( 423, 94, 203 ), ( 423, 141, 174 ), ( 423, 188, 145 ), ( 423, 235, 116 ), ( 423, 282, 87 ), ( 423, 329, 58 ), ( 423, 376, 29 ),
( 470, 0, 290 ), ( 470, 47, 261 ), ( 470, 94, 232 ), ( 470, 141, 203 ), ( 470, 188, 174 ), ( 470, 235, 145 ), ( 470, 282, 116 ), ( 470, 329, 87 ), ( 470, 376, 58 ), ( 470, 423, 29 ),
( 517, 0, 319 ), ( 517, 47, 290 ), ( 517, 94, 261 ), ( 517, 141, 232 ), ( 517, 188, 203 ), ( 517, 235, 174 ), ( 517, 282, 145 ), ( 517, 329, 116 ), ( 517, 376, 87 ), ( 517, 423, 58 ), ( 517, 470, 29 ),
( 564, 0, 348 ), ( 564, 47, 319 ), ( 564, 94, 290 ), ( 564, 141, 261 ), ( 564, 188, 232 ), ( 564, 235, 203 ), ( 564, 282, 174 ), ( 564, 329, 145 ), ( 564, 376, 116 ), ( 564, 423, 87 ), ( 564, 470, 58 ), ( 564, 517, 29 ),
( 611, 0, 377 ), ( 611, 47, 348 ), ( 611, 94, 319 ), ( 611, 141, 290 ), ( 611, 188, 261 ), ( 611, 235, 232 ), ( 611, 282, 203 ), ( 611, 329, 174 ), ( 611, 376, 145 ), ( 611, 423, 116 ), ( 611, 470, 87 ), ( 611, 517, 58 ), ( 611, 564, 29 ),
( 658, 0, 406 ), ( 658, 47, 377 ), ( 658, 94, 348 ), ( 658, 141, 319 ), ( 658, 188, 290 ), ( 658, 235, 261 ), ( 658, 282, 232 ), ( 658, 329, 203 ), ( 658, 376, 174 ), ( 658, 423, 145 ), ( 658, 470, 116 ), ( 658, 517, 87 ), ( 658, 564, 58 ), ( 658, 611, 29 ),
...
}
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 "}"