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, 28 ), ( 54, 27, 14 ),
( 81, 0, 42 ), ( 81, 27, 28 ), ( 81, 54, 14 ),
( 108, 0, 56 ), ( 108, 27, 42 ), ( 108, 54, 28 ), ( 108, 81, 14 ),
( 135, 0, 70 ), ( 135, 27, 56 ), ( 135, 54, 42 ), ( 135, 81, 28 ), ( 135, 108, 14 ),
( 162, 0, 84 ), ( 162, 27, 70 ), ( 162, 54, 56 ), ( 162, 81, 42 ), ( 162, 108, 28 ), ( 162, 135, 14 ),
( 189, 0, 98 ), ( 189, 27, 84 ), ( 189, 54, 70 ), ( 189, 81, 56 ), ( 189, 108, 42 ), ( 189, 135, 28 ), ( 189, 162, 14 ),
( 216, 0, 112 ), ( 216, 27, 98 ), ( 216, 54, 84 ), ( 216, 81, 70 ), ( 216, 108, 56 ), ( 216, 135, 42 ), ( 216, 162, 28 ), ( 216, 189, 14 ),
( 243, 0, 126 ), ( 243, 27, 112 ), ( 243, 54, 98 ), ( 243, 81, 84 ), ( 243, 108, 70 ), ( 243, 135, 56 ), ( 243, 162, 42 ), ( 243, 189, 28 ), ( 243, 216, 14 ),
( 270, 0, 140 ), ( 270, 27, 126 ), ( 270, 54, 112 ), ( 270, 81, 98 ), ( 270, 108, 84 ), ( 270, 135, 70 ), ( 270, 162, 56 ), ( 270, 189, 42 ), ( 270, 216, 28 ), ( 270, 243, 14 ),
( 297, 0, 154 ), ( 297, 27, 140 ), ( 297, 54, 126 ), ( 297, 81, 112 ), ( 297, 108, 98 ), ( 297, 135, 84 ), ( 297, 162, 70 ), ( 297, 189, 56 ), ( 297, 216, 42 ), ( 297, 243, 28 ), ( 297, 270, 14 ),
( 324, 0, 168 ), ( 324, 27, 154 ), ( 324, 54, 140 ), ( 324, 81, 126 ), ( 324, 108, 112 ), ( 324, 135, 98 ), ( 324, 162, 84 ), ( 324, 189, 70 ), ( 324, 216, 56 ), ( 324, 243, 42 ), ( 324, 270, 28 ), ( 324, 297, 14 ),
( 351, 0, 182 ), ( 351, 27, 168 ), ( 351, 54, 154 ), ( 351, 81, 140 ), ( 351, 108, 126 ), ( 351, 135, 112 ), ( 351, 162, 98 ), ( 351, 189, 84 ), ( 351, 216, 70 ), ( 351, 243, 56 ), ( 351, 270, 42 ), ( 351, 297, 28 ), ( 351, 324, 14 ),
( 378, 0, 196 ), ( 378, 27, 182 ), ( 378, 54, 168 ), ( 378, 81, 154 ), ( 378, 108, 140 ), ( 378, 135, 126 ), ( 378, 162, 112 ), ( 378, 189, 98 ), ( 378, 216, 84 ), ( 378, 243, 70 ), ( 378, 270, 56 ), ( 378, 297, 42 ), ( 378, 324, 28 ), ( 378, 351, 14 ),
...
}
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 "}"