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.
( 81, 0, 3 ), ( 81, 27, 2 ), ( 81, 54, 1 ),
( 108, 0, 4 ), ( 108, 27, 3 ), ( 108, 54, 2 ), ( 108, 81, 1 ),
( 135, 0, 5 ), ( 135, 27, 4 ), ( 135, 54, 3 ), ( 135, 81, 2 ), ( 135, 108, 1 ),
( 162, 0, 6 ), ( 162, 27, 5 ), ( 162, 54, 4 ), ( 162, 81, 3 ), ( 162, 108, 2 ), ( 162, 135, 1 ),
( 189, 0, 7 ), ( 189, 27, 6 ), ( 189, 54, 5 ), ( 189, 81, 4 ), ( 189, 108, 3 ), ( 189, 135, 2 ), ( 189, 162, 1 ),
( 216, 0, 8 ), ( 216, 27, 7 ), ( 216, 54, 6 ), ( 216, 81, 5 ), ( 216, 108, 4 ), ( 216, 135, 3 ), ( 216, 162, 2 ), ( 216, 189, 1 ),
( 243, 0, 9 ), ( 243, 27, 8 ), ( 243, 54, 7 ), ( 243, 81, 6 ), ( 243, 108, 5 ), ( 243, 135, 4 ), ( 243, 162, 3 ), ( 243, 189, 2 ), ( 243, 216, 1 ),
( 270, 0, 10 ), ( 270, 27, 9 ), ( 270, 54, 8 ), ( 270, 81, 7 ), ( 270, 108, 6 ), ( 270, 135, 5 ), ( 270, 162, 4 ), ( 270, 189, 3 ), ( 270, 216, 2 ), ( 270, 243, 1 ),
( 297, 0, 11 ), ( 297, 27, 10 ), ( 297, 54, 9 ), ( 297, 81, 8 ), ( 297, 108, 7 ), ( 297, 135, 6 ), ( 297, 162, 5 ), ( 297, 189, 4 ), ( 297, 216, 3 ), ( 297, 243, 2 ), ( 297, 270, 1 ),
( 324, 0, 12 ), ( 324, 27, 11 ), ( 324, 54, 10 ), ( 324, 81, 9 ), ( 324, 108, 8 ), ( 324, 135, 7 ), ( 324, 162, 6 ), ( 324, 189, 5 ), ( 324, 216, 4 ), ( 324, 243, 3 ), ( 324, 270, 2 ), ( 324, 297, 1 ),
( 351, 0, 13 ), ( 351, 27, 12 ), ( 351, 54, 11 ), ( 351, 81, 10 ), ( 351, 108, 9 ), ( 351, 135, 8 ), ( 351, 162, 7 ), ( 351, 189, 6 ), ( 351, 216, 5 ), ( 351, 243, 4 ), ( 351, 270, 3 ), ( 351, 297, 2 ), ( 351, 324, 1 ),
( 378, 0, 14 ), ( 378, 27, 13 ), ( 378, 54, 12 ), ( 378, 81, 11 ), ( 378, 108, 10 ), ( 378, 135, 9 ), ( 378, 162, 8 ), ( 378, 189, 7 ), ( 378, 216, 6 ), ( 378, 243, 5 ), ( 378, 270, 4 ), ( 378, 297, 3 ), ( 378, 324, 2 ), ( 378, 351, 1 ),
...
}
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 "}"