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.
( 108, 0, 15 ), ( 108, 36, 10 ), ( 108, 72, 5 ),
( 144, 0, 20 ), ( 144, 36, 15 ), ( 144, 72, 10 ), ( 144, 108, 5 ),
( 180, 0, 25 ), ( 180, 36, 20 ), ( 180, 72, 15 ), ( 180, 108, 10 ), ( 180, 144, 5 ),
( 216, 0, 30 ), ( 216, 36, 25 ), ( 216, 72, 20 ), ( 216, 108, 15 ), ( 216, 144, 10 ), ( 216, 180, 5 ),
( 252, 0, 35 ), ( 252, 36, 30 ), ( 252, 72, 25 ), ( 252, 108, 20 ), ( 252, 144, 15 ), ( 252, 180, 10 ), ( 252, 216, 5 ),
( 288, 0, 40 ), ( 288, 36, 35 ), ( 288, 72, 30 ), ( 288, 108, 25 ), ( 288, 144, 20 ), ( 288, 180, 15 ), ( 288, 216, 10 ), ( 288, 252, 5 ),
( 324, 0, 45 ), ( 324, 36, 40 ), ( 324, 72, 35 ), ( 324, 108, 30 ), ( 324, 144, 25 ), ( 324, 180, 20 ), ( 324, 216, 15 ), ( 324, 252, 10 ), ( 324, 288, 5 ),
( 360, 0, 50 ), ( 360, 36, 45 ), ( 360, 72, 40 ), ( 360, 108, 35 ), ( 360, 144, 30 ), ( 360, 180, 25 ), ( 360, 216, 20 ), ( 360, 252, 15 ), ( 360, 288, 10 ), ( 360, 324, 5 ),
( 396, 0, 55 ), ( 396, 36, 50 ), ( 396, 72, 45 ), ( 396, 108, 40 ), ( 396, 144, 35 ), ( 396, 180, 30 ), ( 396, 216, 25 ), ( 396, 252, 20 ), ( 396, 288, 15 ), ( 396, 324, 10 ), ( 396, 360, 5 ),
( 432, 0, 60 ), ( 432, 36, 55 ), ( 432, 72, 50 ), ( 432, 108, 45 ), ( 432, 144, 40 ), ( 432, 180, 35 ), ( 432, 216, 30 ), ( 432, 252, 25 ), ( 432, 288, 20 ), ( 432, 324, 15 ), ( 432, 360, 10 ), ( 432, 396, 5 ),
( 468, 0, 65 ), ( 468, 36, 60 ), ( 468, 72, 55 ), ( 468, 108, 50 ), ( 468, 144, 45 ), ( 468, 180, 40 ), ( 468, 216, 35 ), ( 468, 252, 30 ), ( 468, 288, 25 ), ( 468, 324, 20 ), ( 468, 360, 15 ), ( 468, 396, 10 ), ( 468, 432, 5 ),
( 504, 0, 70 ), ( 504, 36, 65 ), ( 504, 72, 60 ), ( 504, 108, 55 ), ( 504, 144, 50 ), ( 504, 180, 45 ), ( 504, 216, 40 ), ( 504, 252, 35 ), ( 504, 288, 30 ), ( 504, 324, 25 ), ( 504, 360, 20 ), ( 504, 396, 15 ), ( 504, 432, 10 ), ( 504, 468, 5 ),
...
}
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 "}"