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, 15 ), ( 72, 24, 10 ), ( 72, 48, 5 ),
( 96, 0, 20 ), ( 96, 24, 15 ), ( 96, 48, 10 ), ( 96, 72, 5 ),
( 120, 0, 25 ), ( 120, 24, 20 ), ( 120, 48, 15 ), ( 120, 72, 10 ), ( 120, 96, 5 ),
( 144, 0, 30 ), ( 144, 24, 25 ), ( 144, 48, 20 ), ( 144, 72, 15 ), ( 144, 96, 10 ), ( 144, 120, 5 ),
( 168, 0, 35 ), ( 168, 24, 30 ), ( 168, 48, 25 ), ( 168, 72, 20 ), ( 168, 96, 15 ), ( 168, 120, 10 ), ( 168, 144, 5 ),
( 192, 0, 40 ), ( 192, 24, 35 ), ( 192, 48, 30 ), ( 192, 72, 25 ), ( 192, 96, 20 ), ( 192, 120, 15 ), ( 192, 144, 10 ), ( 192, 168, 5 ),
( 216, 0, 45 ), ( 216, 24, 40 ), ( 216, 48, 35 ), ( 216, 72, 30 ), ( 216, 96, 25 ), ( 216, 120, 20 ), ( 216, 144, 15 ), ( 216, 168, 10 ), ( 216, 192, 5 ),
( 240, 0, 50 ), ( 240, 24, 45 ), ( 240, 48, 40 ), ( 240, 72, 35 ), ( 240, 96, 30 ), ( 240, 120, 25 ), ( 240, 144, 20 ), ( 240, 168, 15 ), ( 240, 192, 10 ), ( 240, 216, 5 ),
( 264, 0, 55 ), ( 264, 24, 50 ), ( 264, 48, 45 ), ( 264, 72, 40 ), ( 264, 96, 35 ), ( 264, 120, 30 ), ( 264, 144, 25 ), ( 264, 168, 20 ), ( 264, 192, 15 ), ( 264, 216, 10 ), ( 264, 240, 5 ),
( 288, 0, 60 ), ( 288, 24, 55 ), ( 288, 48, 50 ), ( 288, 72, 45 ), ( 288, 96, 40 ), ( 288, 120, 35 ), ( 288, 144, 30 ), ( 288, 168, 25 ), ( 288, 192, 20 ), ( 288, 216, 15 ), ( 288, 240, 10 ), ( 288, 264, 5 ),
( 312, 0, 65 ), ( 312, 24, 60 ), ( 312, 48, 55 ), ( 312, 72, 50 ), ( 312, 96, 45 ), ( 312, 120, 40 ), ( 312, 144, 35 ), ( 312, 168, 30 ), ( 312, 192, 25 ), ( 312, 216, 20 ), ( 312, 240, 15 ), ( 312, 264, 10 ), ( 312, 288, 5 ),
( 336, 0, 70 ), ( 336, 24, 65 ), ( 336, 48, 60 ), ( 336, 72, 55 ), ( 336, 96, 50 ), ( 336, 120, 45 ), ( 336, 144, 40 ), ( 336, 168, 35 ), ( 336, 192, 30 ), ( 336, 216, 25 ), ( 336, 240, 20 ), ( 336, 264, 15 ), ( 336, 288, 10 ), ( 336, 312, 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 "}"