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.
( 123, 0, 24 ), ( 123, 41, 16 ), ( 123, 82, 8 ),
( 164, 0, 32 ), ( 164, 41, 24 ), ( 164, 82, 16 ), ( 164, 123, 8 ),
( 205, 0, 40 ), ( 205, 41, 32 ), ( 205, 82, 24 ), ( 205, 123, 16 ), ( 205, 164, 8 ),
( 246, 0, 48 ), ( 246, 41, 40 ), ( 246, 82, 32 ), ( 246, 123, 24 ), ( 246, 164, 16 ), ( 246, 205, 8 ),
( 287, 0, 56 ), ( 287, 41, 48 ), ( 287, 82, 40 ), ( 287, 123, 32 ), ( 287, 164, 24 ), ( 287, 205, 16 ), ( 287, 246, 8 ),
( 328, 0, 64 ), ( 328, 41, 56 ), ( 328, 82, 48 ), ( 328, 123, 40 ), ( 328, 164, 32 ), ( 328, 205, 24 ), ( 328, 246, 16 ), ( 328, 287, 8 ),
( 369, 0, 72 ), ( 369, 41, 64 ), ( 369, 82, 56 ), ( 369, 123, 48 ), ( 369, 164, 40 ), ( 369, 205, 32 ), ( 369, 246, 24 ), ( 369, 287, 16 ), ( 369, 328, 8 ),
( 410, 0, 80 ), ( 410, 41, 72 ), ( 410, 82, 64 ), ( 410, 123, 56 ), ( 410, 164, 48 ), ( 410, 205, 40 ), ( 410, 246, 32 ), ( 410, 287, 24 ), ( 410, 328, 16 ), ( 410, 369, 8 ),
( 451, 0, 88 ), ( 451, 41, 80 ), ( 451, 82, 72 ), ( 451, 123, 64 ), ( 451, 164, 56 ), ( 451, 205, 48 ), ( 451, 246, 40 ), ( 451, 287, 32 ), ( 451, 328, 24 ), ( 451, 369, 16 ), ( 451, 410, 8 ),
( 492, 0, 96 ), ( 492, 41, 88 ), ( 492, 82, 80 ), ( 492, 123, 72 ), ( 492, 164, 64 ), ( 492, 205, 56 ), ( 492, 246, 48 ), ( 492, 287, 40 ), ( 492, 328, 32 ), ( 492, 369, 24 ), ( 492, 410, 16 ), ( 492, 451, 8 ),
( 533, 0, 104 ), ( 533, 41, 96 ), ( 533, 82, 88 ), ( 533, 123, 80 ), ( 533, 164, 72 ), ( 533, 205, 64 ), ( 533, 246, 56 ), ( 533, 287, 48 ), ( 533, 328, 40 ), ( 533, 369, 32 ), ( 533, 410, 24 ), ( 533, 451, 16 ), ( 533, 492, 8 ),
( 574, 0, 112 ), ( 574, 41, 104 ), ( 574, 82, 96 ), ( 574, 123, 88 ), ( 574, 164, 80 ), ( 574, 205, 72 ), ( 574, 246, 64 ), ( 574, 287, 56 ), ( 574, 328, 48 ), ( 574, 369, 40 ), ( 574, 410, 32 ), ( 574, 451, 24 ), ( 574, 492, 16 ), ( 574, 533, 8 ),
...
}
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 "}"