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.
( 84, 0, 3 ), ( 84, 28, 2 ), ( 84, 56, 1 ),
( 112, 0, 4 ), ( 112, 28, 3 ), ( 112, 56, 2 ), ( 112, 84, 1 ),
( 140, 0, 5 ), ( 140, 28, 4 ), ( 140, 56, 3 ), ( 140, 84, 2 ), ( 140, 112, 1 ),
( 168, 0, 6 ), ( 168, 28, 5 ), ( 168, 56, 4 ), ( 168, 84, 3 ), ( 168, 112, 2 ), ( 168, 140, 1 ),
( 196, 0, 7 ), ( 196, 28, 6 ), ( 196, 56, 5 ), ( 196, 84, 4 ), ( 196, 112, 3 ), ( 196, 140, 2 ), ( 196, 168, 1 ),
( 224, 0, 8 ), ( 224, 28, 7 ), ( 224, 56, 6 ), ( 224, 84, 5 ), ( 224, 112, 4 ), ( 224, 140, 3 ), ( 224, 168, 2 ), ( 224, 196, 1 ),
( 252, 0, 9 ), ( 252, 28, 8 ), ( 252, 56, 7 ), ( 252, 84, 6 ), ( 252, 112, 5 ), ( 252, 140, 4 ), ( 252, 168, 3 ), ( 252, 196, 2 ), ( 252, 224, 1 ),
( 280, 0, 10 ), ( 280, 28, 9 ), ( 280, 56, 8 ), ( 280, 84, 7 ), ( 280, 112, 6 ), ( 280, 140, 5 ), ( 280, 168, 4 ), ( 280, 196, 3 ), ( 280, 224, 2 ), ( 280, 252, 1 ),
( 308, 0, 11 ), ( 308, 28, 10 ), ( 308, 56, 9 ), ( 308, 84, 8 ), ( 308, 112, 7 ), ( 308, 140, 6 ), ( 308, 168, 5 ), ( 308, 196, 4 ), ( 308, 224, 3 ), ( 308, 252, 2 ), ( 308, 280, 1 ),
( 336, 0, 12 ), ( 336, 28, 11 ), ( 336, 56, 10 ), ( 336, 84, 9 ), ( 336, 112, 8 ), ( 336, 140, 7 ), ( 336, 168, 6 ), ( 336, 196, 5 ), ( 336, 224, 4 ), ( 336, 252, 3 ), ( 336, 280, 2 ), ( 336, 308, 1 ),
( 364, 0, 13 ), ( 364, 28, 12 ), ( 364, 56, 11 ), ( 364, 84, 10 ), ( 364, 112, 9 ), ( 364, 140, 8 ), ( 364, 168, 7 ), ( 364, 196, 6 ), ( 364, 224, 5 ), ( 364, 252, 4 ), ( 364, 280, 3 ), ( 364, 308, 2 ), ( 364, 336, 1 ),
( 392, 0, 14 ), ( 392, 28, 13 ), ( 392, 56, 12 ), ( 392, 84, 11 ), ( 392, 112, 10 ), ( 392, 140, 9 ), ( 392, 168, 8 ), ( 392, 196, 7 ), ( 392, 224, 6 ), ( 392, 252, 5 ), ( 392, 280, 4 ), ( 392, 308, 3 ), ( 392, 336, 2 ), ( 392, 364, 1 ),
...
}
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 "}"