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.
( 57, 0, 27 ), ( 57, 19, 18 ), ( 57, 38, 9 ),
( 76, 0, 36 ), ( 76, 19, 27 ), ( 76, 38, 18 ), ( 76, 57, 9 ),
( 95, 0, 45 ), ( 95, 19, 36 ), ( 95, 38, 27 ), ( 95, 57, 18 ), ( 95, 76, 9 ),
( 114, 0, 54 ), ( 114, 19, 45 ), ( 114, 38, 36 ), ( 114, 57, 27 ), ( 114, 76, 18 ), ( 114, 95, 9 ),
( 133, 0, 63 ), ( 133, 19, 54 ), ( 133, 38, 45 ), ( 133, 57, 36 ), ( 133, 76, 27 ), ( 133, 95, 18 ), ( 133, 114, 9 ),
( 152, 0, 72 ), ( 152, 19, 63 ), ( 152, 38, 54 ), ( 152, 57, 45 ), ( 152, 76, 36 ), ( 152, 95, 27 ), ( 152, 114, 18 ), ( 152, 133, 9 ),
( 171, 0, 81 ), ( 171, 19, 72 ), ( 171, 38, 63 ), ( 171, 57, 54 ), ( 171, 76, 45 ), ( 171, 95, 36 ), ( 171, 114, 27 ), ( 171, 133, 18 ), ( 171, 152, 9 ),
( 190, 0, 90 ), ( 190, 19, 81 ), ( 190, 38, 72 ), ( 190, 57, 63 ), ( 190, 76, 54 ), ( 190, 95, 45 ), ( 190, 114, 36 ), ( 190, 133, 27 ), ( 190, 152, 18 ), ( 190, 171, 9 ),
( 209, 0, 99 ), ( 209, 19, 90 ), ( 209, 38, 81 ), ( 209, 57, 72 ), ( 209, 76, 63 ), ( 209, 95, 54 ), ( 209, 114, 45 ), ( 209, 133, 36 ), ( 209, 152, 27 ), ( 209, 171, 18 ), ( 209, 190, 9 ),
( 228, 0, 108 ), ( 228, 19, 99 ), ( 228, 38, 90 ), ( 228, 57, 81 ), ( 228, 76, 72 ), ( 228, 95, 63 ), ( 228, 114, 54 ), ( 228, 133, 45 ), ( 228, 152, 36 ), ( 228, 171, 27 ), ( 228, 190, 18 ), ( 228, 209, 9 ),
( 247, 0, 117 ), ( 247, 19, 108 ), ( 247, 38, 99 ), ( 247, 57, 90 ), ( 247, 76, 81 ), ( 247, 95, 72 ), ( 247, 114, 63 ), ( 247, 133, 54 ), ( 247, 152, 45 ), ( 247, 171, 36 ), ( 247, 190, 27 ), ( 247, 209, 18 ), ( 247, 228, 9 ),
( 266, 0, 126 ), ( 266, 19, 117 ), ( 266, 38, 108 ), ( 266, 57, 99 ), ( 266, 76, 90 ), ( 266, 95, 81 ), ( 266, 114, 72 ), ( 266, 133, 63 ), ( 266, 152, 54 ), ( 266, 171, 45 ), ( 266, 190, 36 ), ( 266, 209, 27 ), ( 266, 228, 18 ), ( 266, 247, 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 "}"