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.
( 60, 0, 21 ), ( 60, 20, 14 ), ( 60, 40, 7 ),
( 80, 0, 28 ), ( 80, 20, 21 ), ( 80, 40, 14 ), ( 80, 60, 7 ),
( 100, 0, 35 ), ( 100, 20, 28 ), ( 100, 40, 21 ), ( 100, 60, 14 ), ( 100, 80, 7 ),
( 120, 0, 42 ), ( 120, 20, 35 ), ( 120, 40, 28 ), ( 120, 60, 21 ), ( 120, 80, 14 ), ( 120, 100, 7 ),
( 140, 0, 49 ), ( 140, 20, 42 ), ( 140, 40, 35 ), ( 140, 60, 28 ), ( 140, 80, 21 ), ( 140, 100, 14 ), ( 140, 120, 7 ),
( 160, 0, 56 ), ( 160, 20, 49 ), ( 160, 40, 42 ), ( 160, 60, 35 ), ( 160, 80, 28 ), ( 160, 100, 21 ), ( 160, 120, 14 ), ( 160, 140, 7 ),
( 180, 0, 63 ), ( 180, 20, 56 ), ( 180, 40, 49 ), ( 180, 60, 42 ), ( 180, 80, 35 ), ( 180, 100, 28 ), ( 180, 120, 21 ), ( 180, 140, 14 ), ( 180, 160, 7 ),
( 200, 0, 70 ), ( 200, 20, 63 ), ( 200, 40, 56 ), ( 200, 60, 49 ), ( 200, 80, 42 ), ( 200, 100, 35 ), ( 200, 120, 28 ), ( 200, 140, 21 ), ( 200, 160, 14 ), ( 200, 180, 7 ),
( 220, 0, 77 ), ( 220, 20, 70 ), ( 220, 40, 63 ), ( 220, 60, 56 ), ( 220, 80, 49 ), ( 220, 100, 42 ), ( 220, 120, 35 ), ( 220, 140, 28 ), ( 220, 160, 21 ), ( 220, 180, 14 ), ( 220, 200, 7 ),
( 240, 0, 84 ), ( 240, 20, 77 ), ( 240, 40, 70 ), ( 240, 60, 63 ), ( 240, 80, 56 ), ( 240, 100, 49 ), ( 240, 120, 42 ), ( 240, 140, 35 ), ( 240, 160, 28 ), ( 240, 180, 21 ), ( 240, 200, 14 ), ( 240, 220, 7 ),
( 260, 0, 91 ), ( 260, 20, 84 ), ( 260, 40, 77 ), ( 260, 60, 70 ), ( 260, 80, 63 ), ( 260, 100, 56 ), ( 260, 120, 49 ), ( 260, 140, 42 ), ( 260, 160, 35 ), ( 260, 180, 28 ), ( 260, 200, 21 ), ( 260, 220, 14 ), ( 260, 240, 7 ),
( 280, 0, 98 ), ( 280, 20, 91 ), ( 280, 40, 84 ), ( 280, 60, 77 ), ( 280, 80, 70 ), ( 280, 100, 63 ), ( 280, 120, 56 ), ( 280, 140, 49 ), ( 280, 160, 42 ), ( 280, 180, 35 ), ( 280, 200, 28 ), ( 280, 220, 21 ), ( 280, 240, 14 ), ( 280, 260, 7 ),
...
}
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 "}"