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.
( 52, 0, 34 ), ( 52, 26, 17 ),
( 78, 0, 51 ), ( 78, 26, 34 ), ( 78, 52, 17 ),
( 104, 0, 68 ), ( 104, 26, 51 ), ( 104, 52, 34 ), ( 104, 78, 17 ),
( 130, 0, 85 ), ( 130, 26, 68 ), ( 130, 52, 51 ), ( 130, 78, 34 ), ( 130, 104, 17 ),
( 156, 0, 102 ), ( 156, 26, 85 ), ( 156, 52, 68 ), ( 156, 78, 51 ), ( 156, 104, 34 ), ( 156, 130, 17 ),
( 182, 0, 119 ), ( 182, 26, 102 ), ( 182, 52, 85 ), ( 182, 78, 68 ), ( 182, 104, 51 ), ( 182, 130, 34 ), ( 182, 156, 17 ),
( 208, 0, 136 ), ( 208, 26, 119 ), ( 208, 52, 102 ), ( 208, 78, 85 ), ( 208, 104, 68 ), ( 208, 130, 51 ), ( 208, 156, 34 ), ( 208, 182, 17 ),
( 234, 0, 153 ), ( 234, 26, 136 ), ( 234, 52, 119 ), ( 234, 78, 102 ), ( 234, 104, 85 ), ( 234, 130, 68 ), ( 234, 156, 51 ), ( 234, 182, 34 ), ( 234, 208, 17 ),
( 260, 0, 170 ), ( 260, 26, 153 ), ( 260, 52, 136 ), ( 260, 78, 119 ), ( 260, 104, 102 ), ( 260, 130, 85 ), ( 260, 156, 68 ), ( 260, 182, 51 ), ( 260, 208, 34 ), ( 260, 234, 17 ),
( 286, 0, 187 ), ( 286, 26, 170 ), ( 286, 52, 153 ), ( 286, 78, 136 ), ( 286, 104, 119 ), ( 286, 130, 102 ), ( 286, 156, 85 ), ( 286, 182, 68 ), ( 286, 208, 51 ), ( 286, 234, 34 ), ( 286, 260, 17 ),
( 312, 0, 204 ), ( 312, 26, 187 ), ( 312, 52, 170 ), ( 312, 78, 153 ), ( 312, 104, 136 ), ( 312, 130, 119 ), ( 312, 156, 102 ), ( 312, 182, 85 ), ( 312, 208, 68 ), ( 312, 234, 51 ), ( 312, 260, 34 ), ( 312, 286, 17 ),
( 338, 0, 221 ), ( 338, 26, 204 ), ( 338, 52, 187 ), ( 338, 78, 170 ), ( 338, 104, 153 ), ( 338, 130, 136 ), ( 338, 156, 119 ), ( 338, 182, 102 ), ( 338, 208, 85 ), ( 338, 234, 68 ), ( 338, 260, 51 ), ( 338, 286, 34 ), ( 338, 312, 17 ),
( 364, 0, 238 ), ( 364, 26, 221 ), ( 364, 52, 204 ), ( 364, 78, 187 ), ( 364, 104, 170 ), ( 364, 130, 153 ), ( 364, 156, 136 ), ( 364, 182, 119 ), ( 364, 208, 102 ), ( 364, 234, 85 ), ( 364, 260, 68 ), ( 364, 286, 51 ), ( 364, 312, 34 ), ( 364, 338, 17 ),
...
}
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 "}"