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.
( 60, 0, 3 ), ( 60, 20, 2 ), ( 60, 40, 1 ),
( 80, 0, 4 ), ( 80, 20, 3 ), ( 80, 40, 2 ), ( 80, 60, 1 ),
( 100, 0, 5 ), ( 100, 20, 4 ), ( 100, 40, 3 ), ( 100, 60, 2 ), ( 100, 80, 1 ),
( 120, 0, 6 ), ( 120, 20, 5 ), ( 120, 40, 4 ), ( 120, 60, 3 ), ( 120, 80, 2 ), ( 120, 100, 1 ),
( 140, 0, 7 ), ( 140, 20, 6 ), ( 140, 40, 5 ), ( 140, 60, 4 ), ( 140, 80, 3 ), ( 140, 100, 2 ), ( 140, 120, 1 ),
( 160, 0, 8 ), ( 160, 20, 7 ), ( 160, 40, 6 ), ( 160, 60, 5 ), ( 160, 80, 4 ), ( 160, 100, 3 ), ( 160, 120, 2 ), ( 160, 140, 1 ),
( 180, 0, 9 ), ( 180, 20, 8 ), ( 180, 40, 7 ), ( 180, 60, 6 ), ( 180, 80, 5 ), ( 180, 100, 4 ), ( 180, 120, 3 ), ( 180, 140, 2 ), ( 180, 160, 1 ),
( 200, 0, 10 ), ( 200, 20, 9 ), ( 200, 40, 8 ), ( 200, 60, 7 ), ( 200, 80, 6 ), ( 200, 100, 5 ), ( 200, 120, 4 ), ( 200, 140, 3 ), ( 200, 160, 2 ), ( 200, 180, 1 ),
( 220, 0, 11 ), ( 220, 20, 10 ), ( 220, 40, 9 ), ( 220, 60, 8 ), ( 220, 80, 7 ), ( 220, 100, 6 ), ( 220, 120, 5 ), ( 220, 140, 4 ), ( 220, 160, 3 ), ( 220, 180, 2 ), ( 220, 200, 1 ),
( 240, 0, 12 ), ( 240, 20, 11 ), ( 240, 40, 10 ), ( 240, 60, 9 ), ( 240, 80, 8 ), ( 240, 100, 7 ), ( 240, 120, 6 ), ( 240, 140, 5 ), ( 240, 160, 4 ), ( 240, 180, 3 ), ( 240, 200, 2 ), ( 240, 220, 1 ),
( 260, 0, 13 ), ( 260, 20, 12 ), ( 260, 40, 11 ), ( 260, 60, 10 ), ( 260, 80, 9 ), ( 260, 100, 8 ), ( 260, 120, 7 ), ( 260, 140, 6 ), ( 260, 160, 5 ), ( 260, 180, 4 ), ( 260, 200, 3 ), ( 260, 220, 2 ), ( 260, 240, 1 ),
( 280, 0, 14 ), ( 280, 20, 13 ), ( 280, 40, 12 ), ( 280, 60, 11 ), ( 280, 80, 10 ), ( 280, 100, 9 ), ( 280, 120, 8 ), ( 280, 140, 7 ), ( 280, 160, 6 ), ( 280, 180, 5 ), ( 280, 200, 4 ), ( 280, 220, 3 ), ( 280, 240, 2 ), ( 280, 260, 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 "}"