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, 52 ), ( 74, 37, 26 ),
( 111, 0, 78 ), ( 111, 37, 52 ), ( 111, 74, 26 ),
( 148, 0, 104 ), ( 148, 37, 78 ), ( 148, 74, 52 ), ( 148, 111, 26 ),
( 185, 0, 130 ), ( 185, 37, 104 ), ( 185, 74, 78 ), ( 185, 111, 52 ), ( 185, 148, 26 ),
( 222, 0, 156 ), ( 222, 37, 130 ), ( 222, 74, 104 ), ( 222, 111, 78 ), ( 222, 148, 52 ), ( 222, 185, 26 ),
( 259, 0, 182 ), ( 259, 37, 156 ), ( 259, 74, 130 ), ( 259, 111, 104 ), ( 259, 148, 78 ), ( 259, 185, 52 ), ( 259, 222, 26 ),
( 296, 0, 208 ), ( 296, 37, 182 ), ( 296, 74, 156 ), ( 296, 111, 130 ), ( 296, 148, 104 ), ( 296, 185, 78 ), ( 296, 222, 52 ), ( 296, 259, 26 ),
( 333, 0, 234 ), ( 333, 37, 208 ), ( 333, 74, 182 ), ( 333, 111, 156 ), ( 333, 148, 130 ), ( 333, 185, 104 ), ( 333, 222, 78 ), ( 333, 259, 52 ), ( 333, 296, 26 ),
( 370, 0, 260 ), ( 370, 37, 234 ), ( 370, 74, 208 ), ( 370, 111, 182 ), ( 370, 148, 156 ), ( 370, 185, 130 ), ( 370, 222, 104 ), ( 370, 259, 78 ), ( 370, 296, 52 ), ( 370, 333, 26 ),
( 407, 0, 286 ), ( 407, 37, 260 ), ( 407, 74, 234 ), ( 407, 111, 208 ), ( 407, 148, 182 ), ( 407, 185, 156 ), ( 407, 222, 130 ), ( 407, 259, 104 ), ( 407, 296, 78 ), ( 407, 333, 52 ), ( 407, 370, 26 ),
( 444, 0, 312 ), ( 444, 37, 286 ), ( 444, 74, 260 ), ( 444, 111, 234 ), ( 444, 148, 208 ), ( 444, 185, 182 ), ( 444, 222, 156 ), ( 444, 259, 130 ), ( 444, 296, 104 ), ( 444, 333, 78 ), ( 444, 370, 52 ), ( 444, 407, 26 ),
( 481, 0, 338 ), ( 481, 37, 312 ), ( 481, 74, 286 ), ( 481, 111, 260 ), ( 481, 148, 234 ), ( 481, 185, 208 ), ( 481, 222, 182 ), ( 481, 259, 156 ), ( 481, 296, 130 ), ( 481, 333, 104 ), ( 481, 370, 78 ), ( 481, 407, 52 ), ( 481, 444, 26 ),
( 518, 0, 364 ), ( 518, 37, 338 ), ( 518, 74, 312 ), ( 518, 111, 286 ), ( 518, 148, 260 ), ( 518, 185, 234 ), ( 518, 222, 208 ), ( 518, 259, 182 ), ( 518, 296, 156 ), ( 518, 333, 130 ), ( 518, 370, 104 ), ( 518, 407, 78 ), ( 518, 444, 52 ), ( 518, 481, 26 ),
...
}
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 "}"