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.
( 82, 0, 48 ), ( 82, 41, 24 ),
( 123, 0, 72 ), ( 123, 41, 48 ), ( 123, 82, 24 ),
( 164, 0, 96 ), ( 164, 41, 72 ), ( 164, 82, 48 ), ( 164, 123, 24 ),
( 205, 0, 120 ), ( 205, 41, 96 ), ( 205, 82, 72 ), ( 205, 123, 48 ), ( 205, 164, 24 ),
( 246, 0, 144 ), ( 246, 41, 120 ), ( 246, 82, 96 ), ( 246, 123, 72 ), ( 246, 164, 48 ), ( 246, 205, 24 ),
( 287, 0, 168 ), ( 287, 41, 144 ), ( 287, 82, 120 ), ( 287, 123, 96 ), ( 287, 164, 72 ), ( 287, 205, 48 ), ( 287, 246, 24 ),
( 328, 0, 192 ), ( 328, 41, 168 ), ( 328, 82, 144 ), ( 328, 123, 120 ), ( 328, 164, 96 ), ( 328, 205, 72 ), ( 328, 246, 48 ), ( 328, 287, 24 ),
( 369, 0, 216 ), ( 369, 41, 192 ), ( 369, 82, 168 ), ( 369, 123, 144 ), ( 369, 164, 120 ), ( 369, 205, 96 ), ( 369, 246, 72 ), ( 369, 287, 48 ), ( 369, 328, 24 ),
( 410, 0, 240 ), ( 410, 41, 216 ), ( 410, 82, 192 ), ( 410, 123, 168 ), ( 410, 164, 144 ), ( 410, 205, 120 ), ( 410, 246, 96 ), ( 410, 287, 72 ), ( 410, 328, 48 ), ( 410, 369, 24 ),
( 451, 0, 264 ), ( 451, 41, 240 ), ( 451, 82, 216 ), ( 451, 123, 192 ), ( 451, 164, 168 ), ( 451, 205, 144 ), ( 451, 246, 120 ), ( 451, 287, 96 ), ( 451, 328, 72 ), ( 451, 369, 48 ), ( 451, 410, 24 ),
( 492, 0, 288 ), ( 492, 41, 264 ), ( 492, 82, 240 ), ( 492, 123, 216 ), ( 492, 164, 192 ), ( 492, 205, 168 ), ( 492, 246, 144 ), ( 492, 287, 120 ), ( 492, 328, 96 ), ( 492, 369, 72 ), ( 492, 410, 48 ), ( 492, 451, 24 ),
( 533, 0, 312 ), ( 533, 41, 288 ), ( 533, 82, 264 ), ( 533, 123, 240 ), ( 533, 164, 216 ), ( 533, 205, 192 ), ( 533, 246, 168 ), ( 533, 287, 144 ), ( 533, 328, 120 ), ( 533, 369, 96 ), ( 533, 410, 72 ), ( 533, 451, 48 ), ( 533, 492, 24 ),
( 574, 0, 336 ), ( 574, 41, 312 ), ( 574, 82, 288 ), ( 574, 123, 264 ), ( 574, 164, 240 ), ( 574, 205, 216 ), ( 574, 246, 192 ), ( 574, 287, 168 ), ( 574, 328, 144 ), ( 574, 369, 120 ), ( 574, 410, 96 ), ( 574, 451, 72 ), ( 574, 492, 48 ), ( 574, 533, 24 ),
...
}
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 "}"