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.
( 57, 0, 21 ), ( 57, 19, 14 ), ( 57, 38, 7 ),
( 76, 0, 28 ), ( 76, 19, 21 ), ( 76, 38, 14 ), ( 76, 57, 7 ),
( 95, 0, 35 ), ( 95, 19, 28 ), ( 95, 38, 21 ), ( 95, 57, 14 ), ( 95, 76, 7 ),
( 114, 0, 42 ), ( 114, 19, 35 ), ( 114, 38, 28 ), ( 114, 57, 21 ), ( 114, 76, 14 ), ( 114, 95, 7 ),
( 133, 0, 49 ), ( 133, 19, 42 ), ( 133, 38, 35 ), ( 133, 57, 28 ), ( 133, 76, 21 ), ( 133, 95, 14 ), ( 133, 114, 7 ),
( 152, 0, 56 ), ( 152, 19, 49 ), ( 152, 38, 42 ), ( 152, 57, 35 ), ( 152, 76, 28 ), ( 152, 95, 21 ), ( 152, 114, 14 ), ( 152, 133, 7 ),
( 171, 0, 63 ), ( 171, 19, 56 ), ( 171, 38, 49 ), ( 171, 57, 42 ), ( 171, 76, 35 ), ( 171, 95, 28 ), ( 171, 114, 21 ), ( 171, 133, 14 ), ( 171, 152, 7 ),
( 190, 0, 70 ), ( 190, 19, 63 ), ( 190, 38, 56 ), ( 190, 57, 49 ), ( 190, 76, 42 ), ( 190, 95, 35 ), ( 190, 114, 28 ), ( 190, 133, 21 ), ( 190, 152, 14 ), ( 190, 171, 7 ),
( 209, 0, 77 ), ( 209, 19, 70 ), ( 209, 38, 63 ), ( 209, 57, 56 ), ( 209, 76, 49 ), ( 209, 95, 42 ), ( 209, 114, 35 ), ( 209, 133, 28 ), ( 209, 152, 21 ), ( 209, 171, 14 ), ( 209, 190, 7 ),
( 228, 0, 84 ), ( 228, 19, 77 ), ( 228, 38, 70 ), ( 228, 57, 63 ), ( 228, 76, 56 ), ( 228, 95, 49 ), ( 228, 114, 42 ), ( 228, 133, 35 ), ( 228, 152, 28 ), ( 228, 171, 21 ), ( 228, 190, 14 ), ( 228, 209, 7 ),
( 247, 0, 91 ), ( 247, 19, 84 ), ( 247, 38, 77 ), ( 247, 57, 70 ), ( 247, 76, 63 ), ( 247, 95, 56 ), ( 247, 114, 49 ), ( 247, 133, 42 ), ( 247, 152, 35 ), ( 247, 171, 28 ), ( 247, 190, 21 ), ( 247, 209, 14 ), ( 247, 228, 7 ),
( 266, 0, 98 ), ( 266, 19, 91 ), ( 266, 38, 84 ), ( 266, 57, 77 ), ( 266, 76, 70 ), ( 266, 95, 63 ), ( 266, 114, 56 ), ( 266, 133, 49 ), ( 266, 152, 42 ), ( 266, 171, 35 ), ( 266, 190, 28 ), ( 266, 209, 21 ), ( 266, 228, 14 ), ( 266, 247, 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 "}"