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.
( 108, 0, 21 ), ( 108, 36, 14 ), ( 108, 72, 7 ),
( 144, 0, 28 ), ( 144, 36, 21 ), ( 144, 72, 14 ), ( 144, 108, 7 ),
( 180, 0, 35 ), ( 180, 36, 28 ), ( 180, 72, 21 ), ( 180, 108, 14 ), ( 180, 144, 7 ),
( 216, 0, 42 ), ( 216, 36, 35 ), ( 216, 72, 28 ), ( 216, 108, 21 ), ( 216, 144, 14 ), ( 216, 180, 7 ),
( 252, 0, 49 ), ( 252, 36, 42 ), ( 252, 72, 35 ), ( 252, 108, 28 ), ( 252, 144, 21 ), ( 252, 180, 14 ), ( 252, 216, 7 ),
( 288, 0, 56 ), ( 288, 36, 49 ), ( 288, 72, 42 ), ( 288, 108, 35 ), ( 288, 144, 28 ), ( 288, 180, 21 ), ( 288, 216, 14 ), ( 288, 252, 7 ),
( 324, 0, 63 ), ( 324, 36, 56 ), ( 324, 72, 49 ), ( 324, 108, 42 ), ( 324, 144, 35 ), ( 324, 180, 28 ), ( 324, 216, 21 ), ( 324, 252, 14 ), ( 324, 288, 7 ),
( 360, 0, 70 ), ( 360, 36, 63 ), ( 360, 72, 56 ), ( 360, 108, 49 ), ( 360, 144, 42 ), ( 360, 180, 35 ), ( 360, 216, 28 ), ( 360, 252, 21 ), ( 360, 288, 14 ), ( 360, 324, 7 ),
( 396, 0, 77 ), ( 396, 36, 70 ), ( 396, 72, 63 ), ( 396, 108, 56 ), ( 396, 144, 49 ), ( 396, 180, 42 ), ( 396, 216, 35 ), ( 396, 252, 28 ), ( 396, 288, 21 ), ( 396, 324, 14 ), ( 396, 360, 7 ),
( 432, 0, 84 ), ( 432, 36, 77 ), ( 432, 72, 70 ), ( 432, 108, 63 ), ( 432, 144, 56 ), ( 432, 180, 49 ), ( 432, 216, 42 ), ( 432, 252, 35 ), ( 432, 288, 28 ), ( 432, 324, 21 ), ( 432, 360, 14 ), ( 432, 396, 7 ),
( 468, 0, 91 ), ( 468, 36, 84 ), ( 468, 72, 77 ), ( 468, 108, 70 ), ( 468, 144, 63 ), ( 468, 180, 56 ), ( 468, 216, 49 ), ( 468, 252, 42 ), ( 468, 288, 35 ), ( 468, 324, 28 ), ( 468, 360, 21 ), ( 468, 396, 14 ), ( 468, 432, 7 ),
( 504, 0, 98 ), ( 504, 36, 91 ), ( 504, 72, 84 ), ( 504, 108, 77 ), ( 504, 144, 70 ), ( 504, 180, 63 ), ( 504, 216, 56 ), ( 504, 252, 49 ), ( 504, 288, 42 ), ( 504, 324, 35 ), ( 504, 360, 28 ), ( 504, 396, 21 ), ( 504, 432, 14 ), ( 504, 468, 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 "}"