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, 50 ), ( 76, 38, 25 ),
( 114, 0, 75 ), ( 114, 38, 50 ), ( 114, 76, 25 ),
( 152, 0, 100 ), ( 152, 38, 75 ), ( 152, 76, 50 ), ( 152, 114, 25 ),
( 190, 0, 125 ), ( 190, 38, 100 ), ( 190, 76, 75 ), ( 190, 114, 50 ), ( 190, 152, 25 ),
( 228, 0, 150 ), ( 228, 38, 125 ), ( 228, 76, 100 ), ( 228, 114, 75 ), ( 228, 152, 50 ), ( 228, 190, 25 ),
( 266, 0, 175 ), ( 266, 38, 150 ), ( 266, 76, 125 ), ( 266, 114, 100 ), ( 266, 152, 75 ), ( 266, 190, 50 ), ( 266, 228, 25 ),
( 304, 0, 200 ), ( 304, 38, 175 ), ( 304, 76, 150 ), ( 304, 114, 125 ), ( 304, 152, 100 ), ( 304, 190, 75 ), ( 304, 228, 50 ), ( 304, 266, 25 ),
( 342, 0, 225 ), ( 342, 38, 200 ), ( 342, 76, 175 ), ( 342, 114, 150 ), ( 342, 152, 125 ), ( 342, 190, 100 ), ( 342, 228, 75 ), ( 342, 266, 50 ), ( 342, 304, 25 ),
( 380, 0, 250 ), ( 380, 38, 225 ), ( 380, 76, 200 ), ( 380, 114, 175 ), ( 380, 152, 150 ), ( 380, 190, 125 ), ( 380, 228, 100 ), ( 380, 266, 75 ), ( 380, 304, 50 ), ( 380, 342, 25 ),
( 418, 0, 275 ), ( 418, 38, 250 ), ( 418, 76, 225 ), ( 418, 114, 200 ), ( 418, 152, 175 ), ( 418, 190, 150 ), ( 418, 228, 125 ), ( 418, 266, 100 ), ( 418, 304, 75 ), ( 418, 342, 50 ), ( 418, 380, 25 ),
( 456, 0, 300 ), ( 456, 38, 275 ), ( 456, 76, 250 ), ( 456, 114, 225 ), ( 456, 152, 200 ), ( 456, 190, 175 ), ( 456, 228, 150 ), ( 456, 266, 125 ), ( 456, 304, 100 ), ( 456, 342, 75 ), ( 456, 380, 50 ), ( 456, 418, 25 ),
( 494, 0, 325 ), ( 494, 38, 300 ), ( 494, 76, 275 ), ( 494, 114, 250 ), ( 494, 152, 225 ), ( 494, 190, 200 ), ( 494, 228, 175 ), ( 494, 266, 150 ), ( 494, 304, 125 ), ( 494, 342, 100 ), ( 494, 380, 75 ), ( 494, 418, 50 ), ( 494, 456, 25 ),
( 532, 0, 350 ), ( 532, 38, 325 ), ( 532, 76, 300 ), ( 532, 114, 275 ), ( 532, 152, 250 ), ( 532, 190, 225 ), ( 532, 228, 200 ), ( 532, 266, 175 ), ( 532, 304, 150 ), ( 532, 342, 125 ), ( 532, 380, 100 ), ( 532, 418, 75 ), ( 532, 456, 50 ), ( 532, 494, 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 "}"