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.
( 69, 0, 27 ), ( 69, 23, 18 ), ( 69, 46, 9 ),
( 92, 0, 36 ), ( 92, 23, 27 ), ( 92, 46, 18 ), ( 92, 69, 9 ),
( 115, 0, 45 ), ( 115, 23, 36 ), ( 115, 46, 27 ), ( 115, 69, 18 ), ( 115, 92, 9 ),
( 138, 0, 54 ), ( 138, 23, 45 ), ( 138, 46, 36 ), ( 138, 69, 27 ), ( 138, 92, 18 ), ( 138, 115, 9 ),
( 161, 0, 63 ), ( 161, 23, 54 ), ( 161, 46, 45 ), ( 161, 69, 36 ), ( 161, 92, 27 ), ( 161, 115, 18 ), ( 161, 138, 9 ),
( 184, 0, 72 ), ( 184, 23, 63 ), ( 184, 46, 54 ), ( 184, 69, 45 ), ( 184, 92, 36 ), ( 184, 115, 27 ), ( 184, 138, 18 ), ( 184, 161, 9 ),
( 207, 0, 81 ), ( 207, 23, 72 ), ( 207, 46, 63 ), ( 207, 69, 54 ), ( 207, 92, 45 ), ( 207, 115, 36 ), ( 207, 138, 27 ), ( 207, 161, 18 ), ( 207, 184, 9 ),
( 230, 0, 90 ), ( 230, 23, 81 ), ( 230, 46, 72 ), ( 230, 69, 63 ), ( 230, 92, 54 ), ( 230, 115, 45 ), ( 230, 138, 36 ), ( 230, 161, 27 ), ( 230, 184, 18 ), ( 230, 207, 9 ),
( 253, 0, 99 ), ( 253, 23, 90 ), ( 253, 46, 81 ), ( 253, 69, 72 ), ( 253, 92, 63 ), ( 253, 115, 54 ), ( 253, 138, 45 ), ( 253, 161, 36 ), ( 253, 184, 27 ), ( 253, 207, 18 ), ( 253, 230, 9 ),
( 276, 0, 108 ), ( 276, 23, 99 ), ( 276, 46, 90 ), ( 276, 69, 81 ), ( 276, 92, 72 ), ( 276, 115, 63 ), ( 276, 138, 54 ), ( 276, 161, 45 ), ( 276, 184, 36 ), ( 276, 207, 27 ), ( 276, 230, 18 ), ( 276, 253, 9 ),
( 299, 0, 117 ), ( 299, 23, 108 ), ( 299, 46, 99 ), ( 299, 69, 90 ), ( 299, 92, 81 ), ( 299, 115, 72 ), ( 299, 138, 63 ), ( 299, 161, 54 ), ( 299, 184, 45 ), ( 299, 207, 36 ), ( 299, 230, 27 ), ( 299, 253, 18 ), ( 299, 276, 9 ),
( 322, 0, 126 ), ( 322, 23, 117 ), ( 322, 46, 108 ), ( 322, 69, 99 ), ( 322, 92, 90 ), ( 322, 115, 81 ), ( 322, 138, 72 ), ( 322, 161, 63 ), ( 322, 184, 54 ), ( 322, 207, 45 ), ( 322, 230, 36 ), ( 322, 253, 27 ), ( 322, 276, 18 ), ( 322, 299, 9 ),
...
}
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 "}"