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, 18 ), ( 141, 47, 12 ), ( 141, 94, 6 ),
( 188, 0, 24 ), ( 188, 47, 18 ), ( 188, 94, 12 ), ( 188, 141, 6 ),
( 235, 0, 30 ), ( 235, 47, 24 ), ( 235, 94, 18 ), ( 235, 141, 12 ), ( 235, 188, 6 ),
( 282, 0, 36 ), ( 282, 47, 30 ), ( 282, 94, 24 ), ( 282, 141, 18 ), ( 282, 188, 12 ), ( 282, 235, 6 ),
( 329, 0, 42 ), ( 329, 47, 36 ), ( 329, 94, 30 ), ( 329, 141, 24 ), ( 329, 188, 18 ), ( 329, 235, 12 ), ( 329, 282, 6 ),
( 376, 0, 48 ), ( 376, 47, 42 ), ( 376, 94, 36 ), ( 376, 141, 30 ), ( 376, 188, 24 ), ( 376, 235, 18 ), ( 376, 282, 12 ), ( 376, 329, 6 ),
( 423, 0, 54 ), ( 423, 47, 48 ), ( 423, 94, 42 ), ( 423, 141, 36 ), ( 423, 188, 30 ), ( 423, 235, 24 ), ( 423, 282, 18 ), ( 423, 329, 12 ), ( 423, 376, 6 ),
( 470, 0, 60 ), ( 470, 47, 54 ), ( 470, 94, 48 ), ( 470, 141, 42 ), ( 470, 188, 36 ), ( 470, 235, 30 ), ( 470, 282, 24 ), ( 470, 329, 18 ), ( 470, 376, 12 ), ( 470, 423, 6 ),
( 517, 0, 66 ), ( 517, 47, 60 ), ( 517, 94, 54 ), ( 517, 141, 48 ), ( 517, 188, 42 ), ( 517, 235, 36 ), ( 517, 282, 30 ), ( 517, 329, 24 ), ( 517, 376, 18 ), ( 517, 423, 12 ), ( 517, 470, 6 ),
( 564, 0, 72 ), ( 564, 47, 66 ), ( 564, 94, 60 ), ( 564, 141, 54 ), ( 564, 188, 48 ), ( 564, 235, 42 ), ( 564, 282, 36 ), ( 564, 329, 30 ), ( 564, 376, 24 ), ( 564, 423, 18 ), ( 564, 470, 12 ), ( 564, 517, 6 ),
( 611, 0, 78 ), ( 611, 47, 72 ), ( 611, 94, 66 ), ( 611, 141, 60 ), ( 611, 188, 54 ), ( 611, 235, 48 ), ( 611, 282, 42 ), ( 611, 329, 36 ), ( 611, 376, 30 ), ( 611, 423, 24 ), ( 611, 470, 18 ), ( 611, 517, 12 ), ( 611, 564, 6 ),
( 658, 0, 84 ), ( 658, 47, 78 ), ( 658, 94, 72 ), ( 658, 141, 66 ), ( 658, 188, 60 ), ( 658, 235, 54 ), ( 658, 282, 48 ), ( 658, 329, 42 ), ( 658, 376, 36 ), ( 658, 423, 30 ), ( 658, 470, 24 ), ( 658, 517, 18 ), ( 658, 564, 12 ), ( 658, 611, 6 ),
...
}
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 "}"