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, 22 ), ( 54, 27, 11 ),
( 81, 0, 33 ), ( 81, 27, 22 ), ( 81, 54, 11 ),
( 108, 0, 44 ), ( 108, 27, 33 ), ( 108, 54, 22 ), ( 108, 81, 11 ),
( 135, 0, 55 ), ( 135, 27, 44 ), ( 135, 54, 33 ), ( 135, 81, 22 ), ( 135, 108, 11 ),
( 162, 0, 66 ), ( 162, 27, 55 ), ( 162, 54, 44 ), ( 162, 81, 33 ), ( 162, 108, 22 ), ( 162, 135, 11 ),
( 189, 0, 77 ), ( 189, 27, 66 ), ( 189, 54, 55 ), ( 189, 81, 44 ), ( 189, 108, 33 ), ( 189, 135, 22 ), ( 189, 162, 11 ),
( 216, 0, 88 ), ( 216, 27, 77 ), ( 216, 54, 66 ), ( 216, 81, 55 ), ( 216, 108, 44 ), ( 216, 135, 33 ), ( 216, 162, 22 ), ( 216, 189, 11 ),
( 243, 0, 99 ), ( 243, 27, 88 ), ( 243, 54, 77 ), ( 243, 81, 66 ), ( 243, 108, 55 ), ( 243, 135, 44 ), ( 243, 162, 33 ), ( 243, 189, 22 ), ( 243, 216, 11 ),
( 270, 0, 110 ), ( 270, 27, 99 ), ( 270, 54, 88 ), ( 270, 81, 77 ), ( 270, 108, 66 ), ( 270, 135, 55 ), ( 270, 162, 44 ), ( 270, 189, 33 ), ( 270, 216, 22 ), ( 270, 243, 11 ),
( 297, 0, 121 ), ( 297, 27, 110 ), ( 297, 54, 99 ), ( 297, 81, 88 ), ( 297, 108, 77 ), ( 297, 135, 66 ), ( 297, 162, 55 ), ( 297, 189, 44 ), ( 297, 216, 33 ), ( 297, 243, 22 ), ( 297, 270, 11 ),
( 324, 0, 132 ), ( 324, 27, 121 ), ( 324, 54, 110 ), ( 324, 81, 99 ), ( 324, 108, 88 ), ( 324, 135, 77 ), ( 324, 162, 66 ), ( 324, 189, 55 ), ( 324, 216, 44 ), ( 324, 243, 33 ), ( 324, 270, 22 ), ( 324, 297, 11 ),
( 351, 0, 143 ), ( 351, 27, 132 ), ( 351, 54, 121 ), ( 351, 81, 110 ), ( 351, 108, 99 ), ( 351, 135, 88 ), ( 351, 162, 77 ), ( 351, 189, 66 ), ( 351, 216, 55 ), ( 351, 243, 44 ), ( 351, 270, 33 ), ( 351, 297, 22 ), ( 351, 324, 11 ),
( 378, 0, 154 ), ( 378, 27, 143 ), ( 378, 54, 132 ), ( 378, 81, 121 ), ( 378, 108, 110 ), ( 378, 135, 99 ), ( 378, 162, 88 ), ( 378, 189, 77 ), ( 378, 216, 66 ), ( 378, 243, 55 ), ( 378, 270, 44 ), ( 378, 297, 33 ), ( 378, 324, 22 ), ( 378, 351, 11 ),
...
}
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 "}"