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, 26 ), ( 60, 30, 13 ),
( 90, 0, 39 ), ( 90, 30, 26 ), ( 90, 60, 13 ),
( 120, 0, 52 ), ( 120, 30, 39 ), ( 120, 60, 26 ), ( 120, 90, 13 ),
( 150, 0, 65 ), ( 150, 30, 52 ), ( 150, 60, 39 ), ( 150, 90, 26 ), ( 150, 120, 13 ),
( 180, 0, 78 ), ( 180, 30, 65 ), ( 180, 60, 52 ), ( 180, 90, 39 ), ( 180, 120, 26 ), ( 180, 150, 13 ),
( 210, 0, 91 ), ( 210, 30, 78 ), ( 210, 60, 65 ), ( 210, 90, 52 ), ( 210, 120, 39 ), ( 210, 150, 26 ), ( 210, 180, 13 ),
( 240, 0, 104 ), ( 240, 30, 91 ), ( 240, 60, 78 ), ( 240, 90, 65 ), ( 240, 120, 52 ), ( 240, 150, 39 ), ( 240, 180, 26 ), ( 240, 210, 13 ),
( 270, 0, 117 ), ( 270, 30, 104 ), ( 270, 60, 91 ), ( 270, 90, 78 ), ( 270, 120, 65 ), ( 270, 150, 52 ), ( 270, 180, 39 ), ( 270, 210, 26 ), ( 270, 240, 13 ),
( 300, 0, 130 ), ( 300, 30, 117 ), ( 300, 60, 104 ), ( 300, 90, 91 ), ( 300, 120, 78 ), ( 300, 150, 65 ), ( 300, 180, 52 ), ( 300, 210, 39 ), ( 300, 240, 26 ), ( 300, 270, 13 ),
( 330, 0, 143 ), ( 330, 30, 130 ), ( 330, 60, 117 ), ( 330, 90, 104 ), ( 330, 120, 91 ), ( 330, 150, 78 ), ( 330, 180, 65 ), ( 330, 210, 52 ), ( 330, 240, 39 ), ( 330, 270, 26 ), ( 330, 300, 13 ),
( 360, 0, 156 ), ( 360, 30, 143 ), ( 360, 60, 130 ), ( 360, 90, 117 ), ( 360, 120, 104 ), ( 360, 150, 91 ), ( 360, 180, 78 ), ( 360, 210, 65 ), ( 360, 240, 52 ), ( 360, 270, 39 ), ( 360, 300, 26 ), ( 360, 330, 13 ),
( 390, 0, 169 ), ( 390, 30, 156 ), ( 390, 60, 143 ), ( 390, 90, 130 ), ( 390, 120, 117 ), ( 390, 150, 104 ), ( 390, 180, 91 ), ( 390, 210, 78 ), ( 390, 240, 65 ), ( 390, 270, 52 ), ( 390, 300, 39 ), ( 390, 330, 26 ), ( 390, 360, 13 ),
( 420, 0, 182 ), ( 420, 30, 169 ), ( 420, 60, 156 ), ( 420, 90, 143 ), ( 420, 120, 130 ), ( 420, 150, 117 ), ( 420, 180, 104 ), ( 420, 210, 91 ), ( 420, 240, 78 ), ( 420, 270, 65 ), ( 420, 300, 52 ), ( 420, 330, 39 ), ( 420, 360, 26 ), ( 420, 390, 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 "}"