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.
( 78, 0, 44 ), ( 78, 39, 22 ),
( 117, 0, 66 ), ( 117, 39, 44 ), ( 117, 78, 22 ),
( 156, 0, 88 ), ( 156, 39, 66 ), ( 156, 78, 44 ), ( 156, 117, 22 ),
( 195, 0, 110 ), ( 195, 39, 88 ), ( 195, 78, 66 ), ( 195, 117, 44 ), ( 195, 156, 22 ),
( 234, 0, 132 ), ( 234, 39, 110 ), ( 234, 78, 88 ), ( 234, 117, 66 ), ( 234, 156, 44 ), ( 234, 195, 22 ),
( 273, 0, 154 ), ( 273, 39, 132 ), ( 273, 78, 110 ), ( 273, 117, 88 ), ( 273, 156, 66 ), ( 273, 195, 44 ), ( 273, 234, 22 ),
( 312, 0, 176 ), ( 312, 39, 154 ), ( 312, 78, 132 ), ( 312, 117, 110 ), ( 312, 156, 88 ), ( 312, 195, 66 ), ( 312, 234, 44 ), ( 312, 273, 22 ),
( 351, 0, 198 ), ( 351, 39, 176 ), ( 351, 78, 154 ), ( 351, 117, 132 ), ( 351, 156, 110 ), ( 351, 195, 88 ), ( 351, 234, 66 ), ( 351, 273, 44 ), ( 351, 312, 22 ),
( 390, 0, 220 ), ( 390, 39, 198 ), ( 390, 78, 176 ), ( 390, 117, 154 ), ( 390, 156, 132 ), ( 390, 195, 110 ), ( 390, 234, 88 ), ( 390, 273, 66 ), ( 390, 312, 44 ), ( 390, 351, 22 ),
( 429, 0, 242 ), ( 429, 39, 220 ), ( 429, 78, 198 ), ( 429, 117, 176 ), ( 429, 156, 154 ), ( 429, 195, 132 ), ( 429, 234, 110 ), ( 429, 273, 88 ), ( 429, 312, 66 ), ( 429, 351, 44 ), ( 429, 390, 22 ),
( 468, 0, 264 ), ( 468, 39, 242 ), ( 468, 78, 220 ), ( 468, 117, 198 ), ( 468, 156, 176 ), ( 468, 195, 154 ), ( 468, 234, 132 ), ( 468, 273, 110 ), ( 468, 312, 88 ), ( 468, 351, 66 ), ( 468, 390, 44 ), ( 468, 429, 22 ),
( 507, 0, 286 ), ( 507, 39, 264 ), ( 507, 78, 242 ), ( 507, 117, 220 ), ( 507, 156, 198 ), ( 507, 195, 176 ), ( 507, 234, 154 ), ( 507, 273, 132 ), ( 507, 312, 110 ), ( 507, 351, 88 ), ( 507, 390, 66 ), ( 507, 429, 44 ), ( 507, 468, 22 ),
( 546, 0, 308 ), ( 546, 39, 286 ), ( 546, 78, 264 ), ( 546, 117, 242 ), ( 546, 156, 220 ), ( 546, 195, 198 ), ( 546, 234, 176 ), ( 546, 273, 154 ), ( 546, 312, 132 ), ( 546, 351, 110 ), ( 546, 390, 88 ), ( 546, 429, 66 ), ( 546, 468, 44 ), ( 546, 507, 22 ),
...
}
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 "}"