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.
( 93, 0, 3 ), ( 93, 31, 2 ), ( 93, 62, 1 ),
( 124, 0, 4 ), ( 124, 31, 3 ), ( 124, 62, 2 ), ( 124, 93, 1 ),
( 155, 0, 5 ), ( 155, 31, 4 ), ( 155, 62, 3 ), ( 155, 93, 2 ), ( 155, 124, 1 ),
( 186, 0, 6 ), ( 186, 31, 5 ), ( 186, 62, 4 ), ( 186, 93, 3 ), ( 186, 124, 2 ), ( 186, 155, 1 ),
( 217, 0, 7 ), ( 217, 31, 6 ), ( 217, 62, 5 ), ( 217, 93, 4 ), ( 217, 124, 3 ), ( 217, 155, 2 ), ( 217, 186, 1 ),
( 248, 0, 8 ), ( 248, 31, 7 ), ( 248, 62, 6 ), ( 248, 93, 5 ), ( 248, 124, 4 ), ( 248, 155, 3 ), ( 248, 186, 2 ), ( 248, 217, 1 ),
( 279, 0, 9 ), ( 279, 31, 8 ), ( 279, 62, 7 ), ( 279, 93, 6 ), ( 279, 124, 5 ), ( 279, 155, 4 ), ( 279, 186, 3 ), ( 279, 217, 2 ), ( 279, 248, 1 ),
( 310, 0, 10 ), ( 310, 31, 9 ), ( 310, 62, 8 ), ( 310, 93, 7 ), ( 310, 124, 6 ), ( 310, 155, 5 ), ( 310, 186, 4 ), ( 310, 217, 3 ), ( 310, 248, 2 ), ( 310, 279, 1 ),
( 341, 0, 11 ), ( 341, 31, 10 ), ( 341, 62, 9 ), ( 341, 93, 8 ), ( 341, 124, 7 ), ( 341, 155, 6 ), ( 341, 186, 5 ), ( 341, 217, 4 ), ( 341, 248, 3 ), ( 341, 279, 2 ), ( 341, 310, 1 ),
( 372, 0, 12 ), ( 372, 31, 11 ), ( 372, 62, 10 ), ( 372, 93, 9 ), ( 372, 124, 8 ), ( 372, 155, 7 ), ( 372, 186, 6 ), ( 372, 217, 5 ), ( 372, 248, 4 ), ( 372, 279, 3 ), ( 372, 310, 2 ), ( 372, 341, 1 ),
( 403, 0, 13 ), ( 403, 31, 12 ), ( 403, 62, 11 ), ( 403, 93, 10 ), ( 403, 124, 9 ), ( 403, 155, 8 ), ( 403, 186, 7 ), ( 403, 217, 6 ), ( 403, 248, 5 ), ( 403, 279, 4 ), ( 403, 310, 3 ), ( 403, 341, 2 ), ( 403, 372, 1 ),
( 434, 0, 14 ), ( 434, 31, 13 ), ( 434, 62, 12 ), ( 434, 93, 11 ), ( 434, 124, 10 ), ( 434, 155, 9 ), ( 434, 186, 8 ), ( 434, 217, 7 ), ( 434, 248, 6 ), ( 434, 279, 5 ), ( 434, 310, 4 ), ( 434, 341, 3 ), ( 434, 372, 2 ), ( 434, 403, 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 "}"