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.
( 84, 0, 50 ), ( 84, 42, 25 ),
( 126, 0, 75 ), ( 126, 42, 50 ), ( 126, 84, 25 ),
( 168, 0, 100 ), ( 168, 42, 75 ), ( 168, 84, 50 ), ( 168, 126, 25 ),
( 210, 0, 125 ), ( 210, 42, 100 ), ( 210, 84, 75 ), ( 210, 126, 50 ), ( 210, 168, 25 ),
( 252, 0, 150 ), ( 252, 42, 125 ), ( 252, 84, 100 ), ( 252, 126, 75 ), ( 252, 168, 50 ), ( 252, 210, 25 ),
( 294, 0, 175 ), ( 294, 42, 150 ), ( 294, 84, 125 ), ( 294, 126, 100 ), ( 294, 168, 75 ), ( 294, 210, 50 ), ( 294, 252, 25 ),
( 336, 0, 200 ), ( 336, 42, 175 ), ( 336, 84, 150 ), ( 336, 126, 125 ), ( 336, 168, 100 ), ( 336, 210, 75 ), ( 336, 252, 50 ), ( 336, 294, 25 ),
( 378, 0, 225 ), ( 378, 42, 200 ), ( 378, 84, 175 ), ( 378, 126, 150 ), ( 378, 168, 125 ), ( 378, 210, 100 ), ( 378, 252, 75 ), ( 378, 294, 50 ), ( 378, 336, 25 ),
( 420, 0, 250 ), ( 420, 42, 225 ), ( 420, 84, 200 ), ( 420, 126, 175 ), ( 420, 168, 150 ), ( 420, 210, 125 ), ( 420, 252, 100 ), ( 420, 294, 75 ), ( 420, 336, 50 ), ( 420, 378, 25 ),
( 462, 0, 275 ), ( 462, 42, 250 ), ( 462, 84, 225 ), ( 462, 126, 200 ), ( 462, 168, 175 ), ( 462, 210, 150 ), ( 462, 252, 125 ), ( 462, 294, 100 ), ( 462, 336, 75 ), ( 462, 378, 50 ), ( 462, 420, 25 ),
( 504, 0, 300 ), ( 504, 42, 275 ), ( 504, 84, 250 ), ( 504, 126, 225 ), ( 504, 168, 200 ), ( 504, 210, 175 ), ( 504, 252, 150 ), ( 504, 294, 125 ), ( 504, 336, 100 ), ( 504, 378, 75 ), ( 504, 420, 50 ), ( 504, 462, 25 ),
( 546, 0, 325 ), ( 546, 42, 300 ), ( 546, 84, 275 ), ( 546, 126, 250 ), ( 546, 168, 225 ), ( 546, 210, 200 ), ( 546, 252, 175 ), ( 546, 294, 150 ), ( 546, 336, 125 ), ( 546, 378, 100 ), ( 546, 420, 75 ), ( 546, 462, 50 ), ( 546, 504, 25 ),
( 588, 0, 350 ), ( 588, 42, 325 ), ( 588, 84, 300 ), ( 588, 126, 275 ), ( 588, 168, 250 ), ( 588, 210, 225 ), ( 588, 252, 200 ), ( 588, 294, 175 ), ( 588, 336, 150 ), ( 588, 378, 125 ), ( 588, 420, 100 ), ( 588, 462, 75 ), ( 588, 504, 50 ), ( 588, 546, 25 ),
...
}
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 "}"