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, 12 ), ( 93, 31, 8 ), ( 93, 62, 4 ),
( 124, 0, 16 ), ( 124, 31, 12 ), ( 124, 62, 8 ), ( 124, 93, 4 ),
( 155, 0, 20 ), ( 155, 31, 16 ), ( 155, 62, 12 ), ( 155, 93, 8 ), ( 155, 124, 4 ),
( 186, 0, 24 ), ( 186, 31, 20 ), ( 186, 62, 16 ), ( 186, 93, 12 ), ( 186, 124, 8 ), ( 186, 155, 4 ),
( 217, 0, 28 ), ( 217, 31, 24 ), ( 217, 62, 20 ), ( 217, 93, 16 ), ( 217, 124, 12 ), ( 217, 155, 8 ), ( 217, 186, 4 ),
( 248, 0, 32 ), ( 248, 31, 28 ), ( 248, 62, 24 ), ( 248, 93, 20 ), ( 248, 124, 16 ), ( 248, 155, 12 ), ( 248, 186, 8 ), ( 248, 217, 4 ),
( 279, 0, 36 ), ( 279, 31, 32 ), ( 279, 62, 28 ), ( 279, 93, 24 ), ( 279, 124, 20 ), ( 279, 155, 16 ), ( 279, 186, 12 ), ( 279, 217, 8 ), ( 279, 248, 4 ),
( 310, 0, 40 ), ( 310, 31, 36 ), ( 310, 62, 32 ), ( 310, 93, 28 ), ( 310, 124, 24 ), ( 310, 155, 20 ), ( 310, 186, 16 ), ( 310, 217, 12 ), ( 310, 248, 8 ), ( 310, 279, 4 ),
( 341, 0, 44 ), ( 341, 31, 40 ), ( 341, 62, 36 ), ( 341, 93, 32 ), ( 341, 124, 28 ), ( 341, 155, 24 ), ( 341, 186, 20 ), ( 341, 217, 16 ), ( 341, 248, 12 ), ( 341, 279, 8 ), ( 341, 310, 4 ),
( 372, 0, 48 ), ( 372, 31, 44 ), ( 372, 62, 40 ), ( 372, 93, 36 ), ( 372, 124, 32 ), ( 372, 155, 28 ), ( 372, 186, 24 ), ( 372, 217, 20 ), ( 372, 248, 16 ), ( 372, 279, 12 ), ( 372, 310, 8 ), ( 372, 341, 4 ),
( 403, 0, 52 ), ( 403, 31, 48 ), ( 403, 62, 44 ), ( 403, 93, 40 ), ( 403, 124, 36 ), ( 403, 155, 32 ), ( 403, 186, 28 ), ( 403, 217, 24 ), ( 403, 248, 20 ), ( 403, 279, 16 ), ( 403, 310, 12 ), ( 403, 341, 8 ), ( 403, 372, 4 ),
( 434, 0, 56 ), ( 434, 31, 52 ), ( 434, 62, 48 ), ( 434, 93, 44 ), ( 434, 124, 40 ), ( 434, 155, 36 ), ( 434, 186, 32 ), ( 434, 217, 28 ), ( 434, 248, 24 ), ( 434, 279, 20 ), ( 434, 310, 16 ), ( 434, 341, 12 ), ( 434, 372, 8 ), ( 434, 403, 4 ),
...
}
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 "}"