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.
( 98, 0, 64 ), ( 98, 49, 32 ),
( 147, 0, 96 ), ( 147, 49, 64 ), ( 147, 98, 32 ),
( 196, 0, 128 ), ( 196, 49, 96 ), ( 196, 98, 64 ), ( 196, 147, 32 ),
( 245, 0, 160 ), ( 245, 49, 128 ), ( 245, 98, 96 ), ( 245, 147, 64 ), ( 245, 196, 32 ),
( 294, 0, 192 ), ( 294, 49, 160 ), ( 294, 98, 128 ), ( 294, 147, 96 ), ( 294, 196, 64 ), ( 294, 245, 32 ),
( 343, 0, 224 ), ( 343, 49, 192 ), ( 343, 98, 160 ), ( 343, 147, 128 ), ( 343, 196, 96 ), ( 343, 245, 64 ), ( 343, 294, 32 ),
( 392, 0, 256 ), ( 392, 49, 224 ), ( 392, 98, 192 ), ( 392, 147, 160 ), ( 392, 196, 128 ), ( 392, 245, 96 ), ( 392, 294, 64 ), ( 392, 343, 32 ),
( 441, 0, 288 ), ( 441, 49, 256 ), ( 441, 98, 224 ), ( 441, 147, 192 ), ( 441, 196, 160 ), ( 441, 245, 128 ), ( 441, 294, 96 ), ( 441, 343, 64 ), ( 441, 392, 32 ),
( 490, 0, 320 ), ( 490, 49, 288 ), ( 490, 98, 256 ), ( 490, 147, 224 ), ( 490, 196, 192 ), ( 490, 245, 160 ), ( 490, 294, 128 ), ( 490, 343, 96 ), ( 490, 392, 64 ), ( 490, 441, 32 ),
( 539, 0, 352 ), ( 539, 49, 320 ), ( 539, 98, 288 ), ( 539, 147, 256 ), ( 539, 196, 224 ), ( 539, 245, 192 ), ( 539, 294, 160 ), ( 539, 343, 128 ), ( 539, 392, 96 ), ( 539, 441, 64 ), ( 539, 490, 32 ),
( 588, 0, 384 ), ( 588, 49, 352 ), ( 588, 98, 320 ), ( 588, 147, 288 ), ( 588, 196, 256 ), ( 588, 245, 224 ), ( 588, 294, 192 ), ( 588, 343, 160 ), ( 588, 392, 128 ), ( 588, 441, 96 ), ( 588, 490, 64 ), ( 588, 539, 32 ),
( 637, 0, 416 ), ( 637, 49, 384 ), ( 637, 98, 352 ), ( 637, 147, 320 ), ( 637, 196, 288 ), ( 637, 245, 256 ), ( 637, 294, 224 ), ( 637, 343, 192 ), ( 637, 392, 160 ), ( 637, 441, 128 ), ( 637, 490, 96 ), ( 637, 539, 64 ), ( 637, 588, 32 ),
( 686, 0, 448 ), ( 686, 49, 416 ), ( 686, 98, 384 ), ( 686, 147, 352 ), ( 686, 196, 320 ), ( 686, 245, 288 ), ( 686, 294, 256 ), ( 686, 343, 224 ), ( 686, 392, 192 ), ( 686, 441, 160 ), ( 686, 490, 128 ), ( 686, 539, 96 ), ( 686, 588, 64 ), ( 686, 637, 32 ),
...
}
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 "}"