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.
( 40, 0, 26 ), ( 40, 20, 13 ),
( 60, 0, 39 ), ( 60, 20, 26 ), ( 60, 40, 13 ),
( 80, 0, 52 ), ( 80, 20, 39 ), ( 80, 40, 26 ), ( 80, 60, 13 ),
( 100, 0, 65 ), ( 100, 20, 52 ), ( 100, 40, 39 ), ( 100, 60, 26 ), ( 100, 80, 13 ),
( 120, 0, 78 ), ( 120, 20, 65 ), ( 120, 40, 52 ), ( 120, 60, 39 ), ( 120, 80, 26 ), ( 120, 100, 13 ),
( 140, 0, 91 ), ( 140, 20, 78 ), ( 140, 40, 65 ), ( 140, 60, 52 ), ( 140, 80, 39 ), ( 140, 100, 26 ), ( 140, 120, 13 ),
( 160, 0, 104 ), ( 160, 20, 91 ), ( 160, 40, 78 ), ( 160, 60, 65 ), ( 160, 80, 52 ), ( 160, 100, 39 ), ( 160, 120, 26 ), ( 160, 140, 13 ),
( 180, 0, 117 ), ( 180, 20, 104 ), ( 180, 40, 91 ), ( 180, 60, 78 ), ( 180, 80, 65 ), ( 180, 100, 52 ), ( 180, 120, 39 ), ( 180, 140, 26 ), ( 180, 160, 13 ),
( 200, 0, 130 ), ( 200, 20, 117 ), ( 200, 40, 104 ), ( 200, 60, 91 ), ( 200, 80, 78 ), ( 200, 100, 65 ), ( 200, 120, 52 ), ( 200, 140, 39 ), ( 200, 160, 26 ), ( 200, 180, 13 ),
( 220, 0, 143 ), ( 220, 20, 130 ), ( 220, 40, 117 ), ( 220, 60, 104 ), ( 220, 80, 91 ), ( 220, 100, 78 ), ( 220, 120, 65 ), ( 220, 140, 52 ), ( 220, 160, 39 ), ( 220, 180, 26 ), ( 220, 200, 13 ),
( 240, 0, 156 ), ( 240, 20, 143 ), ( 240, 40, 130 ), ( 240, 60, 117 ), ( 240, 80, 104 ), ( 240, 100, 91 ), ( 240, 120, 78 ), ( 240, 140, 65 ), ( 240, 160, 52 ), ( 240, 180, 39 ), ( 240, 200, 26 ), ( 240, 220, 13 ),
( 260, 0, 169 ), ( 260, 20, 156 ), ( 260, 40, 143 ), ( 260, 60, 130 ), ( 260, 80, 117 ), ( 260, 100, 104 ), ( 260, 120, 91 ), ( 260, 140, 78 ), ( 260, 160, 65 ), ( 260, 180, 52 ), ( 260, 200, 39 ), ( 260, 220, 26 ), ( 260, 240, 13 ),
( 280, 0, 182 ), ( 280, 20, 169 ), ( 280, 40, 156 ), ( 280, 60, 143 ), ( 280, 80, 130 ), ( 280, 100, 117 ), ( 280, 120, 104 ), ( 280, 140, 91 ), ( 280, 160, 78 ), ( 280, 180, 65 ), ( 280, 200, 52 ), ( 280, 220, 39 ), ( 280, 240, 26 ), ( 280, 260, 13 ),
...
}
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 "}"