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.
( 51, 0, 9 ), ( 51, 17, 6 ), ( 51, 34, 3 ),
( 68, 0, 12 ), ( 68, 17, 9 ), ( 68, 34, 6 ), ( 68, 51, 3 ),
( 85, 0, 15 ), ( 85, 17, 12 ), ( 85, 34, 9 ), ( 85, 51, 6 ), ( 85, 68, 3 ),
( 102, 0, 18 ), ( 102, 17, 15 ), ( 102, 34, 12 ), ( 102, 51, 9 ), ( 102, 68, 6 ), ( 102, 85, 3 ),
( 119, 0, 21 ), ( 119, 17, 18 ), ( 119, 34, 15 ), ( 119, 51, 12 ), ( 119, 68, 9 ), ( 119, 85, 6 ), ( 119, 102, 3 ),
( 136, 0, 24 ), ( 136, 17, 21 ), ( 136, 34, 18 ), ( 136, 51, 15 ), ( 136, 68, 12 ), ( 136, 85, 9 ), ( 136, 102, 6 ), ( 136, 119, 3 ),
( 153, 0, 27 ), ( 153, 17, 24 ), ( 153, 34, 21 ), ( 153, 51, 18 ), ( 153, 68, 15 ), ( 153, 85, 12 ), ( 153, 102, 9 ), ( 153, 119, 6 ), ( 153, 136, 3 ),
( 170, 0, 30 ), ( 170, 17, 27 ), ( 170, 34, 24 ), ( 170, 51, 21 ), ( 170, 68, 18 ), ( 170, 85, 15 ), ( 170, 102, 12 ), ( 170, 119, 9 ), ( 170, 136, 6 ), ( 170, 153, 3 ),
( 187, 0, 33 ), ( 187, 17, 30 ), ( 187, 34, 27 ), ( 187, 51, 24 ), ( 187, 68, 21 ), ( 187, 85, 18 ), ( 187, 102, 15 ), ( 187, 119, 12 ), ( 187, 136, 9 ), ( 187, 153, 6 ), ( 187, 170, 3 ),
( 204, 0, 36 ), ( 204, 17, 33 ), ( 204, 34, 30 ), ( 204, 51, 27 ), ( 204, 68, 24 ), ( 204, 85, 21 ), ( 204, 102, 18 ), ( 204, 119, 15 ), ( 204, 136, 12 ), ( 204, 153, 9 ), ( 204, 170, 6 ), ( 204, 187, 3 ),
( 221, 0, 39 ), ( 221, 17, 36 ), ( 221, 34, 33 ), ( 221, 51, 30 ), ( 221, 68, 27 ), ( 221, 85, 24 ), ( 221, 102, 21 ), ( 221, 119, 18 ), ( 221, 136, 15 ), ( 221, 153, 12 ), ( 221, 170, 9 ), ( 221, 187, 6 ), ( 221, 204, 3 ),
( 238, 0, 42 ), ( 238, 17, 39 ), ( 238, 34, 36 ), ( 238, 51, 33 ), ( 238, 68, 30 ), ( 238, 85, 27 ), ( 238, 102, 24 ), ( 238, 119, 21 ), ( 238, 136, 18 ), ( 238, 153, 15 ), ( 238, 170, 12 ), ( 238, 187, 9 ), ( 238, 204, 6 ), ( 238, 221, 3 ),
...
}
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 "}"