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.
( 46, 0, 32 ), ( 46, 23, 16 ),
( 69, 0, 48 ), ( 69, 23, 32 ), ( 69, 46, 16 ),
( 92, 0, 64 ), ( 92, 23, 48 ), ( 92, 46, 32 ), ( 92, 69, 16 ),
( 115, 0, 80 ), ( 115, 23, 64 ), ( 115, 46, 48 ), ( 115, 69, 32 ), ( 115, 92, 16 ),
( 138, 0, 96 ), ( 138, 23, 80 ), ( 138, 46, 64 ), ( 138, 69, 48 ), ( 138, 92, 32 ), ( 138, 115, 16 ),
( 161, 0, 112 ), ( 161, 23, 96 ), ( 161, 46, 80 ), ( 161, 69, 64 ), ( 161, 92, 48 ), ( 161, 115, 32 ), ( 161, 138, 16 ),
( 184, 0, 128 ), ( 184, 23, 112 ), ( 184, 46, 96 ), ( 184, 69, 80 ), ( 184, 92, 64 ), ( 184, 115, 48 ), ( 184, 138, 32 ), ( 184, 161, 16 ),
( 207, 0, 144 ), ( 207, 23, 128 ), ( 207, 46, 112 ), ( 207, 69, 96 ), ( 207, 92, 80 ), ( 207, 115, 64 ), ( 207, 138, 48 ), ( 207, 161, 32 ), ( 207, 184, 16 ),
( 230, 0, 160 ), ( 230, 23, 144 ), ( 230, 46, 128 ), ( 230, 69, 112 ), ( 230, 92, 96 ), ( 230, 115, 80 ), ( 230, 138, 64 ), ( 230, 161, 48 ), ( 230, 184, 32 ), ( 230, 207, 16 ),
( 253, 0, 176 ), ( 253, 23, 160 ), ( 253, 46, 144 ), ( 253, 69, 128 ), ( 253, 92, 112 ), ( 253, 115, 96 ), ( 253, 138, 80 ), ( 253, 161, 64 ), ( 253, 184, 48 ), ( 253, 207, 32 ), ( 253, 230, 16 ),
( 276, 0, 192 ), ( 276, 23, 176 ), ( 276, 46, 160 ), ( 276, 69, 144 ), ( 276, 92, 128 ), ( 276, 115, 112 ), ( 276, 138, 96 ), ( 276, 161, 80 ), ( 276, 184, 64 ), ( 276, 207, 48 ), ( 276, 230, 32 ), ( 276, 253, 16 ),
( 299, 0, 208 ), ( 299, 23, 192 ), ( 299, 46, 176 ), ( 299, 69, 160 ), ( 299, 92, 144 ), ( 299, 115, 128 ), ( 299, 138, 112 ), ( 299, 161, 96 ), ( 299, 184, 80 ), ( 299, 207, 64 ), ( 299, 230, 48 ), ( 299, 253, 32 ), ( 299, 276, 16 ),
( 322, 0, 224 ), ( 322, 23, 208 ), ( 322, 46, 192 ), ( 322, 69, 176 ), ( 322, 92, 160 ), ( 322, 115, 144 ), ( 322, 138, 128 ), ( 322, 161, 112 ), ( 322, 184, 96 ), ( 322, 207, 80 ), ( 322, 230, 64 ), ( 322, 253, 48 ), ( 322, 276, 32 ), ( 322, 299, 16 ),
...
}
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 "}"