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.
( 70, 0, 38 ), ( 70, 35, 19 ),
( 105, 0, 57 ), ( 105, 35, 38 ), ( 105, 70, 19 ),
( 140, 0, 76 ), ( 140, 35, 57 ), ( 140, 70, 38 ), ( 140, 105, 19 ),
( 175, 0, 95 ), ( 175, 35, 76 ), ( 175, 70, 57 ), ( 175, 105, 38 ), ( 175, 140, 19 ),
( 210, 0, 114 ), ( 210, 35, 95 ), ( 210, 70, 76 ), ( 210, 105, 57 ), ( 210, 140, 38 ), ( 210, 175, 19 ),
( 245, 0, 133 ), ( 245, 35, 114 ), ( 245, 70, 95 ), ( 245, 105, 76 ), ( 245, 140, 57 ), ( 245, 175, 38 ), ( 245, 210, 19 ),
( 280, 0, 152 ), ( 280, 35, 133 ), ( 280, 70, 114 ), ( 280, 105, 95 ), ( 280, 140, 76 ), ( 280, 175, 57 ), ( 280, 210, 38 ), ( 280, 245, 19 ),
( 315, 0, 171 ), ( 315, 35, 152 ), ( 315, 70, 133 ), ( 315, 105, 114 ), ( 315, 140, 95 ), ( 315, 175, 76 ), ( 315, 210, 57 ), ( 315, 245, 38 ), ( 315, 280, 19 ),
( 350, 0, 190 ), ( 350, 35, 171 ), ( 350, 70, 152 ), ( 350, 105, 133 ), ( 350, 140, 114 ), ( 350, 175, 95 ), ( 350, 210, 76 ), ( 350, 245, 57 ), ( 350, 280, 38 ), ( 350, 315, 19 ),
( 385, 0, 209 ), ( 385, 35, 190 ), ( 385, 70, 171 ), ( 385, 105, 152 ), ( 385, 140, 133 ), ( 385, 175, 114 ), ( 385, 210, 95 ), ( 385, 245, 76 ), ( 385, 280, 57 ), ( 385, 315, 38 ), ( 385, 350, 19 ),
( 420, 0, 228 ), ( 420, 35, 209 ), ( 420, 70, 190 ), ( 420, 105, 171 ), ( 420, 140, 152 ), ( 420, 175, 133 ), ( 420, 210, 114 ), ( 420, 245, 95 ), ( 420, 280, 76 ), ( 420, 315, 57 ), ( 420, 350, 38 ), ( 420, 385, 19 ),
( 455, 0, 247 ), ( 455, 35, 228 ), ( 455, 70, 209 ), ( 455, 105, 190 ), ( 455, 140, 171 ), ( 455, 175, 152 ), ( 455, 210, 133 ), ( 455, 245, 114 ), ( 455, 280, 95 ), ( 455, 315, 76 ), ( 455, 350, 57 ), ( 455, 385, 38 ), ( 455, 420, 19 ),
( 490, 0, 266 ), ( 490, 35, 247 ), ( 490, 70, 228 ), ( 490, 105, 209 ), ( 490, 140, 190 ), ( 490, 175, 171 ), ( 490, 210, 152 ), ( 490, 245, 133 ), ( 490, 280, 114 ), ( 490, 315, 95 ), ( 490, 350, 76 ), ( 490, 385, 57 ), ( 490, 420, 38 ), ( 490, 455, 19 ),
...
}
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 "}"