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.
( 111, 0, 15 ), ( 111, 37, 10 ), ( 111, 74, 5 ),
( 148, 0, 20 ), ( 148, 37, 15 ), ( 148, 74, 10 ), ( 148, 111, 5 ),
( 185, 0, 25 ), ( 185, 37, 20 ), ( 185, 74, 15 ), ( 185, 111, 10 ), ( 185, 148, 5 ),
( 222, 0, 30 ), ( 222, 37, 25 ), ( 222, 74, 20 ), ( 222, 111, 15 ), ( 222, 148, 10 ), ( 222, 185, 5 ),
( 259, 0, 35 ), ( 259, 37, 30 ), ( 259, 74, 25 ), ( 259, 111, 20 ), ( 259, 148, 15 ), ( 259, 185, 10 ), ( 259, 222, 5 ),
( 296, 0, 40 ), ( 296, 37, 35 ), ( 296, 74, 30 ), ( 296, 111, 25 ), ( 296, 148, 20 ), ( 296, 185, 15 ), ( 296, 222, 10 ), ( 296, 259, 5 ),
( 333, 0, 45 ), ( 333, 37, 40 ), ( 333, 74, 35 ), ( 333, 111, 30 ), ( 333, 148, 25 ), ( 333, 185, 20 ), ( 333, 222, 15 ), ( 333, 259, 10 ), ( 333, 296, 5 ),
( 370, 0, 50 ), ( 370, 37, 45 ), ( 370, 74, 40 ), ( 370, 111, 35 ), ( 370, 148, 30 ), ( 370, 185, 25 ), ( 370, 222, 20 ), ( 370, 259, 15 ), ( 370, 296, 10 ), ( 370, 333, 5 ),
( 407, 0, 55 ), ( 407, 37, 50 ), ( 407, 74, 45 ), ( 407, 111, 40 ), ( 407, 148, 35 ), ( 407, 185, 30 ), ( 407, 222, 25 ), ( 407, 259, 20 ), ( 407, 296, 15 ), ( 407, 333, 10 ), ( 407, 370, 5 ),
( 444, 0, 60 ), ( 444, 37, 55 ), ( 444, 74, 50 ), ( 444, 111, 45 ), ( 444, 148, 40 ), ( 444, 185, 35 ), ( 444, 222, 30 ), ( 444, 259, 25 ), ( 444, 296, 20 ), ( 444, 333, 15 ), ( 444, 370, 10 ), ( 444, 407, 5 ),
( 481, 0, 65 ), ( 481, 37, 60 ), ( 481, 74, 55 ), ( 481, 111, 50 ), ( 481, 148, 45 ), ( 481, 185, 40 ), ( 481, 222, 35 ), ( 481, 259, 30 ), ( 481, 296, 25 ), ( 481, 333, 20 ), ( 481, 370, 15 ), ( 481, 407, 10 ), ( 481, 444, 5 ),
( 518, 0, 70 ), ( 518, 37, 65 ), ( 518, 74, 60 ), ( 518, 111, 55 ), ( 518, 148, 50 ), ( 518, 185, 45 ), ( 518, 222, 40 ), ( 518, 259, 35 ), ( 518, 296, 30 ), ( 518, 333, 25 ), ( 518, 370, 20 ), ( 518, 407, 15 ), ( 518, 444, 10 ), ( 518, 481, 5 ),
...
}
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 "}"