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.
( 38, 0, 22 ), ( 38, 19, 11 ),
( 57, 0, 33 ), ( 57, 19, 22 ), ( 57, 38, 11 ),
( 76, 0, 44 ), ( 76, 19, 33 ), ( 76, 38, 22 ), ( 76, 57, 11 ),
( 95, 0, 55 ), ( 95, 19, 44 ), ( 95, 38, 33 ), ( 95, 57, 22 ), ( 95, 76, 11 ),
( 114, 0, 66 ), ( 114, 19, 55 ), ( 114, 38, 44 ), ( 114, 57, 33 ), ( 114, 76, 22 ), ( 114, 95, 11 ),
( 133, 0, 77 ), ( 133, 19, 66 ), ( 133, 38, 55 ), ( 133, 57, 44 ), ( 133, 76, 33 ), ( 133, 95, 22 ), ( 133, 114, 11 ),
( 152, 0, 88 ), ( 152, 19, 77 ), ( 152, 38, 66 ), ( 152, 57, 55 ), ( 152, 76, 44 ), ( 152, 95, 33 ), ( 152, 114, 22 ), ( 152, 133, 11 ),
( 171, 0, 99 ), ( 171, 19, 88 ), ( 171, 38, 77 ), ( 171, 57, 66 ), ( 171, 76, 55 ), ( 171, 95, 44 ), ( 171, 114, 33 ), ( 171, 133, 22 ), ( 171, 152, 11 ),
( 190, 0, 110 ), ( 190, 19, 99 ), ( 190, 38, 88 ), ( 190, 57, 77 ), ( 190, 76, 66 ), ( 190, 95, 55 ), ( 190, 114, 44 ), ( 190, 133, 33 ), ( 190, 152, 22 ), ( 190, 171, 11 ),
( 209, 0, 121 ), ( 209, 19, 110 ), ( 209, 38, 99 ), ( 209, 57, 88 ), ( 209, 76, 77 ), ( 209, 95, 66 ), ( 209, 114, 55 ), ( 209, 133, 44 ), ( 209, 152, 33 ), ( 209, 171, 22 ), ( 209, 190, 11 ),
( 228, 0, 132 ), ( 228, 19, 121 ), ( 228, 38, 110 ), ( 228, 57, 99 ), ( 228, 76, 88 ), ( 228, 95, 77 ), ( 228, 114, 66 ), ( 228, 133, 55 ), ( 228, 152, 44 ), ( 228, 171, 33 ), ( 228, 190, 22 ), ( 228, 209, 11 ),
( 247, 0, 143 ), ( 247, 19, 132 ), ( 247, 38, 121 ), ( 247, 57, 110 ), ( 247, 76, 99 ), ( 247, 95, 88 ), ( 247, 114, 77 ), ( 247, 133, 66 ), ( 247, 152, 55 ), ( 247, 171, 44 ), ( 247, 190, 33 ), ( 247, 209, 22 ), ( 247, 228, 11 ),
( 266, 0, 154 ), ( 266, 19, 143 ), ( 266, 38, 132 ), ( 266, 57, 121 ), ( 266, 76, 110 ), ( 266, 95, 99 ), ( 266, 114, 88 ), ( 266, 133, 77 ), ( 266, 152, 66 ), ( 266, 171, 55 ), ( 266, 190, 44 ), ( 266, 209, 33 ), ( 266, 228, 22 ), ( 266, 247, 11 ),
...
}
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 "}"