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, 27 ), ( 60, 20, 18 ), ( 60, 40, 9 ),
( 80, 0, 36 ), ( 80, 20, 27 ), ( 80, 40, 18 ), ( 80, 60, 9 ),
( 100, 0, 45 ), ( 100, 20, 36 ), ( 100, 40, 27 ), ( 100, 60, 18 ), ( 100, 80, 9 ),
( 120, 0, 54 ), ( 120, 20, 45 ), ( 120, 40, 36 ), ( 120, 60, 27 ), ( 120, 80, 18 ), ( 120, 100, 9 ),
( 140, 0, 63 ), ( 140, 20, 54 ), ( 140, 40, 45 ), ( 140, 60, 36 ), ( 140, 80, 27 ), ( 140, 100, 18 ), ( 140, 120, 9 ),
( 160, 0, 72 ), ( 160, 20, 63 ), ( 160, 40, 54 ), ( 160, 60, 45 ), ( 160, 80, 36 ), ( 160, 100, 27 ), ( 160, 120, 18 ), ( 160, 140, 9 ),
( 180, 0, 81 ), ( 180, 20, 72 ), ( 180, 40, 63 ), ( 180, 60, 54 ), ( 180, 80, 45 ), ( 180, 100, 36 ), ( 180, 120, 27 ), ( 180, 140, 18 ), ( 180, 160, 9 ),
( 200, 0, 90 ), ( 200, 20, 81 ), ( 200, 40, 72 ), ( 200, 60, 63 ), ( 200, 80, 54 ), ( 200, 100, 45 ), ( 200, 120, 36 ), ( 200, 140, 27 ), ( 200, 160, 18 ), ( 200, 180, 9 ),
( 220, 0, 99 ), ( 220, 20, 90 ), ( 220, 40, 81 ), ( 220, 60, 72 ), ( 220, 80, 63 ), ( 220, 100, 54 ), ( 220, 120, 45 ), ( 220, 140, 36 ), ( 220, 160, 27 ), ( 220, 180, 18 ), ( 220, 200, 9 ),
( 240, 0, 108 ), ( 240, 20, 99 ), ( 240, 40, 90 ), ( 240, 60, 81 ), ( 240, 80, 72 ), ( 240, 100, 63 ), ( 240, 120, 54 ), ( 240, 140, 45 ), ( 240, 160, 36 ), ( 240, 180, 27 ), ( 240, 200, 18 ), ( 240, 220, 9 ),
( 260, 0, 117 ), ( 260, 20, 108 ), ( 260, 40, 99 ), ( 260, 60, 90 ), ( 260, 80, 81 ), ( 260, 100, 72 ), ( 260, 120, 63 ), ( 260, 140, 54 ), ( 260, 160, 45 ), ( 260, 180, 36 ), ( 260, 200, 27 ), ( 260, 220, 18 ), ( 260, 240, 9 ),
( 280, 0, 126 ), ( 280, 20, 117 ), ( 280, 40, 108 ), ( 280, 60, 99 ), ( 280, 80, 90 ), ( 280, 100, 81 ), ( 280, 120, 72 ), ( 280, 140, 63 ), ( 280, 160, 54 ), ( 280, 180, 45 ), ( 280, 200, 36 ), ( 280, 220, 27 ), ( 280, 240, 18 ), ( 280, 260, 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 "}"