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.
( 120, 0, 27 ), ( 120, 40, 18 ), ( 120, 80, 9 ),
( 160, 0, 36 ), ( 160, 40, 27 ), ( 160, 80, 18 ), ( 160, 120, 9 ),
( 200, 0, 45 ), ( 200, 40, 36 ), ( 200, 80, 27 ), ( 200, 120, 18 ), ( 200, 160, 9 ),
( 240, 0, 54 ), ( 240, 40, 45 ), ( 240, 80, 36 ), ( 240, 120, 27 ), ( 240, 160, 18 ), ( 240, 200, 9 ),
( 280, 0, 63 ), ( 280, 40, 54 ), ( 280, 80, 45 ), ( 280, 120, 36 ), ( 280, 160, 27 ), ( 280, 200, 18 ), ( 280, 240, 9 ),
( 320, 0, 72 ), ( 320, 40, 63 ), ( 320, 80, 54 ), ( 320, 120, 45 ), ( 320, 160, 36 ), ( 320, 200, 27 ), ( 320, 240, 18 ), ( 320, 280, 9 ),
( 360, 0, 81 ), ( 360, 40, 72 ), ( 360, 80, 63 ), ( 360, 120, 54 ), ( 360, 160, 45 ), ( 360, 200, 36 ), ( 360, 240, 27 ), ( 360, 280, 18 ), ( 360, 320, 9 ),
( 400, 0, 90 ), ( 400, 40, 81 ), ( 400, 80, 72 ), ( 400, 120, 63 ), ( 400, 160, 54 ), ( 400, 200, 45 ), ( 400, 240, 36 ), ( 400, 280, 27 ), ( 400, 320, 18 ), ( 400, 360, 9 ),
( 440, 0, 99 ), ( 440, 40, 90 ), ( 440, 80, 81 ), ( 440, 120, 72 ), ( 440, 160, 63 ), ( 440, 200, 54 ), ( 440, 240, 45 ), ( 440, 280, 36 ), ( 440, 320, 27 ), ( 440, 360, 18 ), ( 440, 400, 9 ),
( 480, 0, 108 ), ( 480, 40, 99 ), ( 480, 80, 90 ), ( 480, 120, 81 ), ( 480, 160, 72 ), ( 480, 200, 63 ), ( 480, 240, 54 ), ( 480, 280, 45 ), ( 480, 320, 36 ), ( 480, 360, 27 ), ( 480, 400, 18 ), ( 480, 440, 9 ),
( 520, 0, 117 ), ( 520, 40, 108 ), ( 520, 80, 99 ), ( 520, 120, 90 ), ( 520, 160, 81 ), ( 520, 200, 72 ), ( 520, 240, 63 ), ( 520, 280, 54 ), ( 520, 320, 45 ), ( 520, 360, 36 ), ( 520, 400, 27 ), ( 520, 440, 18 ), ( 520, 480, 9 ),
( 560, 0, 126 ), ( 560, 40, 117 ), ( 560, 80, 108 ), ( 560, 120, 99 ), ( 560, 160, 90 ), ( 560, 200, 81 ), ( 560, 240, 72 ), ( 560, 280, 63 ), ( 560, 320, 54 ), ( 560, 360, 45 ), ( 560, 400, 36 ), ( 560, 440, 27 ), ( 560, 480, 18 ), ( 560, 520, 9 ),
...
}
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 "}"