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, 3 ), ( 120, 40, 2 ), ( 120, 80, 1 ),
( 160, 0, 4 ), ( 160, 40, 3 ), ( 160, 80, 2 ), ( 160, 120, 1 ),
( 200, 0, 5 ), ( 200, 40, 4 ), ( 200, 80, 3 ), ( 200, 120, 2 ), ( 200, 160, 1 ),
( 240, 0, 6 ), ( 240, 40, 5 ), ( 240, 80, 4 ), ( 240, 120, 3 ), ( 240, 160, 2 ), ( 240, 200, 1 ),
( 280, 0, 7 ), ( 280, 40, 6 ), ( 280, 80, 5 ), ( 280, 120, 4 ), ( 280, 160, 3 ), ( 280, 200, 2 ), ( 280, 240, 1 ),
( 320, 0, 8 ), ( 320, 40, 7 ), ( 320, 80, 6 ), ( 320, 120, 5 ), ( 320, 160, 4 ), ( 320, 200, 3 ), ( 320, 240, 2 ), ( 320, 280, 1 ),
( 360, 0, 9 ), ( 360, 40, 8 ), ( 360, 80, 7 ), ( 360, 120, 6 ), ( 360, 160, 5 ), ( 360, 200, 4 ), ( 360, 240, 3 ), ( 360, 280, 2 ), ( 360, 320, 1 ),
( 400, 0, 10 ), ( 400, 40, 9 ), ( 400, 80, 8 ), ( 400, 120, 7 ), ( 400, 160, 6 ), ( 400, 200, 5 ), ( 400, 240, 4 ), ( 400, 280, 3 ), ( 400, 320, 2 ), ( 400, 360, 1 ),
( 440, 0, 11 ), ( 440, 40, 10 ), ( 440, 80, 9 ), ( 440, 120, 8 ), ( 440, 160, 7 ), ( 440, 200, 6 ), ( 440, 240, 5 ), ( 440, 280, 4 ), ( 440, 320, 3 ), ( 440, 360, 2 ), ( 440, 400, 1 ),
( 480, 0, 12 ), ( 480, 40, 11 ), ( 480, 80, 10 ), ( 480, 120, 9 ), ( 480, 160, 8 ), ( 480, 200, 7 ), ( 480, 240, 6 ), ( 480, 280, 5 ), ( 480, 320, 4 ), ( 480, 360, 3 ), ( 480, 400, 2 ), ( 480, 440, 1 ),
( 520, 0, 13 ), ( 520, 40, 12 ), ( 520, 80, 11 ), ( 520, 120, 10 ), ( 520, 160, 9 ), ( 520, 200, 8 ), ( 520, 240, 7 ), ( 520, 280, 6 ), ( 520, 320, 5 ), ( 520, 360, 4 ), ( 520, 400, 3 ), ( 520, 440, 2 ), ( 520, 480, 1 ),
( 560, 0, 14 ), ( 560, 40, 13 ), ( 560, 80, 12 ), ( 560, 120, 11 ), ( 560, 160, 10 ), ( 560, 200, 9 ), ( 560, 240, 8 ), ( 560, 280, 7 ), ( 560, 320, 6 ), ( 560, 360, 5 ), ( 560, 400, 4 ), ( 560, 440, 3 ), ( 560, 480, 2 ), ( 560, 520, 1 ),
...
}
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 "}"