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.
( 68, 0, 30 ), ( 68, 34, 15 ),
( 102, 0, 45 ), ( 102, 34, 30 ), ( 102, 68, 15 ),
( 136, 0, 60 ), ( 136, 34, 45 ), ( 136, 68, 30 ), ( 136, 102, 15 ),
( 170, 0, 75 ), ( 170, 34, 60 ), ( 170, 68, 45 ), ( 170, 102, 30 ), ( 170, 136, 15 ),
( 204, 0, 90 ), ( 204, 34, 75 ), ( 204, 68, 60 ), ( 204, 102, 45 ), ( 204, 136, 30 ), ( 204, 170, 15 ),
( 238, 0, 105 ), ( 238, 34, 90 ), ( 238, 68, 75 ), ( 238, 102, 60 ), ( 238, 136, 45 ), ( 238, 170, 30 ), ( 238, 204, 15 ),
( 272, 0, 120 ), ( 272, 34, 105 ), ( 272, 68, 90 ), ( 272, 102, 75 ), ( 272, 136, 60 ), ( 272, 170, 45 ), ( 272, 204, 30 ), ( 272, 238, 15 ),
( 306, 0, 135 ), ( 306, 34, 120 ), ( 306, 68, 105 ), ( 306, 102, 90 ), ( 306, 136, 75 ), ( 306, 170, 60 ), ( 306, 204, 45 ), ( 306, 238, 30 ), ( 306, 272, 15 ),
( 340, 0, 150 ), ( 340, 34, 135 ), ( 340, 68, 120 ), ( 340, 102, 105 ), ( 340, 136, 90 ), ( 340, 170, 75 ), ( 340, 204, 60 ), ( 340, 238, 45 ), ( 340, 272, 30 ), ( 340, 306, 15 ),
( 374, 0, 165 ), ( 374, 34, 150 ), ( 374, 68, 135 ), ( 374, 102, 120 ), ( 374, 136, 105 ), ( 374, 170, 90 ), ( 374, 204, 75 ), ( 374, 238, 60 ), ( 374, 272, 45 ), ( 374, 306, 30 ), ( 374, 340, 15 ),
( 408, 0, 180 ), ( 408, 34, 165 ), ( 408, 68, 150 ), ( 408, 102, 135 ), ( 408, 136, 120 ), ( 408, 170, 105 ), ( 408, 204, 90 ), ( 408, 238, 75 ), ( 408, 272, 60 ), ( 408, 306, 45 ), ( 408, 340, 30 ), ( 408, 374, 15 ),
( 442, 0, 195 ), ( 442, 34, 180 ), ( 442, 68, 165 ), ( 442, 102, 150 ), ( 442, 136, 135 ), ( 442, 170, 120 ), ( 442, 204, 105 ), ( 442, 238, 90 ), ( 442, 272, 75 ), ( 442, 306, 60 ), ( 442, 340, 45 ), ( 442, 374, 30 ), ( 442, 408, 15 ),
( 476, 0, 210 ), ( 476, 34, 195 ), ( 476, 68, 180 ), ( 476, 102, 165 ), ( 476, 136, 150 ), ( 476, 170, 135 ), ( 476, 204, 120 ), ( 476, 238, 105 ), ( 476, 272, 90 ), ( 476, 306, 75 ), ( 476, 340, 60 ), ( 476, 374, 45 ), ( 476, 408, 30 ), ( 476, 442, 15 ),
...
}
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 "}"