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.
( 27, 0, 6 ), ( 27, 9, 4 ), ( 27, 18, 2 ),
( 36, 0, 8 ), ( 36, 9, 6 ), ( 36, 18, 4 ), ( 36, 27, 2 ),
( 45, 0, 10 ), ( 45, 9, 8 ), ( 45, 18, 6 ), ( 45, 27, 4 ), ( 45, 36, 2 ),
( 54, 0, 12 ), ( 54, 9, 10 ), ( 54, 18, 8 ), ( 54, 27, 6 ), ( 54, 36, 4 ), ( 54, 45, 2 ),
( 63, 0, 14 ), ( 63, 9, 12 ), ( 63, 18, 10 ), ( 63, 27, 8 ), ( 63, 36, 6 ), ( 63, 45, 4 ), ( 63, 54, 2 ),
( 72, 0, 16 ), ( 72, 9, 14 ), ( 72, 18, 12 ), ( 72, 27, 10 ), ( 72, 36, 8 ), ( 72, 45, 6 ), ( 72, 54, 4 ), ( 72, 63, 2 ),
( 81, 0, 18 ), ( 81, 9, 16 ), ( 81, 18, 14 ), ( 81, 27, 12 ), ( 81, 36, 10 ), ( 81, 45, 8 ), ( 81, 54, 6 ), ( 81, 63, 4 ), ( 81, 72, 2 ),
( 90, 0, 20 ), ( 90, 9, 18 ), ( 90, 18, 16 ), ( 90, 27, 14 ), ( 90, 36, 12 ), ( 90, 45, 10 ), ( 90, 54, 8 ), ( 90, 63, 6 ), ( 90, 72, 4 ), ( 90, 81, 2 ),
( 99, 0, 22 ), ( 99, 9, 20 ), ( 99, 18, 18 ), ( 99, 27, 16 ), ( 99, 36, 14 ), ( 99, 45, 12 ), ( 99, 54, 10 ), ( 99, 63, 8 ), ( 99, 72, 6 ), ( 99, 81, 4 ), ( 99, 90, 2 ),
( 108, 0, 24 ), ( 108, 9, 22 ), ( 108, 18, 20 ), ( 108, 27, 18 ), ( 108, 36, 16 ), ( 108, 45, 14 ), ( 108, 54, 12 ), ( 108, 63, 10 ), ( 108, 72, 8 ), ( 108, 81, 6 ), ( 108, 90, 4 ), ( 108, 99, 2 ),
( 117, 0, 26 ), ( 117, 9, 24 ), ( 117, 18, 22 ), ( 117, 27, 20 ), ( 117, 36, 18 ), ( 117, 45, 16 ), ( 117, 54, 14 ), ( 117, 63, 12 ), ( 117, 72, 10 ), ( 117, 81, 8 ), ( 117, 90, 6 ), ( 117, 99, 4 ), ( 117, 108, 2 ),
( 126, 0, 28 ), ( 126, 9, 26 ), ( 126, 18, 24 ), ( 126, 27, 22 ), ( 126, 36, 20 ), ( 126, 45, 18 ), ( 126, 54, 16 ), ( 126, 63, 14 ), ( 126, 72, 12 ), ( 126, 81, 10 ), ( 126, 90, 8 ), ( 126, 99, 6 ), ( 126, 108, 4 ), ( 126, 117, 2 ),
...
}
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 "}"