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.
( 80, 0, 46 ), ( 80, 40, 23 ),
( 120, 0, 69 ), ( 120, 40, 46 ), ( 120, 80, 23 ),
( 160, 0, 92 ), ( 160, 40, 69 ), ( 160, 80, 46 ), ( 160, 120, 23 ),
( 200, 0, 115 ), ( 200, 40, 92 ), ( 200, 80, 69 ), ( 200, 120, 46 ), ( 200, 160, 23 ),
( 240, 0, 138 ), ( 240, 40, 115 ), ( 240, 80, 92 ), ( 240, 120, 69 ), ( 240, 160, 46 ), ( 240, 200, 23 ),
( 280, 0, 161 ), ( 280, 40, 138 ), ( 280, 80, 115 ), ( 280, 120, 92 ), ( 280, 160, 69 ), ( 280, 200, 46 ), ( 280, 240, 23 ),
( 320, 0, 184 ), ( 320, 40, 161 ), ( 320, 80, 138 ), ( 320, 120, 115 ), ( 320, 160, 92 ), ( 320, 200, 69 ), ( 320, 240, 46 ), ( 320, 280, 23 ),
( 360, 0, 207 ), ( 360, 40, 184 ), ( 360, 80, 161 ), ( 360, 120, 138 ), ( 360, 160, 115 ), ( 360, 200, 92 ), ( 360, 240, 69 ), ( 360, 280, 46 ), ( 360, 320, 23 ),
( 400, 0, 230 ), ( 400, 40, 207 ), ( 400, 80, 184 ), ( 400, 120, 161 ), ( 400, 160, 138 ), ( 400, 200, 115 ), ( 400, 240, 92 ), ( 400, 280, 69 ), ( 400, 320, 46 ), ( 400, 360, 23 ),
( 440, 0, 253 ), ( 440, 40, 230 ), ( 440, 80, 207 ), ( 440, 120, 184 ), ( 440, 160, 161 ), ( 440, 200, 138 ), ( 440, 240, 115 ), ( 440, 280, 92 ), ( 440, 320, 69 ), ( 440, 360, 46 ), ( 440, 400, 23 ),
( 480, 0, 276 ), ( 480, 40, 253 ), ( 480, 80, 230 ), ( 480, 120, 207 ), ( 480, 160, 184 ), ( 480, 200, 161 ), ( 480, 240, 138 ), ( 480, 280, 115 ), ( 480, 320, 92 ), ( 480, 360, 69 ), ( 480, 400, 46 ), ( 480, 440, 23 ),
( 520, 0, 299 ), ( 520, 40, 276 ), ( 520, 80, 253 ), ( 520, 120, 230 ), ( 520, 160, 207 ), ( 520, 200, 184 ), ( 520, 240, 161 ), ( 520, 280, 138 ), ( 520, 320, 115 ), ( 520, 360, 92 ), ( 520, 400, 69 ), ( 520, 440, 46 ), ( 520, 480, 23 ),
( 560, 0, 322 ), ( 560, 40, 299 ), ( 560, 80, 276 ), ( 560, 120, 253 ), ( 560, 160, 230 ), ( 560, 200, 207 ), ( 560, 240, 184 ), ( 560, 280, 161 ), ( 560, 320, 138 ), ( 560, 360, 115 ), ( 560, 400, 92 ), ( 560, 440, 69 ), ( 560, 480, 46 ), ( 560, 520, 23 ),
...
}
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 "}"