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, 6 ), ( 57, 19, 4 ), ( 57, 38, 2 ),
( 76, 0, 8 ), ( 76, 19, 6 ), ( 76, 38, 4 ), ( 76, 57, 2 ),
( 95, 0, 10 ), ( 95, 19, 8 ), ( 95, 38, 6 ), ( 95, 57, 4 ), ( 95, 76, 2 ),
( 114, 0, 12 ), ( 114, 19, 10 ), ( 114, 38, 8 ), ( 114, 57, 6 ), ( 114, 76, 4 ), ( 114, 95, 2 ),
( 133, 0, 14 ), ( 133, 19, 12 ), ( 133, 38, 10 ), ( 133, 57, 8 ), ( 133, 76, 6 ), ( 133, 95, 4 ), ( 133, 114, 2 ),
( 152, 0, 16 ), ( 152, 19, 14 ), ( 152, 38, 12 ), ( 152, 57, 10 ), ( 152, 76, 8 ), ( 152, 95, 6 ), ( 152, 114, 4 ), ( 152, 133, 2 ),
( 171, 0, 18 ), ( 171, 19, 16 ), ( 171, 38, 14 ), ( 171, 57, 12 ), ( 171, 76, 10 ), ( 171, 95, 8 ), ( 171, 114, 6 ), ( 171, 133, 4 ), ( 171, 152, 2 ),
( 190, 0, 20 ), ( 190, 19, 18 ), ( 190, 38, 16 ), ( 190, 57, 14 ), ( 190, 76, 12 ), ( 190, 95, 10 ), ( 190, 114, 8 ), ( 190, 133, 6 ), ( 190, 152, 4 ), ( 190, 171, 2 ),
( 209, 0, 22 ), ( 209, 19, 20 ), ( 209, 38, 18 ), ( 209, 57, 16 ), ( 209, 76, 14 ), ( 209, 95, 12 ), ( 209, 114, 10 ), ( 209, 133, 8 ), ( 209, 152, 6 ), ( 209, 171, 4 ), ( 209, 190, 2 ),
( 228, 0, 24 ), ( 228, 19, 22 ), ( 228, 38, 20 ), ( 228, 57, 18 ), ( 228, 76, 16 ), ( 228, 95, 14 ), ( 228, 114, 12 ), ( 228, 133, 10 ), ( 228, 152, 8 ), ( 228, 171, 6 ), ( 228, 190, 4 ), ( 228, 209, 2 ),
( 247, 0, 26 ), ( 247, 19, 24 ), ( 247, 38, 22 ), ( 247, 57, 20 ), ( 247, 76, 18 ), ( 247, 95, 16 ), ( 247, 114, 14 ), ( 247, 133, 12 ), ( 247, 152, 10 ), ( 247, 171, 8 ), ( 247, 190, 6 ), ( 247, 209, 4 ), ( 247, 228, 2 ),
( 266, 0, 28 ), ( 266, 19, 26 ), ( 266, 38, 24 ), ( 266, 57, 22 ), ( 266, 76, 20 ), ( 266, 95, 18 ), ( 266, 114, 16 ), ( 266, 133, 14 ), ( 266, 152, 12 ), ( 266, 171, 10 ), ( 266, 190, 8 ), ( 266, 209, 6 ), ( 266, 228, 4 ), ( 266, 247, 2 ),
...
}
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 "}"