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.
( 117, 0, 12 ), ( 117, 39, 8 ), ( 117, 78, 4 ),
( 156, 0, 16 ), ( 156, 39, 12 ), ( 156, 78, 8 ), ( 156, 117, 4 ),
( 195, 0, 20 ), ( 195, 39, 16 ), ( 195, 78, 12 ), ( 195, 117, 8 ), ( 195, 156, 4 ),
( 234, 0, 24 ), ( 234, 39, 20 ), ( 234, 78, 16 ), ( 234, 117, 12 ), ( 234, 156, 8 ), ( 234, 195, 4 ),
( 273, 0, 28 ), ( 273, 39, 24 ), ( 273, 78, 20 ), ( 273, 117, 16 ), ( 273, 156, 12 ), ( 273, 195, 8 ), ( 273, 234, 4 ),
( 312, 0, 32 ), ( 312, 39, 28 ), ( 312, 78, 24 ), ( 312, 117, 20 ), ( 312, 156, 16 ), ( 312, 195, 12 ), ( 312, 234, 8 ), ( 312, 273, 4 ),
( 351, 0, 36 ), ( 351, 39, 32 ), ( 351, 78, 28 ), ( 351, 117, 24 ), ( 351, 156, 20 ), ( 351, 195, 16 ), ( 351, 234, 12 ), ( 351, 273, 8 ), ( 351, 312, 4 ),
( 390, 0, 40 ), ( 390, 39, 36 ), ( 390, 78, 32 ), ( 390, 117, 28 ), ( 390, 156, 24 ), ( 390, 195, 20 ), ( 390, 234, 16 ), ( 390, 273, 12 ), ( 390, 312, 8 ), ( 390, 351, 4 ),
( 429, 0, 44 ), ( 429, 39, 40 ), ( 429, 78, 36 ), ( 429, 117, 32 ), ( 429, 156, 28 ), ( 429, 195, 24 ), ( 429, 234, 20 ), ( 429, 273, 16 ), ( 429, 312, 12 ), ( 429, 351, 8 ), ( 429, 390, 4 ),
( 468, 0, 48 ), ( 468, 39, 44 ), ( 468, 78, 40 ), ( 468, 117, 36 ), ( 468, 156, 32 ), ( 468, 195, 28 ), ( 468, 234, 24 ), ( 468, 273, 20 ), ( 468, 312, 16 ), ( 468, 351, 12 ), ( 468, 390, 8 ), ( 468, 429, 4 ),
( 507, 0, 52 ), ( 507, 39, 48 ), ( 507, 78, 44 ), ( 507, 117, 40 ), ( 507, 156, 36 ), ( 507, 195, 32 ), ( 507, 234, 28 ), ( 507, 273, 24 ), ( 507, 312, 20 ), ( 507, 351, 16 ), ( 507, 390, 12 ), ( 507, 429, 8 ), ( 507, 468, 4 ),
( 546, 0, 56 ), ( 546, 39, 52 ), ( 546, 78, 48 ), ( 546, 117, 44 ), ( 546, 156, 40 ), ( 546, 195, 36 ), ( 546, 234, 32 ), ( 546, 273, 28 ), ( 546, 312, 24 ), ( 546, 351, 20 ), ( 546, 390, 16 ), ( 546, 429, 12 ), ( 546, 468, 8 ), ( 546, 507, 4 ),
...
}
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 "}"