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.
( 74, 0, 30 ), ( 74, 37, 15 ),
( 111, 0, 45 ), ( 111, 37, 30 ), ( 111, 74, 15 ),
( 148, 0, 60 ), ( 148, 37, 45 ), ( 148, 74, 30 ), ( 148, 111, 15 ),
( 185, 0, 75 ), ( 185, 37, 60 ), ( 185, 74, 45 ), ( 185, 111, 30 ), ( 185, 148, 15 ),
( 222, 0, 90 ), ( 222, 37, 75 ), ( 222, 74, 60 ), ( 222, 111, 45 ), ( 222, 148, 30 ), ( 222, 185, 15 ),
( 259, 0, 105 ), ( 259, 37, 90 ), ( 259, 74, 75 ), ( 259, 111, 60 ), ( 259, 148, 45 ), ( 259, 185, 30 ), ( 259, 222, 15 ),
( 296, 0, 120 ), ( 296, 37, 105 ), ( 296, 74, 90 ), ( 296, 111, 75 ), ( 296, 148, 60 ), ( 296, 185, 45 ), ( 296, 222, 30 ), ( 296, 259, 15 ),
( 333, 0, 135 ), ( 333, 37, 120 ), ( 333, 74, 105 ), ( 333, 111, 90 ), ( 333, 148, 75 ), ( 333, 185, 60 ), ( 333, 222, 45 ), ( 333, 259, 30 ), ( 333, 296, 15 ),
( 370, 0, 150 ), ( 370, 37, 135 ), ( 370, 74, 120 ), ( 370, 111, 105 ), ( 370, 148, 90 ), ( 370, 185, 75 ), ( 370, 222, 60 ), ( 370, 259, 45 ), ( 370, 296, 30 ), ( 370, 333, 15 ),
( 407, 0, 165 ), ( 407, 37, 150 ), ( 407, 74, 135 ), ( 407, 111, 120 ), ( 407, 148, 105 ), ( 407, 185, 90 ), ( 407, 222, 75 ), ( 407, 259, 60 ), ( 407, 296, 45 ), ( 407, 333, 30 ), ( 407, 370, 15 ),
( 444, 0, 180 ), ( 444, 37, 165 ), ( 444, 74, 150 ), ( 444, 111, 135 ), ( 444, 148, 120 ), ( 444, 185, 105 ), ( 444, 222, 90 ), ( 444, 259, 75 ), ( 444, 296, 60 ), ( 444, 333, 45 ), ( 444, 370, 30 ), ( 444, 407, 15 ),
( 481, 0, 195 ), ( 481, 37, 180 ), ( 481, 74, 165 ), ( 481, 111, 150 ), ( 481, 148, 135 ), ( 481, 185, 120 ), ( 481, 222, 105 ), ( 481, 259, 90 ), ( 481, 296, 75 ), ( 481, 333, 60 ), ( 481, 370, 45 ), ( 481, 407, 30 ), ( 481, 444, 15 ),
( 518, 0, 210 ), ( 518, 37, 195 ), ( 518, 74, 180 ), ( 518, 111, 165 ), ( 518, 148, 150 ), ( 518, 185, 135 ), ( 518, 222, 120 ), ( 518, 259, 105 ), ( 518, 296, 90 ), ( 518, 333, 75 ), ( 518, 370, 60 ), ( 518, 407, 45 ), ( 518, 444, 30 ), ( 518, 481, 15 ),
...
}
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 "}"