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.
( 39, 0, 3 ), ( 39, 13, 2 ), ( 39, 26, 1 ),
( 52, 0, 4 ), ( 52, 13, 3 ), ( 52, 26, 2 ), ( 52, 39, 1 ),
( 65, 0, 5 ), ( 65, 13, 4 ), ( 65, 26, 3 ), ( 65, 39, 2 ), ( 65, 52, 1 ),
( 78, 0, 6 ), ( 78, 13, 5 ), ( 78, 26, 4 ), ( 78, 39, 3 ), ( 78, 52, 2 ), ( 78, 65, 1 ),
( 91, 0, 7 ), ( 91, 13, 6 ), ( 91, 26, 5 ), ( 91, 39, 4 ), ( 91, 52, 3 ), ( 91, 65, 2 ), ( 91, 78, 1 ),
( 104, 0, 8 ), ( 104, 13, 7 ), ( 104, 26, 6 ), ( 104, 39, 5 ), ( 104, 52, 4 ), ( 104, 65, 3 ), ( 104, 78, 2 ), ( 104, 91, 1 ),
( 117, 0, 9 ), ( 117, 13, 8 ), ( 117, 26, 7 ), ( 117, 39, 6 ), ( 117, 52, 5 ), ( 117, 65, 4 ), ( 117, 78, 3 ), ( 117, 91, 2 ), ( 117, 104, 1 ),
( 130, 0, 10 ), ( 130, 13, 9 ), ( 130, 26, 8 ), ( 130, 39, 7 ), ( 130, 52, 6 ), ( 130, 65, 5 ), ( 130, 78, 4 ), ( 130, 91, 3 ), ( 130, 104, 2 ), ( 130, 117, 1 ),
( 143, 0, 11 ), ( 143, 13, 10 ), ( 143, 26, 9 ), ( 143, 39, 8 ), ( 143, 52, 7 ), ( 143, 65, 6 ), ( 143, 78, 5 ), ( 143, 91, 4 ), ( 143, 104, 3 ), ( 143, 117, 2 ), ( 143, 130, 1 ),
( 156, 0, 12 ), ( 156, 13, 11 ), ( 156, 26, 10 ), ( 156, 39, 9 ), ( 156, 52, 8 ), ( 156, 65, 7 ), ( 156, 78, 6 ), ( 156, 91, 5 ), ( 156, 104, 4 ), ( 156, 117, 3 ), ( 156, 130, 2 ), ( 156, 143, 1 ),
( 169, 0, 13 ), ( 169, 13, 12 ), ( 169, 26, 11 ), ( 169, 39, 10 ), ( 169, 52, 9 ), ( 169, 65, 8 ), ( 169, 78, 7 ), ( 169, 91, 6 ), ( 169, 104, 5 ), ( 169, 117, 4 ), ( 169, 130, 3 ), ( 169, 143, 2 ), ( 169, 156, 1 ),
( 182, 0, 14 ), ( 182, 13, 13 ), ( 182, 26, 12 ), ( 182, 39, 11 ), ( 182, 52, 10 ), ( 182, 65, 9 ), ( 182, 78, 8 ), ( 182, 91, 7 ), ( 182, 104, 6 ), ( 182, 117, 5 ), ( 182, 130, 4 ), ( 182, 143, 3 ), ( 182, 156, 2 ), ( 182, 169, 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 "}"