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.
( 98, 0, 40 ), ( 98, 49, 20 ),
( 147, 0, 60 ), ( 147, 49, 40 ), ( 147, 98, 20 ),
( 196, 0, 80 ), ( 196, 49, 60 ), ( 196, 98, 40 ), ( 196, 147, 20 ),
( 245, 0, 100 ), ( 245, 49, 80 ), ( 245, 98, 60 ), ( 245, 147, 40 ), ( 245, 196, 20 ),
( 294, 0, 120 ), ( 294, 49, 100 ), ( 294, 98, 80 ), ( 294, 147, 60 ), ( 294, 196, 40 ), ( 294, 245, 20 ),
( 343, 0, 140 ), ( 343, 49, 120 ), ( 343, 98, 100 ), ( 343, 147, 80 ), ( 343, 196, 60 ), ( 343, 245, 40 ), ( 343, 294, 20 ),
( 392, 0, 160 ), ( 392, 49, 140 ), ( 392, 98, 120 ), ( 392, 147, 100 ), ( 392, 196, 80 ), ( 392, 245, 60 ), ( 392, 294, 40 ), ( 392, 343, 20 ),
( 441, 0, 180 ), ( 441, 49, 160 ), ( 441, 98, 140 ), ( 441, 147, 120 ), ( 441, 196, 100 ), ( 441, 245, 80 ), ( 441, 294, 60 ), ( 441, 343, 40 ), ( 441, 392, 20 ),
( 490, 0, 200 ), ( 490, 49, 180 ), ( 490, 98, 160 ), ( 490, 147, 140 ), ( 490, 196, 120 ), ( 490, 245, 100 ), ( 490, 294, 80 ), ( 490, 343, 60 ), ( 490, 392, 40 ), ( 490, 441, 20 ),
( 539, 0, 220 ), ( 539, 49, 200 ), ( 539, 98, 180 ), ( 539, 147, 160 ), ( 539, 196, 140 ), ( 539, 245, 120 ), ( 539, 294, 100 ), ( 539, 343, 80 ), ( 539, 392, 60 ), ( 539, 441, 40 ), ( 539, 490, 20 ),
( 588, 0, 240 ), ( 588, 49, 220 ), ( 588, 98, 200 ), ( 588, 147, 180 ), ( 588, 196, 160 ), ( 588, 245, 140 ), ( 588, 294, 120 ), ( 588, 343, 100 ), ( 588, 392, 80 ), ( 588, 441, 60 ), ( 588, 490, 40 ), ( 588, 539, 20 ),
( 637, 0, 260 ), ( 637, 49, 240 ), ( 637, 98, 220 ), ( 637, 147, 200 ), ( 637, 196, 180 ), ( 637, 245, 160 ), ( 637, 294, 140 ), ( 637, 343, 120 ), ( 637, 392, 100 ), ( 637, 441, 80 ), ( 637, 490, 60 ), ( 637, 539, 40 ), ( 637, 588, 20 ),
( 686, 0, 280 ), ( 686, 49, 260 ), ( 686, 98, 240 ), ( 686, 147, 220 ), ( 686, 196, 200 ), ( 686, 245, 180 ), ( 686, 294, 160 ), ( 686, 343, 140 ), ( 686, 392, 120 ), ( 686, 441, 100 ), ( 686, 490, 80 ), ( 686, 539, 60 ), ( 686, 588, 40 ), ( 686, 637, 20 ),
...
}
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 "}"