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.
( 99, 0, 6 ), ( 99, 33, 4 ), ( 99, 66, 2 ),
( 132, 0, 8 ), ( 132, 33, 6 ), ( 132, 66, 4 ), ( 132, 99, 2 ),
( 165, 0, 10 ), ( 165, 33, 8 ), ( 165, 66, 6 ), ( 165, 99, 4 ), ( 165, 132, 2 ),
( 198, 0, 12 ), ( 198, 33, 10 ), ( 198, 66, 8 ), ( 198, 99, 6 ), ( 198, 132, 4 ), ( 198, 165, 2 ),
( 231, 0, 14 ), ( 231, 33, 12 ), ( 231, 66, 10 ), ( 231, 99, 8 ), ( 231, 132, 6 ), ( 231, 165, 4 ), ( 231, 198, 2 ),
( 264, 0, 16 ), ( 264, 33, 14 ), ( 264, 66, 12 ), ( 264, 99, 10 ), ( 264, 132, 8 ), ( 264, 165, 6 ), ( 264, 198, 4 ), ( 264, 231, 2 ),
( 297, 0, 18 ), ( 297, 33, 16 ), ( 297, 66, 14 ), ( 297, 99, 12 ), ( 297, 132, 10 ), ( 297, 165, 8 ), ( 297, 198, 6 ), ( 297, 231, 4 ), ( 297, 264, 2 ),
( 330, 0, 20 ), ( 330, 33, 18 ), ( 330, 66, 16 ), ( 330, 99, 14 ), ( 330, 132, 12 ), ( 330, 165, 10 ), ( 330, 198, 8 ), ( 330, 231, 6 ), ( 330, 264, 4 ), ( 330, 297, 2 ),
( 363, 0, 22 ), ( 363, 33, 20 ), ( 363, 66, 18 ), ( 363, 99, 16 ), ( 363, 132, 14 ), ( 363, 165, 12 ), ( 363, 198, 10 ), ( 363, 231, 8 ), ( 363, 264, 6 ), ( 363, 297, 4 ), ( 363, 330, 2 ),
( 396, 0, 24 ), ( 396, 33, 22 ), ( 396, 66, 20 ), ( 396, 99, 18 ), ( 396, 132, 16 ), ( 396, 165, 14 ), ( 396, 198, 12 ), ( 396, 231, 10 ), ( 396, 264, 8 ), ( 396, 297, 6 ), ( 396, 330, 4 ), ( 396, 363, 2 ),
( 429, 0, 26 ), ( 429, 33, 24 ), ( 429, 66, 22 ), ( 429, 99, 20 ), ( 429, 132, 18 ), ( 429, 165, 16 ), ( 429, 198, 14 ), ( 429, 231, 12 ), ( 429, 264, 10 ), ( 429, 297, 8 ), ( 429, 330, 6 ), ( 429, 363, 4 ), ( 429, 396, 2 ),
( 462, 0, 28 ), ( 462, 33, 26 ), ( 462, 66, 24 ), ( 462, 99, 22 ), ( 462, 132, 20 ), ( 462, 165, 18 ), ( 462, 198, 16 ), ( 462, 231, 14 ), ( 462, 264, 12 ), ( 462, 297, 10 ), ( 462, 330, 8 ), ( 462, 363, 6 ), ( 462, 396, 4 ), ( 462, 429, 2 ),
...
}
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 "}"