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.
( 72, 0, 50 ), ( 72, 36, 25 ),
( 108, 0, 75 ), ( 108, 36, 50 ), ( 108, 72, 25 ),
( 144, 0, 100 ), ( 144, 36, 75 ), ( 144, 72, 50 ), ( 144, 108, 25 ),
( 180, 0, 125 ), ( 180, 36, 100 ), ( 180, 72, 75 ), ( 180, 108, 50 ), ( 180, 144, 25 ),
( 216, 0, 150 ), ( 216, 36, 125 ), ( 216, 72, 100 ), ( 216, 108, 75 ), ( 216, 144, 50 ), ( 216, 180, 25 ),
( 252, 0, 175 ), ( 252, 36, 150 ), ( 252, 72, 125 ), ( 252, 108, 100 ), ( 252, 144, 75 ), ( 252, 180, 50 ), ( 252, 216, 25 ),
( 288, 0, 200 ), ( 288, 36, 175 ), ( 288, 72, 150 ), ( 288, 108, 125 ), ( 288, 144, 100 ), ( 288, 180, 75 ), ( 288, 216, 50 ), ( 288, 252, 25 ),
( 324, 0, 225 ), ( 324, 36, 200 ), ( 324, 72, 175 ), ( 324, 108, 150 ), ( 324, 144, 125 ), ( 324, 180, 100 ), ( 324, 216, 75 ), ( 324, 252, 50 ), ( 324, 288, 25 ),
( 360, 0, 250 ), ( 360, 36, 225 ), ( 360, 72, 200 ), ( 360, 108, 175 ), ( 360, 144, 150 ), ( 360, 180, 125 ), ( 360, 216, 100 ), ( 360, 252, 75 ), ( 360, 288, 50 ), ( 360, 324, 25 ),
( 396, 0, 275 ), ( 396, 36, 250 ), ( 396, 72, 225 ), ( 396, 108, 200 ), ( 396, 144, 175 ), ( 396, 180, 150 ), ( 396, 216, 125 ), ( 396, 252, 100 ), ( 396, 288, 75 ), ( 396, 324, 50 ), ( 396, 360, 25 ),
( 432, 0, 300 ), ( 432, 36, 275 ), ( 432, 72, 250 ), ( 432, 108, 225 ), ( 432, 144, 200 ), ( 432, 180, 175 ), ( 432, 216, 150 ), ( 432, 252, 125 ), ( 432, 288, 100 ), ( 432, 324, 75 ), ( 432, 360, 50 ), ( 432, 396, 25 ),
( 468, 0, 325 ), ( 468, 36, 300 ), ( 468, 72, 275 ), ( 468, 108, 250 ), ( 468, 144, 225 ), ( 468, 180, 200 ), ( 468, 216, 175 ), ( 468, 252, 150 ), ( 468, 288, 125 ), ( 468, 324, 100 ), ( 468, 360, 75 ), ( 468, 396, 50 ), ( 468, 432, 25 ),
( 504, 0, 350 ), ( 504, 36, 325 ), ( 504, 72, 300 ), ( 504, 108, 275 ), ( 504, 144, 250 ), ( 504, 180, 225 ), ( 504, 216, 200 ), ( 504, 252, 175 ), ( 504, 288, 150 ), ( 504, 324, 125 ), ( 504, 360, 100 ), ( 504, 396, 75 ), ( 504, 432, 50 ), ( 504, 468, 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 "}"