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.
( 74, 0, 28 ), ( 74, 37, 14 ),
( 111, 0, 42 ), ( 111, 37, 28 ), ( 111, 74, 14 ),
( 148, 0, 56 ), ( 148, 37, 42 ), ( 148, 74, 28 ), ( 148, 111, 14 ),
( 185, 0, 70 ), ( 185, 37, 56 ), ( 185, 74, 42 ), ( 185, 111, 28 ), ( 185, 148, 14 ),
( 222, 0, 84 ), ( 222, 37, 70 ), ( 222, 74, 56 ), ( 222, 111, 42 ), ( 222, 148, 28 ), ( 222, 185, 14 ),
( 259, 0, 98 ), ( 259, 37, 84 ), ( 259, 74, 70 ), ( 259, 111, 56 ), ( 259, 148, 42 ), ( 259, 185, 28 ), ( 259, 222, 14 ),
( 296, 0, 112 ), ( 296, 37, 98 ), ( 296, 74, 84 ), ( 296, 111, 70 ), ( 296, 148, 56 ), ( 296, 185, 42 ), ( 296, 222, 28 ), ( 296, 259, 14 ),
( 333, 0, 126 ), ( 333, 37, 112 ), ( 333, 74, 98 ), ( 333, 111, 84 ), ( 333, 148, 70 ), ( 333, 185, 56 ), ( 333, 222, 42 ), ( 333, 259, 28 ), ( 333, 296, 14 ),
( 370, 0, 140 ), ( 370, 37, 126 ), ( 370, 74, 112 ), ( 370, 111, 98 ), ( 370, 148, 84 ), ( 370, 185, 70 ), ( 370, 222, 56 ), ( 370, 259, 42 ), ( 370, 296, 28 ), ( 370, 333, 14 ),
( 407, 0, 154 ), ( 407, 37, 140 ), ( 407, 74, 126 ), ( 407, 111, 112 ), ( 407, 148, 98 ), ( 407, 185, 84 ), ( 407, 222, 70 ), ( 407, 259, 56 ), ( 407, 296, 42 ), ( 407, 333, 28 ), ( 407, 370, 14 ),
( 444, 0, 168 ), ( 444, 37, 154 ), ( 444, 74, 140 ), ( 444, 111, 126 ), ( 444, 148, 112 ), ( 444, 185, 98 ), ( 444, 222, 84 ), ( 444, 259, 70 ), ( 444, 296, 56 ), ( 444, 333, 42 ), ( 444, 370, 28 ), ( 444, 407, 14 ),
( 481, 0, 182 ), ( 481, 37, 168 ), ( 481, 74, 154 ), ( 481, 111, 140 ), ( 481, 148, 126 ), ( 481, 185, 112 ), ( 481, 222, 98 ), ( 481, 259, 84 ), ( 481, 296, 70 ), ( 481, 333, 56 ), ( 481, 370, 42 ), ( 481, 407, 28 ), ( 481, 444, 14 ),
( 518, 0, 196 ), ( 518, 37, 182 ), ( 518, 74, 168 ), ( 518, 111, 154 ), ( 518, 148, 140 ), ( 518, 185, 126 ), ( 518, 222, 112 ), ( 518, 259, 98 ), ( 518, 296, 84 ), ( 518, 333, 70 ), ( 518, 370, 56 ), ( 518, 407, 42 ), ( 518, 444, 28 ), ( 518, 481, 14 ),
...
}
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 "}"