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, 38 ), ( 94, 47, 19 ),
( 141, 0, 57 ), ( 141, 47, 38 ), ( 141, 94, 19 ),
( 188, 0, 76 ), ( 188, 47, 57 ), ( 188, 94, 38 ), ( 188, 141, 19 ),
( 235, 0, 95 ), ( 235, 47, 76 ), ( 235, 94, 57 ), ( 235, 141, 38 ), ( 235, 188, 19 ),
( 282, 0, 114 ), ( 282, 47, 95 ), ( 282, 94, 76 ), ( 282, 141, 57 ), ( 282, 188, 38 ), ( 282, 235, 19 ),
( 329, 0, 133 ), ( 329, 47, 114 ), ( 329, 94, 95 ), ( 329, 141, 76 ), ( 329, 188, 57 ), ( 329, 235, 38 ), ( 329, 282, 19 ),
( 376, 0, 152 ), ( 376, 47, 133 ), ( 376, 94, 114 ), ( 376, 141, 95 ), ( 376, 188, 76 ), ( 376, 235, 57 ), ( 376, 282, 38 ), ( 376, 329, 19 ),
( 423, 0, 171 ), ( 423, 47, 152 ), ( 423, 94, 133 ), ( 423, 141, 114 ), ( 423, 188, 95 ), ( 423, 235, 76 ), ( 423, 282, 57 ), ( 423, 329, 38 ), ( 423, 376, 19 ),
( 470, 0, 190 ), ( 470, 47, 171 ), ( 470, 94, 152 ), ( 470, 141, 133 ), ( 470, 188, 114 ), ( 470, 235, 95 ), ( 470, 282, 76 ), ( 470, 329, 57 ), ( 470, 376, 38 ), ( 470, 423, 19 ),
( 517, 0, 209 ), ( 517, 47, 190 ), ( 517, 94, 171 ), ( 517, 141, 152 ), ( 517, 188, 133 ), ( 517, 235, 114 ), ( 517, 282, 95 ), ( 517, 329, 76 ), ( 517, 376, 57 ), ( 517, 423, 38 ), ( 517, 470, 19 ),
( 564, 0, 228 ), ( 564, 47, 209 ), ( 564, 94, 190 ), ( 564, 141, 171 ), ( 564, 188, 152 ), ( 564, 235, 133 ), ( 564, 282, 114 ), ( 564, 329, 95 ), ( 564, 376, 76 ), ( 564, 423, 57 ), ( 564, 470, 38 ), ( 564, 517, 19 ),
( 611, 0, 247 ), ( 611, 47, 228 ), ( 611, 94, 209 ), ( 611, 141, 190 ), ( 611, 188, 171 ), ( 611, 235, 152 ), ( 611, 282, 133 ), ( 611, 329, 114 ), ( 611, 376, 95 ), ( 611, 423, 76 ), ( 611, 470, 57 ), ( 611, 517, 38 ), ( 611, 564, 19 ),
( 658, 0, 266 ), ( 658, 47, 247 ), ( 658, 94, 228 ), ( 658, 141, 209 ), ( 658, 188, 190 ), ( 658, 235, 171 ), ( 658, 282, 152 ), ( 658, 329, 133 ), ( 658, 376, 114 ), ( 658, 423, 95 ), ( 658, 470, 76 ), ( 658, 517, 57 ), ( 658, 564, 38 ), ( 658, 611, 19 ),
...
}
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 "}"