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, 46 ), ( 68, 34, 23 ),
( 102, 0, 69 ), ( 102, 34, 46 ), ( 102, 68, 23 ),
( 136, 0, 92 ), ( 136, 34, 69 ), ( 136, 68, 46 ), ( 136, 102, 23 ),
( 170, 0, 115 ), ( 170, 34, 92 ), ( 170, 68, 69 ), ( 170, 102, 46 ), ( 170, 136, 23 ),
( 204, 0, 138 ), ( 204, 34, 115 ), ( 204, 68, 92 ), ( 204, 102, 69 ), ( 204, 136, 46 ), ( 204, 170, 23 ),
( 238, 0, 161 ), ( 238, 34, 138 ), ( 238, 68, 115 ), ( 238, 102, 92 ), ( 238, 136, 69 ), ( 238, 170, 46 ), ( 238, 204, 23 ),
( 272, 0, 184 ), ( 272, 34, 161 ), ( 272, 68, 138 ), ( 272, 102, 115 ), ( 272, 136, 92 ), ( 272, 170, 69 ), ( 272, 204, 46 ), ( 272, 238, 23 ),
( 306, 0, 207 ), ( 306, 34, 184 ), ( 306, 68, 161 ), ( 306, 102, 138 ), ( 306, 136, 115 ), ( 306, 170, 92 ), ( 306, 204, 69 ), ( 306, 238, 46 ), ( 306, 272, 23 ),
( 340, 0, 230 ), ( 340, 34, 207 ), ( 340, 68, 184 ), ( 340, 102, 161 ), ( 340, 136, 138 ), ( 340, 170, 115 ), ( 340, 204, 92 ), ( 340, 238, 69 ), ( 340, 272, 46 ), ( 340, 306, 23 ),
( 374, 0, 253 ), ( 374, 34, 230 ), ( 374, 68, 207 ), ( 374, 102, 184 ), ( 374, 136, 161 ), ( 374, 170, 138 ), ( 374, 204, 115 ), ( 374, 238, 92 ), ( 374, 272, 69 ), ( 374, 306, 46 ), ( 374, 340, 23 ),
( 408, 0, 276 ), ( 408, 34, 253 ), ( 408, 68, 230 ), ( 408, 102, 207 ), ( 408, 136, 184 ), ( 408, 170, 161 ), ( 408, 204, 138 ), ( 408, 238, 115 ), ( 408, 272, 92 ), ( 408, 306, 69 ), ( 408, 340, 46 ), ( 408, 374, 23 ),
( 442, 0, 299 ), ( 442, 34, 276 ), ( 442, 68, 253 ), ( 442, 102, 230 ), ( 442, 136, 207 ), ( 442, 170, 184 ), ( 442, 204, 161 ), ( 442, 238, 138 ), ( 442, 272, 115 ), ( 442, 306, 92 ), ( 442, 340, 69 ), ( 442, 374, 46 ), ( 442, 408, 23 ),
( 476, 0, 322 ), ( 476, 34, 299 ), ( 476, 68, 276 ), ( 476, 102, 253 ), ( 476, 136, 230 ), ( 476, 170, 207 ), ( 476, 204, 184 ), ( 476, 238, 161 ), ( 476, 272, 138 ), ( 476, 306, 115 ), ( 476, 340, 92 ), ( 476, 374, 69 ), ( 476, 408, 46 ), ( 476, 442, 23 ),
...
}
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 "}"