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.
( 72, 0, 22 ), ( 72, 36, 11 ),
( 108, 0, 33 ), ( 108, 36, 22 ), ( 108, 72, 11 ),
( 144, 0, 44 ), ( 144, 36, 33 ), ( 144, 72, 22 ), ( 144, 108, 11 ),
( 180, 0, 55 ), ( 180, 36, 44 ), ( 180, 72, 33 ), ( 180, 108, 22 ), ( 180, 144, 11 ),
( 216, 0, 66 ), ( 216, 36, 55 ), ( 216, 72, 44 ), ( 216, 108, 33 ), ( 216, 144, 22 ), ( 216, 180, 11 ),
( 252, 0, 77 ), ( 252, 36, 66 ), ( 252, 72, 55 ), ( 252, 108, 44 ), ( 252, 144, 33 ), ( 252, 180, 22 ), ( 252, 216, 11 ),
( 288, 0, 88 ), ( 288, 36, 77 ), ( 288, 72, 66 ), ( 288, 108, 55 ), ( 288, 144, 44 ), ( 288, 180, 33 ), ( 288, 216, 22 ), ( 288, 252, 11 ),
( 324, 0, 99 ), ( 324, 36, 88 ), ( 324, 72, 77 ), ( 324, 108, 66 ), ( 324, 144, 55 ), ( 324, 180, 44 ), ( 324, 216, 33 ), ( 324, 252, 22 ), ( 324, 288, 11 ),
( 360, 0, 110 ), ( 360, 36, 99 ), ( 360, 72, 88 ), ( 360, 108, 77 ), ( 360, 144, 66 ), ( 360, 180, 55 ), ( 360, 216, 44 ), ( 360, 252, 33 ), ( 360, 288, 22 ), ( 360, 324, 11 ),
( 396, 0, 121 ), ( 396, 36, 110 ), ( 396, 72, 99 ), ( 396, 108, 88 ), ( 396, 144, 77 ), ( 396, 180, 66 ), ( 396, 216, 55 ), ( 396, 252, 44 ), ( 396, 288, 33 ), ( 396, 324, 22 ), ( 396, 360, 11 ),
( 432, 0, 132 ), ( 432, 36, 121 ), ( 432, 72, 110 ), ( 432, 108, 99 ), ( 432, 144, 88 ), ( 432, 180, 77 ), ( 432, 216, 66 ), ( 432, 252, 55 ), ( 432, 288, 44 ), ( 432, 324, 33 ), ( 432, 360, 22 ), ( 432, 396, 11 ),
( 468, 0, 143 ), ( 468, 36, 132 ), ( 468, 72, 121 ), ( 468, 108, 110 ), ( 468, 144, 99 ), ( 468, 180, 88 ), ( 468, 216, 77 ), ( 468, 252, 66 ), ( 468, 288, 55 ), ( 468, 324, 44 ), ( 468, 360, 33 ), ( 468, 396, 22 ), ( 468, 432, 11 ),
( 504, 0, 154 ), ( 504, 36, 143 ), ( 504, 72, 132 ), ( 504, 108, 121 ), ( 504, 144, 110 ), ( 504, 180, 99 ), ( 504, 216, 88 ), ( 504, 252, 77 ), ( 504, 288, 66 ), ( 504, 324, 55 ), ( 504, 360, 44 ), ( 504, 396, 33 ), ( 504, 432, 22 ), ( 504, 468, 11 ),
...
}
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 "}"