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.
( 141, 0, 15 ), ( 141, 47, 10 ), ( 141, 94, 5 ),
( 188, 0, 20 ), ( 188, 47, 15 ), ( 188, 94, 10 ), ( 188, 141, 5 ),
( 235, 0, 25 ), ( 235, 47, 20 ), ( 235, 94, 15 ), ( 235, 141, 10 ), ( 235, 188, 5 ),
( 282, 0, 30 ), ( 282, 47, 25 ), ( 282, 94, 20 ), ( 282, 141, 15 ), ( 282, 188, 10 ), ( 282, 235, 5 ),
( 329, 0, 35 ), ( 329, 47, 30 ), ( 329, 94, 25 ), ( 329, 141, 20 ), ( 329, 188, 15 ), ( 329, 235, 10 ), ( 329, 282, 5 ),
( 376, 0, 40 ), ( 376, 47, 35 ), ( 376, 94, 30 ), ( 376, 141, 25 ), ( 376, 188, 20 ), ( 376, 235, 15 ), ( 376, 282, 10 ), ( 376, 329, 5 ),
( 423, 0, 45 ), ( 423, 47, 40 ), ( 423, 94, 35 ), ( 423, 141, 30 ), ( 423, 188, 25 ), ( 423, 235, 20 ), ( 423, 282, 15 ), ( 423, 329, 10 ), ( 423, 376, 5 ),
( 470, 0, 50 ), ( 470, 47, 45 ), ( 470, 94, 40 ), ( 470, 141, 35 ), ( 470, 188, 30 ), ( 470, 235, 25 ), ( 470, 282, 20 ), ( 470, 329, 15 ), ( 470, 376, 10 ), ( 470, 423, 5 ),
( 517, 0, 55 ), ( 517, 47, 50 ), ( 517, 94, 45 ), ( 517, 141, 40 ), ( 517, 188, 35 ), ( 517, 235, 30 ), ( 517, 282, 25 ), ( 517, 329, 20 ), ( 517, 376, 15 ), ( 517, 423, 10 ), ( 517, 470, 5 ),
( 564, 0, 60 ), ( 564, 47, 55 ), ( 564, 94, 50 ), ( 564, 141, 45 ), ( 564, 188, 40 ), ( 564, 235, 35 ), ( 564, 282, 30 ), ( 564, 329, 25 ), ( 564, 376, 20 ), ( 564, 423, 15 ), ( 564, 470, 10 ), ( 564, 517, 5 ),
( 611, 0, 65 ), ( 611, 47, 60 ), ( 611, 94, 55 ), ( 611, 141, 50 ), ( 611, 188, 45 ), ( 611, 235, 40 ), ( 611, 282, 35 ), ( 611, 329, 30 ), ( 611, 376, 25 ), ( 611, 423, 20 ), ( 611, 470, 15 ), ( 611, 517, 10 ), ( 611, 564, 5 ),
( 658, 0, 70 ), ( 658, 47, 65 ), ( 658, 94, 60 ), ( 658, 141, 55 ), ( 658, 188, 50 ), ( 658, 235, 45 ), ( 658, 282, 40 ), ( 658, 329, 35 ), ( 658, 376, 30 ), ( 658, 423, 25 ), ( 658, 470, 20 ), ( 658, 517, 15 ), ( 658, 564, 10 ), ( 658, 611, 5 ),
...
}
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 "}"