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.
( 90, 0, 28 ), ( 90, 45, 14 ),
( 135, 0, 42 ), ( 135, 45, 28 ), ( 135, 90, 14 ),
( 180, 0, 56 ), ( 180, 45, 42 ), ( 180, 90, 28 ), ( 180, 135, 14 ),
( 225, 0, 70 ), ( 225, 45, 56 ), ( 225, 90, 42 ), ( 225, 135, 28 ), ( 225, 180, 14 ),
( 270, 0, 84 ), ( 270, 45, 70 ), ( 270, 90, 56 ), ( 270, 135, 42 ), ( 270, 180, 28 ), ( 270, 225, 14 ),
( 315, 0, 98 ), ( 315, 45, 84 ), ( 315, 90, 70 ), ( 315, 135, 56 ), ( 315, 180, 42 ), ( 315, 225, 28 ), ( 315, 270, 14 ),
( 360, 0, 112 ), ( 360, 45, 98 ), ( 360, 90, 84 ), ( 360, 135, 70 ), ( 360, 180, 56 ), ( 360, 225, 42 ), ( 360, 270, 28 ), ( 360, 315, 14 ),
( 405, 0, 126 ), ( 405, 45, 112 ), ( 405, 90, 98 ), ( 405, 135, 84 ), ( 405, 180, 70 ), ( 405, 225, 56 ), ( 405, 270, 42 ), ( 405, 315, 28 ), ( 405, 360, 14 ),
( 450, 0, 140 ), ( 450, 45, 126 ), ( 450, 90, 112 ), ( 450, 135, 98 ), ( 450, 180, 84 ), ( 450, 225, 70 ), ( 450, 270, 56 ), ( 450, 315, 42 ), ( 450, 360, 28 ), ( 450, 405, 14 ),
( 495, 0, 154 ), ( 495, 45, 140 ), ( 495, 90, 126 ), ( 495, 135, 112 ), ( 495, 180, 98 ), ( 495, 225, 84 ), ( 495, 270, 70 ), ( 495, 315, 56 ), ( 495, 360, 42 ), ( 495, 405, 28 ), ( 495, 450, 14 ),
( 540, 0, 168 ), ( 540, 45, 154 ), ( 540, 90, 140 ), ( 540, 135, 126 ), ( 540, 180, 112 ), ( 540, 225, 98 ), ( 540, 270, 84 ), ( 540, 315, 70 ), ( 540, 360, 56 ), ( 540, 405, 42 ), ( 540, 450, 28 ), ( 540, 495, 14 ),
( 585, 0, 182 ), ( 585, 45, 168 ), ( 585, 90, 154 ), ( 585, 135, 140 ), ( 585, 180, 126 ), ( 585, 225, 112 ), ( 585, 270, 98 ), ( 585, 315, 84 ), ( 585, 360, 70 ), ( 585, 405, 56 ), ( 585, 450, 42 ), ( 585, 495, 28 ), ( 585, 540, 14 ),
( 630, 0, 196 ), ( 630, 45, 182 ), ( 630, 90, 168 ), ( 630, 135, 154 ), ( 630, 180, 140 ), ( 630, 225, 126 ), ( 630, 270, 112 ), ( 630, 315, 98 ), ( 630, 360, 84 ), ( 630, 405, 70 ), ( 630, 450, 56 ), ( 630, 495, 42 ), ( 630, 540, 28 ), ( 630, 585, 14 ),
...
}
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 "}"