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.
( 76, 0, 42 ), ( 76, 38, 21 ),
( 114, 0, 63 ), ( 114, 38, 42 ), ( 114, 76, 21 ),
( 152, 0, 84 ), ( 152, 38, 63 ), ( 152, 76, 42 ), ( 152, 114, 21 ),
( 190, 0, 105 ), ( 190, 38, 84 ), ( 190, 76, 63 ), ( 190, 114, 42 ), ( 190, 152, 21 ),
( 228, 0, 126 ), ( 228, 38, 105 ), ( 228, 76, 84 ), ( 228, 114, 63 ), ( 228, 152, 42 ), ( 228, 190, 21 ),
( 266, 0, 147 ), ( 266, 38, 126 ), ( 266, 76, 105 ), ( 266, 114, 84 ), ( 266, 152, 63 ), ( 266, 190, 42 ), ( 266, 228, 21 ),
( 304, 0, 168 ), ( 304, 38, 147 ), ( 304, 76, 126 ), ( 304, 114, 105 ), ( 304, 152, 84 ), ( 304, 190, 63 ), ( 304, 228, 42 ), ( 304, 266, 21 ),
( 342, 0, 189 ), ( 342, 38, 168 ), ( 342, 76, 147 ), ( 342, 114, 126 ), ( 342, 152, 105 ), ( 342, 190, 84 ), ( 342, 228, 63 ), ( 342, 266, 42 ), ( 342, 304, 21 ),
( 380, 0, 210 ), ( 380, 38, 189 ), ( 380, 76, 168 ), ( 380, 114, 147 ), ( 380, 152, 126 ), ( 380, 190, 105 ), ( 380, 228, 84 ), ( 380, 266, 63 ), ( 380, 304, 42 ), ( 380, 342, 21 ),
( 418, 0, 231 ), ( 418, 38, 210 ), ( 418, 76, 189 ), ( 418, 114, 168 ), ( 418, 152, 147 ), ( 418, 190, 126 ), ( 418, 228, 105 ), ( 418, 266, 84 ), ( 418, 304, 63 ), ( 418, 342, 42 ), ( 418, 380, 21 ),
( 456, 0, 252 ), ( 456, 38, 231 ), ( 456, 76, 210 ), ( 456, 114, 189 ), ( 456, 152, 168 ), ( 456, 190, 147 ), ( 456, 228, 126 ), ( 456, 266, 105 ), ( 456, 304, 84 ), ( 456, 342, 63 ), ( 456, 380, 42 ), ( 456, 418, 21 ),
( 494, 0, 273 ), ( 494, 38, 252 ), ( 494, 76, 231 ), ( 494, 114, 210 ), ( 494, 152, 189 ), ( 494, 190, 168 ), ( 494, 228, 147 ), ( 494, 266, 126 ), ( 494, 304, 105 ), ( 494, 342, 84 ), ( 494, 380, 63 ), ( 494, 418, 42 ), ( 494, 456, 21 ),
( 532, 0, 294 ), ( 532, 38, 273 ), ( 532, 76, 252 ), ( 532, 114, 231 ), ( 532, 152, 210 ), ( 532, 190, 189 ), ( 532, 228, 168 ), ( 532, 266, 147 ), ( 532, 304, 126 ), ( 532, 342, 105 ), ( 532, 380, 84 ), ( 532, 418, 63 ), ( 532, 456, 42 ), ( 532, 494, 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 "}"