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, 38 ), ( 88, 44, 19 ),
( 132, 0, 57 ), ( 132, 44, 38 ), ( 132, 88, 19 ),
( 176, 0, 76 ), ( 176, 44, 57 ), ( 176, 88, 38 ), ( 176, 132, 19 ),
( 220, 0, 95 ), ( 220, 44, 76 ), ( 220, 88, 57 ), ( 220, 132, 38 ), ( 220, 176, 19 ),
( 264, 0, 114 ), ( 264, 44, 95 ), ( 264, 88, 76 ), ( 264, 132, 57 ), ( 264, 176, 38 ), ( 264, 220, 19 ),
( 308, 0, 133 ), ( 308, 44, 114 ), ( 308, 88, 95 ), ( 308, 132, 76 ), ( 308, 176, 57 ), ( 308, 220, 38 ), ( 308, 264, 19 ),
( 352, 0, 152 ), ( 352, 44, 133 ), ( 352, 88, 114 ), ( 352, 132, 95 ), ( 352, 176, 76 ), ( 352, 220, 57 ), ( 352, 264, 38 ), ( 352, 308, 19 ),
( 396, 0, 171 ), ( 396, 44, 152 ), ( 396, 88, 133 ), ( 396, 132, 114 ), ( 396, 176, 95 ), ( 396, 220, 76 ), ( 396, 264, 57 ), ( 396, 308, 38 ), ( 396, 352, 19 ),
( 440, 0, 190 ), ( 440, 44, 171 ), ( 440, 88, 152 ), ( 440, 132, 133 ), ( 440, 176, 114 ), ( 440, 220, 95 ), ( 440, 264, 76 ), ( 440, 308, 57 ), ( 440, 352, 38 ), ( 440, 396, 19 ),
( 484, 0, 209 ), ( 484, 44, 190 ), ( 484, 88, 171 ), ( 484, 132, 152 ), ( 484, 176, 133 ), ( 484, 220, 114 ), ( 484, 264, 95 ), ( 484, 308, 76 ), ( 484, 352, 57 ), ( 484, 396, 38 ), ( 484, 440, 19 ),
( 528, 0, 228 ), ( 528, 44, 209 ), ( 528, 88, 190 ), ( 528, 132, 171 ), ( 528, 176, 152 ), ( 528, 220, 133 ), ( 528, 264, 114 ), ( 528, 308, 95 ), ( 528, 352, 76 ), ( 528, 396, 57 ), ( 528, 440, 38 ), ( 528, 484, 19 ),
( 572, 0, 247 ), ( 572, 44, 228 ), ( 572, 88, 209 ), ( 572, 132, 190 ), ( 572, 176, 171 ), ( 572, 220, 152 ), ( 572, 264, 133 ), ( 572, 308, 114 ), ( 572, 352, 95 ), ( 572, 396, 76 ), ( 572, 440, 57 ), ( 572, 484, 38 ), ( 572, 528, 19 ),
( 616, 0, 266 ), ( 616, 44, 247 ), ( 616, 88, 228 ), ( 616, 132, 209 ), ( 616, 176, 190 ), ( 616, 220, 171 ), ( 616, 264, 152 ), ( 616, 308, 133 ), ( 616, 352, 114 ), ( 616, 396, 95 ), ( 616, 440, 76 ), ( 616, 484, 57 ), ( 616, 528, 38 ), ( 616, 572, 19 ),
...
}
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 "}"