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.
( 36, 0, 15 ), ( 36, 12, 10 ), ( 36, 24, 5 ),
( 48, 0, 20 ), ( 48, 12, 15 ), ( 48, 24, 10 ), ( 48, 36, 5 ),
( 60, 0, 25 ), ( 60, 12, 20 ), ( 60, 24, 15 ), ( 60, 36, 10 ), ( 60, 48, 5 ),
( 72, 0, 30 ), ( 72, 12, 25 ), ( 72, 24, 20 ), ( 72, 36, 15 ), ( 72, 48, 10 ), ( 72, 60, 5 ),
( 84, 0, 35 ), ( 84, 12, 30 ), ( 84, 24, 25 ), ( 84, 36, 20 ), ( 84, 48, 15 ), ( 84, 60, 10 ), ( 84, 72, 5 ),
( 96, 0, 40 ), ( 96, 12, 35 ), ( 96, 24, 30 ), ( 96, 36, 25 ), ( 96, 48, 20 ), ( 96, 60, 15 ), ( 96, 72, 10 ), ( 96, 84, 5 ),
( 108, 0, 45 ), ( 108, 12, 40 ), ( 108, 24, 35 ), ( 108, 36, 30 ), ( 108, 48, 25 ), ( 108, 60, 20 ), ( 108, 72, 15 ), ( 108, 84, 10 ), ( 108, 96, 5 ),
( 120, 0, 50 ), ( 120, 12, 45 ), ( 120, 24, 40 ), ( 120, 36, 35 ), ( 120, 48, 30 ), ( 120, 60, 25 ), ( 120, 72, 20 ), ( 120, 84, 15 ), ( 120, 96, 10 ), ( 120, 108, 5 ),
( 132, 0, 55 ), ( 132, 12, 50 ), ( 132, 24, 45 ), ( 132, 36, 40 ), ( 132, 48, 35 ), ( 132, 60, 30 ), ( 132, 72, 25 ), ( 132, 84, 20 ), ( 132, 96, 15 ), ( 132, 108, 10 ), ( 132, 120, 5 ),
( 144, 0, 60 ), ( 144, 12, 55 ), ( 144, 24, 50 ), ( 144, 36, 45 ), ( 144, 48, 40 ), ( 144, 60, 35 ), ( 144, 72, 30 ), ( 144, 84, 25 ), ( 144, 96, 20 ), ( 144, 108, 15 ), ( 144, 120, 10 ), ( 144, 132, 5 ),
( 156, 0, 65 ), ( 156, 12, 60 ), ( 156, 24, 55 ), ( 156, 36, 50 ), ( 156, 48, 45 ), ( 156, 60, 40 ), ( 156, 72, 35 ), ( 156, 84, 30 ), ( 156, 96, 25 ), ( 156, 108, 20 ), ( 156, 120, 15 ), ( 156, 132, 10 ), ( 156, 144, 5 ),
( 168, 0, 70 ), ( 168, 12, 65 ), ( 168, 24, 60 ), ( 168, 36, 55 ), ( 168, 48, 50 ), ( 168, 60, 45 ), ( 168, 72, 40 ), ( 168, 84, 35 ), ( 168, 96, 30 ), ( 168, 108, 25 ), ( 168, 120, 20 ), ( 168, 132, 15 ), ( 168, 144, 10 ), ( 168, 156, 5 ),
...
}
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 "}"