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, 48 ), ( 74, 37, 24 ),
( 111, 0, 72 ), ( 111, 37, 48 ), ( 111, 74, 24 ),
( 148, 0, 96 ), ( 148, 37, 72 ), ( 148, 74, 48 ), ( 148, 111, 24 ),
( 185, 0, 120 ), ( 185, 37, 96 ), ( 185, 74, 72 ), ( 185, 111, 48 ), ( 185, 148, 24 ),
( 222, 0, 144 ), ( 222, 37, 120 ), ( 222, 74, 96 ), ( 222, 111, 72 ), ( 222, 148, 48 ), ( 222, 185, 24 ),
( 259, 0, 168 ), ( 259, 37, 144 ), ( 259, 74, 120 ), ( 259, 111, 96 ), ( 259, 148, 72 ), ( 259, 185, 48 ), ( 259, 222, 24 ),
( 296, 0, 192 ), ( 296, 37, 168 ), ( 296, 74, 144 ), ( 296, 111, 120 ), ( 296, 148, 96 ), ( 296, 185, 72 ), ( 296, 222, 48 ), ( 296, 259, 24 ),
( 333, 0, 216 ), ( 333, 37, 192 ), ( 333, 74, 168 ), ( 333, 111, 144 ), ( 333, 148, 120 ), ( 333, 185, 96 ), ( 333, 222, 72 ), ( 333, 259, 48 ), ( 333, 296, 24 ),
( 370, 0, 240 ), ( 370, 37, 216 ), ( 370, 74, 192 ), ( 370, 111, 168 ), ( 370, 148, 144 ), ( 370, 185, 120 ), ( 370, 222, 96 ), ( 370, 259, 72 ), ( 370, 296, 48 ), ( 370, 333, 24 ),
( 407, 0, 264 ), ( 407, 37, 240 ), ( 407, 74, 216 ), ( 407, 111, 192 ), ( 407, 148, 168 ), ( 407, 185, 144 ), ( 407, 222, 120 ), ( 407, 259, 96 ), ( 407, 296, 72 ), ( 407, 333, 48 ), ( 407, 370, 24 ),
( 444, 0, 288 ), ( 444, 37, 264 ), ( 444, 74, 240 ), ( 444, 111, 216 ), ( 444, 148, 192 ), ( 444, 185, 168 ), ( 444, 222, 144 ), ( 444, 259, 120 ), ( 444, 296, 96 ), ( 444, 333, 72 ), ( 444, 370, 48 ), ( 444, 407, 24 ),
( 481, 0, 312 ), ( 481, 37, 288 ), ( 481, 74, 264 ), ( 481, 111, 240 ), ( 481, 148, 216 ), ( 481, 185, 192 ), ( 481, 222, 168 ), ( 481, 259, 144 ), ( 481, 296, 120 ), ( 481, 333, 96 ), ( 481, 370, 72 ), ( 481, 407, 48 ), ( 481, 444, 24 ),
( 518, 0, 336 ), ( 518, 37, 312 ), ( 518, 74, 288 ), ( 518, 111, 264 ), ( 518, 148, 240 ), ( 518, 185, 216 ), ( 518, 222, 192 ), ( 518, 259, 168 ), ( 518, 296, 144 ), ( 518, 333, 120 ), ( 518, 370, 96 ), ( 518, 407, 72 ), ( 518, 444, 48 ), ( 518, 481, 24 ),
...
}
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 "}"