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.
( 94, 0, 28 ), ( 94, 47, 14 ),
( 141, 0, 42 ), ( 141, 47, 28 ), ( 141, 94, 14 ),
( 188, 0, 56 ), ( 188, 47, 42 ), ( 188, 94, 28 ), ( 188, 141, 14 ),
( 235, 0, 70 ), ( 235, 47, 56 ), ( 235, 94, 42 ), ( 235, 141, 28 ), ( 235, 188, 14 ),
( 282, 0, 84 ), ( 282, 47, 70 ), ( 282, 94, 56 ), ( 282, 141, 42 ), ( 282, 188, 28 ), ( 282, 235, 14 ),
( 329, 0, 98 ), ( 329, 47, 84 ), ( 329, 94, 70 ), ( 329, 141, 56 ), ( 329, 188, 42 ), ( 329, 235, 28 ), ( 329, 282, 14 ),
( 376, 0, 112 ), ( 376, 47, 98 ), ( 376, 94, 84 ), ( 376, 141, 70 ), ( 376, 188, 56 ), ( 376, 235, 42 ), ( 376, 282, 28 ), ( 376, 329, 14 ),
( 423, 0, 126 ), ( 423, 47, 112 ), ( 423, 94, 98 ), ( 423, 141, 84 ), ( 423, 188, 70 ), ( 423, 235, 56 ), ( 423, 282, 42 ), ( 423, 329, 28 ), ( 423, 376, 14 ),
( 470, 0, 140 ), ( 470, 47, 126 ), ( 470, 94, 112 ), ( 470, 141, 98 ), ( 470, 188, 84 ), ( 470, 235, 70 ), ( 470, 282, 56 ), ( 470, 329, 42 ), ( 470, 376, 28 ), ( 470, 423, 14 ),
( 517, 0, 154 ), ( 517, 47, 140 ), ( 517, 94, 126 ), ( 517, 141, 112 ), ( 517, 188, 98 ), ( 517, 235, 84 ), ( 517, 282, 70 ), ( 517, 329, 56 ), ( 517, 376, 42 ), ( 517, 423, 28 ), ( 517, 470, 14 ),
( 564, 0, 168 ), ( 564, 47, 154 ), ( 564, 94, 140 ), ( 564, 141, 126 ), ( 564, 188, 112 ), ( 564, 235, 98 ), ( 564, 282, 84 ), ( 564, 329, 70 ), ( 564, 376, 56 ), ( 564, 423, 42 ), ( 564, 470, 28 ), ( 564, 517, 14 ),
( 611, 0, 182 ), ( 611, 47, 168 ), ( 611, 94, 154 ), ( 611, 141, 140 ), ( 611, 188, 126 ), ( 611, 235, 112 ), ( 611, 282, 98 ), ( 611, 329, 84 ), ( 611, 376, 70 ), ( 611, 423, 56 ), ( 611, 470, 42 ), ( 611, 517, 28 ), ( 611, 564, 14 ),
( 658, 0, 196 ), ( 658, 47, 182 ), ( 658, 94, 168 ), ( 658, 141, 154 ), ( 658, 188, 140 ), ( 658, 235, 126 ), ( 658, 282, 112 ), ( 658, 329, 98 ), ( 658, 376, 84 ), ( 658, 423, 70 ), ( 658, 470, 56 ), ( 658, 517, 42 ), ( 658, 564, 28 ), ( 658, 611, 14 ),
...
}
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 "}"