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.
( 62, 0, 40 ), ( 62, 31, 20 ),
( 93, 0, 60 ), ( 93, 31, 40 ), ( 93, 62, 20 ),
( 124, 0, 80 ), ( 124, 31, 60 ), ( 124, 62, 40 ), ( 124, 93, 20 ),
( 155, 0, 100 ), ( 155, 31, 80 ), ( 155, 62, 60 ), ( 155, 93, 40 ), ( 155, 124, 20 ),
( 186, 0, 120 ), ( 186, 31, 100 ), ( 186, 62, 80 ), ( 186, 93, 60 ), ( 186, 124, 40 ), ( 186, 155, 20 ),
( 217, 0, 140 ), ( 217, 31, 120 ), ( 217, 62, 100 ), ( 217, 93, 80 ), ( 217, 124, 60 ), ( 217, 155, 40 ), ( 217, 186, 20 ),
( 248, 0, 160 ), ( 248, 31, 140 ), ( 248, 62, 120 ), ( 248, 93, 100 ), ( 248, 124, 80 ), ( 248, 155, 60 ), ( 248, 186, 40 ), ( 248, 217, 20 ),
( 279, 0, 180 ), ( 279, 31, 160 ), ( 279, 62, 140 ), ( 279, 93, 120 ), ( 279, 124, 100 ), ( 279, 155, 80 ), ( 279, 186, 60 ), ( 279, 217, 40 ), ( 279, 248, 20 ),
( 310, 0, 200 ), ( 310, 31, 180 ), ( 310, 62, 160 ), ( 310, 93, 140 ), ( 310, 124, 120 ), ( 310, 155, 100 ), ( 310, 186, 80 ), ( 310, 217, 60 ), ( 310, 248, 40 ), ( 310, 279, 20 ),
( 341, 0, 220 ), ( 341, 31, 200 ), ( 341, 62, 180 ), ( 341, 93, 160 ), ( 341, 124, 140 ), ( 341, 155, 120 ), ( 341, 186, 100 ), ( 341, 217, 80 ), ( 341, 248, 60 ), ( 341, 279, 40 ), ( 341, 310, 20 ),
( 372, 0, 240 ), ( 372, 31, 220 ), ( 372, 62, 200 ), ( 372, 93, 180 ), ( 372, 124, 160 ), ( 372, 155, 140 ), ( 372, 186, 120 ), ( 372, 217, 100 ), ( 372, 248, 80 ), ( 372, 279, 60 ), ( 372, 310, 40 ), ( 372, 341, 20 ),
( 403, 0, 260 ), ( 403, 31, 240 ), ( 403, 62, 220 ), ( 403, 93, 200 ), ( 403, 124, 180 ), ( 403, 155, 160 ), ( 403, 186, 140 ), ( 403, 217, 120 ), ( 403, 248, 100 ), ( 403, 279, 80 ), ( 403, 310, 60 ), ( 403, 341, 40 ), ( 403, 372, 20 ),
( 434, 0, 280 ), ( 434, 31, 260 ), ( 434, 62, 240 ), ( 434, 93, 220 ), ( 434, 124, 200 ), ( 434, 155, 180 ), ( 434, 186, 160 ), ( 434, 217, 140 ), ( 434, 248, 120 ), ( 434, 279, 100 ), ( 434, 310, 80 ), ( 434, 341, 60 ), ( 434, 372, 40 ), ( 434, 403, 20 ),
...
}
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 "}"