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.
( 68, 0, 42 ), ( 68, 34, 21 ),
( 102, 0, 63 ), ( 102, 34, 42 ), ( 102, 68, 21 ),
( 136, 0, 84 ), ( 136, 34, 63 ), ( 136, 68, 42 ), ( 136, 102, 21 ),
( 170, 0, 105 ), ( 170, 34, 84 ), ( 170, 68, 63 ), ( 170, 102, 42 ), ( 170, 136, 21 ),
( 204, 0, 126 ), ( 204, 34, 105 ), ( 204, 68, 84 ), ( 204, 102, 63 ), ( 204, 136, 42 ), ( 204, 170, 21 ),
( 238, 0, 147 ), ( 238, 34, 126 ), ( 238, 68, 105 ), ( 238, 102, 84 ), ( 238, 136, 63 ), ( 238, 170, 42 ), ( 238, 204, 21 ),
( 272, 0, 168 ), ( 272, 34, 147 ), ( 272, 68, 126 ), ( 272, 102, 105 ), ( 272, 136, 84 ), ( 272, 170, 63 ), ( 272, 204, 42 ), ( 272, 238, 21 ),
( 306, 0, 189 ), ( 306, 34, 168 ), ( 306, 68, 147 ), ( 306, 102, 126 ), ( 306, 136, 105 ), ( 306, 170, 84 ), ( 306, 204, 63 ), ( 306, 238, 42 ), ( 306, 272, 21 ),
( 340, 0, 210 ), ( 340, 34, 189 ), ( 340, 68, 168 ), ( 340, 102, 147 ), ( 340, 136, 126 ), ( 340, 170, 105 ), ( 340, 204, 84 ), ( 340, 238, 63 ), ( 340, 272, 42 ), ( 340, 306, 21 ),
( 374, 0, 231 ), ( 374, 34, 210 ), ( 374, 68, 189 ), ( 374, 102, 168 ), ( 374, 136, 147 ), ( 374, 170, 126 ), ( 374, 204, 105 ), ( 374, 238, 84 ), ( 374, 272, 63 ), ( 374, 306, 42 ), ( 374, 340, 21 ),
( 408, 0, 252 ), ( 408, 34, 231 ), ( 408, 68, 210 ), ( 408, 102, 189 ), ( 408, 136, 168 ), ( 408, 170, 147 ), ( 408, 204, 126 ), ( 408, 238, 105 ), ( 408, 272, 84 ), ( 408, 306, 63 ), ( 408, 340, 42 ), ( 408, 374, 21 ),
( 442, 0, 273 ), ( 442, 34, 252 ), ( 442, 68, 231 ), ( 442, 102, 210 ), ( 442, 136, 189 ), ( 442, 170, 168 ), ( 442, 204, 147 ), ( 442, 238, 126 ), ( 442, 272, 105 ), ( 442, 306, 84 ), ( 442, 340, 63 ), ( 442, 374, 42 ), ( 442, 408, 21 ),
( 476, 0, 294 ), ( 476, 34, 273 ), ( 476, 68, 252 ), ( 476, 102, 231 ), ( 476, 136, 210 ), ( 476, 170, 189 ), ( 476, 204, 168 ), ( 476, 238, 147 ), ( 476, 272, 126 ), ( 476, 306, 105 ), ( 476, 340, 84 ), ( 476, 374, 63 ), ( 476, 408, 42 ), ( 476, 442, 21 ),
...
}
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 "}"