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, 38 ), ( 72, 36, 19 ),
( 108, 0, 57 ), ( 108, 36, 38 ), ( 108, 72, 19 ),
( 144, 0, 76 ), ( 144, 36, 57 ), ( 144, 72, 38 ), ( 144, 108, 19 ),
( 180, 0, 95 ), ( 180, 36, 76 ), ( 180, 72, 57 ), ( 180, 108, 38 ), ( 180, 144, 19 ),
( 216, 0, 114 ), ( 216, 36, 95 ), ( 216, 72, 76 ), ( 216, 108, 57 ), ( 216, 144, 38 ), ( 216, 180, 19 ),
( 252, 0, 133 ), ( 252, 36, 114 ), ( 252, 72, 95 ), ( 252, 108, 76 ), ( 252, 144, 57 ), ( 252, 180, 38 ), ( 252, 216, 19 ),
( 288, 0, 152 ), ( 288, 36, 133 ), ( 288, 72, 114 ), ( 288, 108, 95 ), ( 288, 144, 76 ), ( 288, 180, 57 ), ( 288, 216, 38 ), ( 288, 252, 19 ),
( 324, 0, 171 ), ( 324, 36, 152 ), ( 324, 72, 133 ), ( 324, 108, 114 ), ( 324, 144, 95 ), ( 324, 180, 76 ), ( 324, 216, 57 ), ( 324, 252, 38 ), ( 324, 288, 19 ),
( 360, 0, 190 ), ( 360, 36, 171 ), ( 360, 72, 152 ), ( 360, 108, 133 ), ( 360, 144, 114 ), ( 360, 180, 95 ), ( 360, 216, 76 ), ( 360, 252, 57 ), ( 360, 288, 38 ), ( 360, 324, 19 ),
( 396, 0, 209 ), ( 396, 36, 190 ), ( 396, 72, 171 ), ( 396, 108, 152 ), ( 396, 144, 133 ), ( 396, 180, 114 ), ( 396, 216, 95 ), ( 396, 252, 76 ), ( 396, 288, 57 ), ( 396, 324, 38 ), ( 396, 360, 19 ),
( 432, 0, 228 ), ( 432, 36, 209 ), ( 432, 72, 190 ), ( 432, 108, 171 ), ( 432, 144, 152 ), ( 432, 180, 133 ), ( 432, 216, 114 ), ( 432, 252, 95 ), ( 432, 288, 76 ), ( 432, 324, 57 ), ( 432, 360, 38 ), ( 432, 396, 19 ),
( 468, 0, 247 ), ( 468, 36, 228 ), ( 468, 72, 209 ), ( 468, 108, 190 ), ( 468, 144, 171 ), ( 468, 180, 152 ), ( 468, 216, 133 ), ( 468, 252, 114 ), ( 468, 288, 95 ), ( 468, 324, 76 ), ( 468, 360, 57 ), ( 468, 396, 38 ), ( 468, 432, 19 ),
( 504, 0, 266 ), ( 504, 36, 247 ), ( 504, 72, 228 ), ( 504, 108, 209 ), ( 504, 144, 190 ), ( 504, 180, 171 ), ( 504, 216, 152 ), ( 504, 252, 133 ), ( 504, 288, 114 ), ( 504, 324, 95 ), ( 504, 360, 76 ), ( 504, 396, 57 ), ( 504, 432, 38 ), ( 504, 468, 19 ),
...
}
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 "}"