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.
( 69, 0, 21 ), ( 69, 23, 14 ), ( 69, 46, 7 ),
( 92, 0, 28 ), ( 92, 23, 21 ), ( 92, 46, 14 ), ( 92, 69, 7 ),
( 115, 0, 35 ), ( 115, 23, 28 ), ( 115, 46, 21 ), ( 115, 69, 14 ), ( 115, 92, 7 ),
( 138, 0, 42 ), ( 138, 23, 35 ), ( 138, 46, 28 ), ( 138, 69, 21 ), ( 138, 92, 14 ), ( 138, 115, 7 ),
( 161, 0, 49 ), ( 161, 23, 42 ), ( 161, 46, 35 ), ( 161, 69, 28 ), ( 161, 92, 21 ), ( 161, 115, 14 ), ( 161, 138, 7 ),
( 184, 0, 56 ), ( 184, 23, 49 ), ( 184, 46, 42 ), ( 184, 69, 35 ), ( 184, 92, 28 ), ( 184, 115, 21 ), ( 184, 138, 14 ), ( 184, 161, 7 ),
( 207, 0, 63 ), ( 207, 23, 56 ), ( 207, 46, 49 ), ( 207, 69, 42 ), ( 207, 92, 35 ), ( 207, 115, 28 ), ( 207, 138, 21 ), ( 207, 161, 14 ), ( 207, 184, 7 ),
( 230, 0, 70 ), ( 230, 23, 63 ), ( 230, 46, 56 ), ( 230, 69, 49 ), ( 230, 92, 42 ), ( 230, 115, 35 ), ( 230, 138, 28 ), ( 230, 161, 21 ), ( 230, 184, 14 ), ( 230, 207, 7 ),
( 253, 0, 77 ), ( 253, 23, 70 ), ( 253, 46, 63 ), ( 253, 69, 56 ), ( 253, 92, 49 ), ( 253, 115, 42 ), ( 253, 138, 35 ), ( 253, 161, 28 ), ( 253, 184, 21 ), ( 253, 207, 14 ), ( 253, 230, 7 ),
( 276, 0, 84 ), ( 276, 23, 77 ), ( 276, 46, 70 ), ( 276, 69, 63 ), ( 276, 92, 56 ), ( 276, 115, 49 ), ( 276, 138, 42 ), ( 276, 161, 35 ), ( 276, 184, 28 ), ( 276, 207, 21 ), ( 276, 230, 14 ), ( 276, 253, 7 ),
( 299, 0, 91 ), ( 299, 23, 84 ), ( 299, 46, 77 ), ( 299, 69, 70 ), ( 299, 92, 63 ), ( 299, 115, 56 ), ( 299, 138, 49 ), ( 299, 161, 42 ), ( 299, 184, 35 ), ( 299, 207, 28 ), ( 299, 230, 21 ), ( 299, 253, 14 ), ( 299, 276, 7 ),
( 322, 0, 98 ), ( 322, 23, 91 ), ( 322, 46, 84 ), ( 322, 69, 77 ), ( 322, 92, 70 ), ( 322, 115, 63 ), ( 322, 138, 56 ), ( 322, 161, 49 ), ( 322, 184, 42 ), ( 322, 207, 35 ), ( 322, 230, 28 ), ( 322, 253, 21 ), ( 322, 276, 14 ), ( 322, 299, 7 ),
...
}
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 "}"