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.
( 88, 0, 34 ), ( 88, 44, 17 ),
( 132, 0, 51 ), ( 132, 44, 34 ), ( 132, 88, 17 ),
( 176, 0, 68 ), ( 176, 44, 51 ), ( 176, 88, 34 ), ( 176, 132, 17 ),
( 220, 0, 85 ), ( 220, 44, 68 ), ( 220, 88, 51 ), ( 220, 132, 34 ), ( 220, 176, 17 ),
( 264, 0, 102 ), ( 264, 44, 85 ), ( 264, 88, 68 ), ( 264, 132, 51 ), ( 264, 176, 34 ), ( 264, 220, 17 ),
( 308, 0, 119 ), ( 308, 44, 102 ), ( 308, 88, 85 ), ( 308, 132, 68 ), ( 308, 176, 51 ), ( 308, 220, 34 ), ( 308, 264, 17 ),
( 352, 0, 136 ), ( 352, 44, 119 ), ( 352, 88, 102 ), ( 352, 132, 85 ), ( 352, 176, 68 ), ( 352, 220, 51 ), ( 352, 264, 34 ), ( 352, 308, 17 ),
( 396, 0, 153 ), ( 396, 44, 136 ), ( 396, 88, 119 ), ( 396, 132, 102 ), ( 396, 176, 85 ), ( 396, 220, 68 ), ( 396, 264, 51 ), ( 396, 308, 34 ), ( 396, 352, 17 ),
( 440, 0, 170 ), ( 440, 44, 153 ), ( 440, 88, 136 ), ( 440, 132, 119 ), ( 440, 176, 102 ), ( 440, 220, 85 ), ( 440, 264, 68 ), ( 440, 308, 51 ), ( 440, 352, 34 ), ( 440, 396, 17 ),
( 484, 0, 187 ), ( 484, 44, 170 ), ( 484, 88, 153 ), ( 484, 132, 136 ), ( 484, 176, 119 ), ( 484, 220, 102 ), ( 484, 264, 85 ), ( 484, 308, 68 ), ( 484, 352, 51 ), ( 484, 396, 34 ), ( 484, 440, 17 ),
( 528, 0, 204 ), ( 528, 44, 187 ), ( 528, 88, 170 ), ( 528, 132, 153 ), ( 528, 176, 136 ), ( 528, 220, 119 ), ( 528, 264, 102 ), ( 528, 308, 85 ), ( 528, 352, 68 ), ( 528, 396, 51 ), ( 528, 440, 34 ), ( 528, 484, 17 ),
( 572, 0, 221 ), ( 572, 44, 204 ), ( 572, 88, 187 ), ( 572, 132, 170 ), ( 572, 176, 153 ), ( 572, 220, 136 ), ( 572, 264, 119 ), ( 572, 308, 102 ), ( 572, 352, 85 ), ( 572, 396, 68 ), ( 572, 440, 51 ), ( 572, 484, 34 ), ( 572, 528, 17 ),
( 616, 0, 238 ), ( 616, 44, 221 ), ( 616, 88, 204 ), ( 616, 132, 187 ), ( 616, 176, 170 ), ( 616, 220, 153 ), ( 616, 264, 136 ), ( 616, 308, 119 ), ( 616, 352, 102 ), ( 616, 396, 85 ), ( 616, 440, 68 ), ( 616, 484, 51 ), ( 616, 528, 34 ), ( 616, 572, 17 ),
...
}
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 "}"