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, 24 ), ( 94, 47, 12 ),
( 141, 0, 36 ), ( 141, 47, 24 ), ( 141, 94, 12 ),
( 188, 0, 48 ), ( 188, 47, 36 ), ( 188, 94, 24 ), ( 188, 141, 12 ),
( 235, 0, 60 ), ( 235, 47, 48 ), ( 235, 94, 36 ), ( 235, 141, 24 ), ( 235, 188, 12 ),
( 282, 0, 72 ), ( 282, 47, 60 ), ( 282, 94, 48 ), ( 282, 141, 36 ), ( 282, 188, 24 ), ( 282, 235, 12 ),
( 329, 0, 84 ), ( 329, 47, 72 ), ( 329, 94, 60 ), ( 329, 141, 48 ), ( 329, 188, 36 ), ( 329, 235, 24 ), ( 329, 282, 12 ),
( 376, 0, 96 ), ( 376, 47, 84 ), ( 376, 94, 72 ), ( 376, 141, 60 ), ( 376, 188, 48 ), ( 376, 235, 36 ), ( 376, 282, 24 ), ( 376, 329, 12 ),
( 423, 0, 108 ), ( 423, 47, 96 ), ( 423, 94, 84 ), ( 423, 141, 72 ), ( 423, 188, 60 ), ( 423, 235, 48 ), ( 423, 282, 36 ), ( 423, 329, 24 ), ( 423, 376, 12 ),
( 470, 0, 120 ), ( 470, 47, 108 ), ( 470, 94, 96 ), ( 470, 141, 84 ), ( 470, 188, 72 ), ( 470, 235, 60 ), ( 470, 282, 48 ), ( 470, 329, 36 ), ( 470, 376, 24 ), ( 470, 423, 12 ),
( 517, 0, 132 ), ( 517, 47, 120 ), ( 517, 94, 108 ), ( 517, 141, 96 ), ( 517, 188, 84 ), ( 517, 235, 72 ), ( 517, 282, 60 ), ( 517, 329, 48 ), ( 517, 376, 36 ), ( 517, 423, 24 ), ( 517, 470, 12 ),
( 564, 0, 144 ), ( 564, 47, 132 ), ( 564, 94, 120 ), ( 564, 141, 108 ), ( 564, 188, 96 ), ( 564, 235, 84 ), ( 564, 282, 72 ), ( 564, 329, 60 ), ( 564, 376, 48 ), ( 564, 423, 36 ), ( 564, 470, 24 ), ( 564, 517, 12 ),
( 611, 0, 156 ), ( 611, 47, 144 ), ( 611, 94, 132 ), ( 611, 141, 120 ), ( 611, 188, 108 ), ( 611, 235, 96 ), ( 611, 282, 84 ), ( 611, 329, 72 ), ( 611, 376, 60 ), ( 611, 423, 48 ), ( 611, 470, 36 ), ( 611, 517, 24 ), ( 611, 564, 12 ),
( 658, 0, 168 ), ( 658, 47, 156 ), ( 658, 94, 144 ), ( 658, 141, 132 ), ( 658, 188, 120 ), ( 658, 235, 108 ), ( 658, 282, 96 ), ( 658, 329, 84 ), ( 658, 376, 72 ), ( 658, 423, 60 ), ( 658, 470, 48 ), ( 658, 517, 36 ), ( 658, 564, 24 ), ( 658, 611, 12 ),
...
}
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 "}"