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.
( 96, 0, 26 ), ( 96, 48, 13 ),
( 144, 0, 39 ), ( 144, 48, 26 ), ( 144, 96, 13 ),
( 192, 0, 52 ), ( 192, 48, 39 ), ( 192, 96, 26 ), ( 192, 144, 13 ),
( 240, 0, 65 ), ( 240, 48, 52 ), ( 240, 96, 39 ), ( 240, 144, 26 ), ( 240, 192, 13 ),
( 288, 0, 78 ), ( 288, 48, 65 ), ( 288, 96, 52 ), ( 288, 144, 39 ), ( 288, 192, 26 ), ( 288, 240, 13 ),
( 336, 0, 91 ), ( 336, 48, 78 ), ( 336, 96, 65 ), ( 336, 144, 52 ), ( 336, 192, 39 ), ( 336, 240, 26 ), ( 336, 288, 13 ),
( 384, 0, 104 ), ( 384, 48, 91 ), ( 384, 96, 78 ), ( 384, 144, 65 ), ( 384, 192, 52 ), ( 384, 240, 39 ), ( 384, 288, 26 ), ( 384, 336, 13 ),
( 432, 0, 117 ), ( 432, 48, 104 ), ( 432, 96, 91 ), ( 432, 144, 78 ), ( 432, 192, 65 ), ( 432, 240, 52 ), ( 432, 288, 39 ), ( 432, 336, 26 ), ( 432, 384, 13 ),
( 480, 0, 130 ), ( 480, 48, 117 ), ( 480, 96, 104 ), ( 480, 144, 91 ), ( 480, 192, 78 ), ( 480, 240, 65 ), ( 480, 288, 52 ), ( 480, 336, 39 ), ( 480, 384, 26 ), ( 480, 432, 13 ),
( 528, 0, 143 ), ( 528, 48, 130 ), ( 528, 96, 117 ), ( 528, 144, 104 ), ( 528, 192, 91 ), ( 528, 240, 78 ), ( 528, 288, 65 ), ( 528, 336, 52 ), ( 528, 384, 39 ), ( 528, 432, 26 ), ( 528, 480, 13 ),
( 576, 0, 156 ), ( 576, 48, 143 ), ( 576, 96, 130 ), ( 576, 144, 117 ), ( 576, 192, 104 ), ( 576, 240, 91 ), ( 576, 288, 78 ), ( 576, 336, 65 ), ( 576, 384, 52 ), ( 576, 432, 39 ), ( 576, 480, 26 ), ( 576, 528, 13 ),
( 624, 0, 169 ), ( 624, 48, 156 ), ( 624, 96, 143 ), ( 624, 144, 130 ), ( 624, 192, 117 ), ( 624, 240, 104 ), ( 624, 288, 91 ), ( 624, 336, 78 ), ( 624, 384, 65 ), ( 624, 432, 52 ), ( 624, 480, 39 ), ( 624, 528, 26 ), ( 624, 576, 13 ),
( 672, 0, 182 ), ( 672, 48, 169 ), ( 672, 96, 156 ), ( 672, 144, 143 ), ( 672, 192, 130 ), ( 672, 240, 117 ), ( 672, 288, 104 ), ( 672, 336, 91 ), ( 672, 384, 78 ), ( 672, 432, 65 ), ( 672, 480, 52 ), ( 672, 528, 39 ), ( 672, 576, 26 ), ( 672, 624, 13 ),
...
}
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 "}"