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.
( 78, 0, 50 ), ( 78, 39, 25 ),
( 117, 0, 75 ), ( 117, 39, 50 ), ( 117, 78, 25 ),
( 156, 0, 100 ), ( 156, 39, 75 ), ( 156, 78, 50 ), ( 156, 117, 25 ),
( 195, 0, 125 ), ( 195, 39, 100 ), ( 195, 78, 75 ), ( 195, 117, 50 ), ( 195, 156, 25 ),
( 234, 0, 150 ), ( 234, 39, 125 ), ( 234, 78, 100 ), ( 234, 117, 75 ), ( 234, 156, 50 ), ( 234, 195, 25 ),
( 273, 0, 175 ), ( 273, 39, 150 ), ( 273, 78, 125 ), ( 273, 117, 100 ), ( 273, 156, 75 ), ( 273, 195, 50 ), ( 273, 234, 25 ),
( 312, 0, 200 ), ( 312, 39, 175 ), ( 312, 78, 150 ), ( 312, 117, 125 ), ( 312, 156, 100 ), ( 312, 195, 75 ), ( 312, 234, 50 ), ( 312, 273, 25 ),
( 351, 0, 225 ), ( 351, 39, 200 ), ( 351, 78, 175 ), ( 351, 117, 150 ), ( 351, 156, 125 ), ( 351, 195, 100 ), ( 351, 234, 75 ), ( 351, 273, 50 ), ( 351, 312, 25 ),
( 390, 0, 250 ), ( 390, 39, 225 ), ( 390, 78, 200 ), ( 390, 117, 175 ), ( 390, 156, 150 ), ( 390, 195, 125 ), ( 390, 234, 100 ), ( 390, 273, 75 ), ( 390, 312, 50 ), ( 390, 351, 25 ),
( 429, 0, 275 ), ( 429, 39, 250 ), ( 429, 78, 225 ), ( 429, 117, 200 ), ( 429, 156, 175 ), ( 429, 195, 150 ), ( 429, 234, 125 ), ( 429, 273, 100 ), ( 429, 312, 75 ), ( 429, 351, 50 ), ( 429, 390, 25 ),
( 468, 0, 300 ), ( 468, 39, 275 ), ( 468, 78, 250 ), ( 468, 117, 225 ), ( 468, 156, 200 ), ( 468, 195, 175 ), ( 468, 234, 150 ), ( 468, 273, 125 ), ( 468, 312, 100 ), ( 468, 351, 75 ), ( 468, 390, 50 ), ( 468, 429, 25 ),
( 507, 0, 325 ), ( 507, 39, 300 ), ( 507, 78, 275 ), ( 507, 117, 250 ), ( 507, 156, 225 ), ( 507, 195, 200 ), ( 507, 234, 175 ), ( 507, 273, 150 ), ( 507, 312, 125 ), ( 507, 351, 100 ), ( 507, 390, 75 ), ( 507, 429, 50 ), ( 507, 468, 25 ),
( 546, 0, 350 ), ( 546, 39, 325 ), ( 546, 78, 300 ), ( 546, 117, 275 ), ( 546, 156, 250 ), ( 546, 195, 225 ), ( 546, 234, 200 ), ( 546, 273, 175 ), ( 546, 312, 150 ), ( 546, 351, 125 ), ( 546, 390, 100 ), ( 546, 429, 75 ), ( 546, 468, 50 ), ( 546, 507, 25 ),
...
}
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 "}"