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.
( 129, 0, 21 ), ( 129, 43, 14 ), ( 129, 86, 7 ),
( 172, 0, 28 ), ( 172, 43, 21 ), ( 172, 86, 14 ), ( 172, 129, 7 ),
( 215, 0, 35 ), ( 215, 43, 28 ), ( 215, 86, 21 ), ( 215, 129, 14 ), ( 215, 172, 7 ),
( 258, 0, 42 ), ( 258, 43, 35 ), ( 258, 86, 28 ), ( 258, 129, 21 ), ( 258, 172, 14 ), ( 258, 215, 7 ),
( 301, 0, 49 ), ( 301, 43, 42 ), ( 301, 86, 35 ), ( 301, 129, 28 ), ( 301, 172, 21 ), ( 301, 215, 14 ), ( 301, 258, 7 ),
( 344, 0, 56 ), ( 344, 43, 49 ), ( 344, 86, 42 ), ( 344, 129, 35 ), ( 344, 172, 28 ), ( 344, 215, 21 ), ( 344, 258, 14 ), ( 344, 301, 7 ),
( 387, 0, 63 ), ( 387, 43, 56 ), ( 387, 86, 49 ), ( 387, 129, 42 ), ( 387, 172, 35 ), ( 387, 215, 28 ), ( 387, 258, 21 ), ( 387, 301, 14 ), ( 387, 344, 7 ),
( 430, 0, 70 ), ( 430, 43, 63 ), ( 430, 86, 56 ), ( 430, 129, 49 ), ( 430, 172, 42 ), ( 430, 215, 35 ), ( 430, 258, 28 ), ( 430, 301, 21 ), ( 430, 344, 14 ), ( 430, 387, 7 ),
( 473, 0, 77 ), ( 473, 43, 70 ), ( 473, 86, 63 ), ( 473, 129, 56 ), ( 473, 172, 49 ), ( 473, 215, 42 ), ( 473, 258, 35 ), ( 473, 301, 28 ), ( 473, 344, 21 ), ( 473, 387, 14 ), ( 473, 430, 7 ),
( 516, 0, 84 ), ( 516, 43, 77 ), ( 516, 86, 70 ), ( 516, 129, 63 ), ( 516, 172, 56 ), ( 516, 215, 49 ), ( 516, 258, 42 ), ( 516, 301, 35 ), ( 516, 344, 28 ), ( 516, 387, 21 ), ( 516, 430, 14 ), ( 516, 473, 7 ),
( 559, 0, 91 ), ( 559, 43, 84 ), ( 559, 86, 77 ), ( 559, 129, 70 ), ( 559, 172, 63 ), ( 559, 215, 56 ), ( 559, 258, 49 ), ( 559, 301, 42 ), ( 559, 344, 35 ), ( 559, 387, 28 ), ( 559, 430, 21 ), ( 559, 473, 14 ), ( 559, 516, 7 ),
( 602, 0, 98 ), ( 602, 43, 91 ), ( 602, 86, 84 ), ( 602, 129, 77 ), ( 602, 172, 70 ), ( 602, 215, 63 ), ( 602, 258, 56 ), ( 602, 301, 49 ), ( 602, 344, 42 ), ( 602, 387, 35 ), ( 602, 430, 28 ), ( 602, 473, 21 ), ( 602, 516, 14 ), ( 602, 559, 7 ),
...
}
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 "}"