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.
( 6, 0, 3 ), ( 6, 2, 2 ), ( 6, 4, 1 ),
( 8, 0, 4 ), ( 8, 2, 3 ), ( 8, 4, 2 ), ( 8, 6, 1 ),
( 10, 0, 5 ), ( 10, 2, 4 ), ( 10, 4, 3 ), ( 10, 6, 2 ), ( 10, 8, 1 ),
( 12, 0, 6 ), ( 12, 2, 5 ), ( 12, 4, 4 ), ( 12, 6, 3 ), ( 12, 8, 2 ), ( 12, 10, 1 ),
( 14, 0, 7 ), ( 14, 2, 6 ), ( 14, 4, 5 ), ( 14, 6, 4 ), ( 14, 8, 3 ), ( 14, 10, 2 ), ( 14, 12, 1 ),
( 16, 0, 8 ), ( 16, 2, 7 ), ( 16, 4, 6 ), ( 16, 6, 5 ), ( 16, 8, 4 ), ( 16, 10, 3 ), ( 16, 12, 2 ), ( 16, 14, 1 ),
( 18, 0, 9 ), ( 18, 2, 8 ), ( 18, 4, 7 ), ( 18, 6, 6 ), ( 18, 8, 5 ), ( 18, 10, 4 ), ( 18, 12, 3 ), ( 18, 14, 2 ), ( 18, 16, 1 ),
( 20, 0, 10 ), ( 20, 2, 9 ), ( 20, 4, 8 ), ( 20, 6, 7 ), ( 20, 8, 6 ), ( 20, 10, 5 ), ( 20, 12, 4 ), ( 20, 14, 3 ), ( 20, 16, 2 ), ( 20, 18, 1 ),
( 22, 0, 11 ), ( 22, 2, 10 ), ( 22, 4, 9 ), ( 22, 6, 8 ), ( 22, 8, 7 ), ( 22, 10, 6 ), ( 22, 12, 5 ), ( 22, 14, 4 ), ( 22, 16, 3 ), ( 22, 18, 2 ), ( 22, 20, 1 ),
( 24, 0, 12 ), ( 24, 2, 11 ), ( 24, 4, 10 ), ( 24, 6, 9 ), ( 24, 8, 8 ), ( 24, 10, 7 ), ( 24, 12, 6 ), ( 24, 14, 5 ), ( 24, 16, 4 ), ( 24, 18, 3 ), ( 24, 20, 2 ), ( 24, 22, 1 ),
( 26, 0, 13 ), ( 26, 2, 12 ), ( 26, 4, 11 ), ( 26, 6, 10 ), ( 26, 8, 9 ), ( 26, 10, 8 ), ( 26, 12, 7 ), ( 26, 14, 6 ), ( 26, 16, 5 ), ( 26, 18, 4 ), ( 26, 20, 3 ), ( 26, 22, 2 ), ( 26, 24, 1 ),
( 28, 0, 14 ), ( 28, 2, 13 ), ( 28, 4, 12 ), ( 28, 6, 11 ), ( 28, 8, 10 ), ( 28, 10, 9 ), ( 28, 12, 8 ), ( 28, 14, 7 ), ( 28, 16, 6 ), ( 28, 18, 5 ), ( 28, 20, 4 ), ( 28, 22, 3 ), ( 28, 24, 2 ), ( 28, 26, 1 ),
...
}
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 "}"