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.
( 54, 0, 38 ), ( 54, 27, 19 ),
( 81, 0, 57 ), ( 81, 27, 38 ), ( 81, 54, 19 ),
( 108, 0, 76 ), ( 108, 27, 57 ), ( 108, 54, 38 ), ( 108, 81, 19 ),
( 135, 0, 95 ), ( 135, 27, 76 ), ( 135, 54, 57 ), ( 135, 81, 38 ), ( 135, 108, 19 ),
( 162, 0, 114 ), ( 162, 27, 95 ), ( 162, 54, 76 ), ( 162, 81, 57 ), ( 162, 108, 38 ), ( 162, 135, 19 ),
( 189, 0, 133 ), ( 189, 27, 114 ), ( 189, 54, 95 ), ( 189, 81, 76 ), ( 189, 108, 57 ), ( 189, 135, 38 ), ( 189, 162, 19 ),
( 216, 0, 152 ), ( 216, 27, 133 ), ( 216, 54, 114 ), ( 216, 81, 95 ), ( 216, 108, 76 ), ( 216, 135, 57 ), ( 216, 162, 38 ), ( 216, 189, 19 ),
( 243, 0, 171 ), ( 243, 27, 152 ), ( 243, 54, 133 ), ( 243, 81, 114 ), ( 243, 108, 95 ), ( 243, 135, 76 ), ( 243, 162, 57 ), ( 243, 189, 38 ), ( 243, 216, 19 ),
( 270, 0, 190 ), ( 270, 27, 171 ), ( 270, 54, 152 ), ( 270, 81, 133 ), ( 270, 108, 114 ), ( 270, 135, 95 ), ( 270, 162, 76 ), ( 270, 189, 57 ), ( 270, 216, 38 ), ( 270, 243, 19 ),
( 297, 0, 209 ), ( 297, 27, 190 ), ( 297, 54, 171 ), ( 297, 81, 152 ), ( 297, 108, 133 ), ( 297, 135, 114 ), ( 297, 162, 95 ), ( 297, 189, 76 ), ( 297, 216, 57 ), ( 297, 243, 38 ), ( 297, 270, 19 ),
( 324, 0, 228 ), ( 324, 27, 209 ), ( 324, 54, 190 ), ( 324, 81, 171 ), ( 324, 108, 152 ), ( 324, 135, 133 ), ( 324, 162, 114 ), ( 324, 189, 95 ), ( 324, 216, 76 ), ( 324, 243, 57 ), ( 324, 270, 38 ), ( 324, 297, 19 ),
( 351, 0, 247 ), ( 351, 27, 228 ), ( 351, 54, 209 ), ( 351, 81, 190 ), ( 351, 108, 171 ), ( 351, 135, 152 ), ( 351, 162, 133 ), ( 351, 189, 114 ), ( 351, 216, 95 ), ( 351, 243, 76 ), ( 351, 270, 57 ), ( 351, 297, 38 ), ( 351, 324, 19 ),
( 378, 0, 266 ), ( 378, 27, 247 ), ( 378, 54, 228 ), ( 378, 81, 209 ), ( 378, 108, 190 ), ( 378, 135, 171 ), ( 378, 162, 152 ), ( 378, 189, 133 ), ( 378, 216, 114 ), ( 378, 243, 95 ), ( 378, 270, 76 ), ( 378, 297, 57 ), ( 378, 324, 38 ), ( 378, 351, 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 "}"